problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03286 | u652895610 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["import sys\nN = int(sys.stdin.readline())\n\ndef div(a):\n return -(a // 2), a % 2\n\n\nres = []\nwhile N < 0 or 2 <= N:\n N, a = div(N)\n print(N, a)\n res.append(a)\nres.append(N)\n\nprint(''.join(map(str, reversed(res))))\n", "import sys\nN = int(sys.stdin.readline())\n\ndef div(a):\n return -(a // 2), a % 2\n\n\nres = []\nwhile N < 0 or 2 <= N:\n N, a = div(N)\n res.append(a)\nres.append(N)\n\nprint(''.join(map(str, reversed(res))))\n"] | ['Wrong Answer', 'Accepted'] | ['s870004407', 's514284379'] | [3060.0, 3060.0] | [17.0, 17.0] | [223, 207] |
p03286 | u653807637 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['import math\n\ndef main():\n\tn = int(input())\n\tans = ""\n\n\ti = 0\n\twhile n != 0:\n\t\tprint(n)\n\t\tif n % (2 ** (i + 1)) != 0:\n\t\t\tans += "1"\n\t\t\tn -= (-2) ** i\n\t\telse:\n\t\t\tans += "0"\n\n\t\ti += 1\n\n\tif n == 0:\n\t\tprint(0)\n\telse:\n\t\tprint(ans[::-1])\n\nif __name__ == \'__main__\':\n\tmain()', 'import math\n\ndef main():\n\tn = int(input())\n\tans = ""\n\n\ti = 0\n\n\tif n == 0:\n\t\tprint(0)\n\t\treturn \n\n\twhile n != 0:\n\t\tif n % (2 ** (i + 1)) != 0:\n\t\t\tans += "1"\n\t\t\tn -= (-2) ** i\n\t\telse:\n\t\t\tans += "0"\n\n\t\ti += 1\n\n\tprint(ans[::-1])\n\nif __name__ == \'__main__\':\n\tmain()'] | ['Wrong Answer', 'Accepted'] | ['s953781664', 's962682095'] | [3060.0, 3060.0] | [17.0, 17.0] | [266, 259] |
p03286 | u656643475 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["# C\nN = int(input())\n\ndata = N\nre = ''\n\nwhile True:\n print(data)\n if data == 1:\n re = '1' + re\n break\n elif data == -1:\n re = '11' + re\n break\n elif data % -2 != 0:\n data += data // abs(data) \n re = '1' + re\n else:\n if data // -2 != 0:\n re = '0' + re\n else:\n break\n data = data // -2\n \nprint(re)", "# C\nN = int(input())\n\ndata = N\nif data == 0:\n re = '0'\nelse:\n re = ''\n\n while True:\n if data % 2 == 1:\n data -= 1 \n re = '1' + re\n else:\n if data // -2 != 0:\n re = '0' + re\n else:\n break\n data = data // -2\n \nprint(re)"] | ['Wrong Answer', 'Accepted'] | ['s876241236', 's169957315'] | [3060.0, 3060.0] | [17.0, 17.0] | [412, 361] |
p03286 | u658993896 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["N = int(input())\n\nt = 0\nans = ''\nwhile N != 0:\n a = N%2\n if t % 2 == 0:\n ans = str(int(a)) + ans\n N -= a\n N /= 2\n else:\n ans = str(int(a)) + ans\n N += a\n N /= 2\n t +=1\n print(N)\nif ans == '':\n ans = '0'\nprint(ans)", "N = int(input())\n\nt = 0\nans = ''\nwhile N != 0:\n a = N%2\n if t % 2 == 0:\n ans = str(int(a)) + ans\n N -= a\n N /= 2\n else:\n ans = str(int(a)) + ans\n N += a\n N /= 2\n t +=1\n print(N)\nif ans == '':\n ans = '0'\nprint(ans)", "N = int(input())\n\nt = 0\nans = ''\nwhile N != 0:\n a = N%2\n if t % 2 == 0:\n ans = str(int(a)) + ans\n N -= a\n N /= 2\n else:\n ans = str(int(a)) + ans\n N += a\n N /= 2\n t +=1\nif ans == '':\n ans = '0'\nprint(ans)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s037160085', 's957550551', 's252044268'] | [3188.0, 3064.0, 3060.0] | [17.0, 17.0, 17.0] | [273, 273, 260] |
p03286 | u665038048 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nx = ""\nwhile n != 0:\n x = str(n % 2) + x\n n -= (n//2)\nprint(0 if x == "" else x)', "n = int(input())\nx = ''\nwhile n != 0:\n x = str(n % 2) + x\n n -= (n//2)\nprint(0 if x == '' else x)", "n = int(input())\nans = []\ncnt = 0\nwhile n != 0:\n ans.append(str(n % 2))\n n -= (n//2)\nprint(''.join(ans))", 'n = int(input())\nx = ""\nwhile n != 0:\n x = str(n % 2) + x\n n =- (n//2)\nprint(0 if x == "" else x)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s081797170', 's555616940', 's802670529', 's405242101'] | [3672.0, 3672.0, 356248.0, 2940.0] | [2104.0, 2104.0, 2131.0, 17.0] | [103, 103, 110, 103] |
p03286 | u666198201 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["\nflaga=True\nS='1'\nN=int(input())\nD=N\nflag=0\np=1\nK=0\nif N==0:\n print(0)\n exit(0)\nelif N==1:\n print(1)\n exit(0)\nelif N>0:\n D-=1\n while flag==0:\n if D+1-p>0:\n D-=p\n p*=4\n K+=2\n else:\n print(D)\n for i in range(K):\n if D<p//2:\n if flaga==True:\n S +='1'\n else:\n S +='0'\n else:\n D-=p//2\n if flaga==True:\n S +='0'\n else:\n S +='1'\n p=p//2\n flaga = not flaga\n print(S)\n exit(0)\nelse:\n D=abs(D)-2\n while flag==0:\n if D+1-p>0:\n D-=p\n p*=4\n K+=2\n print(D,p)\n else:\n p*=2\n print(D)\n for i in range(K+1):\n if D<p//2:\n if flaga==True:\n S +='1'\n else:\n S +='0'\n else:\n D-=p//2\n if flaga==True:\n S +='0'\n else:\n S +='1'\n p=p//2\n flaga = not flaga\n print(S)\n exit(0)\n\n\n\n\n\n", "import math\nflaga=True\nS='1'\nN=int(input())\nD=N\nflag=0\np=1\nK=0\nif N==0:\n print(0)\n exit(0)\nelif N==1:\n print(1)\n exit(0)\nelif N>0:\n D-=1\n while flag==0:\n if D+1-p>0:\n D-=p\n p*=4\n K+=2\n else:\n #print(D)\n for i in range(K):\n if D<p//2:\n if flaga==True:\n S +='1'\n else:\n S +='0'\n else:\n D-=p//2\n if flaga==True:\n S +='0'\n else:\n S +='1'\n p=p//2\n flaga = not flaga\n \n print(S)\n exit(0)\nelse:\n D=abs(D)-1\n p+=1\n while flag==0:\n if D-p>=0:\n D-=p\n p*=4\n K+=2\n #print(D,p)\n else:\n \n for i in range(K+1):\n if D<p//2:\n if flaga==True:\n S +='1'\n else:\n S +='0'\n\n else:\n D-=p//2\n if flaga==True:\n S +='0'\n else:\n S +='1'\n flaga = not flaga\n p=p//2\n\n print(S)\n exit(0)\n\n\n\n"] | ['Wrong Answer', 'Accepted'] | ['s293276001', 's182764917'] | [3064.0, 3188.0] | [17.0, 17.0] | [1375, 1416] |
p03286 | u667024514 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nif n > 0:key = 1\nif n < 0:key = 0\nlis = []\nwhile abs(n) >= 1:\n if n % 2 == 1:\n n -= 1\n lis.insert(0,"1")\n else:\n lis.insert(0,"0")\n n = n // (-2)\nif n == 0:\n lis.append("0")\nprint("".join(lis))', 'n = int(input())\nif n > 0:key = 1\nif n < 0:key = 0\nlis = []\nif n == 0:\n lis.append("0")\nwhile abs(n) >= 1:\n if n % 2 == 1:\n n -= 1\n lis.insert(0,"1")\n else:\n lis.insert(0,"0")\n n = n // (-2)\nprint("".join(lis))\n '] | ['Wrong Answer', 'Accepted'] | ['s826687580', 's235013626'] | [3064.0, 3060.0] | [19.0, 17.0] | [223, 226] |
p03286 | u667458133 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["N = int(input())\nresult = '1'\n\nif N > 0:\n s = 1\n e = 1\n r = 4\n degit = 0\n \n while True:\n if N <= e:\n for i in range(degit):\n if i % 2 == 0:\n if N <= (s+e)//2:\n result += '1'\n e = (s+e)//2\n else:\n result += '0'\n s = (s+e)//2+1\n else:\n if N <= (s+e)//2:\n result += '0'\n e = (s+e)//2\n else:\n result += '1'\n s = (s+e)//2+1\n break\n \n s = e + 1\n e = e + r\n r *= 4\n degit += 2\n \n\nelif N < 0:\n s = -1\n e = -2\n r = -8\n degit = 1\n\n while True:\n if N >= e:\n for i in range(degit):\n print((s+e)//2+1)\n if i % 2 == 0:\n if N >= (s+e)//2+1:\n result += '1'\n e = (s+e)//2+1\n else:\n result += '0'\n s = (s+e)//2\n else:\n if N >= (s+e)//2+1:\n result += '0'\n e = (s+e)//2+1\n else:\n result += '1'\n s = (s+e)//2\n break\n \n s = e - 1\n e = e + r\n r *= 4\n degit += 2\n \n\nelse:\n result = '0'\n\nprint(result)\n", "N = int(input())\nresult = ''\nif N == 0:\n result = '0'\nelse: \n while N != 0:\n if N % 2 == 1 :\n result = '1' + result\n N -= 1\n else:\n result = '0' + result\n N = -N//2\n\nprint(result) \n"] | ['Wrong Answer', 'Accepted'] | ['s427006787', 's462029705'] | [3192.0, 2940.0] | [24.0, 18.0] | [1562, 247] |
p03286 | u668503853 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N=int(input())\ndef B10n(X, n):\n if (int(X/n)):\n return B10n(int(X/n), n)+str(X%n)\n return str(X%n)\nans=B10n(N,-2)\nprint(ans.replace("-",""))', 'N=int(input())\nS=""\nif N==0:\n print(0)\n exit(0) \nwhile N!=0:\n r=N%(-2)\n N=N//(-2)\n if r<0:\n r+=2\n N+=1\n S+=str(r)\nprint(S[::-1])\n'] | ['Wrong Answer', 'Accepted'] | ['s114852266', 's844882303'] | [3060.0, 3064.0] | [17.0, 17.0] | [145, 144] |
p03286 | u672213161 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["a=int(input())\nsum=0\ns=''\n'''if a<0:\n b = abs(a)\n if b%2==1:\n b=b+1\n print(str(bin(b))[2:-1]+'1')\n else:\n print(str(bin(b))[2:-1])''\nif a!=0:\n while(a!=1):\n if a%(-2)==-1:\n s=s+'1'\n a=a-1\n a=a/-2\n else:\n s = s + '0'\n a=a/-2\n s=s+'1'\n for i in range(len(s)):\n print(s[len(s)-1-i],end='')\n print()\nelse:\n print(0)\n", "a=int(input())\nsum=0\ns=''\n\nif a!=0:\n while(a!=1):\n if a%(-2)==-1:\n s=s+'1'\n a=a-1\n a=a/-2\n else:\n s = s + '0'\n a=a/-2\n s=s+'1'\n for i in range(len(s)):\n print(s[len(s)-1-i],end='')\n print()\nelse:\n print(0)\n"] | ['Runtime Error', 'Accepted'] | ['s359652440', 's660650331'] | [2940.0, 3060.0] | [17.0, 17.0] | [433, 297] |
p03286 | u672475305 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\ns = ''\nwhile(n!=0):\n r = n % 2\n if r<0:\n r += 2\n n = (n-r) // (-2)\n s += str(r)\nans = s[::-1]\nif n==0:\n print(0)\nelse:\n print(ans)", "n = int(input())\ns = ''\nif n==0:\n print(0)\n exit()\nwhile(n!=0):\n r = n % 2\n if r<0:\n r += 2\n n = (n-r) // (-2)\n s += str(r)\nans = s[::-1]\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s690690393', 's211658744'] | [3060.0, 3060.0] | [17.0, 17.0] | [172, 169] |
p03286 | u673338219 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\na = []\nwhile n > 0:\n if n%2 ==0:\n n = n/(-2)\n a.append("0")\n else:\n n = (n-1)(-2)\n a.append("1")\n \nb = ""\nfor i in range(len(a)):\n b += a[len(a)-i-1]\n \nprint(b)\n \n ', 'n = int(input())\na = []\nif n ==0:\n print(0)\nelse:\n while n != 0:\n if n%2 ==0:\n n = n/(-2)\n a.append("0")\n else:\n n = (n-1)/(-2)\n a.append("1")\n \nb = ""\nfor i in range(len(a)):\n b += a[len(a)-i-1]\n\nprint(b)\n\n \n ', 'n = int(input())\na = []\nwhile n > 0:\n if n%2 ==0:\n n = n/(-2)\n a.append("0")\n else:\n n = (n-1)(-2)\n a.append("1")\n \nb = ""\nfor i in range(len(a)):\n b += a[len(a)-i-1]\n \nprint("b")\n \n ', 'n = int(input())\na = []\nif n ==0:\n print(0)\nelse:\n while n != 0:\n if n%2 ==0:\n n = n/(-2)\n a.append("0")\n else:\n n = (n-1)/(-2)\n a.append("1")\n \n b = ""\n for i in range(len(a)):\n b += a[len(a)-i-1]\n\n print(b)\n\n \n '] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s032505424', 's380788615', 's420368767', 's006606085'] | [3188.0, 2940.0, 3060.0, 3060.0] | [18.0, 17.0, 17.0, 17.0] | [202, 232, 204, 252] |
p03286 | u677440371 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\n\nS = ""\nwhile N != 0:\n if N %2 != 0:\n S = "1" + S\n N -= 1\n else:\n S = "0" + S\n N /= -2\nif N == 0:\n print("0")\nelse:\n print(S)', "n = int(input())\n\ns = ''\nflag = True\nwhile flag:\n if n % 2 != 0:\n s = '1' + s\n n -= 1\n else:\n s = '0' + s\n n /= -2\n if n == 0:\n flag = False\nprint(s)"] | ['Wrong Answer', 'Accepted'] | ['s596937199', 's943400025'] | [2940.0, 2940.0] | [18.0, 17.0] | [178, 189] |
p03286 | u680851063 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n =int(input())\n\nif n ==0:\n print(0)\n exit()\n\nl = [(-2)**_ for _ in range(100) if abs((-2)**_) <= 10**10]\n\nif n > 0:\n x = [1]\n for i in range(len(l)):\n if abs(l[i]) < abs(n):\n x.append(l[i+1])\n\nelif n < 0:\n x = []\n for j in range(len(l)):\n if abs(l[j]) < abs(n):\n x.append(l[j])\n\n#print(len(x))\n\ny = []\nfrom itertools import combinations\nfor __ in range(len(x)):\n y += list(combinations(x, __))\n\nfor k in y:\n if sum(k) == n:\n z = list(k)\n\n#print(y)\n#print(z)\n\np = []\nfor q in range(len(x)):\n if x[q] in z:\n p.append(1)\n else:\n p.append(0)\n\np.reverse()\nprint(p)\n', "def f_10_to_m2(n):\n if n == 0:\n return 0 \n\n digits = []\n i = 0\n base = 1\n while n != 0:\n if n % (base*2) == 0:\n digits.append(0)\n else:\n digits.append(1)\n n -= base\n i += 1\n base *= -2\n return ''.join(map(str, reversed(digits)))\n\nprint(f_10_to_m2(int(input())))"] | ['Runtime Error', 'Accepted'] | ['s310914553', 's404430051'] | [1663108.0, 3064.0] | [2217.0, 18.0] | [648, 347] |
p03286 | u686036872 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['S=str(bin(abs(int(input()))))\nprint(S[2:])', 's=int(input())\ns=0\nx=s\nlist=[]\nfor i in range(1000000000000000000):\n y=x%(-2)\n if y == -1:\n x = (x-1)//(-2)\n y = 1\n else:\n x=x//(-2)\n list.insert(0, y)\n if x == 0:\n print(*list, sep="")\n break', 'S=str(bin(int(input())))\nif S[0]=="-":\n print(S[3:])\nelse:\n print(S[2:])', 's=int(input())\nx=s\nlist=[]\nfor i in range(1000000000000000000):\n y=x%(-2)\n if y == -1:\n x = (x-1)//(-2)\n y = 1\n else:\n x=x//(-2)\n list.insert(0, y)\n if x == 0:\n print(*list, sep="")\n break'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s416973706', 's650211357', 's829711099', 's415452600'] | [2940.0, 3060.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 17.0] | [42, 242, 78, 238] |
p03286 | u687044304 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['# -*- coding:utf-8 -*-\nimport math\n\ndef solve(N):\n bin_str = bin(N)\n if bin_str[0] == "-":\n bin_str = bin_str[3:]\n else:\n bin_str = bin_str[2:]\n\n print(bin_str)\n exit()\n j = 0\n for k in range(len(bin_str)-1, -1, -1):\n ans = bin_str[i] * j\n\ndef solve2(N):\n """\n 1011\n 1001111001000111011100111111\n """\n if N <= 0:\n N *= -1\n print(bin(N)[2:])\n exit()\n\n ans = ""\n while True:\n if N%(-2) == 0:\n ans = "0" + ans\n else:\n ans = "1" + ans\n N = math.floor(N/(-2))\n if N == 0:\n #ans = "1" + ans\n break\n print(ans)\n\nif __name__ == "__main__":\n N = int(input())\n\n solve(N)\n', '# -*- coding:utf-8 -*-\n\ndef solve():\n N = int(input())\n ans = ""\n \n if N==0:\n print(N)\n return\n\n while N!=0:\n if N%2 != 0:\n \n ans = "1" + ans\n N -= 1\n N //= -2\n else:\n ans = "0" + ans\n N //= -2\n \n print(ans)\n\n\nif __name__ == "__main__":\n solve()\n'] | ['Wrong Answer', 'Accepted'] | ['s909087007', 's590772893'] | [3188.0, 3064.0] | [19.0, 17.0] | [726, 2057] |
p03286 | u692632484 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N=int(input())\nres=""\nwhile N!=0:\n\tif N%2==0:\n\t\tres+="0"\n\telse:\n\t\tN-=1\n\t\tres+="1"\n\tprint(N)\n\tN//=-2\nif len(res)==0:\n\tres="0"\nprint(res[::-1])\n', 'N=int(input())\nres=""\nwhile N!=0:\n\tif N%2==0:\n\t\tres+="0"\n\telse:\n\t\tN-=1\n\t\tres+="1"\n\t#print(N)\n\tN//=-2\nif len(res)==0:\n\tres="0"\nprint(res[::-1])\n'] | ['Wrong Answer', 'Accepted'] | ['s954245502', 's050103532'] | [3064.0, 2940.0] | [17.0, 17.0] | [142, 143] |
p03286 | u695811449 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['x=int(input())\n\nLIST2=[1]\nLIST2X=[-2]\n\nN=1\nfor i in range(1,30):\n N=N+4**i\n LIST2.append(N)\nN=-2\nfor i in range(1,30):\n N=N-2*4**i\n LIST2X.append(N)\n\n\n\nLIST=[0]*60\n\ndef nex(N):\n if N>0:\n for i in range(30):\n if N<=LIST2[i]:\n break\n LIST[i*2]+=1\n return N-(-2)**(i*2)\n\n if N<0:\n for i in range(30):\n if N>=LIST2X[i]:\n break\n LIST[i*2+1]+=1\n return N-(-2)**(i*2+1)\n\nwhile x!=0:\n x=nex(x)\n print(x)\n\nfor i in range(59,-1,-1):\n if LIST[i]==1:\n break\n\nfor j in range(i,-1,-1):\n print(LIST[j],end="")\n \n\n \n', 'N=int(input())\nif N==0:\n print(0)\ns=""\nwhile N:\n if N%2==1:\n s="1"+s\n N-=1\n else:\n s="0"+s\n N=-N//2\nprint(s)'] | ['Wrong Answer', 'Accepted'] | ['s157646743', 's346885265'] | [3064.0, 2940.0] | [17.0, 17.0] | [649, 141] |
p03286 | u698771758 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n=-int(input())\na=""\nwhile n:\n a+=str(n%2)\n n//=-2\nprint(a[::-1] if n else 0)', 'n=-int(input())\na=""\nwhile n:\n a+=str(n%2)\n n//=-2\nprint(a[::-1] if a else 0)'] | ['Wrong Answer', 'Accepted'] | ['s144180904', 's114490822'] | [2940.0, 2940.0] | [17.0, 17.0] | [83, 83] |
p03286 | u709304134 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["#coding:utf-8\nn = int(input())\n\nif n=0:\n print ('0')\n exit()\n\ni=0\ns=''\nwhile(n!=0):\n if n%(2**(i+1))!=0:\n s+='1'\n n-=(-2)**i\n else:\n s+='0'\n i+=1\nprint (s[::-1])\n", "#coding:utf-8\nn = int(input())\n\nif n==0:\n print ('0')\n exit()\n\ni=0\ns=''\nwhile(n!=0):\n if n%(2**(i+1))!=0:\n s+='1'\n n-=(-2)**i\n else:\n s+='0'\n i+=1\nprint (s[::-1])\n"] | ['Runtime Error', 'Accepted'] | ['s763225635', 's758283334'] | [2940.0, 3060.0] | [17.0, 17.0] | [198, 199] |
p03286 | u721316601 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["N = int(input())\nans = ''\n\nwhile N:\n if N % 2:\n N -= 1\n ans += '1'\n else:\n ans += '0'\n N //= -2\nif len(ans):\n print(ans)\nelse:\n print(0)", "N = int(input())\nans = ''\n\nwhile N:\n if N % 2:\n N -= 1\n ans += '1'\n else:\n ans += '0'\n N //= -2\nif len(ans):\n print(ans[::-1])\nelse:\n print(0)"] | ['Wrong Answer', 'Accepted'] | ['s713521154', 's747145495'] | [2940.0, 3060.0] | [17.0, 18.0] | [172, 178] |
p03286 | u722535636 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n=int(input())\nabsn=abs(n)\nsign=[1,-1]\n\nb,cnt=1,0\nwhile b<absn*2:\n b*=2\n cnt+=1\nans=[]\nwhile cnt >= 0:\n sub=n-b*sign[cnt%2]\n if abs(sub)<abs(b) or abs(sub)<=abs(n):\n ans.append("1")\n n=sub\n else:\n ans.append("0")\n b//=2\n cnt-=1\nfor i in range(3):\n if ans[i]=="1":break\nprint("".join(ans[i::]))\n\n', 'n=int(input())\nans=[]\nif n%2==1:\n ans.append("1")\n n-=1\nelse:ans.append("0")\nn//=2\nwhile n!=0:\n ans.append("1") if n%2==1 else ans.append("0")\n n//=-2\nprint("".join(ans[::-1]))'] | ['Runtime Error', 'Accepted'] | ['s940327062', 's688410221'] | [3064.0, 3060.0] | [18.0, 17.0] | [340, 188] |
p03286 | u723792785 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nansl = []\nif n == 0:\n\tprint(0)\n exit()\nwhile n != 0:\n\tif n % 2 == 1:\n\t\tansl.append("1")\n\t\tn -= 1\n\telse:\n\t\tansl.append("0")\n\tn //= -2\nprint("".join(ansl)[::-1])', 'n = int(input())\nansl = []\nif n == 0:\n\tprint(0)\n\texit()\nwhile n != 0:\n\tif n % 2 == 1:\n\t\tansl.append("1")\n\t\tn -= 1\n\telse:\n\t\tansl.append("0")\n\tn //= -2\nprint("".join(ansl)[::-1])'] | ['Runtime Error', 'Accepted'] | ['s009607490', 's617540017'] | [2940.0, 3060.0] | [17.0, 17.0] | [179, 176] |
p03286 | u729133443 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n=int(input())\ns=''\nwhile n!=0:\n s=str(n%2)+s\n n=-(n//2)\nprint(s*(if s)else 0)", "n=int(input())\ns=''\nwhile n!=0:\n s=str(n%2)+s\n n=-(n//2)\nprint(s*(s!='')else 0)", 'm=2**33//3;print(bin(int(input())+m^m)[2:])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s020451144', 's378990049', 's618156320'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [80, 81, 43] |
p03286 | u729939940 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\na = []\nif N == 0:\n a = ["0"]\nwhile N != 0:\n a.append(str(N % 2))\n N = -(N - N % 2) \nprint("".join(list(reversed(a))))', 'N = int(input())\na = []\nif N == 0:\n a = ["0"]\nwhile N != 0:\n a.append(str(N % 2))\n # N = -(N - N % 2) \nprint("".join(list(reversed(a))))', 'N = int(input())\na = []\nif N == 0:\n a.append("0")\nwhile N != 0:\n a.append(str(N % 2))\n N = -(N // 2)\nprint("".join(reversed(a)))'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s032355372', 's551264501', 's124406051'] | [300440.0, 443544.0, 2940.0] | [2123.0, 2131.0, 17.0] | [143, 145, 131] |
p03286 | u735008991 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nS = ""\nwhile N:\n S = chr(N % (-2)) + S\n N /= (-2)\nprint(S)\n ', 'N = int(input())\nS = ""\nwhile N != 0:\n if N % 2 != 0:\n N -= 1\n S = "0" + S\n else:\n S = "1" + S\n N //= (-2)\nprint(S if S != "" else "0")\n', 'N = int(input())\nS = ""\nwhile N != 0:\n if N % 2 != 0:\n N -= 1\n S = "1" + S\n else:\n S = "0" + S\n N //= (-2)\nprint(S if S != "" else "0")\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s047537684', 's868217982', 's187423630'] | [3060.0, 2940.0, 2940.0] | [18.0, 17.0, 18.0] | [88, 166, 166] |
p03286 | u738835924 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nS = []\nans = "0"\nwhile(abs(N) > 1):\n S.append(str(abs(-N % (-2))))\n N += N % (-2)\n N = N // (-2)\n \nS.append(str(abs(N)))\nS.append("1")\nS.reverse()\n\nif S == []:\n print(ans)\nelse:\n ans = ""\n for i in S:\n ans += i\n \n print(ans)\n \n ', 'N = int(input())\nS = []\nans = "0"\nwhile(abs(N) > 0):\n S.append(str(abs(N % (-2))))\n N += N % (-2)\n N = N // (-2)\n \nS.reverse()\n\nif S == []:\n print(ans)\nelse:\n ans = ""\n for i in S:\n ans += i\n \n print(ans)\n \n '] | ['Wrong Answer', 'Accepted'] | ['s844086815', 's056777967'] | [3060.0, 3060.0] | [18.0, 20.0] | [263, 226] |
p03286 | u740284863 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['import sys\ninput = sys.stdin.readline\nN, M = map(int, input().split(" "))\nA = [int(i) for i in input().split()]\ncount = 0\nfor i in range(N):\n for k in range(i,N):\n S = sum(A[i:k+1])\n if S % M ==0:\n count = count +1\n \nprint(count)\n', "n=int(input())\ns=''\nwhile n != 0:\n s = str( n % 2 ) + s\n n = - ( n // 2 )\nprint(s*(s != '') or 0)\n"] | ['Runtime Error', 'Accepted'] | ['s436262658', 's172188112'] | [3060.0, 3064.0] | [18.0, 17.0] | [258, 104] |
p03286 | u741397536 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\n\nplus = []\nminus = []\nplus_sum = []\nminus_sum = []\n\ns_p = 0\ns_m = 0\nfor i in range(31):\n if i % 2 == 0:\n plus.append(2**i)\n s_p += 2**i\n plus_sum.append(s_p)\n else:\n minus.append(2**i)\n s_m += 2**i\n minus_sum.append(s_m)\n\ndef ten_four(num):\n def for_four(num, arr):\n if num == 0:\n if arr == []:\n return '0'\n else:\n arr_str = map(str, arr[::-1])\n ans = (''.join(arr_str))\n return ans\n else:\n s = num // 4\n a = num % 4\n arr.append(a)\n return for_four(s, arr)\n \n arr = []\n return for_four(num, arr)\n\n\nif n == 0:\n print(0)\nelif n == 1:\n print(1)\nelif n == -1:\n print(11)\nelif n == -2:\n print(10)\n\nelif n > 0:\n for i in range(len(plus_sum)):\n if n <= plus_sum[i]:\n max_4 = i - 1\n n_4 = n - 1 - plus_sum[max_4]\n break\n else:\n pass\n n_4zf = ten_four(n_4).zfill(max_4 + 1)\n n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))\n print('1'+n_ans)\n\nelif n < 0:\n n_1 = n % 2\n n = int(abs((n - n_1)/2))\n print(n)\n for i in range(len(plus_sum)):\n if n <= plus_sum[i]:\n max_4 = i - 1\n n_4 = n - 1 - plus_sum[max_4]\n break\n else:\n pass\n n_4zf = ten_four(n_4).zfill(max_4 + 1)\n n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))\n print('1'+n_ans+str(n_1))", "n = int(input())\n\nplus = []\nminus = []\nplus_sum = []\nminus_sum = []\n\ns_p = 0\ns_m = 0\nfor i in range(31):\n if i % 2 == 0:\n plus.append(2**i)\n s_p += 2**i\n plus_sum.append(s_p)\n else:\n minus.append(2**i)\n s_m += 2**i\n minus_sum.append(s_m)\n\ndef ten_four(num):\n def for_four(num, arr):\n if num == 0:\n if arr == []:\n return '0'\n else:\n arr_str = map(str, arr[::-1])\n ans = (''.join(arr_str))\n return ans\n else:\n s = num // 4\n a = num % 4\n arr.append(a)\n return for_four(s, arr)\n \n arr = []\n return for_four(num, arr)\n\n\nif n == 0:\n print(0)\nelif n == 1:\n print(1)\nelif n == -1:\n print(11)\nelif n == -2:\n print(10)\n\nelif n > 0:\n for i in range(len(plus_sum)):\n if n <= plus_sum[i]:\n max_4 = i - 1\n n_4 = n - 1 - plus_sum[max_4]\n break\n else:\n pass\n n_4zf = ten_four(n_4).zfill(max_4 + 1)\n n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))\n print('1'+n_ans)\n\nelif n < 0:\n n_1 = n % 2\n n = int(abs((n - n_1)/2))\n for i in range(len(plus_sum)):\n if n <= plus_sum[i]:\n max_4 = i - 1\n n_4 = n - 1 - plus_sum[max_4]\n break\n else:\n pass\n n_4zf = ten_four(n_4).zfill(max_4 + 1)\n n_ans = n_4zf.translate(str.maketrans({'0': '10', '1': '11', '2': '00', '3': '01'}))\n print('1'+n_ans+str(n_1))"] | ['Wrong Answer', 'Accepted'] | ['s602526060', 's383663756'] | [3188.0, 3188.0] | [19.0, 19.0] | [1582, 1569] |
p03286 | u745087332 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["# coding:utf-8\n\nn = input()\n\nif n == 0:\n print(0)\n exit()\n\nans = ''\nwhile abs(n) > 0:\n if n % 2 != 0:\n ans += '1'\n n -= 1\n n //= -2\n else:\n ans += '0'\n n //= -2\n\nprint(ans[::-1])", "# coding:utf-8\n\nn = int(input())\n\nif n == 0:\n print(0)\n exit()\n\nans = ''\nwhile abs(n) > 0:\n if n % 2 != 0:\n ans += '1'\n n -= 1\n n //= -2\n else:\n ans += '0'\n n //= -2\n\nprint(ans[::-1])"] | ['Runtime Error', 'Accepted'] | ['s524814621', 's584447413'] | [3060.0, 3064.0] | [18.0, 20.0] | [225, 230] |
p03286 | u746849814 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\n\na = []\nwhile n != 0:\n if n%2 == 0:\n a.append(0)\n else:\n a.append(1)\n n -= 1\n n//=(-2)\n \nif n == 0:\n print(0)\nelse:\n print(''.join(map(str, a[::-1])))", "n = int(input())\n\nif n == 0:\n print(0)\n \nelse:\n a = []\n while n != 0:\n if n%2 == 0:\n a.append(0)\n else:\n a.append(1)\n n -= 1\n n//=(-2)\n \n print(''.join(map(str, a[::-1])))"] | ['Wrong Answer', 'Accepted'] | ['s551887056', 's271415297'] | [3060.0, 3060.0] | [17.0, 18.0] | [206, 243] |
p03286 | u757274384 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['import math\nn = int(input())\nif n == 0:\n print(0)\n exit()\nelse:\n pass\n\nm = math.floor(math.log2(abs(n)))\nans = []\nfor i in range(m+2):\n ans.append(n//((-2)**(m+1-i)))\n\nwhile True:\n if ans[0] == 0:\n ans = ans[1:len(ans)]\n else:\n break\n\nANS = [str(ans[i]) for i in range(len(ans))]\nprint(int("".join(ANS)))', 'n = int(input())\n\nif n == 0:\n print(0)\n exit()\n\ns = ""\n\nwhile True:\n if n == 0:\n break\n if n%2 == 0:\n s += "0"\n n = n//(-2)\n else:\n s += "1"\n n = (n-1)//(-2)\n\nprint(s[::-1])\n'] | ['Runtime Error', 'Accepted'] | ['s344881557', 's202326136'] | [3188.0, 3060.0] | [18.0, 17.0] | [316, 224] |
p03286 | u767871438 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nans=""\nwhile n!=0:\n if n%2==0:\n ans = "0"+ans\n else\n n-=1\n ans = "1"+ans\n n//=-2 \n\nif n==0:\n print("0")\nelse\n print(ans)', 'n = int(input())\nans=""\nwhile n!=0:\n if n%2==0:\n ans = "0"+ans\n else:\n n-=1\n ans = "1"+ans\n n//=-2 \n\nif ans=="":\n print("0")\nelse:\n print(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s434958475', 's901945695'] | [2940.0, 2940.0] | [17.0, 17.0] | [152, 158] |
p03286 | u769698512 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nbin_n = bin(n)\nranges = []\n\ndef base_minus2(m, i, s):\n tmp = s\n if i == 1:\n return tmp + str(m%2)\n for j in range(i-1, -1, -1):\n if m >= ranges[j-1][0] and m <= ranges[j-1][1]:\n print(ranges[j-1], j)\n tmp += "1"\n print(tmp)\n return base_minus2(m-(-2)**j, j, tmp)\n else:\n tmp += "0"\n\nif n == 0:\n print("0")\nelif n == 1:\n print("1")\nelse:\n for i in range(1, 30):\n min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i\n max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i\n ranges.append([min_r, max_r])\n\n result = base_minus2(n, 30, "")\n print(result.lstrip("0"))\n', 'n = int(input())\nbin_n = bin(n)\nranges = []\n\ndef base_minus2(m, i, s):\n tmp = s\n if i == 1:\n return tmp + str(m%2)\n for j in range(i-1, -1, -1):\n\n if m >= ranges[j-1][0] and m <= ranges[j-1][1]:\n tmp += "1"\n return base_minus2(m-(-2)**j, j, tmp)\n else:\n if j == 0:\n return tmp + str(m%2)\n else:\n tmp += "0"\n\n\nif n == 0:\n print("0")\nelif n == 1:\n print("1")\nelse:\n for i in range(1, 60):\n min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i\n max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i\n ranges.append([min_r, max_r])\n\n result = base_minus2(n, 60, "")\n print(result.lstrip("0"))\n'] | ['Runtime Error', 'Accepted'] | ['s515804432', 's269901466'] | [3064.0, 3064.0] | [19.0, 19.0] | [707, 735] |
p03286 | u770077083 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nif n == 0:\n print(0)\n exit(0)\n\noddsum = [2, 10, 42, 170, 682, 2730, 10922, 43690, 174762, 699050, 2796202, 11184810, 44739242, 178956970, 715827882, 2863311530]\nevensum = [1, 5, 21, 85, 341, 1365, 5461, 21845, 87381, 349525, 1398101, 5592405, 22369621, 89478485, 357913941, 1431655765]\ntwo = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184]\nans = 0\nwhile n != 0:\n if n < 0:\n x = 1\n for i in oddsum:\n if n >= -1 * i:\n break\n x += 2\n n += two[x]\n else:\n x = 0\n for i in evensum:\n if n <= i:\n break\n x += 2\n n -= two[x]\n v = 1 << x\n ans += v\nprint(bin(ans))', 'n = int(input())\nif n == 0:\n print(0)\n exit(0)\n\noddsum = [2, 10, 42, 170, 682, 2730, 10922, 43690, 174762, 699050, 2796202, 11184810, 44739242, 178956970, 715827882, 2863311530]\nevensum = [1, 5, 21, 85, 341, 1365, 5461, 21845, 87381, 349525, 1398101, 5592405, 22369621, 89478485, 357913941, 1431655765]\ntwo = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184]\nans = 0\nwhile n != 0:\n if n < 0:\n x = 1\n for i in oddsum:\n if n >= -1 * i:\n break\n x += 2\n n += two[x]\n else:\n x = 0\n for i in evensum:\n if n <= i:\n break\n x += 2\n n -= two[x]\n v = 1 << x\n ans += v\nprint(bin(ans)[2:])'] | ['Wrong Answer', 'Accepted'] | ['s693891699', 's843023590'] | [3064.0, 3192.0] | [18.0, 20.0] | [925, 929] |
p03286 | u782930273 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['import math\n\nN = int(input())\nif N == 0:\n print(0)\n exit()\n\nbits = []\nfor keta in range(int(math.log2(abs(N))) + 1)[::-1]:\n print(N, keta)\n if abs(N - (-2)**keta) <= abs(N):\n bits.append("1")\n N -= (-2)**keta\n else:\n bits.append("0")\n\n\nprint("".join(bits))', 'import math\n\nN = int(input())\nif N == 0:\n print(0)\n exit()\n\nbits = []\nfor keta in range(5 + int(math.log2(abs(N)))):\n if N % 2 == 1:\n bits.append("1")\n N -= 1\n else:\n bits.append("0")\n N //= -2\n if N == 0:\n break\n\nprint("".join(bits[::-1]))'] | ['Wrong Answer', 'Accepted'] | ['s695133819', 's062458057'] | [3064.0, 3316.0] | [17.0, 21.0] | [292, 286] |
p03286 | u787562674 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nans = ""\n\nwhile N != 0:\n if N % 2 != 0:\n N -= 1\n ans = "1" + ans\n else:\n ans = "0" + ans\n N /= -2\n if ans == "":\n ans = "0"\n\nprint(ans) ', 'N = int(input())\nans = ""\n\nwhile N != 0:\n if N % 2 != 0:\n N -= 1\n ans = "1" + ans\n else:\n ans = "0" + ans\n N /= -2\nif ans == "":\n ans = "0"\n\nprint(ans) '] | ['Wrong Answer', 'Accepted'] | ['s614592483', 's947387867'] | [2940.0, 3060.0] | [17.0, 20.0] | [197, 185] |
p03286 | u788137651 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\ni = 1\nans = []\nwhile N != 0:\n if N % (-2 ** i) == 0:\n ans.append(0)\n else:\n ans.append(1)\n N -= ((-2)**(i-1))\n i += 1\nprint("".join(map(str, ans)))', 'N = int(input())\ni = 1\nans = [0 for i in range(1) if N == 0]\nwhile N != 0:\n if N % (-2 ** i) == 0:\n ans.append(0)\n else:\n ans.append(1)\n N -= ((-2)**(i-1))\n i += 1\nprint("".join(map(str, ans))[::-1])\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s518129204', 's842829013'] | [3060.0, 3060.0] | [18.0, 20.0] | [194, 774] |
p03286 | u801512570 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["N=int(input())\n\nif N%2==0:\n ans='0'\nelse:\n ans='1'\n \ni=2\nwhile abs(tmp)<=abs(N):\n if N%((-2)**i)==0:\n ans='0'+ans\n else:\n ans='1'+ans\n \nprint(ans)", "N=int(input())\n\nif N%2==0:\n ans='0'\nelse:\n ans='1'\n N-=1\n \ni=2\nwhile abs(N)>0:\n if N%((-2)**i)==0:\n ans='0'+ans\n else:\n ans='1'+ans\n N-=(-2)**(i-1)\n i+=1\n \nprint(ans)"] | ['Runtime Error', 'Accepted'] | ['s271689277', 's937873130'] | [3064.0, 3060.0] | [19.0, 18.0] | [160, 185] |
p03286 | u807772568 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\n\ns = ""\n\nwhile n != 0:\n\ts = str(n%2) + s\n\ts = -(s//2)\n\nprint(s if s != "" else 0)', 'n = int(input())\n\ns = ""\n\nwhile n != 0:\n\ts = str(n%2) + s\n\tn = -(n//2)\n\nprint(s if s != "" else 0)'] | ['Runtime Error', 'Accepted'] | ['s459666178', 's089224313'] | [2940.0, 2940.0] | [18.0, 17.0] | [98, 98] |
p03286 | u845152373 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["import sys\nfrom collections import deque\n\nsys.setrecursionlimit(10 ** 6)\n\n\ndef input(): return sys.stdin.readline().rstrip()\n\n\nN = int(input())\nl = deque()\nwhile N != 0:\n x = (-2) ** len(l)\n y = (-2) * x\n if abs(N) % abs(y) != 0:\n N -= x\n l.appendleft('1')\n else:\n l.appendleft('0')\nprint(0 if N == 0 else ''.join(l))", "import sys\nfrom collections import deque\n\nsys.setrecursionlimit(10 ** 6)\n\n\ndef input(): return sys.stdin.readline().rstrip()\n\n\nN = int(input())\nl = deque()\nif N == 0:\n print(0)\nelse:\n while N != 0:\n x = (-2) ** len(l)\n y = (-2) * x\n if abs(N) % abs(y) != 0:\n N -= x\n l.appendleft('1')\n else:\n l.appendleft('0')\n print(''.join(l))"] | ['Wrong Answer', 'Accepted'] | ['s621493979', 's536968210'] | [3316.0, 3316.0] | [21.0, 21.0] | [350, 399] |
p03286 | u853185302 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\nx = ""\nwhile n!=0:\n x = str(n%2)+x\n print("-n//2 : {}, -(n//2) : {}".format(-n//2,-(n//2)))\n n = -(n//2)\nprint(0 if x=="" else x)\n\n', 'n = int(input())\nx = ""\nwhile n!=0:\n x = str(n%2)+x\n n = -(n//2)\nprint(0 if x=="" else x)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s005178542', 's902390074'] | [2940.0, 2940.0] | [18.0, 17.0] | [151, 93] |
p03286 | u853900545 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["a=int(input())\nb=''\nwhile a:\n b=str(a&1)+b\n a= a>>1\nprint(b if b else 0)\n", "a=int(input())\nb=''\nwhile a:\n b=str(a&1)+b\n a=-(a<<1)\nprint(b if b else 0)\n", "a=int(input())\nb=''\nwhile a:\n b=str(a&1)+b\n a= (a>>1)\nprint(b if b else 0)", "a=int(input())\nb=''\nwhile a:\n b=str(a&1)+b\n a=-(a>>1)\nprint(b if b else 0)\n"] | ['Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted'] | ['s255212535', 's437499668', 's987305737', 's474828653'] | [3660.0, 3456.0, 3672.0, 2940.0] | [2104.0, 2108.0, 2104.0, 18.0] | [73, 75, 74, 75] |
p03286 | u853952087 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n=int(input())\nL=[]\nif n==0:\n print('0')\nelse: \n while n!=0:\n if n>0 and n%2==0:\n n=-n//2\n L.append('0')\n elif n>0 and n%2==1:\n n=(-n+1)//2\n L.append('1')\n elif n<0 and -n%2==0:\n n=-n//2\n L.append('0')\n elif n<0 and -n%2==1:\n n=(-n+1)//2\n L.append('1')\n print(n)\n print(L)\n print(int(''.join(L[::-1])))", "\nn=int(input())\nL=[]\nif n==0:\n print('0')\nelse:\n\n while n!=0:\n if n>0 and n%2==0:\n n=-n//2\n L.append('0')\n elif n>0 and n%2==1:\n n=(-n+1)//2\n L.append('1')\n elif n<0 and -n%2==0:\n n=-n//2\n L.append('0')\n elif n<0 and -n%2==1:\n n=(-n+1)//2\n L.append('1')\n print(int(''.join(L[::-1])))\n"] | ['Wrong Answer', 'Accepted'] | ['s192276350', 's471204050'] | [3064.0, 3064.0] | [20.0, 17.0] | [440, 578] |
p03286 | u854144714 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N=int(input())\nS=""\nfor i in range(50):\n if N%(-2)==0:\n S=S+"0"\n else:\n S=S+"1"\n N-=1\n N=N//(-2)\nprint(int(S))', '\nN=int(input())\nS=""\nfor i in range(50):\n if N%(-2)==0:\n S="0"+S\n else:\n S="1"+S\n N-=1\n N=N//(-2)\nprint(int(S))'] | ['Wrong Answer', 'Accepted'] | ['s836166913', 's454593046'] | [3064.0, 2940.0] | [17.0, 17.0] | [140, 141] |
p03286 | u856232850 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\nans = ''\na = 2\nwhile True:\n\tif n == 0:\n\t\tbreak\n\tif n % a == 0:\n\t\tans += '0'\n\telse:\n\t\tans += '1'\n\t\tn -= (a//2)\n\n\tn = n//2\n\tif a == 2:\n\t\ta = -2\n\telse:\n\t\ta = 2\n\n\nans = ans[::-1]\nif n == 0:\n\tprint(0)\nelse:\n\tprint(ans)", "n = int(input())\nnn = n\nans = ''\na = 2\nwhile True:\n\tif n == 0:\n\t\tbreak\n\tif n % a == 0:\n\t\tans += '0'\n\telse:\n\t\tans += '1'\n\t\tn -= (a//2)\n\n\tn = n//2\n\tif a == 2:\n\t\ta = -2\n\telse:\n\t\ta = 2\n\n\nans = ans[::-1]\nif nn == 0:\n\tprint(0)\nelse:\n\tprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s900529689', 's389762144'] | [3064.0, 3064.0] | [18.0, 18.0] | [230, 238] |
p03286 | u858136677 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['invtwos = [1]\ni = 0\nwhile abs(invtwos[i]) <= 10**10:\n invtwos.append(invtwos[i]*(-2))\n i += 1\ninvtwos.append(invtwos[-1]*(-2))\n\nn = int(input())\nans = []\ni = 0\nwhile n != 0:\n if n%abs(invtwos[i+1]) != 0:\n ans.append(1)\n n -= invtwos[i]\n else:\n ans.append(0)\n i += 1\nans.reverse()\nif n == 0:\n print("0")\nelse:\n for i in range(len(ans)):\n if i != len(ans)-1:\n print(ans[i],end="")\n else:\n print(ans[i])', 'invtwos = [1]\ni = 0\nwhile abs(invtwos[i]) <= 10**10:\n invtwos.append(invtwos[i]*(-2))\n i += 1\ninvtwos.append(invtwos[-1]*(-2))\n\nn = int(input())\nans = []\ni = 0\nwhile n != 0:\n if n%abs(invtwos[i+1]) != 0:\n ans.append(1)\n n -= invtwos[i]\n else:\n ans.append(0)\n i += 1\nans.reverse()\n\nif len(ans) == 0:\n print("0")\nelse:\n for i in range(len(ans)):\n if i != len(ans)-1:\n print(ans[i],end="")\n else:\n print(ans[i])'] | ['Wrong Answer', 'Accepted'] | ['s665743559', 's370330358'] | [3064.0, 3064.0] | [17.0, 17.0] | [478, 486] |
p03286 | u858670323 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nS = list()\nif N==0:\n print(0)\n exit()\nelif N>0:\n while N>0:\n S.append(N%2)\n N//=2\n S.append(0)\n S.append(0)\n for i in range(len(S)-1):\n if i%2==1 and S[i]==1:\n S[i+1] += 1\n if S[i]==2:\n S[i]=0\n S[i+1]+=1\nelse:\n N *= -1\n while N>0:\n S.append(N%2)\n N//=2\n S.append(0)\n S.append(0)\n for i in range(len(S)-1):\n if i%2==0 and S[i]==1:\n S[i+1] += 1\n if S[i]==2:\n S[i]=0\n S[i+1]+=1\n \nS.reverse()\nif S[0]==0:\n S = S[1:]\nans = ""\nfor s in S:\n ans += str(s)\nprint(ans)\n', 'N = int(input())\nS = list()\nif N==0:\n print(0)\n exit()\nelif N>0:\n while N>0:\n S.append(N%2)\n N//=2\n S.append(0)\n S.append(0)\n for i in range(len(S)-1):\n if i%2==1 and S[i]==1:\n S[i+1] += 1\n if S[i]==2:\n S[i]=0\n S[i+1]+=1\nelse:\n N *= -1\n while N>0:\n S.append(N%2)\n N//=2\n S.append(0)\n S.append(0)\n for i in range(len(S)-1):\n if i%2==0 and S[i]==1:\n S[i+1] += 1\n if S[i]==2:\n S[i]=0\n S[i+1]+=1\n \nS.reverse()\nwhile S[0]==0:\n S = S[1:]\nans = ""\nfor s in S:\n ans += str(s)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s806192627', 's363601999'] | [9100.0, 9276.0] | [32.0, 30.0] | [544, 547] |
p03286 | u859897687 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n=abs(int(input()))\nm=n\ni=0\nnn=0\nwhile m//2>0:\n nn+=m%2*(2**i)\n i+=1\n m//=2\nn+=nn\na=[]\nwhile n//2>2:\n a.append(n%2)\n n//=2\nans=""\nfor i in range(len(a)-1,-1,-1):\n ans+=str(a[i])\nprint(ans)', 'n=abs(int(input()))\nm=n\ni=0\nnn=0\nwhile m//2>0:\n nn+=m%2*(2**(i+1))\n i+=1\n m//=2\nn+=nn\na=[]\nwhile n//2>2:\n a.append(n%2)\n n//=2\nans=""\nfor i in range(len(a)-1,-1,-1):\n ans+=str(a[i])\nprint(ans)', 'n,i,a,r=int(input()),0,0,1\nwhile n:\n r*=-2;i-=1\n if (n-r)%(-2*r)==0:a+=10**i;n-=r\nprint(a)\n \n', 'n,i,a=int(input()),0,0\nwhile n:\n r=-2**i\n if (n-r)%(-2*r)==0:\n a+=10**i;n-=r\n i+=1\nprint(a)\n ', 'n=abs(int(input()))\nm=n\ni=0\nnn=0\nwhile m//2>0:\n if i%2==0:\n nn+=m%2*(2**(i+1))\n i+=1\n m//=2\nn+=nn\na=[]\nwhile n//2>2:\n a.append(n%2)\n n//=2\nans=""\nfor i in range(len(a)-1,-1,-1):\n ans+=str(a[i])\nprint(ans)', 'n,i,a=int(input()),0,0\nwhile n:\n r=(-2)**i\n if (n-r)%(-2*r)==0:\n a+=10**i;n-=r\n i+=1\nprint(a)\n \n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s315744188', 's604547316', 's630874831', 's927470761', 's966313826', 's801900443'] | [3064.0, 3064.0, 3060.0, 3060.0, 3064.0, 2940.0] | [17.0, 18.0, 2104.0, 2104.0, 18.0, 19.0] | [194, 198, 98, 102, 213, 105] |
p03286 | u860002137 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\n\nans = ""\n\nwhile n != 0:\n if n % 2 == 1:\n ans += "1"\n n = n - 1\n n //= -2\n else:\n ans += "0"\n n //= -2\n\nprint(ans[::-1] if n != 0 else 0)', 'n = int(input())\nN = n\n\nans = ""\n\nwhile n != 0:\n if n % 2 == 1:\n ans += "1"\n n = n - 1\n n //= -2\n else:\n ans += "0"\n n //= -2\n\nprint(ans[::-1] if N != 0 else 0)'] | ['Wrong Answer', 'Accepted'] | ['s619071857', 's438205003'] | [9048.0, 9108.0] | [31.0, 24.0] | [195, 201] |
p03286 | u879870653 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nS = ""\nwhile N != 0 :\n if N % (-2) == 0 :\n S = "0"+S\n else :\n S = "1"+S\n N -= 1\n N = N / 2\nif len(S) != 0 :\n print(S)\nelse :\n print(0)\n\n', 'N = int(input())\nS = ""\nwhile N != 0 :\n if N % (-2) != 0 :\n S = "1" + S\n N -= 1\n else :\n S = "0" + S\n N /= (-2)\nif len(S) == 0 :\n print(0)\nelse :\n print(S)\n \n '] | ['Wrong Answer', 'Accepted'] | ['s144146448', 's650064672'] | [3672.0, 3064.0] | [2104.0, 18.0] | [189, 201] |
p03286 | u887207211 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['N = int(input())\nans = ""\nwhile N != 0:\n if(N%2 == 0):\n ans += "0"\n else:\n ans += "1"\n N -= 1\n N //= -2\nif(bit == ""):\n ans = ""\nprint(ans[::-1]) ', 'N = int(input())\nans = ""\nwhile N:\n if(N%2 == 0):\n ans += "0"\n else:\n ans += "1"\n N -= 1\n N //= -2\nif(ans == ""):\n ans = "0"\nprint(ans[::-1])'] | ['Runtime Error', 'Accepted'] | ['s422763157', 's776434929'] | [2940.0, 2940.0] | [18.0, 18.0] | [160, 152] |
p03286 | u892340697 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['\nans = ""\nif N == 1:\n print("1")\nelif N == -1:\n print("10")\nelse:\n while True:\n r = N % 2\n N = (N-r) /-2\n ans = str(int(r)) + ans\n if N == 0 or N == 1:\n ans = str(int(N)) + ans\n break\n\n print(ans)', 'import math\nN = int(input())\n\nans = ""\nif N == 1:\n print("1") \nelif N == 0:\n print("0") \nelif N == -1:\n print("10")\nelse:\n while True:\n r = N % 2\n N = (N-r) /-2\n ans = str(int(r)) + ans\n if N == 0 or N == 1:\n ans = str(int(N)) + ans\n break\n\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s561835110', 's039954446'] | [9032.0, 9072.0] | [26.0, 27.0] | [258, 318] |
p03286 | u911507660 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["N = int(input())\n\nif N == 0:\n print('0')\n exit(0)\n\nidx = 0\nwhile True:\n idx += 1\n left = sum([(-2)**i for i in range(idx+1) if i%2==1])\n right = sum([(-2)**i for i in range(idx+1) if i%2==0])\n if left <= N <= right:\n break\n \nmax_idx = idx\ncoeff = [0 for _ in range(max_idx+1)]\nfor idx in range(max_idx, 0-1, -1):\n left = sum([(-2)**i for i in range(idx) if i%2==1])\n right = sum([(-2)**i for i in range(idx) if i%2==0])\n print(left, N, right)\n if not left <= N <= right:\n N -= (-2)**(idx)\n coeff[idx] = 1\n# print(N)\n# print(reversed(coeff)\nprint(''.join(map(str, reversed(coeff))))", "# C\nN = int(input())\n\nif N == 0:\n print('0')\nelse:\n\n idx = 0\n while True:\n idx += 1\n left = sum([(-2)**i for i in range(idx+1) if i%2==1])\n right = sum([(-2)**i for i in range(idx+1) if i%2==0])\n if left <= N <= right:\n break\n\n max_idx = idx\n coeff = [0 for _ in range(max_idx+1)]\n for idx in range(max_idx, 0-1, -1):\n left = sum([(-2)**i for i in range(idx) if i%2==1])\n right = sum([(-2)**i for i in range(idx) if i%2==0])\n print(left, N, right)\n if not left <= N <= right:\n N -= (-2)**(idx)\n coeff[idx] = 1\n # print(N)\n # print(reversed(coeff)\n print(''.join(map(str, reversed(coeff))))", "# C\nN = int(input())\n\nif N == 0:\n print('0')\nelse:\n\n idx = 0\n while True:\n idx += 1\n left = sum([(-2)**i for i in range(idx+1) if i%2==1])\n right = sum([(-2)**i for i in range(idx+1) if i%2==0])\n if left <= N <= right:\n break\n\n max_idx = idx\n coeff = [0 for _ in range(max_idx+1)]\n for idx in range(max_idx, 0-1, -1):\n left = sum([(-2)**i for i in range(idx) if i%2==1])\n right = sum([(-2)**i for i in range(idx) if i%2==0])\n# print(left, N, right)\n if not left <= N <= right:\n N -= (-2)**(idx)\n coeff[idx] = 1\n # print(N)\n # print(reversed(coeff)\n print(''.join(map(str, reversed(coeff))))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s059603229', 's175352370', 's113095222'] | [3064.0, 3064.0, 3064.0] | [18.0, 18.0, 18.0] | [643, 709, 711] |
p03286 | u918601425 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n=int(input())\nif n==0:\n print('0')\nelse:\n ls=[]\n while(n!=0):\n ls.append(n%2)\n n=-1*(n-n%2)//2\nls.sort(reverse:True)\nprint(ls)\n \n \n ", 'N=int(input())\nls=[]\nwhile True:\n ls.append(N%2)\n N=-(N//2)\n if N==0:\n break\nprint(*reversed(ls),sep="")'] | ['Runtime Error', 'Accepted'] | ['s603073677', 's508348066'] | [3064.0, 2940.0] | [17.0, 17.0] | [149, 110] |
p03286 | u921773161 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["import math\nN = int(input())\n\ndef order2(x):\n if x > 0 :\n k = 0\n check = 0\n while check == 0 :\n s = 0\n for i in range(0, k+1, 2):\n s += (-2)**i\n ans = i\n if s >= x:\n check = 1\n k += 2\n elif x < 0 :\n k = 1\n check = 0\n while check == 0 :\n s = 0\n for i in range(1, k+1, 2):\n s += (-2)**i\n ans = i\n if s <= x:\n check = 1\n k += 2\n return ans\n\nif N!= 0 :\n\n\n l = [] \n a = N\n i = order2(N)\n while i >= 0:\n if a == 0 :\n l.append(0)\n if a > 0 and (-2)**i >0 :\n s = 0\n for j in range(0, i, 2):\n s += (-2)**j\n print(a,s)\n if a > s :\n l.append('1')\n a -= (-2)**i\n else :\n l.append('0')\n elif a > 0 and (-2)**i < 0:\n l.append('0')\n elif a < 0 and (-2)**i > 0:\n l.append('0')\n elif a < 0 and (-2)**i < 0:\n s = 0\n for j in range(1, i, 2):\n s += (-2)**j\n if a < s :\n l.append('1')\n a -= (-2)**i\n else :\n l.append('0')\n i -= 1\n\n print(''.join(l))\n\nelse :\n print(0)", "N = int(input())\n\ndef order2(x):\n if x > 0 :\n k = 0\n check = 0\n while check == 0 :\n s = 0\n for i in range(0, k+1, 2):\n s += (-2)**i\n ans = i\n if s >= x:\n check = 1\n k += 2\n elif x < 0 :\n k = 1\n check = 0\n while check == 0 :\n s = 0\n for i in range(1, k+1, 2):\n s += (-2)**i\n ans = i\n if s <= x:\n check = 1\n k += 2\n return ans\n\nif N!= 0 :\n\n\n l = [] \n a = N\n i = order2(N)\n while i >= 0:\n if a == 0 :\n l.append('0')\n if a > 0 and (-2)**i >0 :\n s = 0\n for j in range(0, i, 2):\n s += (-2)**j\n if a > s :\n l.append('1')\n a -= (-2)**i\n else :\n l.append('0')\n elif a > 0 and (-2)**i < 0:\n l.append('0')\n elif a < 0 and (-2)**i > 0:\n l.append('0')\n elif a < 0 and (-2)**i < 0:\n s = 0\n for j in range(1, i, 2):\n s += (-2)**j\n if a < s :\n l.append('1')\n a -= (-2)**i\n else :\n l.append('0')\n i -= 1\n\n print(''.join(l))\n\nelse :\n print(0)"] | ['Runtime Error', 'Accepted'] | ['s806333743', 's253032804'] | [3188.0, 3188.0] | [19.0, 19.0] | [1127, 1098] |
p03286 | u923662841 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n=int(input())\nx = ""\nwhile n!=0:\n x = str(n%2) + x\n n = -(n//2)\nif x = "":\n print(0)\nelse:\n print(x)', 'n=int(input())\nx = ""\nwhile n!=0:\n x = str(n%2) + x\n n = -(n//2)\nif x == "":\n print(0)\nelse:\n print(x)\n'] | ['Runtime Error', 'Accepted'] | ['s826477905', 's032334304'] | [8956.0, 9068.0] | [29.0, 29.0] | [113, 115] |
p03286 | u924406834 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\nans = ''\nfor i in range(30):\n if n == 0:\n break\n if n % 2 ** (i + 1) == 0: \n ans = ans + '0'\n else:\n n -= (-2)**i\n ans = ans + '1'\nprint(ans)", "n = int(input())\nans = ''\nfor i in range(30):\n if n == 0:\n break\n if n % 2 ** (i + 1) == 0: \n ans = ans + '0'\n else:\n n -= (-2)**i\n ans = ans + '1'\nprint(int(ans))", "n = int(input())\nant = 0\nif n == 0:\n ant = 1\nans = ''\nfor i in range(10000):\n if n == 0:\n break\n if n % 2 ** (i + 1) == 0: \n ans = '0' + ans\n else:\n n -= (-2)**i\n ans = '1' + ans\nif ant == 0:\n print(ans)\nelse:\n print('0')"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s008952914', 's392820302', 's669148306'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0] | [195, 200, 267] |
p03286 | u932868243 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n=int(input())\nif n==0:\n print(0)\n exit()\nif n==1:\n print(1)\n exit()\nans=[]\nwhile n!=1:\n r=n%(-2)\n ans.append(str(r))\n n=(n-r)//(-2)\nans.append(str(1))\nans.reverse()\nprint(''.join(ans))\n ", "n=int(input())\nans=''\nwhile n!1:\n r=n%(-2)\n ans+=r\n n=n//(-2)\nans+=n\nans.reverse()\nprint(ans)\n ", "n=int(input())\nif n==0:\n print(0)\n exit()\nif n==1:\n print(1)\n exit()\nans=[]\nwhile n!=1:\n r=n%2\n ans.append(str(r))\n n=(n-r)//(-2)\nans.append(str(1))\nans.reverse()\nprint(''.join(ans))\n "] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s339032226', 's855400402', 's067732789'] | [338584.0, 2940.0, 3064.0] | [2125.0, 17.0, 18.0] | [199, 103, 196] |
p03286 | u934868410 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\npow_m2 = [1]\nfor i in range(100):\n pow_m2.append(pow_m2[-1]*-2)\ndiv = 2\nk = 0\nbit_m2 = []\nwhile div < 2 * n:\n if (n % div - k) // (div / 2) == 1:\n bit_m2.append('1')\n else:\n bit_m2.append('0')\n k = n % div\n div *= 2\nprint(''.join(reversed(bit_m2)))", "n = int(input())\nif n == 0:\n print(0)\n exit()\n\nans = list()\nwhile n != 0:\n ans.append(str((n%-2)*(-1)))\n if n % (-2) < 0:\n n = (n-1) // (-2)\n else:\n n = n // (-2)\n\nprint(''.join(reversed(ans)))"] | ['Wrong Answer', 'Accepted'] | ['s002879371', 's539382073'] | [3064.0, 3060.0] | [17.0, 18.0] | [276, 222] |
p03286 | u940102677 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['n = int(input())\ns =""\nk = 0\nwhile n!=0:\n if n%(2**(k+1)) == 2**k:\n if k%2 == 0:\n n -= 2**k\n else:\n n += 2**k\n s += "1"\n else:\n s += "0"\n k += 1\n\nif s="":\n s="0"\n\nprint("".join(s))', 'n = int(input())\ns = ""\nk = 0\nwhile n!=0:\n if n%(2**(k+1)) == 2**k:\n if k%2 == 0:\n n -= 2**k\n else:\n n += 2**k\n s = "1"+s\n else:\n s = "0"+s\n k += 1\n\nif s=="":\n s="0"\n\nprint("".join(s))'] | ['Runtime Error', 'Accepted'] | ['s240908113', 's272551407'] | [2940.0, 3060.0] | [17.0, 17.0] | [206, 210] |
p03286 | u943657163 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\ns = ''\n\nif n == 0:\n print(0)\n exit()\n\ni = 0\nwhile n != 0:\n if n % (2 ** (i+1)) != 0:\n s += '1'\n n -= (-2) ** i\n else:\n s += '0'\n print(s)\n i += 1\nprint(s[::-1])", "n = int(input())\ns = ''\n \nif n == 0:\n print(0)\n exit()\n \ni = 0\nwhile n != 0:\n if n % (2 ** (i+1)) != 0:\n s += '1'\n n -= (-2) ** i\n else:\n s += '0'\n i += 1\nprint(s[::-1])"] | ['Wrong Answer', 'Accepted'] | ['s600985261', 's013500557'] | [3060.0, 3060.0] | [17.0, 17.0] | [216, 205] |
p03286 | u946996108 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['mod = 10 ** 9 + 7\nmod2 = 2 ** 61 + 1\nfrom collections import deque\nimport heapq\nfrom bisect import bisect_left, insort_left, bisect_right\n\n_NUMINT_ALL = list(range(10))\n\n\ndef main():\n ans = solve()\n\n if ans in [True, False]:\n YesNo(ans)\n elif ans is not None:\n print(ans)\n\n\ndef solve():\n N = iip(False)\n\n n = N \n result = []\n cur = 2\n for i in range(10**6):\n print(n, cur, i)\n if abs(n) == cur:\n if i % 2 == 0:\n if n < 0:\n result.append(0)\n result.append(1)\n else:\n result.append(0)\n result.append(1)\n result.append(1)\n else:\n result.append(1)\n break\n\n if n % cur != 0:\n result.append(1)\n if i % 2 == 0:\n n -= cur // 2\n else:\n n += cur // 2\n else:\n result.append(0)\n\n cur *= 2\n\n result.reverse()\n print("".join([str(i) for i in result]))\n\n\n\n\n\ndef iip(listed=True, num_only=True): \n if num_only:\n ret = [int(i) for i in input().split()]\n else:\n ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]\n\n if len(ret) == 1 and not listed:\n return ret[0]\n return ret\n\n\ndef saidai_kouyakusuu(A): \n l = len(A)\n while True:\n m = min(A)\n mx = max(A)\n if m == mx:\n return m\n\n for i in range(l):\n if A[i] % m == 0:\n A[i] = m\n else:\n A[i] %= m\n\n\ndef sort_tuples(l, index): \n if isinstance(l, list):\n l.sort(key=lambda x: x[index])\n return l\n else:\n l = list(l)\n return sorted(l, key=lambda x: x[index])\n\n\ndef count_elements(l): \n d = {}\n for i in l:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n return d\n\n\ndef safeget(l, index, default="exception"): \n if index >= len(l): \n if default == "exception":\n raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))\n else:\n return default\n elif index < 0:\n if default == "exception":\n raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))\n else:\n return default\n else:\n return l[index]\n\n\ndef iipt(l, listed=False, num_only=True): \n ret = []\n for i in range(l):\n ret.append(iip(listed=listed, num_only=num_only))\n return ret\n\n\ndef sortstr(s): \n return "".join(sorted(s))\n\n\ndef iip_ord(startcode="a"): \n if isinstance(startcode, str):\n startcode = ord(startcode)\n return [ord(i) - startcode for i in input()]\n\n\ndef YesNo(s): \n if s:\n print("Yes")\n else:\n print("No")\n\n\ndef fprint(s): \n for i in s:\n print(i)\n\n\ndef bitall(N): \n ret = []\n for i in range(2 ** N):\n a = []\n for j in range(N):\n a.append(i % 2)\n i //= 2\n ret.append(a)\n return ret\n\ndef split_print_space(s): \n print(" ".join([str(i) for i in s]))\n\n\ndef split_print_enter(s): \n print("\\n".join([str(i) for i in s]))\n\n\ndef soinsuu_bunkai(n): \n ret = []\n for i in range(2, int(n ** 0.5) + 1):\n while n % i == 0:\n n //= i\n ret.append(i)\n if i > n:\n break\n if n != 1:\n ret.append(n)\n return ret\n\n\ndef conbination(n, r, mod, test=False): \n if n <= 0:\n return 0\n if r == 0:\n return 1\n if r < 0:\n return 0\n if r == 1:\n return n\n ret = 1\n for i in range(n - r + 1, n + 1):\n ret *= i\n ret = ret % mod\n\n bunbo = 1\n for i in range(1, r + 1):\n bunbo *= i\n bunbo = bunbo % mod\n\n ret = (ret * inv(bunbo, mod)) % mod\n if test:\n # print(f"{n}C{r} = {ret}")\n pass\n return ret\n\n\ndef inv(n, mod): \n return power(n, mod - 2)\n\n\ndef power(n, p, mod_=mod): \n if p == 0:\n return 1\n if p % 2 == 0:\n return (power(n, p // 2, mod_) ** 2) % mod_\n if p % 2 == 1:\n return (n * power(n, p - 1, mod_)) % mod_\n\n\nif __name__ == "__main__":\n main()\n', 'mod = 10 ** 9 + 7\nmod2 = 2 ** 61 + 1\nfrom collections import deque\nimport heapq\nfrom bisect import bisect_left, insort_left, bisect_right\n\n_NUMINT_ALL = list(range(10))\n\n\ndef main():\n ans = solve()\n\n if ans is True or ans is False:\n YesNo(ans)\n elif ans is not None:\n print(ans)\n\n\ndef solve():\n N = iip(False)\n if N == 0:\n return 0\n\n n = N \n result = []\n cur = -2\n for i in range(100):\n if n % cur != 0:\n result.append(1)\n n -= cur/(-2)\n else:\n result.append(0)\n cur *= -2\n\n if abs(cur) > abs(N) * 10:\n break\n\n\n result.reverse()\n r = []\n f = False\n for i in result:\n if f:\n r.append(i)\n elif i == 1:\n r.append(i)\n f = True\n\n print("".join([str(i) for i in r]))\n\n\n\n\n\ndef iip(listed=True, num_only=True): \n if num_only:\n ret = [int(i) for i in input().split()]\n else:\n ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]\n\n if len(ret) == 1 and not listed:\n return ret[0]\n return ret\n\n\ndef saidai_kouyakusuu(A): \n l = len(A)\n while True:\n m = min(A)\n mx = max(A)\n if m == mx:\n return m\n\n for i in range(l):\n if A[i] % m == 0:\n A[i] = m\n else:\n A[i] %= m\n\n\ndef sort_tuples(l, index): \n if isinstance(l, list):\n l.sort(key=lambda x: x[index])\n return l\n else:\n l = list(l)\n return sorted(l, key=lambda x: x[index])\n\n\ndef count_elements(l): \n d = {}\n for i in l:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n return d\n\n\ndef safeget(l, index, default="exception"): \n if index >= len(l): \n if default == "exception":\n raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))\n else:\n return default\n elif index < 0:\n if default == "exception":\n raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))\n else:\n return default\n else:\n return l[index]\n\n\ndef iipt(l, listed=False, num_only=True): \n ret = []\n for i in range(l):\n ret.append(iip(listed=listed, num_only=num_only))\n return ret\n\n\ndef sortstr(s): \n return "".join(sorted(s))\n\n\ndef iip_ord(startcode="a"): \n if isinstance(startcode, str):\n startcode = ord(startcode)\n return [ord(i) - startcode for i in input()]\n\n\ndef YesNo(s): \n if s:\n print("Yes")\n else:\n print("No")\n\n\ndef fprint(s): \n for i in s:\n print(i)\n\n\ndef bitall(N): \n ret = []\n for i in range(2 ** N):\n a = []\n for j in range(N):\n a.append(i % 2)\n i //= 2\n ret.append(a)\n return ret\n\ndef split_print_space(s): \n print(" ".join([str(i) for i in s]))\n\n\ndef split_print_enter(s): \n print("\\n".join([str(i) for i in s]))\n\n\ndef soinsuu_bunkai(n): \n ret = []\n for i in range(2, int(n ** 0.5) + 1):\n while n % i == 0:\n n //= i\n ret.append(i)\n if i > n:\n break\n if n != 1:\n ret.append(n)\n return ret\n\n\ndef conbination(n, r, mod, test=False): \n if n <= 0:\n return 0\n if r == 0:\n return 1\n if r < 0:\n return 0\n if r == 1:\n return n\n ret = 1\n for i in range(n - r + 1, n + 1):\n ret *= i\n ret = ret % mod\n\n bunbo = 1\n for i in range(1, r + 1):\n bunbo *= i\n bunbo = bunbo % mod\n\n ret = (ret * inv(bunbo, mod)) % mod\n if test:\n # print(f"{n}C{r} = {ret}")\n pass\n return ret\n\n\ndef inv(n, mod): \n return power(n, mod - 2)\n\n\ndef power(n, p, mod_=mod): \n if p == 0:\n return 1\n if p % 2 == 0:\n return (power(n, p // 2, mod_) ** 2) % mod_\n if p % 2 == 1:\n return (n * power(n, p - 1, mod_)) % mod_\n\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s490152046', 's863372896'] | [41588.0, 3444.0] | [2104.0, 22.0] | [5378, 5157] |
p03286 | u970899068 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n=int(input())\nans=[]\nif n==0:\n print(0)\n exit()\n \nfor i in range(100):\n if n==0:\n break\n if n%(2**(i+1))==0:\n ans.append('0')\n else:\n if i%2==0:\n n-=2**i\n else:\n n+=2**i\n ans.append('1')\n\nprint(''.join(map(str, ans)))", 'n=int(input())\nans=[]\nif n==0:\n print(0)\n exit()\n \nfor i in range(100):\n if n==0:\n break\n if n%(2**(i+1))==0:\n ans.append(0)\n else:\n if i%2==0:\n n-=2**i\n else:\n n+=2**i\n ans.append(1)\nans.reverse()\nprint(*ans)', "n=int(input())\nans=[]\nif n==0:\n print(0)\n exit()\n \nfor i in range(100):\n if n==0:\n break\n if n%(2**(i+1))==0:\n ans.append('0')\n else:\n if i%2==0:\n n-=2**i\n else:\n n+=2**i\n ans.append('1')\nans.reverse()\nprint(''.join(map(str, ans)))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s019080878', 's869663163', 's208942754'] | [3060.0, 3060.0, 3064.0] | [18.0, 20.0, 17.0] | [294, 285, 307] |
p03286 | u977389981 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ["n = int(input())\nans = []\n\nwhile n != 0:\n if n % -2 == -1:\n n = n // -2 + 1\n ans.append('1')\n else:\n n = n // -2\n ans.append('0')\n \nans.reverse()\n\nif n == 0:\n print('0')\nelse:\n print(''.join(ans))", "n = int(input())\nbinary = []\nflag = 0\n\nif n == 0:\n print(0)\n flag = 1\n \nwhile n != 0:\n if n % -2 != 0:\n binary.append('1')\n n = n // -2 + 1\n else:\n binary.append('0')\n n = n // -2\n \nif flag == 0:\n print(''.join(binary))", "N = int(input())\nbinarys = []\nflag = 0\n\nif N == 0:\n print(0)\n flag = 1\n \nwhile N != 0:\n if N % -2 != 0:\n binarys.append('1')\n N = N // -2\n else:\n binarys.append('0')\n N = N // -2\n\nbinarys.reverse()\n\nif flag == 0:\n print(''.join(binarys))", "n = int(input())\nA = []\n\nif n == 0:\n print(0)\nelse:\n while n != 0:\n if n % -2 != 0:\n A.append('1')\n n = n // -2 + 1\n else:\n A.append('0')\n n = n // -2\n\nA.reverse()\nprint(''.join(A))"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s244335958', 's405623939', 's633440578', 's941446732'] | [3060.0, 3060.0, 3060.0, 3060.0] | [18.0, 17.0, 18.0, 18.0] | [239, 272, 283, 245] |
p03286 | u985170143 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['def is_even(n):\n if n % 2 == 0:\n return True\n else:\n return False\n\ndef mainas_number():\n N = int(input())\n\n k =[]\n if N == 0:\n print(0)\n exit()\n\n if is_even(N):\n k.append(0)\n else:\n N -= 1\n k.append(1)\n\n for i in range(1,100):\n if (N // (-2)**i) % 2 == 1:\n N -= (-2)**i\n k.append(1)\n\n else:\n k.append(0)\n\n if N == 0:\n break\n\n print(k[::-1])\n \nif __name__ == "__main__":\n mainas_number()', 'def is_even(n):\n if n % 2 == 0:\n return True\n else:\n return False\n\ndef mainas_number():\n N = int(input())\n\n k =[]\n if N == 0:\n print(0)\n exit()\n\n if is_even(N):\n k.append(0)\n else:\n N -= 1\n k.append(1)\n\n for i in range(1,100):\n if (N // (-2)**i) % 2 == 1:\n N -= (-2)**i\n k.append(1)\n\n else:\n k.append(0)\n\n if N == 0:\n break\n\n ans = ""\n for c in k[::-1]:\n ans += str(c)\n print(ans)\n \nif __name__ == "__main__":\n mainas_number()'] | ['Wrong Answer', 'Accepted'] | ['s807353002', 's691529062'] | [3064.0, 3064.0] | [18.0, 20.0] | [533, 586] |
p03286 | u987164499 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['from sys import stdin\nn = int(stdin.readline().rstrip())\ndef num(n):\n if n%2 == 0:\n return num(n//(-2)) + "0"\n else:\n return num(n//(-2)) + "1"\n\nif n == 0:\n print(0)\n exit()\n\nprint(num(n))', 'n = int(input())\n\nif n == 0:\n print(0)\n exit()\n\ns = ""\n\nwhile True:\n if n == 0:\n break\n if n%2 == 0:\n s += "0"\n n = n//(-2)\n else:\n s += "1"\n n = (n-1)//(-2)\n\nprint(s)', 'n = int(input())\n\nif n == 0:\n print(0)\n exit()\n\ns = ""\n\nwhile True:\n if n == 0:\n break\n if n%2 == 0:\n s += "0"\n n = n//(-2)\n else:\n s += "1"\n n = (n-1)//(-2)\n\nprint(s[::-1])'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s542794157', 's625018748', 's850315239'] | [3864.0, 2940.0, 3060.0] | [73.0, 18.0, 17.0] | [214, 217, 223] |
p03286 | u989345508 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['import math\n\nn=int(input())\ns=""\n\ni=0\nwhile n!=0:\n #print(s)\n if abs(n)%2==0:\n s="0"+s\n n=n//2\n else:\n if i%2==0:\n n=(n-1)//2\n else:\n n=(n+1)//2\n s="1"+s\n i+=1\nif n!=0:\n print(s)\nelse:\n print(0)', '\n\nfrom itertools import dropwhile\nfrom collections import deque\nn=int(input())\nans=deque([["",n]])\ndef bfs(d):\n global ans\n l=len(ans)\n for i in range(l):\n x=ans.popleft()\n new1=[x[0]+"0",x[1]]\n if abs(new1[1])<abs((-2)**d):\n ans.append(new1)\n new2=[x[0]+"1",x[1]-(-2)**d]\n if abs(new2[1])<abs((-2)**d):\n ans.append(new2)\n if d!=0:\n bfs(d-1)\nbfs(32)\n\n\nfor i in ans:\n if i[1]==0:\n ans=list(dropwhile(lambda x:x=="0",i[0]))\n if len(ans)==0:\n print(0)\n else:\n print("".join(ans))\n break'] | ['Wrong Answer', 'Accepted'] | ['s711928558', 's898217264'] | [3064.0, 3316.0] | [17.0, 21.0] | [265, 681] |
p03286 | u993435350 | 2,000 | 1,048,576 | Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: * S is a string consisting of `0` and `1`. * Unless S = `0`, the initial character of S is `1`. * Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N. It can be proved that, for any integer M, the base -2 representation of M is uniquely determined. | ['Z = int(input())\nn = (-2)\n\nans = ""\n\nwhile abs(Z) >= 1:\n r = Z % n\n if r < 0:\n r = r + 2\n Z = int((Z - r) / n)\n ans += str(r)\n\nans = "".join(list(reversed(ans)))\n\nif Z == 0:\n print(0)\nelse:\n print(int(ans))', 'Z = int(input())\nn = (-2)\n\nans = ""\n\nwhile abs(Z) >= 1:\n r = Z % n\n if r < 0:\n r = r + 2\n Z = int((Z - r) / n)\n ans += str(r)\n \nprint(int(ans))', 'Z = int(input())\n\nif Z == 0:\n print(0)\n\nelse:\n n = (-2)\n\n ans = ""\n\n while abs(Z) >= 1:\n r = Z % n\n if r < 0:\n r = r + 2\n Z = int((Z - r) / n)\n ans += str(r)\n\n ans = "".join(list(reversed(ans)))\n\n\n print(int(ans))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s237215639', 's384440465', 's878967191'] | [3060.0, 3060.0, 3060.0] | [17.0, 18.0, 18.0] | [215, 151, 236] |
p03287 | u046187684 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ["def solve(string):\n n, m, *a = map(int, string.split())\n for i in range(1, n):\n a[i] += a[i - 1]\n l = [0] * m\n print(a)\n for i in range(n):\n l[a[i] % m] += 1\n ans = l[0]\n for i in range(m):\n ans += l[i] * (l[i] - 1) // 2\n return str(ans)\n\n\nif __name__ == '__main__':\n print(solve('\\n'.join([input(), input()])))\n", "from itertools import accumulate\nfrom collections import defaultdict\n\n\ndef solve(s):\n n, m, *a = map(int, s.split())\n ac_a = [_a % m for _a in accumulate(a)]\n d = defaultdict(list)\n for i, _a in enumerate(ac_a):\n d[_a].append(i)\n ans = len(d[0])\n for v in d.values():\n if len(v) > 1:\n ans += len(v) * (len(v) - 1) // 2\n return ans\n\n\nprint(solve('\\n'.join([input(), input()])))\n"] | ['Runtime Error', 'Accepted'] | ['s986806798', 's743063859'] | [876476.0, 24872.0] | [2147.0, 111.0] | [360, 423] |
p03287 | u062147869 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N, M = list(map(int, input().split()))\nP=map(int, input().split()):\nAcnt = [0 for i in range(M)]\nsym = 0\n\nfor A in P:\n sym = (sym + A) % M\n Acnt[sym] += 1\n\nprint(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))\n\n', 'from collections import Counter\nfrom itertools import accumulate\nN,M=map(int,input().split())\nprint(sum( (s*(s-1))//2 for s in Counter((i%M for i in accumulate([0]+[int(i) for i in input().split()]))).values()))'] | ['Runtime Error', 'Accepted'] | ['s873411476', 's270745093'] | [2940.0, 14808.0] | [17.0, 76.0] | [228, 213] |
p03287 | u071680334 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['#include<stdio.h>\n#include<string.h>\n#include<math.h>\n#include<stdlib.h>\n#include<limits.h>\n\n#define rep(i,begin,end) for(int i=begin; i<end; i++)\n\n\n\nint cmpAsc(const void* a, const void* b){\n int x = *(int*)a, y = *(int*)b;\n if(x > y){\n return 1;\n }\n if(x < y){\n return -1;\n }\n return 0;\n}\n\nint main(){\n int n;\n lld m;\n scanf("%d %lld", &n, &m);\n lld a[n+1];\n a[0] = 0;\n rep(i, 1, n+1){\n scanf("%lld", &a[i]);\n }\n rep(i, 1, n+1){\n a[i] += a[i-1];\n a[i] %= m;\n }\n qsort(a, n+1, sizeof(lld), cmpAsc);\n int cnt = 1, target = -1;\n lld ans = 0;\n rep(i, 0, n+1){\n if(a[i] == target){\n ans += (lld)cnt;\n cnt++;\n }else{\n target = a[i];\n cnt = 1;\n }\n }\n printf("%lld", ans);\n\n return 0;\n}', 'import sys\n\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\ndef main():\n n, m = map(int, input().split())\n a = list(map(int, input().split()))\n ans = 0\n a[0] = a[0]%m\n for i in range(1, n):\n a[i] += a[i-1]\n a[i] %= m\n a.sort()\n target = 0\n cnt = 1\n for i in a:\n if i == target:\n ans += cnt\n cnt += 1\n else:\n target = i\n cnt = 1\n print(ans)\n\nif __name__ == "__main__":\n main()'] | ['Runtime Error', 'Accepted'] | ['s320829014', 's928179930'] | [2940.0, 14252.0] | [17.0, 87.0] | [927, 489] |
p03287 | u096820121 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['# coding: utf-8\nimport collections\nimport math\nlist = input().split()\nN = int(list[0])\nM = int(list[1])\na = input().split()\nx = 0\nhako = [0]\nfor i in a:\n hako.append(int(i))\nB = []\nb = 0\nfor i in hako:\n b += i\n B.append(b%M)\nc = collections.Counter(B)\naaa =[]\nfor i in c:\n if c[i] >= 2:\n aaa.append(c[i])\ndef kumi(n):\n return int(math.factrial(n)//(2*math.factrial(n-2)))\nfor i in aaa:\n x += kumi(i)\nprint(x)', '# coding: utf-8\nimport collections\nimport math\nlist = input().split()\nN = int(list[0])\nM = int(list[1])\na = input().split()\nx = 0\nhako = [0]\nfor i in a:\n hako.append(int(i))\nB = []\nb = 0\nfor i in hako:\n b += i\n B.append(b%M)\nc = collections.Counter(B)\naaa =[]\nfor i in c:\n if c[i] >= 2:\n aaa.append(c[i])\ndef kumi(n):\n return int(math.factorial(n)/(2*math.factorial(n-2)))\nfor i in aaa:\n x += kumi(i)\nprint(x)'] | ['Runtime Error', 'Accepted'] | ['s983678784', 's510368479'] | [22884.0, 22884.0] | [114.0, 408.0] | [433, 434] |
p03287 | u102126195 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['import math\ndef PC(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = []\nj = 0\nfor i in A:\n if j == 0:\n B.append(i)\n else:\n B.append(B[j - 1] + i)\n j += 1\nfor i in range(len(B)):\n B[i] = B[i] % M\nC = sorted(B)\nanscnt = 0\nsamecnt = 1\nfor i in range(len(C)):\n if C[i] == 0:\n anscnt += 1\n if i != 0:\n if C[i] == C[i - 1]:\n samecnt += 1\n elif samecnt != 1:\n anscnt += PC(samecnt, 2)\n samecnt = 1\n if i == len(C) - 1:\n anscnt += PC(samecnt, 2)\n samecnt = 1\nprint(anscnt)\n ', 'import math\ndef PC(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef ncr(n, r):\n r = min(r, n - r)\n if r == 0: return 1;\n if r == 1: return n;\n numerator = [n - r + i + 1 for i in range(r)]\n denominator = [i + 1 for i in range(r)]\n for p in range(2, r + 1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p - 1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n result = 1\n for k in range(r):\n if numerator[k] > 1: \n result *= numerator[k]\n return result\n\n\n\n \n\n\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = []\nj = 0\nfor i in A:\n if j == 0:\n B.append(i)\n else:\n B.append(B[j - 1] + i)\n j += 1\nfor i in range(len(B)):\n B[i] = B[i] % M\nC = sorted(B)\nanscnt = 0\nsamecnt = 1\nfor i in range(len(C)):\n if C[i] == 0:\n anscnt += 1\n if i != 0:\n if C[i] == C[i - 1]:\n samecnt += 1\n elif samecnt != 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\n if i == len(C) - 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\nprint(int(anscnt))\n ', 'import math\ndef PC(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef ncr(n, r):\n r = min(r, n - r)\n if r == 0: return 1;\n if r == 1: return n;\n numerator = [n - r + i + 1 for i in range(r)]\n denominator = [i + 1 for i in range(r)]\n for p in range(2, r + 1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p - 1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n result = 1\n for k in range(r):\n if numerator[k] > 1: \n result *= numerator[k]\n return int(result)\n\n\n\n \n\n\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = []\nj = 0\nfor i in A:\n if j == 0:\n B.append(i)\n else:\n B.append(B[j - 1] + i)\n j += 1\nfor i in range(len(B)):\n B[i] = B[i] % M\nC = sorted(B)\nanscnt = 0\nsamecnt = 1\nfor i in range(len(C)):\n if C[i] == 0:\n anscnt += 1\n if i != 0:\n if C[i] == C[i - 1]:\n samecnt += 1\n elif samecnt != 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\n if i == len(C) - 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\nprint(anscnt)\n ', 'import math\ndef PC(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef ncr(n, r):\n r = min(r, n - r)\n if r == 0: return 1;\n if r == 1: return n;\n numerator = [n - r + i + 1 for i in range(r)]\n denominator = [i + 1 for i in range(r)]\n for p in range(2, r + 1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p - 1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n result = 1\n for k in range(r):\n if numerator[k] > 1: \n result *= numerator[k]\n return int(result)\n\n\n\n \n\n\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = []\nj = 0\nfor i in A:\n if j == 0:\n B.append(i)\n else:\n B.append(B[j - 1] + i)\n j += 1\nfor i in range(len(B)):\n B[i] = B[i] % M\nC = sorted(B)\nanscnt = 0\nsamecnt = 1\nfor i in range(len(C)):\n if C[i] == 0:\n anscnt += 1\n if i != 0:\n if C[i] == C[i - 1]:\n samecnt += 1\n elif samecnt != 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\n if i == len(C) - 1 and samecnt != 1:\n anscnt += ncr(samecnt, 2)\n samecnt = 1\nprint(anscnt)\n '] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s058744727', 's164587324', 's858897208', 's600563811'] | [15020.0, 15020.0, 15020.0, 15020.0] | [454.0, 177.0, 188.0, 180.0] | [698, 1362, 1362, 1379] |
p03287 | u102461423 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['import numpy as np\nN,M = map(int,input().split())\nA = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)\nA_cum = np.mod(A.cumsum(),M)\n\ncounter = np.bincount(A_cum)\ncounter[0] += 1 \nanswer = (counter * (counter-1)).sum() // 2\nprint(answer)', 'import numpy as np\nN,M = map(int,input().split())\nA = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)\nA_cum = np.mod(A.cumsum(),M)\n\ncounter = np.bincount(A_cum, dtype=np.int64)\ncounter[0] += 1 \nanswer = (counter * (counter-1)).sum() // 2\nprint(answer)', 'import numpy as np\nfrom collections import Counter\n\nN,M = map(int,input().split())\nA = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)\nA_cum = np.mod(A.cumsum(),M)\n\nc = Counter(A_cum)\n\nanswer = 0\nfor x in c.values():\n answer += x*(x-1)//2\nprint(answer)\n\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s111993210', 's575476377', 's895569844'] | [27296.0, 23060.0, 24308.0] | [1689.0, 185.0, 224.0] | [257, 273, 270] |
p03287 | u102902647 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ["import numpy as np\nN, M = 13, 17\nA = [int(i) for i in '29 7 5 7 9 51 7 13 8 55 42 9 81'.split()]\nar = np.eye(N) * A\n\nfor h in range(0, N):\n for w in range(1, h+1):\n ar[-h-1, -h-1+w] = ar[-h, -h-1+w] + ar[-h-1, -h-2+w] - ar[-h, -h-2+w]\nprint(int(sum(sum(ar % M == 0)) - sum(np.linspace(1, N-1, N-1))))", 'def comb1(n, r):\n if n == 0 or r == 0: return 1\n return comb1(n, r-1) * (n-r+1) / r \nN, M = map(int, input().split())\nA = [int(i) for i in input().split()]\n# N, M = 10, 400000000\n\nsurplus = {0:0}\nres = 0\ntmp = 0\nB = []\nfor i in range(0, N):\n tmp += A[i]\n tmp %= M\n B.append(tmp)\n surplus[tmp] = 0\nfor i in B:\n surplus[i] += 1\n\nfor tmp_key in surplus.keys():\n res += comb1(surplus[tmp_key], 2)\n\ncorner = surplus[0]\nif corner == 0:\n res -= 1\nelse:\n res += corner\nprint(int(res))'] | ['Wrong Answer', 'Accepted'] | ['s526400023', 's891087638'] | [12512.0, 14480.0] | [149.0, 152.0] | [310, 649] |
p03287 | u118642796 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | [',M = map(int,input().split())\nA = map(int,input().split())\n\nB = [0]*M\nB[0] = 1\ntmp = 0\nans = 0\n\n\n\nfor a in A:\n tmp = (tmp+a)%M\n ans += B[tmp]\n B[tmp] += 1\n\nprint(ans)', 'N,M = map(int,input().split())\nA = map(int,input().split())\n \nB = {0: 1}\ntmp = 0\nans = 0\n \nfor a in A:\n tmp = (tmp+a)%M\n ans += B.get(tmp,0)\n B[tmp] = B.get(tmp,0)+1\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s452799046', 's414829725'] | [2940.0, 16100.0] | [17.0, 99.0] | [187, 199] |
p03287 | u170201762 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from scipy.misc import comb\nimport numpy as np\nfrom collections import defaultdict\nN,M = map(int,input().split())\nA = list(map(int,input().split()))\nA = np.cumsum(A)\nA %= M\nd = defaultdict(lambda:0)\nd[0] = 1\nfor i in range(N):\n d[A[i]] += 1\nans = 0\nfor k in d:\n ans += comb(d[k],2)\nprint(int(ans))', 'N,M = map(int,input().split())\nA = list(map(int,input().split()))\nfrom collections import defaultdict\nr = defaultdict(lambda:0)\n\ns = 0\nfor i in range(N):\n s += A[i]\n s %= M\n r[s] += 1\n\nans = r[0]\nfor s in r:\n ans += (r[s]*(r[s]-1))//2\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s259598819', 's370566366'] | [24752.0, 14224.0] | [2110.0, 115.0] | [303, 258] |
p03287 | u198905553 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from collections import Counter\n \nn, m = map(int, input().split())\nA = list(map(int, input().split()))\n \nB = [0] * (n + 1)\n \nfor i in range(n):\n B[i + 1] = accr[i] + A[i] \n\nli = [i % m for i in B] \n\nC = Counter(li) \n\nans = 0\nfor v in C.values():\n if v > 1:\n ans += v * (v - 1) // 2\n \nprint(ans)', 'from collections import Counter\n \nn, m = map(int, input().split())\nA = list(map(int, input().split()))\n \nB = [0] * (n + 1)\n \nfor i in range(n):\n B[i + 1] = B[i] + A[i] \n\nli = [i % m for i in B] \n\nC = Counter(li) \n\nans = 0\nfor v in C.values():\n if v > 1:\n ans += v * (v - 1) // 2\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s075565539', 's899179855'] | [14636.0, 18844.0] | [47.0, 99.0] | [507, 504] |
p03287 | u201234972 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N, M = map( int, input().split())\nA = list( map( int, input().split()))\nprint(A)\nA = [ x%M for x in A]\nSUM = [0]\nfor i in range(N):\n SUM.append(SUM[-1]+A[i])\nans = 0\ncnt = 1\nfor l in range(N):\n if A[l] == 0:\n ans += cnt\n cnt += 1\n else:\n PART = 0\n for r in range(l+1,N+1):\n if (SUM[r] - SUM[l])%M == 0:\n PART += 1\n ans += cnt * PART\n cnt = 1\nif cnt != 1:\n ans += cnt*(cnt-1)/2\nprint(int(ans))', 'N, M = map( int, input().split())\nA = list( map( int, input().split()))\nD = {0:1}\na = 0\nans = 0\nfor i in range(N):\n a = (a+A[i])%M\n ans += D.get(a,0)\n D[a] = 1 + D.get(a,0)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s306181166', 's906616361'] | [15144.0, 14424.0] | [2104.0, 112.0] | [472, 192] |
p03287 | u239528020 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['#!/usr/bin/env python3\n\nimport numpy as np\nfrom scipy.special import comb\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\n\na_sum = np.cumsum(a)\n\n\nre_list = {}\nfor i in a_sum:\n re = i % m\n if re in re_list:\n re_list[re] += 1\n else:\n re_list[re] = 1\nre_list[0] += 1\nprint(re_list)\nans = 0\nfor value in re_list.values():\n ans += comb(value, 2, exact=True)\n\nprint(ans)\n', '#!/usr/bin/env python3\n\nimport numpy as np\nfrom scipy.special import comb\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\n\na_sum = np.cumsum(a)\n\n\nre_list = {}\nre_list[0] = 1\nfor i in a_sum:\n re = i % m\n if re in re_list:\n re_list[re] += 1\n else:\n re_list[re] = 1\n\n# print(re_list)\nans = 0\nfor value in re_list.values():\n ans += comb(value, 2, exact=True)\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s557126367', 's080714411'] | [54116.0, 54156.0] | [262.0, 285.0] | [419, 421] |
p03287 | u288087195 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['import collections\nn, m = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nR = [0]*n\na = 0\nfor i in range(n):\n a += A[i]\n a %= m\n R[i] = a\n\n\ndef nc2(n):\n return n*(n-1)//2\n\n\nc = collections.Counter(R)\nans = 0\nfor r in set(R):\n ans += nc2(c[r])\nprint(ans)\n', 'import collections\nn, m = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nR = [0]\na = 0\nfor i in range(n):\n a += A[i]\n a %= m\n R.append(a)\n\n\ndef nc2(n):\n return n*(n-1)//2\n\n\nc = collections.Counter(R)\nans = 0\nfor r in set(R):\n ans += nc2(c[r])\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s921894441', 's574898509'] | [17096.0, 17096.0] | [121.0, 128.0] | [286, 287] |
p03287 | u338824669 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N,M=map(int,input().split())\nA=list(map(int,input().split()))\n\na=0\nm=[0]*N\nfor i in range(N):\n a+=A[i]%M\n a%=M\n m[i]=a\n\nm.sort()\nans=0\ncnt=0\nfor i in range(N-1):\n if m[i]==m[i+1]:\n cnt+=1\n else:\n ans+=cnt*(cnt-1)//2\n cnt=1\nans+=cnt*(cnt-1)//2\nprint(ans)', 'N,M=map(int,input().split())\nA=[0]+list(map(int,input().split()))\n\na=0\nm=[0]*N\nfor i in range(N):\n a+=A[i]%M\n a%=M\n m[i]=a\n\nm.sort()\nans=0\ncnt=0\nfor i in range(N):\n if m[i]==m[i+1]:\n cnt+=1\n else:\n ans+=cnt*(cnt-1)//2\n cnt=1\nans+=cnt*(cnt-1)//2\nprint(ans)', 'N,M=map(int,input().split())\nA=[0]+list(map(int,input().split()))\n\na=0\nm=[0]*(N+1)\nfor i in range(N+1):\n a+=A[i]%M\n a%=M\n m[i]=a\n\nm.sort()\nans=0\ncnt=1\nfor i in range(N):\n if m[i+1]==m[i]:\n cnt+=1\n else:\n ans+=cnt*(cnt-1)//2\n cnt=1\nans+=cnt*(cnt-1)//2\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s072109201', 's543624284', 's317304162'] | [14224.0, 14696.0, 14224.0] | [113.0, 115.0, 115.0] | [289, 291, 297] |
p03287 | u342563578 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N,M = map(int,input().split())\nAlist = list(map(int, input().strip().split()))\nr = list(range(len(Alist)))\nr[0] = Alist[0]\nfor i in range(1,len(Alist)-1):\n r[i] = r[i-1] + Alist[i]\nfor i in range(len(r)):\n r[i] = r[i]%M\np = [0] * M\nfor i in range(len(r)):\n p[r[i]] = p[r[i]] + 1\ndef kaijou(n):\n if n == 0:\n return 1\n else:\n v = n\n for i in range(1,n):\n v = v*i\n return v \ndef combi(n):\n if n == 0:\n return 0\n if n == 1:\n return 0\n else:\n return kaijou(n)/((kaijou(n-2))*2)\ns = 0\nfor i in range(len(p)):\n s = s + combi(p[i])\n print(s)\ns = s + p[0]\nprint(int(s))', 'N,M = map(int,input().split())\nAlist = list(map(int, input().strip().split()))\nr = [0]*N\nr[0] = Alist[0]\nfor i in range(1,len(Alist)):\n r[i] = r[i-1] + Alist[i]\nfor i in range(len(r)):\n r[i] = r[i]%M\nr.sort()\np = []\nm = 0\nfor i in range(len(r)-1):\n m = m+1\n if r[i] != r[i+1]:\n p.append(m)\n m = 0\n if i == len(r)-2:\n p.append(m+1)\nx = 0\nfor i in range(len(r)):\n if r[i] == 0:\n x = x +1\ndef combi(n):\n if n == 0:\n return 0\n if n == 1:\n return 0\n else:\n return (n*(n-1))/2\ns = 0\nfor i in range(len(p)):\n s = s + combi(p[i])\ns = s + x\nprint(int(s))'] | ['Runtime Error', 'Accepted'] | ['s505050150', 's369089240'] | [887700.0, 14480.0] | [2119.0, 163.0] | [655, 625] |
p03287 | u375616706 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from collections import Counter\nN, M = (list)(map(int, input().split()))\nA = (list)(map(int, input().split()))\nA[0] %= M\n\nfor i in range(1, N):\n A[i] += A[i-1]\n A[i] %= M\n\nans = 0\n\nC = Counter(A)\nfor num, val in C:\n if num == 0:\n ans += val\n if val >= 2:\n ans += val*(val-1)//2\nprint(ans)\n', 'N, M = (list)(map(int, input().split()))\nA = (list)(map(int, input().split()))\nAccum = [0]*(N+1)\n\n\ndef comb(n):\n if n >= 2:\n return n*(n-1)//2\n else:\n return 0\n\n\nfor i in range(N-1):\n Accum[i+1] = (Accum[i]+A[i+1]) % M\n\nans = 0\nfor i in range(M):\n \tif i == 0:\n ans += Accum.count(i)\n else:\n \tc = Accum.count(i)\n \tans += comb(c)\nprint(ans)\n', 'from collections import Counter\nN, M = (list)(map(int, input().split()))\nA = (list)(map(int, input().split()))\nA[0] %= M\n\nfor i in range(1, N):\n A[i] += A[i-1]\n A[i] %= M\n\nans = 0\n\nC = Counter(A)\nfor num, val in C.items():\n if num == 0:\n ans += val\n if val >= 2:\n ans += val*(val-1)//2\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s028545042', 's246442845', 's274280555'] | [14920.0, 2940.0, 14636.0] | [87.0, 18.0, 100.0] | [315, 377, 323] |
p03287 | u398942100 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['n,m=map(int,input().split())\na=list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\np=0\ns=0\nfor i in range(1,n):\n\tif a[i]-a[p]:\n\t\tp=i-p\n\t\ts+=p*(p-1)/2\n\t\tp=i\np=n-p\ns+=p*(p+1)/2\nprint(s)n,m=map(int,input().split())\na=list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\nl=0\np=0\ns=0\nfor i in range(0,n):\n\tif a[i]-l:\n\t\tp=i-p\n\t\ts+=p*(p+1)/2\n\t\tp=i\n\t\tl=a[p]\np=n-p\ns+=(p+1)*(p+2)/2\nprint(s/2)', "a=int(input())\nb=[]\nif a==0:\n\tprint(0)\nwhile a:\n\tb.append(a&1)\n\ta-=a&1\n\ta=int(a/-2)\nprint(''.join(map(str,b[::-1])))", 'n,m=map(int,input().split())\na=list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\nl=0\np=1\ns=0\nfor i in range(0,n):\n\tif a[i]-l:\n\t\tl=a[i]\n\t\tp=i-p\n\t\ts+=p*(p-1)\n\t\tp=i\np=n-p\ns+=p*(p-1)\nprint(int(s/2))', 'n,m=map(int,input().split())\na=list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\np=0\ns=0\nfor i in range(1,n):\n\tif a[i]-a[p]:\n\t\tp=i-p\n\t\ts+=p*(p-1)/2\n\t\tp=i\np=n-p\ns+=p*(p+1)/2\nprint(s)', 'n,m=map(int,input().split())\na=list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\nl=0\np=0\ns=0\nfor i in range(0,n):\n\tif a[i]-l:\n\t\tl=a[i]\n\t\tp=i-p\n\t\ts+=p*(p+1)/2\n\t\tp=i\np=n-p\ns+=(p+1)*(p+2)/2\nprint(s/2)', 'n,m=map(int,input().split())\na=[0]+list(map(int,input().split()))\na[0]%=m\nfor i in range(1,n+1):\n\ta[i]+=a[i-1]\n\ta[i]%=m\na.sort()\np=0\ns=0\nfor i in range(1,n+1):\n\tif a[i]-a[p]:\n\t\tp=i-p\n\t\ts+=p*(p-1)\n\t\tp=i\np=n-p\ns+=p*(p+1)\nprint(int(s/2))'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s228779471', 's279584826', 's715929722', 's752296015', 's862335487', 's726242282'] | [3064.0, 3060.0, 14228.0, 14252.0, 14252.0, 14252.0] | [17.0, 17.0, 106.0, 104.0, 114.0, 104.0] | [462, 116, 236, 223, 239, 234] |
p03287 | u404676457 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['import numpy as np\n(n, m) = list(map(int, input().split()))\na = np.array(list(map(int, input().split()))).astype("int64") \na = np.cumsum(a)', 'import numpy as np', 'import numpy as np\n(n, m) = list(map(int, input().split()))\na = np.array(list(map(int, input().split()))).astype("int64") \na = np.cumsum(a)\na %= m\ncount = np.sum(a == 0)\n(key, counts) = np.unique(a, return_counts=True) ', 'import numpy as np\n(n, m) = list(map(int, input().split()))\na = np.array(list(map(int, input().split()))).astype("int64") \na = np.cumsum(a)\na %= m\ncount = np.sum(a == 0)', 'import numpy as np\n(n, m) = list(map(int, input().split()))\na = np.array(list(map(int, input().split()))).astype("int64") ', 'import numpy as np\n(n, m) = list(map(int, input().split()))\na = np.array(list(map(int, input().split()))).astype("int64") \na = np.cumsum(a)\na %= m\ncount = np.sum(a == 0)\n(unique, counts) = np.unique(a, return_counts=True) ', '(n, m) = list(map(int, input().split()))\na = list(map(int, input().split()))\nunique_a = {a[0] % m: 1}\nfor i in range(1, n):\n a[i] += a[i - 1]\n a[i] %= m\n if a[i] in unique_a:\n unique_a[a[i]] += 1\n else:\n unique_a[a[i]] = 1\ncount = 0\nif 0 in unique_a:\n count += unique_a[0]\nfor k, v in sorted(unique_a.items(), key=lambda x: - x[0]):\n if v == 0:\n break\n count += v * (v - 1) // 2\nprint(count)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s181109326', 's198235227', 's241234891', 's258836789', 's511827094', 's834178349', 's079441851'] | [23072.0, 18920.0, 23444.0, 23048.0, 23368.0, 23112.0, 17572.0] | [185.0, 300.0, 189.0, 183.0, 181.0, 186.0, 159.0] | [139, 18, 219, 169, 122, 222, 433] |
p03287 | u445624660 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['\n# [(0, 8, 136), (0, 12, 323), (1, 10, 204), (2, 2, 34), (5, 7, 119), (6, 8, 85), (6, 12, 272), (10, 11, 187)]\n# [(0, 8, 136), (0, 12, 323), (1, 2, 34), (4, 7, 119), (5, 8, 85), (5, 12, 272), (9, 9, 136), (9, 11, 187)]\n\nn, m = map(int, input().split())\narr = list(map(int, input().split()))\nruiseki_arr = [0] * n\nruiseki_arr[0] = arr[0]\nfor i in range(1, n):\n ruiseki_arr[i] = ruiseki_arr[i - 1] + arr[i]\nprint(ruiseki_arr)\nans = 0\nans_arr = []\nfor i in range(n):\n for j in range(i, n):\n if i > 0:\n target = ruiseki_arr[j] - ruiseki_arr[i - 1]\n elif i == j:\n target = arr[i]\n else:\n target = ruiseki_arr[j]\n if target % m == 0:\n # print("----yay?----")\n # print("i, j = {}, {}, target ={}".format(i, j, target))\n # ans_arr.append((i, j, target))\n ans += 1\nprint(ans)', '\n\nn, m = map(int, input().split())\narr = list(map(int, input().split()))\nb = [0]\nd = {0: 1}\nfor i in range(n):\n b.append(b[i] + arr[i])\n if b[i + 1] % m in d:\n d[b[i + 1] % m] += 1\n else:\n d[b[i + 1] % m] = 1\nans = 0\nfor _, v in d.items():\n ans += (v * (v - 1)) // 2\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s408037823', 's734527426'] | [17804.0, 14224.0] | [2104.0, 133.0] | [930, 387] |
p03287 | u467736898 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from collections import defaultdict\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\n\nd = defaultdict(int)\nans = 0\ns = 0\nd[0] = 1\nfor i, a in enumerate(A):\n a %= M\n s += a\n ans += d[s%M]\n d[s % M] += 1\n\nprint(ans, d)', 'from collections import defaultdict\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\n\nd = defaultdict(int)\nans = 0\ns = 0\nd[0] = 1\nfor i, a in enumerate(A):\n a %= M\n s += a\n ans += d[s%M]\n d[s % M] += 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s647005987', 's510439711'] | [16552.0, 14668.0] | [138.0, 119.0] | [248, 245] |
p03287 | u476604182 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ["from collections import Counter\nfrom itertools import accumulate\nN, M, *A = map(int, open('0').read().split())\nB = [b%M for b in accumulate(A)]\nC = Counter(B)\nans = C[0]\nans += sum(C[k]*(C[k]-1)//2 for k in C.keys())\nprint(ans)", 'from collections import Counter\nfrom itertools import accumulate\nN, M, *A = map(int, open(0).read().split())\nB = [b%M for b in accumulate(A)]\nC = Counter(B)\nans = C[0]\nans += sum(C[k]*(C[k]-1)//2 for k in C.keys())\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s022248312', 's695295577'] | [3316.0, 16600.0] | [20.0, 89.0] | [227, 225] |
p03287 | u497046426 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from collections import defaultdict\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\ncumS = [0]\nfor a in A:\n cumS.append(a + cumS[-1])\ncumS_rem = defaultdict(int)\nfor c in cumS:\n r = c % M\n cumS_rem[r] += 1\nans = 0\nfor r, n_r in cumS_rem.items()\n if n_r > 1:\n ans += n_r*(n_r-1)//2\nprint(ans)', 'from collections import defaultdict\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\ncumS = [0]\nfor a in A:\n cumS.append(a + cumS[-1])\ncumS_rem = defaultdict(int)\nfor c in cumS:\n r = c % M\n cumS_rem[r] += 1\nans = 0\nfor r, n_r in cumS_rem.items():\n if n_r > 1:\n ans += n_r*(n_r-1)//2\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s036371795', 's774896274'] | [2940.0, 16808.0] | [17.0, 111.0] | [332, 333] |
p03287 | u497625442 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['from collections import Counter\nfrom itertools import accumulate\nfrom functools import reduce\n\nN, M = map(int, input().split())\nA = [int(x) for x in input().split()]\n\nc = Counter([0] + [x % M for x in accumulate(A)])\nans = reduce(add, [v*(v-1)//2 for v in c.values()])\nprint(ans)\n', 'from collections import Counter\nfrom itertools import accumulate\nfrom functools import reduce\n\nN, M = map(int, input().split())\nA = [int(x) for x in input().split()]\n\nc = Counter([0] + [x % M for x in accumulate(A)])\nans = reduce(lambda x,y:x+y, [v*(v-1)//2 for v in c.values()])\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s107228836', 's261394752'] | [16840.0, 16832.0] | [72.0, 85.0] | [280, 291] |
p03287 | u517152997 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nn,m = map(int, input().split())\n\n\na = [int(i) for i in input().split()]\nb = [0]*(n)\nc ={0:1}\nbb=0\nfor i in range(0,n) :\n bb = ( bb+a[i] ) % m\n c[bb] = c.get(bb,0) + 1\n \n \nanswer = 0\nprint(c)\n\nfor i,j in c.items():\n if j > 1:\n answer += (j * (j-1) // 2 )\n\nprint(answer)\n\n', '# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nn,m = map(int, input().split())\n\n\na = [int(i) for i in input().split()]\nb = [0]*(n)\nc = [0]*(m)\nbb=0\nc[0]=1\nfor i in range(0,n) :\n bb = ( bb+a[i] ) % m\n c[bb] += 1\n \n \nanswer = 0\nprint(c)\nfor i in range(0,m):\n if c[i] > 1:\n answer += (c[i] * (c[i]-1) // 2 )\n\nprint(answer)\n\n', '# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\n\n\nn,m = map(int, input().split())\n\n\na = [int(i) for i in input().split()]\nb = [0]*(n)\nc ={0:1}\nbb=0\nfor i in range(0,n) :\n bb = ( bb+a[i] ) % m\n c[bb] = c.get(bb,0) + 1\n \n \nanswer = 0\n#print(c)\n\nfor i,j in c.items():\n if j > 1:\n answer += (j * (j-1) // 2 )\n\nprint(answer)\n\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s653858769', 's724419190', 's832076470'] | [24288.0, 963792.0, 24148.0] | [257.0, 2132.0, 232.0] | [448, 452, 449] |
p03287 | u518042385 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['n,m=map(int,input().split())\nl=list(map(int,input().split()))\ndic={}\nl1=[]\nc=0\nfor i in l:\n c=(c+i)%m\n l1.append(c)\nprint(len(l)-len(set(l1))) ', 'from collections import defaultdict\nimport math\ndic=defaultdict(int)\nn,m=map(int,input().split())\nl=list(map(int,input().split()))\nl1=[]\nc=0\ncount=0\nfor i in l:\n c=(c+i)%m\n if c==0:\n count+=1\n dic[c]+=1\nfor i in dic:\n if dic[i]==1:\n pass\n else:\n count+=math.factorial(dic[i])//(2*math.factorial(dic[i]-2))\nprint(count) '] | ['Wrong Answer', 'Accepted'] | ['s419811374', 's957760045'] | [14696.0, 14924.0] | [65.0, 394.0] | [146, 334] |
p03287 | u543954314 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['n,m = map(int, input().split())\nans = 0\ndef kx(t):\n return int(t)%m\na = list(map(kx, input().split()))\nb = [0]*(n+1)\nfor i in range(1,n+1):\n a[i] = a[i-1] + b[i-1]\nf = [0]*m\nfor i in b:\n f[i] += 1\nfor i in f:\n ans += i*(i-1)//2\nprint(ans)', 'from collections import defaultdict as dd\nd = dd(int)\nd[0] = 1\nn,m = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nf = 0\nfor i in range(1,n+1):\n f = (f + a[i-1])%m\n d[f] += 1\nfor i in d:\n ans += d[i]*(d[i]-1)//2\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s968385899', 's236678069'] | [14032.0, 14912.0] | [81.0, 114.0] | [242, 249] |
p03287 | u553348533 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N, M = map(int,input().split())\nA = [int(i) for i in input().split()]\nsumA = [0 for i in range(N + 1)]\nfor i in range(1, N + 1):\n sumA[i] = (A[i] + A[i - 1]) % M\nans = 0\n\nfor j in range(N):\n ans += sumA[j:].count(sumA[j]) - 1\n\nprint(ans)', 'from collections import defaultdict as dict\nd = dict(int)\nN, M = map(int,input().split())\nA = [int(i) for i in input().split()]\nsumA = [0 for i in range(N + 1)]\nfor i in range(N):\n sumA[i + 1] = (A[i] + sumA[i]) % M\nans = 0\n\nfor j in range(len(sumA)):\n ans += d[sumA[j]]\n d[sumA[j]] += 1\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s283876004', 's781829126'] | [14252.0, 16568.0] | [76.0, 128.0] | [243, 308] |
p03287 | u562016607 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['N,M=map(int,input().split())\nA=[int(i) for i in input().split()]\nS=[0 for i in range(N+1)]\nfor i in range(N):\n S[i+1]=(S[i]+A[i])%M\nD=dict()\nfor i in range(N+1):\n if S[i] in D:\n D[S[i]]+=1\n else:\n D[S[i]]=1\nprint(D)\nfor si in D:\n print(D[si])\nprint(S)', 'N,M=map(int,input().split())\nA=list(map(int,input().split()))\nD={0:1}\nS=[0 for i in range(N)]\nS[0]=A[0]%M\nif S[0] in D:\n D[S[0]]+=1\nelse:\n D[S[0]]=1\nfor i in range(1,N):\n S[i]=(S[i-1]+A[i])%M\n if S[i] in D:\n D[S[i]]+=1\n else:\n D[S[i]]=1\nans=0\nfor i in D:\n ans+=(D[i]*(D[i]-1))//2\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s440617490', 's255992427'] | [19512.0, 15444.0] | [166.0, 119.0] | [277, 323] |
p03287 | u571444155 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['n, m = map(int, input().split())\n\na = list(map(int, input().split()))\n\ns = 0\ncount = 0\n\nfor l in range(n):\n for r in range(n):\n s = sum(a[l:r+1])\n if s % m == 0:\n count += 1\n\nprint(count/2)\n', 'N, M = list(map(int, input().split()))\n\nD = list(map(int, input().split()))\n\nS = {0 : 1}\nt = 0\nfor i in range(N):\n t = (t + D[i]) % M\n if t in S:\n S[t] += 1\n else:\n S[t] = 1\n\nr = 0\n\nfor i in S.values():\n r += i * (i - 1) // 2\n \nprint(r)'] | ['Wrong Answer', 'Accepted'] | ['s398104895', 's310952204'] | [15020.0, 14224.0] | [2108.0, 90.0] | [218, 247] |
p03287 | u600402037 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ['import sys\nimport numpy as np\n\nstdin = sys.stdin\n \nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split()))\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN, M = rl()\nA0 = rl()\nA = np.array(A0)\nA_cum = A.cumsum()\nA_cum %= M\nanswer = 0\n\nfor i in range(N):\n answer += (A_cum[i:] == 0).sum()\n A_cum -= A0[i]\n\nprint(answer)\n#13', 'import sys\nimport numpy as np\nfrom collections import Counter\nfrom math import factorial\n\nstdin = sys.stdin\n \nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split()))\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN, M = rl()\nA = np.array(rl())\nA_cum = A.cumsum()\nA_cum %= M\nA_cum = A_cum.tolist()\nc = Counter(A_cum)\nanswer = 0\n\nfor k, v in c.items():\n if k == 0:\n answer += v\n if v >= 2:\n answer += factorial(v) // factorial(2) // factorial(v-2)\n\nprint(answer)\n#13\n'] | ['Wrong Answer', 'Accepted'] | ['s182485095', 's462239069'] | [23132.0, 23100.0] | [2109.0, 510.0] | [368, 525] |
p03287 | u603253967 | 2,000 | 1,048,576 | There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs (l, r) that satisfy the following: * l and r are both integers and satisfy 1 \leq l \leq r \leq N. * A_l + A_{l+1} + ... + A_r is a multiple of M. | ["\n\n# c = 0\n#\n# for i, A in enumerate(As):\n# A %= M\n\n\n# if A == 0:\n# c += 1\n# continue\n#\n# ccc = {A: 1}\n# for k in prev.keys():\n\n# newv = (k + A) % M\n# if newv in ccc:\n# ccc[newv] += v\n# else:\n# ccc[newv] = v\n# c += ccc[0] if 0 in ccc else 0\n\n# return c\ndef f(As, M):\n res = 0\n totals = [As[0] % M]\n for A in As[1:]:\n l = (totals[-1] + A) % M\n if l == 0:\n res += 1\n totals.append(l)\n\n # N = len(As)\n\n ddd = {}\n for t in totals:\n if t not in ddd:\n ddd[t] = 0\n res += ddd[t]\n ddd[t] += 1\n\n \n \n \n # res += 1\n # for j in range(i + 1, N):\n \n #\n \n # res += 1\n return res\n\n\ndef main():\n N, M = [int(a) for a in input().split()]\n As = [int(a) for a in input().split()]\n print(f(As, M))\n\n\nif __name__ == '__main__':\n main()\n", "\n\n# c = 0\n#\n# for i, A in enumerate(As):\n# A %= M\n\n\n# if A == 0:\n# c += 1\n# continue\n#\n# ccc = {A: 1}\n# for k in prev.keys():\n\n# newv = (k + A) % M\n# if newv in ccc:\n# ccc[newv] += v\n# else:\n# ccc[newv] = v\n# c += ccc[0] if 0 in ccc else 0\n\n# return c\ndef f(As, M):\n totals = [As[0] % M]\n res = 1 if As[0] % M == 0 else 0\n for A in As[1:]:\n l = (totals[-1] + A) % M\n if l == 0:\n res += 1\n totals.append(l)\n\n # N = len(As)\n\n ddd = {}\n for t in totals:\n if t not in ddd:\n ddd[t] = 0\n res += ddd[t]\n ddd[t] += 1\n\n \n \n \n # res += 1\n # for j in range(i + 1, N):\n \n #\n \n # res += 1\n return res\n\n\ndef main():\n N, M = [int(a) for a in input().split()]\n As = [int(a) for a in input().split()]\n print(f(As, M))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s910684265', 's341183574'] | [15564.0, 15572.0] | [87.0, 89.0] | [1256, 1281] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.