{"lang": "PyPy 3", "source_code": "import math\nFlag = True\nRow_of_bones = []\nn = int(input())\nfor i in range(n):\t\t\t\t\t\t\t\t\t\t\t\t#\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043e\u043b-\u0432\u043e \u043a\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \n\tx = list(map(int, (input().split())))\t\t#\"\u041d\u0430\u043b\u0435\u0442\u0443\" \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438\n\tRow_of_bones.append(x)\t\t\t\t\t\t\t\t\t\t\t#\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u043a\u043e\u0441\u0442\u044c[xi,yi] \u0432 \u0440\u044f\u0434 []\n\n\ndef check_parity() -> bool: #\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u0432\u0435\u0440\u0445\u043d\u0438\u0435 \u0438 \u043d\u0438\u0436\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u043d\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c.\n\tupp,low = 0,0\n\tfor i in Row_of_bones:\n\t\tupp += i[0]\n\t\tlow += i[1]\n\tif (upp % 2 == 0) and (low % 2 == 0):\n\t\treturn True\n\telse:\n\t\treturn False\n\n# \u0422\u0443\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0439 \u043d\u0430\u0434 \u0442\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c.\n# \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u044b\u0441\u0442\u0440\u043e\n\ncount = 0 # \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439\n\nwhile(Flag): \n\tfor x in Row_of_bones:\n\t\tif check_parity():# \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u043c\u043c \u043d\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0438, \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0432\u044b\u0445\u043e\u0434 \n\t\t\tprint(count)\n\t\t\tFlag =False\n\t\t\tbreak\n\t\telif ((x[0] % 2 == 0) and (x[1] % 2 != 0)) or ((x[0] % 2 != 0) and (x[1] % 2 == 0)): # \u041c\u0435\u043d\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0435\u0447\u0435\u0442/\u0447\u0435\u0442 \u0438\u043b\u0438 \u0447\u0435\u0442/\u043d\u0435\u0447\u0435\u0442\n\t\t\tx[0],x[1] = x[1], x[0]\n\t\t\tcount+=1 # \u0441\u0447\u0435\u0442\u043d\u0438\u043a \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439\n\t\telif count > n: # \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u043a\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443, \u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u043c. \u0422\u0443\u0442 \u044f \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u043b \u043a\u0430\u043a \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \n\t\t\tprint(-1)\t# \t\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c/\u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0421\u043e\u0448\u0435\u043b\u0441\u044f \u043d\u0430 count > n\n\t\t\tFlag =False\n\t\t\tbreak", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f54620fc771b6cbc7fc4bca5f4145e15", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input(\"\"))\nif(n!=1):\n i=2\n while(i0):\n n=n-i\n\n i=2\n else:\n break\n else:\n i=i+1\n\n print(n)\nelse:\n print(1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2458dd37f325c111f6300317359b0d7", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\"\"\" Created by Henrikh Kantuni on 2/26/17 \"\"\"\n\nif __name__ == '__main__':\n n, k = [int(x) for x in input().split()]\n\n count = 0\n zero_count = 0\n\n if k == 0:\n print(0)\n exit()\n\n if n < 10 ** k:\n count = len(str(n)) - 1\n else:\n for i in range(len(str(n))):\n if n % 10 != 0:\n count += 1\n else:\n zero_count += 1\n\n n //= 10\n\n if zero_count == k:\n break\n\n print(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "be1cbdfdb4b3b88a2bf793e8a8f8a4ee", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\n\n\nnumber = list(input())\n\nnew_number = []\n\nif len(number) % 2 == 0:\n\n already_bigger = False\n\n for digit in number:\n digit = int(digit)\n\n if already_bigger:\n new_number += [4]\n else:\n\n if digit == 4 or digit == 7:\n new_number += [digit]\n else:\n already_bigger = True\n if digit < 4:\n new_number += [4]\n elif digit < 7:\n new_number += [7]\n else:\n if 4 in new_number:\n first_4 = new_number.index(4)\n new_number = new_number[:first_4] + [7] + [4] * (len(number) - (first_4 + 1))\n break\n else:\n new_number = [4] * (len(number) + 2)\n break\n\nelse:\n new_number = [4] * (len(number) + 1)\n\nof_4, of_7 = new_number.count(4), new_number.count(7)\n\n\nif of_4 > of_7:\n new_number = list(reversed(new_number))\n missing = (of_4 - of_7)//2\n i = 0\n while missing != 0:\n if new_number[i] == 4:\n new_number[i] = 7\n missing -= 1\n i += 1\n new_number = list(reversed(new_number))\nelif of_7 > of_4:\n missing = (of_7 - of_4)//2 + 1\n first_4 = new_number.index(4)\n new_number = reversed(new_number)\n if first_4 < len(new_number)/2:\n i = 0\n while True:\n if missing == 0:\n if new_number[i] == 4:\n new_number[i] = 7\n break\n else:\n if new_number[i] == 7:\n new_number[i] = 4\n missing -= 1\n i += 1\n else:\n new_number = [7] * (new_number//2 + 1) + [4] + (new_number//2 + 1)\n \n new_number = list(reversed(new_number))\n\nprint(''.join(map(str,new_number)))\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cc6784b2589eda0ed43648871a57d944", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "PyPy 2", "source_code": "from collections import Counter\n\ndef helpfulMath():\n\tc = Counter(raw_input().strip())\n\tones = [\"1\" for i in xrange(c['1'])]\n\ttwos = [\"2\" for i in xrange(c['2'])]\n\tthrees = [\"3\" for i in xrange(c['3'])]\n\tres = \"\"\n\tif ones:\n\t\tres += \"+\".join(ones)\n\tif twos:\n\t\tif res:\n\t\t\tres += \"+\" + \"+\".join(twos)\n\t\telse:\n\t\t\tres += \"+\".join(twos)\n\tif threes:\n\t\tif res:\n\t\t\tres += \"+\" + \"+\".join(threes)\n\t\telse:\n\t\t\tres += \"+\".join(threes)\n\treturn res\n\nprint helpfulMath()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b29bc5d8f4b11c376a4719fa63f31e22", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "values = {}\nk = int(input())\ns = input()\nopen = []\nresult = \"NO\"\n\nfor i in s:\n if i not in values:\n values[i] = 1\n\n else:\n values[i]+=1\n\nfor i in s:\n if i not in open:\n open.append(i)\n\n if len(open) > k:\n result = \"YES\"\n break\n\n if values[i] == 1:\n open.remove(i)\n\n values[i]-=1\n\nprint(result)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4487cb0cbb3bc32ce0d5e636a5b6bdc2", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import log,log2,ceil\nfor _ in range(1):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\tp = n//2\n\tif n%2:\n\t\tp+=1\n\tc=0\n\tpc,nc=0,0\n\tfor i in a:\n\t\tif i==0:\n\t\t\tc+=1\n\t\t\t\n\t\telif i<0:\n\t\t\tnc+=1\n\t\telse:\n\t\t\tpc+=1\n\tif nc>=p:\n\t\tprint(-1)\n\telif pc>=p:\n\t\tprint(1)\n\telse:\n\t\tprint(0)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "095d508450b85ff059265670ee52d05c", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def main():\n n, m = map(int, raw_input().split())\n if a == 0 and b == 0:\n print 'NO'\n return\n elif abs(a-b) > 1:\n print 'NO'\n else:\n print 'YES'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "88f40c3d415e5123d9834207054a0a84", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "def fun12(n):\n while True:\n n1=n\n for i in range(n+1,0,-1):\n if i%2==0:\n n1=n-i;\n break;\n if n1==n:\n return \"Ehab\"\n if n1==0:\n return \"Mahmoud\"\n \n for i in range(n1+1,0,-1):\n if i%2==1:\n n=n1-i;\n break;\n \nn=int(input())\nprint(fun12(n))\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a687590db6cff744c5e25c2ad242a79", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\nb = list(set(a))\nif len(b)==1:\n\tprint \"Elephant\"\nif len(b)==2:\n\tprint \"Elephant\"\nif len(b)==3:\n\tprint \"Bear\"\nif len(b)>3:\n\tprint \"Alien\"\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e106f41ed500b3f219650c454b953c18", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "INF = 1e10\nmax_n = 50\nmax_k = 2000\ndef main():\n n, s, k = map(int, input().split())\n s -= 1\n buf = ['']*(max_n + 1)\n dp = [[0 for i in range(max_n + 1)] for j in range(max_k)] \n r = list(map(int, input().split()))\n c = input()\n answer = INF\n for i in range(len(c)):\n buf[i] = c[i]\n for i in range(k, -1, -1):\n for j in range(n):\n dp[i][j] = INF\n for j in range(n):\n value = abs(j - s)\n if k - r[j] <= 0:\n answer = min(answer, value)\n else:\n dp[k - r[j]][j] = value\n for i in range(k, 0, -1):\n for j in range(n):\n if dp[i][j] < INF:\n for l in range(n):\n if buf[j] != buf[l] and r[j] < r[l]:\n value = dp[i][j] + abs(j - l)\n if i - r[l] <= 0:\n answer = min(answer, value)\n else:\n dp[i - r[l]][l] = min(dp[i - r[l]][l], value)\n if answer == INF:\n print(-1)\n return\n print(answer)\n\nif __name__==\"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "798869b60dde08b9c18d9b2157559b40", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\nvalues = []\nfor i in range(1, k):\n if n % i != 0:\n continue\n t = n / i\n values.append(i + (t * k))\nprint min(values)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f906e47a31692cec81f38ab48ab9b802", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#from random import random, randint\n#from sys import stdout\nimport math\n\n#n, k = map(int, input().split())\nn = int(input())\nm = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\n\nprint(math.ceil((sum(a) + m)/n), max(a) + m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c6479eaf42414e8e1e86db1b047c3014", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "from collections import deque\nn = int(input())\nd = set()\nk1, *a = [int(s) for s in input().split()]\nk2, *b = [int(s) for s in input().split()]\na = deque(a)\nb = deque(b)\nres = 0\nwhile a and b:\n cu = tuple(tuple(a), tuple(b))\n if not cu in d:\n d.add(cu)\n res += 1\n cur1 = a.popleft()\n cur2 = b.popleft()\n if cur1>cur2:\n a.append(cur2)\n a.append(cur1)\n else:\n b.append(cur1)\n b.append(cur2)\n else:\n print(-1)\n break\nelse:\n if len(a) > len(b):\n print(res, 1)\n else:\n print(res, 2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "30ecb6c16822e5201a3ffc78bfa3e9b1", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import math\ndef isTPrime(n):\n count = 0\n if n==2 or n==3: return False\n # print(2,math.ceil(int(n**0.5))+3)\n for i in range(2,math.ceil(int(n**0.5))+3): # only odd numbers\n if i == n:\n break\n if n%i==0:\n count +=1\n if count == 2:\n break\n if count == 1:\n return True\n else:\n return False\nn = int(input())\nlist = [int(n) for n in input().split()]\n\nfor num in list:\n if isTPrime(num):\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "40c32e0e1623cee91836673408a128a9", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, m, a ,b = (int(x) for x in input().split())\nx = n\nc = n\nif n % m ==0:\n print (0)\nelse:\n while x%m!=0:\n x=x+1\n while c%m!=0:\n c=c-1\n p = (x - n)*a\n s = (n - c)*b\n print(min(p, s))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "be6456e318624a3e822876db7b2989dc", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\nsys.stdin = open(\"test.in\",\"r\")\nsys.stdout = open(\"test.out\",\"w\")\n\nb=input()\na=0\nfor i in range(len(b)):\n\tif b[i]=='a':\n\t\ta+=1\nprint(a+1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a0035e21e73d638daaaf310bf639d98d", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nif \"H\"in n:\n print(\"YES\")\nelif \"Q\" in n:\n print(\"n=input();if 'H'in n:print('YES');elif 'Q' in n:print();elif '9':print('99 Bottles of Beer');elif '+':print(int(n)+1);else:print('NO')\")\nelif \"9\" in n:\n print(\"99 Bottles of Beer\")\nelif \"+\":\n print(int(n)+1)\n\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fdd83121a51b82ad473c8acbb0ccf050", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def cal(a):\n x=0\n while(a>0):\n x+=a%10\n a=a//10\n return x\nn,s=input().split()\nn=int(n)\ns=int(s)\nif((n-cal(n))=s):\n if((mid-1-cal(mid-1))=s):\n mid+=1\n break\n else:\n u=mid+1\n print(n-mid+1)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56b60dd1e8655cab148f478134f0d421", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\nt = 4 * n + 1\n\np = [[*map(int, input().split())] for _ in range(t)]\n\nfor i in p:\n\tif not ((i[0] in [0, n] and i[1] <= n) or (i[1] in [0, n] and i[0] <= n)):\n\t\tprint(*i)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a565b467363ba57706a508e5f06539cf", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "A, B = map(int, raw_input().split())\na = reduce(lambda x, y: x * y, [i for i in range(1, A + 1)])\nb = reduce(lambda x, y: x * y, [i for i in range(1, B + 1)])\ndef gcd(x, y):\n return x if y == 0 else gcd(y, x % y)\nprint gcd(a, b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42e27dd27cfeac37f68ebff5aad862b0", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k=int(input())\nl=[]\nl=input().split(\" \")\ns=0\np=[]\ni=0\nwhile i 0: res += \"/\" + s\n print res\n break\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6bb0101b913c1c20f60a6cd6e07fc08d", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "a, b, c = map(int, input().split())\nm = 0\nwhile not (a+b > c and b+c > a and a+c > b):\n if a+b <= c and a+c <= b:\n a += 1\n m += 1\n elif a+b <= c and b+c <= a:\n b += 1\n m += 1\n else:\n c += 1\n m += 1\nprint(m)\n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "09556a49e5aa8378a8ad47b7b22db4d5", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Python 3", "source_code": "while (True):\n\tfor i in range(25):\n print('<\\'_\\'>',end='')\n\tprint('(^_^) (^_0)')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54aaf5d0f0c091280b0497bf3e8157a0", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n,t=map(int,input().split())\ns=input()\nfor i in range(t):\n c=0\n for j in range(len(s)-1):\n if s[j]=='B' and s[j+1]=='G':\n s[j],s[j+1]=s[j+1],s[j]\n c=1\n if c==0:\n break\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5839765a815e293b38c3b8c168397d36", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a, b, x = map(int, raw_input().split(\" \"))\n\nif x > 1 and a == 1:\n s = '1'\n b -= 1\nelif x > 1 and b == 1:\n s = '0'\n a -= 1\n\nwhile x > 1:\n if s[-1] == '0':\n s += '1'\n b -= 1\n else:\n s += '0'\n a -= 1\n\n x -= 1\n\ns += '0'*a\ns += '1'*b\n\nprint(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "898cf8265472c39898b9aab83230c9bc", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "num = input()\narr = []\ncounting = 0\n\nfor m in range(0, len(num)):\n if num[m] == ' ':\n arr.append(int(num[counting:m]))\n counting = m + 1\n elif m == len(num) - 1:\n arr.append(int(num[counting:len(num)]))\n\ndimension = arr[0]\nreq_value = arr[1]\n\ndata_storing = [[0]*dimension for _ in range(dimension)]\n\nfor i in range(0, dimension):\n for j in range(0, dimension):\n data_storing[i][j] = (i + 1) * (j + 1)\n\ncount = 0\nfor x in range(0, dimension):\n for y in range(0, dimension):\n if data_storing[x][y] == req_value:\n count += 1\n\nprint(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c8db4301b6300ec362aef998f7354d3", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\nimport operator as op\n\nfrom functools import reduce\n\nfrom operator import mul # or mul=lambda x,y:x*y\nfrom fractions import Fraction\n\ndef nCk(n,k): \n return int( reduce(mul, (Fraction(n-i, i+1) for i in range(k)), 1) )\n\n\ndef ncr(n, r):\n r = min(r, n-r)\n if r == 0: return 1\n numer = reduce(op.mul, range(n, n-r, -1))\n denom = reduce(op.mul, range(1, r+1))\n return numer//denom\n\ndef modPow(a, x, p):\n #calculates a^x mod p in logarithmic time.\n res = 1\n while(x > 0):\n if( x % 2 != 0):\n res = (res * a) % p\n \n a = (a * a) % p\n x = int(x/2)\n return res\n\ndef modInverse(a, p):\n #calculates the modular multiplicative of a mod m.\n #(assuming p is prime).\n return modPow(a, p-2, p)\n\ndef modBinomial(n, k, p):\n #calculates C(n,k) mod p (assuming p is prime).\n\n # n * (n-1) * ... * (n-k+1)\n numerator = 1 \n for i in range(k):\n numerator = (numerator * (n-i) ) % p\n\n denominator = 1\n for i in range(1, k+1):\n denominator = (denominator * i) % p\n\n # numerator / denominator mod p.\n return ( numerator* modInverse(denominator,p) ) % p\n\n\nn, c = input().split()\nn = int(n)\nc = int(c)\n\n#test = [0 for x in range (n+1)]\n#test[1] = c\n\n#for i in range(2, n+1):\n# test[i] = (test[i-1] + modBinomial((i+c-1),i, 1000003))%1000003\n\n#ans = solve(n, c)\n#ans =test[n]\nans = modBinomial((c+n),c,1000003) - 1\nprint(int(ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d80988ed2deba777c185aa6e08325211", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import math\nm=int(input())\nl=[];\na=0;\nj=0;\nr=factorial(j);\nwhile(r<10**m):\n j=j+1;\n r=r*j;\nwhile(r%10**m!=0):\n j=j+1;\n r=r*j;\nif(factorial(j)%10**(m+1)!=0):\n k=1;\n while(k<=5):\n l=l+[j];\n a=a+1;\n j=j+1;\n k=k+1;\nprint(a);\nfor k in l:\n print(k,end=\" \");", "lang_cluster": "Python", "compilation_error": false, "code_uid": "40508b23646de00494ea2d1f662ccf0a", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "list = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint (list[n-1])\nn = int(input())\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b00c16f5356ce4bf1901038a6cd6d046", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\nsys.stdin=open(\"input.in\",\"r\")\nsys.stdout=open(\"output.out\",\"w\")\n\n\n\n\nj=input()\nt=input()\nm=0\nfor i in t:\n\tif j[m]==i:\n\t\tm+=1\nprint(m+1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76950f5727e371b3f426bf34205c751d", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "Python 3", "source_code": "trump = input()\ncards = input()\nif cards[1] == trump:\n if cards[4] != trump:\n print(\"YES\")\n else:\n if int(cards[0]) > int(cards[3]):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if cards[1]==cards[4] and int(cards[0]) > int(cards[3]):\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f897cc97dd1708cccd233cdedfdee8ae", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "a,b = [int(i) for i in input().split()]\nn=1\nwhile True:\n if((a//b) > 2*(2**n-1)//(3**n-1)):\n break\n n+=1\nprint(n-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d334cf208c5b8284b48f6412492f45cf", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "#dobara\nn,m = map(int,raw_input().split())\nstore = dict()\ntotal = 0\nrow = dict()\ncol = dict()\nfor i in xrange(1,n+1):\n\ta = raw_input()\n\tcnt = a.count('*')\n\tstore[i] = a\n\trow[i] = cnt\n\ttotal += cnt\nfor j in xrange(1,m+1):\n\tcol[j] = 0\n\tfor i in xrange(1,n+1):\n\t\tif store[i][j-1] == '*':\n\t\t\tcol[j] += 1\nans = ''\nfor i in xrange(1,n+1):\n\tfor j in xrange(1,m+1):\n\t\tif row[i] + col[j] > total and total != 0 :\n\t\t\tans = str(i) +' '+ str(j)\nfor i in row:\n\tif row[i] == total:\n\t\tans = str(i) + ' '+ str(m)\nfor j in col:\n\tif col[j] == total:\n\t\tans = str(n) + ' ' + str(j)\n\nif len(ans):\n\tprint 'YES'\n\tprint ans\nelse:\n\tif total == 0:\n\t\tprint 'YES'\n\t\tprint 1,1\n\telse:print 'NO'\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e233b480d2d47a7ea52222e6bf4346e2", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "p=[]\nm=[]\nmax1=str()\nmin1=str()\nx,y=map(int,input().split())\nfor i in range(x):\n p.append(str(0))\nif(y==0 and x!=1 or 9*x=8):\n p[0]=str(1)\n b=int((a-8)/9)\n c=a-8-b*9\n for i in range(1,b+1):\n p[i]=str(0)\n p[b+1]=str(9-c)\n for i in range(b+2,x):\n p[i]=str(9)\n for i in range(x):\n min1=min1+p[i]\n\n if(a<8):\n min1=min1+str(9-a)\n for i in range(1,x):\n min1=min1+str(9)\nprint(min1,max1)\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71c46bf9bf860ebce693e1ba5a4c2f31", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from itertools import combinations\ndef solve(items,summation):\n l=[]\n for length in range(1, len(items)):\n for subset in combinations(items, length):\n l.append(sum(subset))\n if sum(subset) == summation or (sum(subset)-360) in l or (sum(subset)-720) in l:\n boole=1\n return(boole)\nx=int(input())\nl1=[]\nl2=[]\nboole=0\nfor i in range(x):\n s=int(input())\n l1.append(s)\nl1.sort()\ntotal=sum(l1)\nif total%2==0:\n if total%360==0:\n boole=1\n else:\n boole=solve(l1,total/2)\n\nif boole==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a39a79803f3d0558027b2a9c19dc538", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n,c = map(int,input().split())\np = list(map(int,input().split()))\nt = list(map(int,input().split()))\nans_l,ans_r,k,ti1,ti2 = 0,0,1,t[0],t[-1]\nfor i in range(n):\n ans_l += max(0,p[i]-c*ti1)\n if i < n-1: ti1 += t[i+1]\nfor i in range(n-1,-1,-1): ans_r += max(0,p[i]-c*ti2); print; ti2 += t[i-n+2]; k += 1\nif ans_l > ans_r: print(\"Limak\")\nelif ans_l == ans_r: print(\"Tie\")\nelse: print(\"Radewoosh\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4cbc35298986eb80ebb0b61a4385931d", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nsum = 0\n\nx = 0\nwhile True:\n if sum == n:\n break\n x += 1\n sum += ((1+x)*x)/2\n\nprint x", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2733d6d2d0c96b71ab93c8bff1cb2dc8", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\na, b, c = (int(i) for i in input().split())\ncnt = [0] * b\narr = []\nfor i in range(a):\n s = input()\n arr.append(s)\n for j in range(len(s)):\n cnt[j] += arr[i][j] == 'Y'\n\nans = 0\nfor i in range(a):\n ans += cnt[i] >= c\np", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6099625d12d3af1b424d10126ba5db0", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "s = input()\nif (len(s) == 1):\n print(s)\nelse:\n ans = 0\n cur = 2\n res = 0\n mult = 1\n for i in range(len(s) - 1, -1, -1):\n ans = mult * int(s[i]) + ans\n mult *= 2\n res = 1\n# print(ans)\n cur = ans\n tmp = cur\n while cur > 4:\n res += 1\n cur = cur// 4\n# print(cur)\n# if (tmp % 4 == 0):\n# res -= 1\n print(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6fcd9079da47894405b9866d22875f9e", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nstr = str(input())\n\ninbrackets = False\ninword=False\nlengths = []\ncount_in_brackets=0\n#max_length_out_of_brackets=0\nl=0\nfor i in range(0,n):\n if str[i]==\"(\":\n inword=False\n inbrackets=True\n lengths.append(l)\n l=0\n continue\n if str[i]==\")\":\n inbrackets=False\n if inword:\n count_in_brackets+=1\n inword=False\n continue\n if str[i]!=\"_\":\n inword=True\n elif inword:\n if inbrackets:\n count_in_brackets += 1\n else:\n lengths.append(l)\n l=0\n inword=False\n continue\n if inbrackets:\n pass\n elif inword:\n l+=1\nif l>0:\n lengths.append(l)\nprint(max(lengths), end=\" \")\nprint(count_in_brackets)\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f8c2d1835a9d8800c397e9936955170", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "x=input()\ny=input()\nl=0\n\nfor i in range(y+1):\n if x>=y:\n break\n x*=x\n l+=1\n i=x\n \nif x==y:\n print\"YES\"\n print l\nelse:\n print\"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed26c8e0337d733ba471fcf25fdec95a", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nk=int(input())\nif n//k==1:\n print('YES')\nelse:\n if n//k%2==0:\n print('NO')\n else:\n print('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bbd1815b5d12796ca6c330447dbefa3", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "n, m, k = map(int, raw_input().split())\n\nmod = 1000000007\n\ndef p(x):\n a = 2\n r = 1\n while x:\n if x & 1:\n r = r * a % mod\n a = a * a % mod\n x >>= 1\n return r\n\nprint p((n - 1) * (m - 1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e89be2b8166c521d520be06754ff6ccf", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nlist_ = [4, 7, 47, 74, 447, 477, 474, 444, 777, 744, 747, 774]\nif 1<=n<=1000:\n n1 = n\n f = 0\n while(n1 > 0):\n d = n1%10\n if d in list_:\n f = 1\n else:\n f = 0\n break\n n1 = n\n sum_ = 0\n while(n1 > 0):\n d = n1 % 10\n sum_ += d\n n1 //= 10\n k = 0\n if sum_%list_[k] == 0 or sum_%[k] == 0:\n f = 1\n else:\n k += 1\n if f == 1:\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "872451ed8f933a9fab9d1c6e3cff28e5", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\nS=raw_input()\nfor S1 in range(len(S)):\n for E1 in range(len(S)+1):\n for S2 in range(len(S)):\n for E2 in range(len(S)+1):\n if S[S1:E1]+S[S2:E2]=='CODEFORCES':\n print'YES'\n sys.exit()\nprint'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "15f7c4cd06e2f8b787d68e4220bc6d40", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "r,b=map(int,input().split())\nc,d=0,0\nwhile r>0 or b>0:\n if r>1 and b>=1:\n c=c+1\n r=r-1\n b=b-1\n elif (r>=2 and b<1):\n d=d+1\n r=r-2\n elif b>=2 and r<1:\n d=d+1\n b=b-2\nprint(c,end=' ')\nprint(d)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "213401c8fc496b0798e780ef90da8547", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n, a, b, p, q = map(int, raw_input().split())\n\ncnta = n / a\ncntb = n / b\nmx = max(p, q)\ncnt = n / b / a\n\nprint (cnta - cnt) * p + (cntb - cnt) * q + cnt * mx", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8cf84c8c811b6329dc6e82bfefd24666", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\ncount = 0\nfor i in range(0,n+1):\n\tif (n - i) >= i:\n\t\t#print(n-i,i)\n\t\tcount+=1\n\telse:\n\t\tbreak\nprint(count)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1dd38017aefde516c1b575ccd2996139", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = input()\nn = int(n)\ncount = 0\nfor i in range(1,n+1):\n s = str(i)\n if('2' in s or '3' in s or '4' in s or '5' in s or '6' in s or '7' in s or '8' in s or '9' in s):\n continue\n else:\n count += 1\nprint count\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "882086ed80b6160138a279dee3ecd20c", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nn = int(raw_input(''))\nvoters = []\nx = 0\n\n#for i in range(1,n+1):\n#\tvoters.append(int(raw_input('')))\n#\t#print 'i = '+str(i)\n\nvoters = map(int, raw_input().split( ))\n\n#print 'voters ='+str(voters)\n#print 'max ='+ str(max(voters))\n#print 'bear = '+str(voters[0])+':\\n'\n\nwhile ( max(voters) >= voters[0] ):\n\tx+=1\n\tvoters[0]+=1\n\tvoters[voters.index(max(voters))] = max(voters)-1\n\t#print 'max = '+str(max(voters))+':\\n'\n\t#print 'bear = '+str(voters[0])+':\\n'\n\t#print 'x = '+str(x)+':\\n'\n\n#x+=1\nprint x\n\t\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "412a6264bed642de19dd946c406e7de8", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import math\n\nans = 0\nn = int(raw_input())\nsq = int(math.sqrt(n))\npythagDict = {}\nfor x in range(1,sq+2):\n for y in range(1,x):\n a = 2*x*y\n b = x*x-y*y\n c = x*x+y*y\n pair = [min(a,b),max(a,b)]\n if c not in pythagDict and c <= n:\n pythagDict[c] = [pair]\n ans += 1\n elif c in pythagDict:\n if pair not in pythagDict[c]:\n pythagDict[c].append(pair)\n ans += 1\n else:\n pass\nfor i in pythagDict:\n for pair in pythagDict[i]:\n for k in range(2,n/i):\n if k*i not in pythagDict:\n pythagDict[k*i] = [[pair[0]*k,pair[1]*k]]\n ans += 1\n elif [pair[0]*k,pair[1]*k] not in pythagDict[k*i]:\n pythagDict[k*i].append([pair[0]*k,pair[1]*k])\n ans += 1\n else:\n pass\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b195b8a8b34a92e7821b5d61be9bec86", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n=int(input())\ncnt=0\nfor i in range(1,(n/2)+1):\n\n if(n%i==0):\n cnt+=1\n \n\nprint(cnt)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "deb7d49cd1d30d344ff2739af74b3493", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Python 3", "source_code": "vp = int(input())\nvd = int(input())\nt = int(input())\nf = int(input())\nc = int(input())\n\np = 0\nb = 0\nif vp > vd:\n while p < c:\n\n time_adv = t\n time_catch = (p + time_adv * vp) / (vd - vp)\n \n p += (time_adv + time_catch) * vp\n t = p / vd + f\n b += 1\n b -= 1\n\nprint(b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a72aebc10ebe1677ca8841f20c146fe6", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n, x = map(int, raw_input().split())\nnums = map(int, raw_input().split())\n\nnums = filter(lambda t: t <= x, nums)\nif len(nums) == x + 1:\n print 1\nelse:\n print x - len(nums)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5dae9450c48575b56424a489f0f02ed", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "res = [int(ele) for ele in str(a / b) if ele.isdigit()]\n# Removing the first zero so it is not counted\nres.pop(0)\n# Appending a final 0 if it is not an approximate result\n\nres.append(0)\nfor i, dig in enumerate(res):\n if dig == c:\n return i + 1\nreturn -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "07c73e0bcaf045e20a50809ea2a06f4a", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "data = [int(info) for info in input().split(' ')]\n\nif data[0] == data[2] and data[1] == data[3]:\n\ttime = data[1] - data[0] + 1\n\tif data[4] <= data[0] and data[4] =< data[1]:\n\t\ttime -= 1\nelse:\n\tif data[0] < data[2]:\n\t\tif data[1] < data[3]:\n\t\t\ttime = data[1] - data[2] + 1\n\t\t\tif data[4] <= data[1] and data[4] =< data[2]:\n\t\t\t\ttime -= 1\n\t\telse:\n\t\t\ttime = data[3] - data[2] + 1\n\t\t\tif data[4] <= data[3] and data[4] =< data[2]:\n\t\t\t\ttime -= 1\n\n\telse:\n\t\tif data[1] > data[3]:\n\t\t\ttime = data[1] - data[3] + 1\n\t\t\tif data[4] => data[3] and data[4] =< data[1]:\n\t\t\t\ttime -= 1\n\t\telse:\n\t\t\ttime = data[1] - data[0] + 1\n\t\t\tif data[4] => data[0] and data[4] =< data[1]:\n\t\t\t\ttime -= 1\nprint(time)\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "be8ebb6656938dcd92b5898f5708f4ad", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a=input()\nb=map(int, raw_input().split())\nb.sort()\n\nfor i in range(a-2):\n if( b[i]+b[i+1]>b[i+2]:\n flag=1\n break\n else:\n flag=0\nif flag==1:\n print \"YES\"\nelse:\n print \"NO\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "845c79141ddb10fa031a9062d15956ad", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def min_max(n, left, r):\n s = 0\n lt = left\n s += (n - (lt - 1))\n s_m = (n - (r - 1)) * (2 ** (r - 1))\n lt -= 1\n r -= 1\n s += (2 * (2 ** lt - 1))\n # print((1 * (2 ** r - 1)))\n s_m += (1 * (2 ** r - 1))\n return s, s_m\n\n\n\nif __name__ == '__main__':\n print(*min_max(*map(int, input", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9b7ef74c2252bf9daa31c4c152a7ce0e", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "a = input()\nprint(!a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af19bcd54bc7f9562e72a24b9899bfb6", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Python 3", "source_code": "def p(x):\n \n x=x.strip(\"0\")\n for i in range(len(x)):\n if (x[i]!=x[-i-1]):\n print(\"NO\")\n return\n \n print(\"YES\")\n \nx=input()\np(x)\n if (plin(strip(x)))cout<<\"YES\";else cout<<\"NO\";\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b491c7f0e1ba42c47d832c3ea39079d0", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "Python 3", "source_code": "N = 44721\na = []\nfor i in range(N):\n a.append(str(i ** i))\n\ns0 = input()\nl = len(s0)\nans = -1\nfor s in a:\n num = 0\n j = 0\n ls = len(s)\n flag = False\n for i in range(l):\n if s0[i] == s[j]:\n num += 1\n j += 1\n if num == ls:\n flag = True\n break\n if flag:\n ans = max(ans,num)\nif ans != -1:\n ans = l - ans\nprint(ans\uff09", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb53412d97cfd9f699fed6cad06ef30c", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#\u64cd\u4f5c\u5b8c\u7b2c\u4e00\u6b21\u540e,\u5b57\u7b26\u4e32\u5fc5\u7136\u662f1...1\u5f62\u5f0f,\u8bb0\u4e3as1\u548cs2\r\n#\u4e4b\u540e\u7684\u5b57\u7b26\u4e32\u5fc5\u7136\u662f111...1s111...1\u5f62\u5f0f\r\n#\u5176\u4e2ds\u53ea\u53ef\u80fd\u662fs1,rev(s1),s2,rev(s2),\u8fd9\u4e5f\u8bf4\u660e\u4e86\u4e4b\u524dbfs\u72b6\u6001\u7684\u6709\u9650\u6027\r\n#\u53ea\u9700\u8981\u53bb\u66b4\u529b\u5339\u914d\u5373\u53ef\r\na, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3dde880aef85ce9cce85386e46b7e1a1", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "if __name__==\"__main__\":\n\tn = input()\n\ttmp = ''\n\tfor i in n:\n\t\tif not len(tmp):\n\t\t\ttmp = i\n\t\telif not i ==\"/\":\n\t\t\ttmp = tmp+i\n\t\telif not tmp[-1]==\"/\":\n\t\t\ttmp = tmp+i\n\tif tmp[-1]==\"/\"and len(tmp) not 1:\n\t\ttmp = tmp[0:-1]\n\t#QQ\n\tprint(tmp)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "413495884875c99c18ca172804f46cee", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x, y = map(input().split(' ')); if (x==y):print(x) else: print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6720c4d738f09eff13c1934e7f9ba8d3", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Python 3", "source_code": "l,r = map(int, input.split())\nif l == r :\n print r\nelse print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2049d17f2b39e0a93f9b499ea897496", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "\n print 3\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a111e35b58527e445c5be5be06d0d95d", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "A = list(map(int, input().split()))\nr1 = A[0]\nc1 = A[1]\nr2 = A[2]\nc2 = A[3]\n\n# Calculate kings movements\ndistance = math.sqrt(pow((r1 - r2),2)+pow((c1 - c2),2))\nking_movements = math.ceil(distance/math.sqrt(2))\n\n# Rooks can always reach their position\nrook_movements = 1 if (r1 == r2 or c1 == c2) else 2\n\n# Bishop can move either 1 or 2 moves, no other way\n# If they are not on the same color\nif ((r1 + c1) % 2 != (r2 + c2) % 2):\n bishop_movements = 0\nelse:\n # If they are on the same diagonal\n if c1 == (-r1 + (c2 + r2)) or c1 == (r1 + (c2 - r2)):\n bishop_movements = 1\n # If they are not, we can get in two moves\n else:\n bishop_movements = 2\n\nprint(rook_movements)\nprint(bishop_movements)\nprint(king_movements)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c48cedae8372b8467df1b11424f67428", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "\"\"\" import sys\nsys.stdin = open('input.txt', 'r')\nsys.stdout = open('output.txt', 'w') \"\"\"\nn, a, b, c = map(int, input().split())\nz = [0]+[-1e9]*5000\nfor i in range(1, n+1):\n z[i] = max(z[i-a], z[i-b], z[i-c])+1\nprint(z[n])\"\"\" \"\"\" \"\"\" \"\"\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "81814bf0bfab0d5b08e0a0fe16159f12", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "s = input()\nl = s.lower()\nu = s.upper()\ncl = 0\ncu = 0\nfor i in range(len(s)):\n if s[i] == l[i]:\n cl += 1\n else:\n cu += 1\n\nprint(l) if cl >= cu else print(u)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40082f686cc37f90ecfa72deb7f1df2f", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# 1. \uc778\uc99d\uc11c\n#n\uba85\uc758 \ud559\uc0dd\uc774 \uc62c\ub9bc\ud53c\uc544\ub4dc \uce58\ub8f8 -> \uc774\uc81c \uc218\uc0c1\uc2dc\uac04!\n# \uba87\uba85\uc740 diploma\ub97c, \uba87\uba85\uc740 certificate\ub97c, \uadf8\ub9ac\uace0 \ub458\ub2e4 \ubabb\ubc1b\ub294 \ub188\ub4e4\uc774 \uc0dd\uaca8.\n# diploma\uc640 certificates\ub97c \ubc1b\uc740 \uc560\ub4e4\uc740 'Winner'\uc57c.\n# Rules\n# 1. certificates\ub294 \uc815\ud655\ud788 diploma\uc758 k\ubc30\uc5ec\uc57c\ud568.\n# 2. winner\uc758 \uc22b\uc790\ub294 \ubaa8\ub4e0 \ud559\uc0dd\uc758 \uc218(n)\uc758 \uc808\ubc18\uc744 \ub118\uc5b4\uc11c\ub294 \uc548\ub3fc.\n# 3. \uc544\ubb34\ub3c4 \uc2b9\uc790\uac00 \uc5c6\ub294 \ucf00\uc774\uc2a4\uac00 \uc788\uc5b4\ub3c4 \ub3fc.\n\n# n = \ud559\uc0dd\uc218\n# k = certificate:diploma\uc758 \ube44\n\ndef diploma():\n import math\n IPT = []\n ipt = input()\n Ipt = ipt.split()\n for x in Ipt:\n IPT.append(int(x))\n n = IPT[0]\n k = IPT[1]\n C = 0\n D = 0\n R = int(n/2)\n C = (int(R/(k+1)))\n D = (C*k)\n print(str(int(C))+' '+str(int(D))+' '+str(int(n-C-D)))\n\ndiploma()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8c239742fe6a610d3674df1b586cbe45", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input()\nstring = input()\ncount = 0\ntotal=1\narr=[]\nfor i in string:\n if(count==0):\n if(i==\"1\"):count=1\n else:\n \n if(i==\"1\"):\n total*=count\n count=1\n else:\n count+=1\n \n \n \nprint(total)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eeea9411fd046480f5208b25de7398ca", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import sys\n\na, b = map(int, sys.stdin.readline().split())\nstring = sys.stdin.readline().split()[0]\n\ndef check1(a, b, x, y, deltax, deltay):\n step1 = (a-x)/deltax\n step2 = (b-y)/deltay\n return step1>=0 and step1==step2\n\ndef check2(a, b, x, y, deltax, deltay):\n return a == x and b == y\n\ndef check3(a, b, x, y, deltax, deltay):\n step = (b\n return a == x and (b - y) % deltay == 0 and (b-y)/deltay >= 0\n\ndef check4(a, b, x, y, deltax, deltay):\n return b == y and (a - x) % deltax == 0 and (a-x)/deltax >= 0\n\n \ndef solve(a, b, string):\n #lets calc step\n deltax = string.count('R') - string.count('L')\n deltay = string.count('U') - string.count('D')\n\n if deltax!=0 and deltay != 0:\n f = check1\n elif deltax==0 and deltay == 0:\n f = check2\n elif deltax == 0:\n f = check3\n else:\n f = check4\n x = y = 0\n for step in string:\n if step == 'U':\n y += 1\n elif step == 'D':\n y -= 1\n elif step == 'L':\n x -= 1\n elif step == 'R':\n x += 1\n else:\n print \"omg\"\n return \"Unknown\"\n\n if f(a, b, x, y, deltax, deltay):\n return \"Yes\"\n\n return \"No\"\n\n\n\nprint solve(a, b, string)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d42818924f8ff7683e3a4541d53a85f", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "def step():\n\tnonlocal x1, x2, y1, y2, step_count\n\t\n\tmove = ''\n\t\n\tif x1 > x2:\n\t\tmove += 'L'\n\t\tx1 -= 1\n\telif x1 < x2:\n\t\tmove += 'R'\n\t\tx1 += 1\n\n\tif y1 > y2:\n\t\tmove += 'D'\n\t\ty1 -= 1\n\telif y2 < y1:\n\t\tmove += 'U'\n\t\ty1 += 1\n\n\tstep_count += 1\n\n\treturn move\n\n\np1 = input()\nx1, y1 = ord(p1[0]) - ord('a'), int(p1[1])\n\np2 = input()\nx2, y2 = ord(p2[0]) - ord('a'), int(p2[1])\n\nstep_count, moves = 0, []\n\nwhile x1 != x2 or y1 != y2:\n\tmoves.append(step())\n\nprint(step_count)\n\nprint('\\n'.join(moves))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc3d94b6ff45e52f647adfa512cc9bd3", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "if __name__ == \"__main__\":\n n = int(input())\n \n # 8, 64, 512, 4096, 32768\n if n == 0:\n print('1')\n return\n\n n = n % 4\n if n == 0:\n print('6')\n elif n == 1:\n print('8')\n elif n == 2:\n print('4')\n else:\n print('2')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d176259f93c3f5807549f8d7151b04b6", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n,m,a,b=map(int,input().split())\nx=n%m\nt1=x*a+b*(n//m)\nt2=a*n\nprint(min(t1,t2))n,m,a,b=map(int,input().split())\nx=n%m\nt1=x*a+b*(n//m)\nt2=a*n\nprint(min(t1,t2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3b6c6c3c4592df72d15b705c47634969", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "print(int(input()) 0 0) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4244cf8897187d3a30c31aa6430deeab", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "print(\"Output a single number.)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6f59a137966071ebbc1b57a8e7ebeb62", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "Python 3", "source_code": "l, q = map(int, raw_input().split())\ns = list(raw_input())\n\nfor i in range(q):\n\tl, r, k = map(int, raw_input().split())\n\tl-=1\n\tt = s[l:r]\n\tif k==1: t.sort()\n\telse: t.sort(reverse=True) \n\ts[l:r] = t\nprint ''.join(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aba58abae07b810ca973411eda26a299", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(1+3n*(n=1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6906c648b88c8d63dee1ea10ef71482e", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "k,a,b,v=map(int,raw_input().split())\nbc=0\nwhile 1:\n if b>k-1:\n b-=(k-1)\n a-=min(a,v*k)\n bc+=1\n else:\n a-=min(a,(b+1)*(v))\n b=0\n bc+=1\n if a==0:\n break\nprint bc\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0a0ca16ae3175065e91763f22eb775cb", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\ns=s.lower()\nf=True\nlis[]=list(range(0,25))\nfor i in range(n):\n lis[s[i]-'a']=26\nfor i in range(len(lis)):\n if lis[i]!=26:\n f=False\nif f==True:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d66dbc0fb82d25e61eeb6d91ba6ffad", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "print(2**(int(input()+1)-2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ef79a2eef01385c0d8491663c3fbb46b", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\n n,k = map(int,input().split())\nif k<3 or k >= 2*n:\n print(0)\nelif k>n:\n if k%2 ==0:\n print(int((k/2-(k-n))))\n else:\n print(int((k-1)/2-(k-n)+1))\nelse:\n if k%2 == 0:\n print(int((k/2-1))\n else:\n print(int((k-1)/2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa5b390cee4298cbec5179b91448d2a1", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a = int(input())\nb = int(input())\nc = int(input())\nmaxi = 0\n\nmaxi = a+b+c\nif a*b+c > maxi:\nmaxi = a*b+c\nif a*(b+c) > maxi:\nmaxi = a*(b+c)\nif a+b*c > maxi:\nmaxi = a+b*c\nif (a+b)*c > maxi:\nmaxi = (a+b)*c\nif a*b*c > maxi:\nmaxi = a*b*c\nprint(maxi)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "528a757324241a5c29afab2d066236e6", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "_ = int(input())\nls =map(int,raw_input().split())\nls = set(sorted(ls)\nif ls[0] == 0:\n print len(ls)-1\nelse:\n print len(ls)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "94630bb3abb035c17a2f311ab8986a6d", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "int k = input()\r\nprint(6 * (pow(4,pow(2,k) - 2) % 1000000007) % 1000000007)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9c7365bc333049aeaebcd0c358b9d3d", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, a, b = map(int, raw_input().split())\nd1 = n // 2\nd2 = n - d1\nif b < a:\n\ta = a + b\n\tb = a - b\n\ta = a - b\n\nif a < d1:\n\tprint(a)\nelif b < d2:\n\tprint(b)\nelse\n\tprint(min(a//d1, b//d2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "be29988d5504eb2b0ce901532bedc1b8", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\n\n\nif a[1] * a[0] + 2 * a[3] < a[2] * a[0] + 2 * a[4]:\n print \"First\" \nelif a[1] * a[0] + 2 * a[3] > a[2] * a[0] + 2 * a[4]:\n print \"Second\"\nelse:\n print \"Friendship\"4 5 3 1 5\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ff4c64351a0a3dde2a6316c61c56701", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0} {"lang": "Python 3", "source_code": "sf=0\nfs=0\nn=int(input())\nc=input()\nn-=1\nd=c[0]\ns=c[1::]\nfor c in s:\n if(c=='S' and t=='F')\n sf++\n elif(c=='F' and t=='S')\n fs++\n c=t\nif(sf>fs):\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e8da6047a322179e4df89883332532d", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\n #1 2 3 4 5 6\nstudents = range(1,n+1)\nif n == 0:\n\tprint 0\n\texit()\nif n == 1 or n==2:\n\tprint 1\n\tprint 1\n\texit()\nif n == 3:\n\tprint 2\n\tprint 1,3\n\texit()\nif n == 4:\n\tprint 4\n\tprint 3, 1, 4, 2\n\texit()\n\nx = [i for i in xrange(1,n+1, 2)]\ny = [i for i in xrange(2,n+1,2)]\nprint n\nprint ' '.join([str(i) for i in x+y])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7704bc08269c9e075086791d24afcef3", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": " for i in range(int(input()):\r\n n=int(input())\r\n a=[*map(int,input().split())]\r\n if a[a[n-1]-1]!=0 and a[n-1]!=0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fea0e478112d1671bc3871dfd8796782", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Python 3", "source_code": "From math import\nx = int(input())\n\nprint (ceil(x / 5))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "279782c994c8361895423fd7686cb01c", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "Python 2", "source_code": "By raquel.paz, contest: Codeforces Round #293 (Div. 2), problem: (C) Anya and Smartphone, Runtime error on test 1, #\n\n#coding: utf-8\nlista = [2,5,6,11,13,14,23,27,29,30,47,55,59,61,62,95,111,119,123,125,126,191,223,239,247,251,253,254,383,447,479,495,503,507,509,510,767,895,959,991,1007,1015,1019,1021,1022,1535,1791,1919,1983,2015,2031,2039,2043,2045,2046,3071,3583,3839,3967,4031,4063,4079,4087,4091,4093,4094,6143,7167,7679,7935,8063,8127,8159,8175,8183,8187,8189,8190,12287,14335,15359,15871,16127,16255,16319,16351,16367,16375,16379,16381,16382,24575,28671,30719,31743,32255,32511,32639,32703,32735,32751,32759,32763,32765,32766,49151,57343,61439,63487,64511,65023,65279,65407,65471,65503,65519,65527,65531,65533,65534,98303,114687,122879,126975,129023,130047,130559,130815,130943,131007,131039,131055,131063,131067,131069,131070,196607,229375,245759,253951,258047,260095,261119,261631,261887,262015,262079,262111,262127,262135,262139,262141,262142,393215,458751,491519,507903,516095,520191,522239,523263,523775,524031,524159,524223,524255,524271,524279,524283,524285,524286,786431,917503,983039,1015807,1032191,1040383,1044479,1046527,1047551,1048063,1048319,1048447,1048511,1048543,1048559,1048567,1048571,1048573,1048574,1572863,1835007,1966079,2031615,2064383,2080767,2088959,2093055,2095103,2096127,2096639,2096895,2097023,2097087,2097119,2097135,2097143,2097147,2097149,2097150,3145727,3670015,3932159,4063231,4128767,4161535,4177919,4186111,4190207,4192255,4193279,4193791,4194047,4194175,4194239,4194271,4194287,4194295,4194299,4194301,4194302,6291455,7340031,7864319,8126463,8257535,8323071,8355839,8372223,8380415,8384511,8386559,8387583,8388095,8388351,8388479,8388543,8388575,8388591,8388599,8388603,8388605,8388606,12582911,14680063,15728639,16252927,16515071,16646143,16711679,16744447,16760831,16769023,16773119,16775167,16776191,16776703,16776959,16777087,16777151,16777183,16777199,16777207,16777211,16777213,16777214,25165823,29360127,31457279,32505855,33030143,33292287,33423359,33488895,33521663,33538047,33546239,33550335,33552383,33553407,33553919,33554175,33554303,33554367,33554399,33554415,33554423,33554427,33554429,33554430,50331647,58720255,62914559,65011711,66060287,66584575,66846719,66977791,67043327,67076095,67092479,67100671,67104767,67106815,67107839,67108351,67108607,67108735,67108799,67108831,67108847,67108855,67108859,67108861,67108862,100663295,117440511,125829119,130023423,132120575,133169151,133693439,133955583,134086655,134152191,134184959,134201343,134209535,134213631,134215679,134216703,134217215,134217471,134217599,134217663,134217695,134217711,134217719,134217723,134217725,134217726,201326591,234881023,251658239,260046847,264241151,266338303,267386879,267911167,268173311,268304383,268369919,268402687,268419071,268427263,268431359,268433407,268434431,268434943,268435199,268435327,268435391,268435423,268435439,268435447,268435451,268435453,268435454,402653183,469762047,503316479,520093695,528482303,532676607,534773759,535822335,536346623,536608767,536739839,536805375,536838143,536854527,536862719,536866815,536868863,536869887,536870399,536870655,536870783,536870847,536870879,536870895,536870903,536870907,536870909,536870910,805306367,939524095,1006632959,1040187391,1056964607,1065353215,1069547519,1071644671,1072693247,1073217535,1073479679,1073610751,1073676287,1073709055,1073725439,1073733631,1073737727,1073739775,1073740799,1073741311,1073741567,1073741695,1073741759,1073741791,1073741807,1073741815,1073741819,1073741821,1073741822,1610612735,1879048191,2013265919,2080374783,2113929215,2130706431,2139095039,2143289343,2145386495,2146435071,2146959359,2147221503,2147352575,2147418111,2147450879,2147467263,2147475455,2147479551,2147481599,2147482623,2147483135,2147483391,2147483519,2147483583,2147483615,2147483631,2147483639,2147483643,2147483645,2147483646,3221225471,3758096383,4026531839,4160749567,4227858431,4261412863,4278190079,4286578687,4290772991,4292870143,4293918719,4294443007,4294705151,4294836223,4294901759,4294934527,4294950911,4294959103,4294963199,4294965247,4294966271,4294966783,4294967039,4294967167,4294967231,4294967263,4294967279,4294967287,4294967291,4294967293,4294967294,6442450943,7516192767,8053063679,8321499135,8455716863,8522825727,8556380159,8573157375,8581545983,8585740287,8587837439,8588886015,8589410303,8589672447,8589803519,8589869055,8589901823,8589918207,8589926399,8589930495,8589932543,8589933567,8589934079,8589934335,8589934463,8589934527,8589934559,8589934575,8589934583,8589934587,8589934589,8589934590,12884901887,15032385535,16106127359,16642998271,16911433727,17045651455,17112760319,17146314751,17163091967,17171480575,17175674879,17177772031,17178820607,17179344895,17179607039,17179738111,17179803647,17179836415,17179852799,17179860991,17179865087,17179867135,17179868159,17179868671,17179868927,17179869055,17179869119,17179869151,17179869167,17179869175,17179869179,17179869181,17179869182,25769803775,30064771071,32212254719,33285996543,33822867455,34091302911,34225520639,34292629503,34326183935,34342961151,34351349759,34355544063,34357641215,34358689791,34359214079,34359476223,34359607295,34359672831,34359705599,34359721983,34359730175,34359734271,34359736319,34359737343,34359737855,34359738111,34359738239,34359738303,34359738335,34359738351,34359738359,34359738363,34359738365,34359738366,51539607551,60129542143,64424509439,66571993087,67645734911,68182605823,68451041279,68585259007,68652367871,68685922303,68702699519,68711088127,68715282431,68717379583,68718428159,68718952447,68719214591,68719345663,68719411199,68719443967,68719460351,68719468543,68719472639,68719474687,68719475711,68719476223,68719476479,68719476607,68719476671,68719476703,68719476719,68719476727,68719476731,68719476733,68719476734,103079215103,120259084287,128849018879,133143986175,135291469823,136365211647,136902082559,137170518015,137304735743,137371844607,137405399039,137422176255,137430564863,137434759167,137436856319,137437904895,137438429183,137438691327,137438822399,137438887935,137438920703,137438937087,137438945279,137438949375,137438951423,137438952447,137438952959,137438953215,137438953343,137438953407,137438953439,137438953455,137438953463,137438953467,137438953469,137438953470,206158430207,240518168575,257698037759,266287972351,270582939647,272730423295,273804165119,274341036031,274609471487,274743689215,274810798079,274844352511,274861129727,274869518335,274873712639,274875809791,274876858367,274877382655,274877644799,274877775871,274877841407,274877874175,274877890559,274877898751,274877902847,274877904895,274877905919,274877906431,274877906687,274877906815,274877906879,274877906911,274877906927,274877906935,274877906939,274877906941,274877906942,412316860415,481036337151,515396075519,532575944703,541165879295,545460846591,547608330239,548682072063,549218942975,549487378431,549621596159,549688705023,549722259455,549739036671,549747425279,549751619583,549753716735,549754765311,549755289599,549755551743,549755682815,549755748351,549755781119,549755797503,549755805695,549755809791,549755811839,549755812863,549755813375,549755813631,549755813759,549755813823,549755813855,549755813871,549755813879,549755813883,549755813885,549755813886,824633720831,962072674303,1030792151039,1065151889407,1082331758591,1090921693183,1095216660479,1097364144127,1098437885951,1098974756863,1099243192319,1099377410047,1099444518911,1099478073343,1099494850559,1099503239167,1099507433471,1099509530623,1099510579199,1099511103487,1099511365631,1099511496703,1099511562239,1099511595007,1099511611391,1099511619583,1099511623679,1099511625727,1099511626751,1099511627263,1099511627519,1099511627647,1099511627711,1099511627743,1099511627759,1099511627767,1099511627771,1099511627773,1099511627774,1649267441663,1924145348607,2061584302079,2130303778815,2164663517183,2181843386367,2190433320959,2194728288255,2196875771903,2197949513727,2198486384639,2198754820095,2198889037823,2198956146687,2198989701119,2199006478335,2199014866943,2199019061247,2199021158399,2199022206975,2199022731263,2199022993407,2199023124479,2199023190015,2199023222783,2199023239167,2199023247359,2199023251455,2199023253503,2199023254527,2199023255039,2199023255295,2199023255423,2199023255487,2199023255519,2199023255535,2199023255543,2199023255547,2199023255549,2199023255550,3298534883327,3848290697215,4123168604159,4260607557631,4329327034367,4363686772735,4380866641919,4389456576511,4393751543807,4395899027455,4396972769279,4397509640191,4397778075647,4397912293375,4397979402239,4398012956671,4398029733887,4398038122495,4398042316799,4398044413951,4398045462527,4398045986815,4398046248959,4398046380031,4398046445567,4398046478335,4398046494719,4398046502911,4398046507007,4398046509055,4398046510079,4398046510591,4398046510847,4398046510975,4398046511039,4398046511071,4398046511087,4398046511095,4398046511099,4398046511101,4398046511102,6597069766655,7696581394431,8246337208319,8521215115263,8658654068735,8727373545471,8761733283839,8778913153023,8787503087615,8791798054911,8793945538559,8795019280383,8795556151295,8795824586751,8795958804479,8796025913343,8796059467775,8796076244991,8796084633599,8796088827903,8796090925055,8796091973631,8796092497919,8796092760063,8796092891135,8796092956671,8796092989439,8796093005823,8796093014015,8796093018111,8796093020159,8796093021183,8796093021695,8796093021951,8796093022079,8796093022143,8796093022175,8796093022191,8796093022199,8796093022203,8796093022205,8796093022206,13194139533311,15393162788863,16492674416639,17042430230527,17317308137471,17454747090943,17523466567679,17557826306047,17575006175231,17583596109823,17587891077119,17590038560767,17591112302591,17591649173503,17591917608959,17592051826687,17592118935551,17592152489983,17592169267199,17592177655807,17592181850111,17592183947263,17592184995839,17592185520127,17592185782271,17592185913343,17592185978879,17592186011647,17592186028031,17592186036223,17592186040319,17592186042367,17592186043391,17592186043903,17592186044159,17592186044287,17592186044351,17592186044383,17592186044399,17592186044407,17592186044411,17592186044413,17592186044414,26388279066623,30786325577727,32985348833279,34084860461055,34634616274943,34909494181887,35046933135359,35115652612095,35150012350463,35167192219647,35175782154239,35180077121535,35182224605183,35183298347007,35183835217919,35184103653375,35184237871103,35184304979967,35184338534399,35184355311615,35184363700223,35184367894527,35184369991679,35184371040255,35184371564543,35184371826687,35184371957759,35184372023295,35184372056063,35184372072447,35184372080639,35184372084735,35184372086783,35184372087807,35184372088319,35184372088575,35184372088703,35184372088767,35184372088799,35184372088815,35184372088823,35184372088827,35184372088829,35184372088830,52776558133247,61572651155455,65970697666559,68169720922111,69269232549887,69818988363775,70093866270719,70231305224191,70300024700927,70334384439295,70351564308479,70360154243071,70364449210367,70366596694015,70367670435839,70368207306751,70368475742207,70368609959935,70368677068799,70368710623231,70368727400447,70368735789055,70368739983359,70368742080511,70368743129087,70368743653375,70368743915519,70368744046591,70368744112127,70368744144895,70368744161279,70368744169471,70368744173567,70368744175615,70368744176639,70368744177151,70368744177407,70368744177535,70368744177599,70368744177631,70368744177647,70368744177655,70368744177659,70368744177661,70368744177662,105553116266495,123145302310911,131941395333119,136339441844223,138538465099775,139637976727551,140187732541439,140462610448383,140600049401855,140668768878591,140703128616959,140720308486143,140728898420735,140733193388031,140735340871679,140736414613503,140736951484415,140737219919871,140737354137599,140737421246463,140737454800895,140737471578111,140737479966719,140737484161023,140737486258175,140737487306751,140737487831039,140737488093183,140737488224255,140737488289791,140737488322559,140737488338943,140737488347135,140737488351231,140737488353279,140737488354303,140737488354815,140737488355071,140737488355199,140737488355263,140737488355295,140737488355311,140737488355319,140737488355323,140737488355325,140737488355326,211106232532991,246290604621823,263882790666239,272678883688447,277076930199551,279275953455103,280375465082879,280925220896767,281200098803711,281337537757183,281406257233919,281440616972287,281457796841471,281466386776063,281470681743359,281472829227007,281473902968831,281474439839743,281474708275199,281474842492927,281474909601791,281474943156223,281474959933439,281474968322047,281474972516351,281474974613503,281474975662079,281474976186367,281474976448511,281474976579583,281474976645119,281474976677887,281474976694271,281474976702463,281474976706559,281474976708607,281474976709631,281474976710143,281474976710399,281474976710527,281474976710591,281474976710623,281474976710639,281474976710647,281474976710651,281474976710653,281474976710654,422212465065983,492581209243647,527765581332479,545357767376895,554153860399103,558551906910207,560750930165759,561850441793535,562400197607423,562675075514367,562812514467839,562881233944575,562915593682943,562932773552127,562941363486719,562945658454015,562947805937663,562948879679487,562949416550399,562949684985855,562949819203583,562949886312447,562949919866879,562949936644095,562949945032703,562949949227007,562949951324159,562949952372735,562949952897023,562949953159167,562949953290239,562949953355775,562949953388543,562949953404927,562949953413119,562949953417215,562949953419263,562949953420287,562949953420799,562949953421055,562949953421183,562949953421247,562949953421279,562949953421295,562949953421303,562949953421307,562949953421309,562949953421310,844424930131967,985162418487295,1055531162664959,1090715534753791,1108307720798207,1117103813820415,1121501860331519,1123700883587071,1124800395214847,1125350151028735,1125625028935679,1125762467889151,1125831187365887,1125865547104255,1125882726973439,1125891316908031,1125895611875327,1125897759358975,1125898833100799,1125899369971711,1125899638407167,1125899772624895,1125899839733759,1125899873288191,1125899890065407,1125899898454015,1125899902648319,1125899904745471,1125899905794047,1125899906318335,1125899906580479,1125899906711551,1125899906777087,1125899906809855,1125899906826239,1125899906834431,1125899906838527,1125899906840575,1125899906841599,1125899906842111,1125899906842367,1125899906842495,1125899906842559,1125899906842591,1125899906842607,1125899906842615,1125899906842619,1125899906842621,1125899906842622,1688849860263935,1970324836974591,2111062325329919,2181431069507583,2216615441596415,2234207627640831,2243003720663039,2247401767174143,2249600790429695,2250700302057471,2251250057871359,2251524935778303,2251662374731775,2251731094208511,2251765453946879,2251782633816063,2251791223750655,2251795518717951,2251797666201599,2251798739943423,2251799276814335,2251799545249791,2251799679467519,2251799746576383,2251799780130815,2251799796908031,2251799805296639,2251799809490943,2251799811588095,2251799812636671,2251799813160959,2251799813423103,2251799813554175,2251799813619711,2251799813652479,2251799813668863,2251799813677055,2251799813681151,2251799813683199,2251799813684223,2251799813684735,2251799813684991,2251799813685119,2251799813685183,2251799813685215,2251799813685231,2251799813685239,2251799813685243,2251799813685245,2251799813685246,3377699720527871,3940649673949183,4222124650659839,4362862139015167,4433230883192831,4468415255281663,4486007441326079,4494803534348287,4499201580859391,4501400604114943,4502500115742719,4503049871556607,4503324749463551,4503462188417023,4503530907893759,4503565267632127,4503582447501311,4503591037435903,4503595332403199,4503597479886847,4503598553628671,4503599090499583,4503599358935039,4503599493152767,4503599560261631,4503599593816063,4503599610593279,4503599618981887,4503599623176191,4503599625273343,4503599626321919,4503599626846207,4503599627108351,4503599627239423,4503599627304959,4503599627337727,4503599627354111,4503599627362303,4503599627366399,4503599627368447,4503599627369471,4503599627369983,4503599627370239,4503599627370367,4503599627370431,4503599627370463,4503599627370479,4503599627370487,4503599627370491,4503599627370493,4503599627370494,6755399441055743,7881299347898367,8444249301319679,8725724278030335,8866461766385663,8936830510563327,8972014882652159,8989607068696575,8998403161718783,9002801208229887,9005000231485439,9006099743113215,9006649498927103,9006924376834047,9007061815787519,9007130535264255,9007164895002623,9007182074871807,9007190664806399,9007194959773695,9007197107257343,9007198180999167,9007198717870079,9007198986305535,9007199120523263,9007199187632127,9007199221186559,9007199237963775,9007199246352383,9007199250546687,9007199252643839,9007199253692415,9007199254216703,9007199254478847,9007199254609919,9007199254675455,9007199254708223,9007199254724607,9007199254732799,9007199254736895,9007199254738943,9007199254739967,9007199254740479,9007199254740735,9007199254740863,9007199254740927,9007199254740959,9007199254740975,9007199254740983,9007199254740987,9007199254740989,9007199254740990,13510798882111487,15762598695796735,16888498602639359,17451448556060671,17732923532771327,17873661021126655,17944029765304319,17979214137393151,17996806323437567,18005602416459775,18010000462970879,18012199486226431,18013298997854207,18013848753668095,18014123631575039,18014261070528511,18014329790005247,18014364149743615,18014381329612799,18014389919547391,18014394214514687,18014396361998335,18014397435740159,18014397972611071,18014398241046527,18014398375264255,18014398442373119,18014398475927551,18014398492704767,18014398501093375,18014398505287679,18014398507384831,18014398508433407,18014398508957695,18014398509219839,18014398509350911,18014398509416447,18014398509449215,18014398509465599,18014398509473791,18014398509477887,18014398509479935,18014398509480959,18014398509481471,18014398509481727,18014398509481855,18014398509481919,18014398509481951,18014398509481967,18014398509481975,18014398509481979,18014398509481981,18014398509481982,27021597764222975,31525197391593471,33776997205278719,34902897112121343,35465847065542655,35747322042253311,35888059530608639,35958428274786303,35993612646875135,36011204832919551,36020000925941759,36024398972452863,36026597995708415,36027697507336191,36028247263150079,36028522141057023,36028659580010495,36028728299487231,36028762659225599,36028779839094783,36028788429029375,36028792723996671,36028794871480319,36028795945222143,36028796482093055,36028796750528511,36028796884746239,36028796951855103,36028796985409535,36028797002186751,36028797010575359,36028797014769663,36028797016866815,36028797017915391,36028797018439679,36028797018701823,36028797018832895,36028797018898431,36028797018931199,36028797018947583,36028797018955775,36028797018959871,36028797018961919,36028797018962943,36028797018963455,36028797018963711,36028797018963839,36028797018963903,36028797018963935,36028797018963951,36028797018963959,36028797018963963,36028797018963965,36028797018963966,54043195528445951,63050394783186943,67553994410557439,69805794224242687,70931694131085311,71494644084506623,71776119061217279,71916856549572607,71987225293750271,72022409665839103,72040001851883519,72048797944905727,72053195991416831,72055395014672383,72056494526300159,72057044282114047,72057319160020991,72057456598974463,72057525318451199,72057559678189567,72057576858058751,72057585447993343,72057589742960639,72057591890444287,72057592964186111,72057593501057023,72057593769492479,72057593903710207,72057593970819071,72057594004373503,72057594021150719,72057594029539327,72057594033733631,72057594035830783,72057594036879359,72057594037403647,72057594037665791,72057594037796863,72057594037862399,72057594037895167,72057594037911551,72057594037919743,72057594037923839,72057594037925887,72057594037926911,72057594037927423,72057594037927679,72057594037927807,72057594037927871,72057594037927903,72057594037927919,72057594037927927,72057594037927931,72057594037927933,72057594037927934,108086391056891903,126100789566373887,135107988821114879,139611588448485375,141863388262170623,142989288169013247,143552238122434559,143833713099145215,143974450587500543,144044819331678207,144080003703767039,144097595889811455,144106391982833663,144110790029344767,144112989052600319,144114088564228095,144114638320041983,144114913197948927,144115050636902399,144115119356379135,144115153716117503,144115170895986687,144115179485921279,144115183780888575,144115185928372223,144115187002114047,144115187538984959,144115187807420415,144115187941638143,144115188008747007,144115188042301439,144115188059078655,144115188067467263,144115188071661567,144115188073758719,144115188074807295,144115188075331583,144115188075593727,144115188075724799,144115188075790335,144115188075823103,144115188075839487,144115188075847679,144115188075851775,144115188075853823,144115188075854847,144115188075855359,144115188075855615,144115188075855743,144115188075855807,144115188075855839,144115188075855855,144115188075855863,144115188075855867,144115188075855869,144115188075855870,216172782113783807,252201579132747775,270215977642229759,279223176896970751,283726776524341247,285978576338026495,287104476244869119,287667426198290431,287948901175001087,288089638663356415,288160007407534079,288195191779622911,288212783965667327,288221580058689535,288225978105200639,288228177128456191,288229276640083967,288229826395897855,288230101273804799,288230238712758271,288230307432235007,288230341791973375,288230358971842559,288230367561777151,288230371856744447,288230374004228095,288230375077969919,288230375614840831,288230375883276287,288230376017494015,288230376084602879,288230376118157311,288230376134934527,288230376143323135,288230376147517439,288230376149614591,288230376150663167,288230376151187455,288230376151449599,288230376151580671,288230376151646207,288230376151678975,288230376151695359,288230376151703551,288230376151707647,288230376151709695,288230376151710719,288230376151711231,288230376151711487,288230376151711615,288230376151711679,288230376151711711,288230376151711727,288230376151711735,288230376151711739,288230376151711741,288230376151711742,432345564227567615,504403158265495551,540431955284459519,558446353793941503,567453553048682495,571957152676052991,574208952489738239,575334852396580863,575897802350002175,576179277326712831,576320014815068159,576390383559245823,576425567931334655,576443160117379071,576451956210401279,576456354256912383,576458553280167935,576459652791795711,576460202547609599,576460477425516543,576460614864470015,576460683583946751,576460717943685119,576460735123554303,576460743713488895,576460748008456191,576460750155939839,576460751229681663,576460751766552575,576460752034988031,576460752169205759,576460752236314623,576460752269869055,576460752286646271,576460752295034879,576460752299229183,576460752301326335,576460752302374911,576460752302899199,576460752303161343,576460752303292415,576460752303357951,576460752303390719,576460752303407103,576460752303415295,576460752303419391,576460752303421439,576460752303422463,576460752303422975,576460752303423231,576460752303423359,576460752303423423,576460752303423455,576460752303423471,576460752303423479,576460752303423483,576460752303423485,576460752303423486,864691128455135231,1008806316530991103,1080863910568919039,1116892707587883007,1134907106097364991,1143914305352105983,1148417904979476479,1150669704793161727,1151795604700004351,1152358554653425663,1152640029630136319,1152780767118491647,1152851135862669311,1152886320234758143,1152903912420802559,1152912708513824767,1152917106560335871,1152919305583591423,1152920405095219199,1152920954851033087,1152921229728940031,1152921367167893503,1152921435887370239,1152921470247108607,1152921487426977791,1152921496016912383,1152921500311879679,1152921502459363327,1152921503533105151,1152921504069976063,1152921504338411519,1152921504472629247,1152921504539738111,1152921504573292543,1152921504590069759,1152921504598458367,1152921504602652671,1152921504604749823,1152921504605798399,1152921504606322687,1152921504606584831,1152921504606715903,1152921504606781439,1152921504606814207,1152921504606830591,1152921504606838783,1152921504606842879,1152921504606844927,1152921504606845951,1152921504606846463,1152921504606846719,1152921504606846847,1152921504606846911,1152921504606846943,1152921504606846959,1152921504606846967,1152921504606846971,1152921504606846973,1152921504606846974,1729382256910270463,2017612633061982207,2161727821137838079,2233785415175766015,2269814212194729983,2287828610704211967,2296835809958952959,2301339409586323455,2303591209400008703,2304717109306851327,2305280059260272639,2305561534236983295,2305702271725338623,2305772640469516287,2305807824841605119,2305825417027649535,2305834213120671743,2305838611167182847,2305840810190438399,2305841909702066175,2305842459457880063,2305842734335787007,2305842871774740479,2305842940494217215,2305842974853955583,2305842992033824767,2305843000623759359,2305843004918726655,2305843007066210303,2305843008139952127,2305843008676823039,2305843008945258495,2305843009079476223,2305843009146585087,2305843009180139519,2305843009196916735,2305843009205305343,2305843009209499647,2305843009211596799,2305843009212645375,2305843009213169663,2305843009213431807,2305843009213562879,2305843009213628415,2305843009213661183,2305843009213677567,2305843009213685759,2305843009213689855,2305843009213691903,2305843009213692927,2305843009213693439,2305843009213693695,2305843009213693823,2305843009213693887,2305843009213693919,2305843009213693935,2305843009213693943,2305843009213693947,2305843009213693949,2305843009213693950,3458764513820540927,4035225266123964415,4323455642275676159,4467570830351532031,4539628424389459967,4575657221408423935,4593671619917905919,4602678819172646911,4607182418800017407,4609434218613702655,4610560118520545279,4611123068473966591,4611404543450677247,4611545280939032575,4611615649683210239,4611650834055299071,4611668426241343487,4611677222334365695,4611681620380876799,4611683819404132351,4611684918915760127,4611685468671574015,4611685743549480959,4611685880988434431,4611685949707911167,4611685984067649535,4611686001247518719,4611686009837453311,4611686014132420607,4611686016279904255,4611686017353646079,4611686017890516991,4611686018158952447,4611686018293170175,4611686018360279039,4611686018393833471,4611686018410610687,4611686018418999295,4611686018423193599,4611686018425290751,4611686018426339327,4611686018426863615,4611686018427125759,4611686018427256831,4611686018427322367,4611686018427355135,4611686018427371519,4611686018427379711,4611686018427383807,4611686018427385855,4611686018427386879,4611686018427387391,4611686018427387647,4611686018427387775,4611686018427387839,4611686018427387871,4611686018427387887,4611686018427387895,4611686018427387899,4611686018427387901,4611686018427387902,6917529027641081855,8070450532247928831,8646911284551352319,8935141660703064063,9079256848778919935,9151314442816847871,9187343239835811839,9205357638345293823,9214364837600034815,9218868437227405311,9221120237041090559,9222246136947933183,9222809086901354495,9223090561878065151,9223231299366420479,9223301668110598143,9223336852482686975,9223354444668731391,9223363240761753599,9223367638808264703,9223369837831520255,9223370937343148031,9223371487098961919,9223371761976868863,9223371899415822335,9223371968135299071,9223372002495037439,9223372019674906623,9223372028264841215,9223372032559808511,9223372034707292159,9223372035781033983,9223372036317904895,9223372036586340351,9223372036720558079,9223372036787666943,9223372036821221375,9223372036837998591,9223372036846387199,9223372036850581503,9223372036852678655,9223372036853727231,9223372036854251519,9223372036854513663,9223372036854644735,9223372036854710271,9223372036854743039,9223372036854759423,9223372036854767615,9223372036854771711,9223372036854773759,9223372036854774783,9223372036854775295,9223372036854775551,9223372036854775679,9223372036854775743,9223372036854775775,9223372036854775791,9223372036854775799,9223372036854775803,9223372036854775805,9223372036854775806,18446744073709551614]\n\ninicio,fim = map(int, raw_input().split())\n\ntotal = 0\nfor i in xrange(len(lista)):\n\tif lista[i] >= inicio and lista[i] <= fim: \n\t\t\n\t\ttotal += 1\n\tif lista[i] > b: \n\t\tbreak\n\t\n\t\nprint total\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4904e57ce54c6fbccc76694d8616a8fc", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a = [int(x) for x in input().split()]\na, b = a[0]. a[1]\nbb = 0\nba = 0\nsr = 0\nfor i in range(1, 7):\n if abs(a-i)= 0 and chr_1 <14:\n count += chr_1\n else:\n count += 26 - chr_1\n \n if chr_2 >= 2 and chr_2 < 16:\n count += chr_2 - 2\n elif chr_2 < 2:\n count += 2 - chr_2\n else:\n count += 28 - chr_2\n \n if chr_3 >= 19:\n count += chr_3 - 19\n elif chr_3 < 7:\n count += chr_3 + 7\n else:\n count += 19 - chr_3\n \n if chr_4 >= 6 and chr_4 < 20:\n count += chr_4 - 6\n elif chr_4 < 6:\n count += 6 - chr_4\n else:\n count += 32 - chr_4\n \n if count < mini:\n mini = count\n \nprint(mini)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e08218b3a7387afc1b8e617b666eba5", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# \u0411\u041e\u041b\u042c\u0428\u041e\u0415 \u0421\u041f\u0410\u0421\u0418\u0411\u041e \u0417\u0410 \u041e\u0422\u0421\u0422\u0423\u0422\u0421\u0422\u0412\u0418\u0415 CLIONA !!!!!!!!\n# \u041e\u0427\u0415\u041d\u042c \u041f\u0420\u0418\u042f\u0422\u041d\u041e\nn = int(input())\nR = list(map(int, input().split()))\nB = list(map(int, input().split()))\nc1 = 0\nc2 = 0\nfor i in range(n):\n if R[i] == 1 and B[i] == 0:\n c1 += 1\n elif R[i] == 0 and B[i] == 1:\n c2 += 1\nif c1 == 0:\n print(-1)\nelse:\n print(1 + c2 // c1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "190a2651d1d4b6da638f40c89fffc1d7", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": null} {"lang": "Python 3", "source_code": "numbers = int(input())\nnumbers = [int(e) for e in str(numbers)]\n\nfor x in range(len(numbers)):\n if(x == 0):\n if(numbers[x] == 9):\n numbers[x] = numbers[x]\n else:\n if(9 - numbers[x] < numbers[x]):\n numbers[x] = 9 - numbers[x]\n if(9 - numbers[x] < numbers[x]):\n numbers[x] = 9 - numbers[x]\nnumbers = [str(e) for e in numbers]\nnumbers = \"\".join(numbers)\nprint(numbers)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b58aed79facdf3c3d6d4bea4c9abdebc", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "x = int(input())\nk = int(input())\nA = int(input())\nB = int(input())\nif (x < k):\n print(A*(x-1))\n else:\n if (k == 1):\n print (A*(x-1))\n else :\n ans = 0\n while (x != 1):\n if (x % k == 0):\n ans += min ((x - (x//k)) * A, B)\n x = x // k\n else :\n if (x < k):\n ans += ((x % k)-1) * A\n x -= ((x % k) - 1)\n else:\n ans += (x % k) * A;\n x -= (x%k)\n print(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ac8bf593d9fce3853cabe6746d559f6", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Python 3", "source_code": " import math\n import os\n import sys\n \n if __name__ == '__main__':\n x=int(input())\n i=1\n while i*i<=x:\n if x%i<1==math.gcd(x//i,i):r=i\n i+=1\n print(r,x//r)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bec4c85c566e8c4cbfb67805c82579de", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nh = int(input())\nm = int(input())\n\nhouses = []\nfor i in range (1,n)\n houses.append(h)\nfor i in range (1,m)\n li=int(input())\n ri=int(input())\n xi=int(input())\n for j in range (li-1,ri-1)\n houses[j]=min(houses[j],xi)\nprofit=0\nfor i in range (1,n)\n profit=profit+houses[i]**2\nprint(profit)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df522d6ac8252cf336893bfed4851513", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, k, x = map(int, input().split())\nballs = list(map(int, input().split()))\nresp = 0\nfor c in range(n):\n\ts = balls.copy()\n\ts.insert(c, x)\n\twhile len(s) > 2:\n\t\tl = len(s)\n\t\tfor i in range(2, len(s)):\n\t\t\tif s[i-2] == s[i-1] == s[i]:\n\t\t\t\tp = i + 1\n\t\t\t\twhile p < len(s):\n\t\t\t\t\tif s[i] != s[p]:\n\t\t\t\t\t\tbreak\n\t\t\t\t\tp += 1\n\t\t\t\ts = s[:i-2] + s[p:]\n\t\t\t\tbreak\n\t\tif len(s) == l:\n\t\t\tbreak\n\tresp = max(resp, n - len(s))\nprint(resp)\n.\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3bfd27c6bf807f5fa8bf1061db6a285", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "a, m = map(int, raw_input().split())\nif (a > m): a %= m\nif ((a == 0) || (m & (m - 1) == 0)):\n print \"Yes\"\nelse:\n if (m % a != 0):\n print \"No\"\n else:\n n = m / a\n if (n & (n - 1) == 0) :\n print \"Yes\"\n else:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c460b5b65a5733b5288fe8c53a5a088", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def binary_search(n,low,high,k):\n index=0\n while(low<=high):\n mid=(low+high)//2\n print(mid)\n if (mid*(mid+1))//2-k==mid:\n return mid\n elif (mid*(mid+1))//2-k>mid:\n \n high=mid-1\n else:\n low=mid+1\n return index\n \nn,k=map(int,input().split())\nprint(binary_search(n,1,n,k))\n\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c8cf9d950d141de2ea83e5cccfdd398d", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,a,x,b,y=map(int,raw_input().split(\",\"))\nflag =1\nwhile a!=x and b!=y:\n\ta = a+ 1\n\tb = b-1\n\tif(a==n+1):\n\t\ta = 1\n\tif(b==0):\n\t\tb=n\n\tif(a==b):\n\t\tflag =1\n\t\tprint 'YES'\n\t\tbreak;\nif flag==0:\n\tprint 'NO'\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7dcfbf4122f5706fde22c1fd663a55db", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "x,y=map(int,input().split())\ntab=list(map(int,input().split()))\nt = 0 ;\nfor i in range(len(tab)) :\n if (y%tab[i] == 0):\n if t== 0 :\n max = tab[i]\n t+=1\n elif (tab[i]> max) and ( t!=0) :\n max = tab[i]\n \nf = y/max\nprint(f)\nFin de la discussion\n\u00c9crivez un message...\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "02b3c91c1adaa5ca72a0225b9683d67e", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "inp = input().split()\nM = int(inp[0])\nN = int(inp[1])\nif M<2 and N<2:\n print('0')\n break\nif M%2==0:\n am,bm=M,0\nelse:\n am,bm=M-1,1\nif N%2==0:\n an,bn=N,0\nelse:\n an,bn=N-1,1\nprint(am*an+bm+bn)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a07b34e53f7e98b37f72ea0be457e190", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from sys import *\nn, m = map(int, input().split())\n\nif m - n == 1:\n print(str(n * 10 + 9) + ' ' + str(m * 10))\nelif n == 9 && m == 1:\n print('9 10')\nelif m == n:\n print(str(n * 10) + ' ' + str(m * 10 + 1))\nelse: print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "87c97376d18687e2bca1299c51aac460", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "Python 2", "source_code": "from itertools import permutations as p\nl = list(p([1,2,3,4,5]))\ng=[]\nfor i in range(5):\n g.append(map(int,raw_input().split()))\nma = 0\nfor it in l:\n hap = g[it[0]][it[1]] + g[it[1]][it[0]] + 2*g[it[2]][it[3]] + 2*g[it[3]][it[2]] + g[it[1]][it[2]] + g[it[2]][it[1]] + 2*g[it[3]][it[4]] + 2*g[it[4]][it[3]]\n if hap>ma:ma=hap\nprint ma", "lang_cluster": "Python", "compilation_error": false, "code_uid": "653df21af2d53e301946213b451e3238", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "inp=input()\nlst=[0]*len(inp)\nfor i in range(len(inp)):\n if inp[i] in \"AEIUOY\":\n lst[i]=i+1\n\njumps=[]\nlast=current=0\n\nfor i in range(len(lst)):\n if lst[i]!=0:\n current=lst[i]\n jump=current-last\n jumps.append(jump)\n last=current\nprint((jumps)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb3c118bc2219aaaa22e9bd7fc181e3f", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x=int(input())\nif x<=4:\n print(\"0\")\nelif x%4==0:\n print(round(x/4)-1)\nelse:\n print(round(x/4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6315f1a5e3ab12c039fc9bc407870235", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s= input()\nsat=[]\nst=set()\n\nfor i in s:\n st.add(i)\nb=int(len(st))\nprint(b)\nprint(st)\nif s=='4744000695826\n':\n print('YES')\nif s=='4':\n print('NO')\nelif b==4 or b==7:\n print('YES')\nelif len(st)==1:\n if ('4' or '7') in st:\n print('YES')\n else:\n print('NO')\n \nelif len(st)==2 and ('4' in st) and ('7' in st):\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a12003470b7fecdf1a634707d9923b5b", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math \n \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n return 2\n n = n / 2\n \n # n must be odd at this point \n # so a skip of 2 ( i = i + 2) can be used \n for i in range(3,int(math.sqrt(n))+1,2): \n \n # while i divides n , print i ad divide n \n while n % i== 0: \n return i, \n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n return n \n \n# Driver Program to test above function \n \nn = int(raw_input())\nc = primeFactors(n)\nres = int(n/c)\nprint res \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "63c6d0cfbfbc0e0bbeae460b421ab8cf", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "l = list(input())\nj = ['a', 'e','i',o','u','1','3','5','7']\nfor i in range(len(l)):\n if l[i] in j:\n s += 1\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c03e952637eb67dc118e3737948a4690", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "pms = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]\ndef ispme(x):\n for i in pms:\n if x % i == 0 and x//i>1:\n return False\n return True\n\n\nn = int(input())\nif n & 1 : # \u662f\u5947\u6570\n print('1')\nelse:\n for m in range (1,1001):\n if not ispme(m*n+1):\n print(m)\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba43a4e90bdc6ea94e1c5074c80cddfd", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nTotal=[]\ncounterT=[]\nfor b in range(n):\n Error=list(map(int,input().split()))\n Error.remove((Error[0]))\n MyListT=[]\n counter=1\n MyList1=list(map(int,input().split()))\n TMP=[]\n for x in range(len(MyList1)):\n TMP.append(MyList1[x]-1)\n for x in range(MyList1[len(MyList1)-1]):\n Check=True\n p=str(x+1)\n for l in range(len(Error)):\n if(p in str(Error[l]):\n Check=False\n break\n if(Check):\n MyListT.append(counter)\n else:\n counter+=1\n MyListT.append(counter)\n counter+=1\n k=TMP[1]\n for x in range(MyList1[0]):\n Total.append(MyListT[TMP[x+1]])\n counterT.append(MyList1[0])\nn=0\nfor _ in range(len(counterT)):\n for __ in range(counterT[_]):\n print(Total[n],end=\" \")\n print()\n n+=1\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "243a700afb2d7299ac2026262fd91656", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n#number = int(input())\narray = input().split()\n\nnumber = int(array[0])\nnArray = []\nfor i in array:\n nArray.append(int(i))\nnArray.pop(0)\n\ncount = 0 \n\nfor i in range (1,number+1):\n for j in range (1,number+1):\n for k in range (1,number+1):\n if((j-k) != (nArray[1]-nArray[2])):\n continue\n for l in range (1,number+1):\n if((j-l) != (nArray[0]-nArray[3])):\n continue\n for m in range (1,number+1):\n if(((k-m) == (nArray[0]-nArray[3]))and((l-m) == (nArray[1]-nArray[2]))):\n count +=1 \nprint (count)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "22a0dd8f862617d2d4a6ad1b5b10480b", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n=input()\nm=input()\n while(1m):\n\t\tif(n%m==0):\n\t\t\tprint n+m+1\n\t\telse:\n\t\t\tprint n+m\n\telse:\n\t\tprint n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d8412d53b620b8ca8c93f75315c63975", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s,e=input().split()\nd={}\nd['^']=0\nd['>']=1\nd['v']=2\nd['<']=3\nn=int(input())\nn=n%4\ncounter=(d[e]-d[s]+4)%4\nif(n==counter and n!=2 and n!=0):\n\tprint(\"cw\")\nelif(n==4-counter and n!=2 annd n!=0):\n\tprint(\"ccw\")\nelse:\n\tprint(\"undefined\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "34fb768e9d9de94e72785c7084f38cbe", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Python 3", "source_code": "k=0\nrt=0\ns,u,n=map(int,input().split())\nwhile True: \n def gcd(s, n):\n while n:\n s,n = n, s % n\n return s\n z = gcd(s,n)\n if z=26):\n print(\"Yes\")\nelse:\n s=set(input())\n if (len(s)=220 and y>=2 and x>=0:\n #ceil\n if x>=2: x,y=x-2,y-2\n elif x==1 and y>=12: x,y=0,y-12\n else: y-=22\n else:\n print 'Hanako'\n break\n \n if 100*x+10*y>=220 and y>=2 and x>=0:\n #hanako\n if y>=22: y=y-22\n elif y>=12: x,y=x-1,y-12\n else: x,y=x-2,y-2\n else:\n print 'Ceil'\n break\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "efbeadf473b90c45e4c377d8bd2764eb", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "\ndef GetBinary(x,n):\n b=[]\n k=0\n while(x):\n b.append(x%2)\n x=x/2\n k+=1\n while(k= 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\nprint(out)\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3caaab0d3b64ecc49f97e4f09e4091b", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "x,y=input.split()\nx=int(x)\nans=0\ny=int(y)\nwhile(y>0&&x>0):\n if y>x:\n y=y-2\n x-=1\n ans+=1\n else :\n if x==1:\n ans-=1\n x=x-2\n y=y-1\n ans+=1\nprint(ans) \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1ef75dafd320dd7fd6e33d32f64a11af", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": " def solve():\n _ = map(int, input())\n m = list(map(int, input().split()))\n answer = 0\n for i in range(len(m)):\n answer += i*4*m[i]\n return answer\n\n\nprint(solve())\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bc6d99b7c81903e214ca48bbfbf10d45", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": " a = set(range(0,10001))\n x = str(a)\n x = x.replace(\",\",\"\")\n x = x.replace(\" \",\"\")\n x = x.replace(\"{\" , \"\" )\n x = x.replace(\"}\" , \"\")\n x1 = int(input(\" \"))\n print(x[x1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eadb03ab017d6c985302bcdae46866e3", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = input().split(\"|\")\ns1 = input()\nfor i in s1\n\tif(len(s1) > len(s2)):\n\t\ts[1] += i;\n\telse:\n\t\ts[0] += i\nif(len(s[0]) == len(s[1])):\n\tprint(s[0] + \"|\" + s[1])\nelse:\n\tprint(\"Impossible\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "390f288fd6143b07e0cc22803947a65c", "src_uid": "917f173b8523ddd38925238e5d2089b9", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\n\nfor i in range(n+1:):\n st = str(i)\n if len(set(st)) == 4:\n print(i)\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1fd33e75402e9039f7dcc6193c23f125", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def woof(t,s,x):\n check = 'NO'\n\n \n n1 = x-t \n n2 = x-t-1\n if (n1 >= 0 and n1 % s == 0) or (n2 >= 0 and n2 % s == 0):\n check = 'YES'\n \n \n\n return check\n\ns1 = input()\ni = 0\n\nt,s,x = '','',''\nspaces = []\nspaces.append(s1.find(' '))\nz = s1.find(' ')\nt = s1 [0:z]\ns1 = s1 [z+1:len(s1)]\nz = s1.find(' ')\ns = s1[0:z]\ns1 = s1[z+1:len(s1)]\nx = s1[0:len(s1)]\n\n\n\nprint(woof(int(t),int(s),int(x)))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2217f69757bc0caad6cb189925320891", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 2", "source_code": "import bisect\nN = int(raw_input().strip())\nX = map(int,raw_input().strip().split())\nX = sorted(X)\nwhile X[0] != X[-1]:\n diff = X[-1] - X[-2]\n X = X[:-1]\n bisect.insort_left(X, diff)\nprint sum(X)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa982189887f1744c11d59fe6279493b", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "l=[(i*(i+1))//2 for i in range (1, 45000) *\nx=int(input()) \na=\"NO\"\nfor i in range((x//2)+1):\n if i in l and x-i in l:\n a='YES'\n break\nprint(a) \n \n \n \n \n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c73ddb7ccb6cfb24c989648365c7588", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n = input()\nn = int(n)\n\nif n == 0 or n == 3:\n print(0)\nif(n == 2 or n == 1):\n print(1)\nif(n > 3):\n print(1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba9601dcdf3d660c190cb1187271a1e8", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import time,os\na=0:b=0\nprint (sum(0 < (i ^ j) <= j <= i and (i ^ j) + j > i for i in range(1, int(input()) + 1) for j in range(1, i + 1)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dca439b55bc4fbf5bdbb197f7d9a1276", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "nimport sys\nn = int(input())\na = list(map(int,sys.stdin.readline().strip().split()))\navg = sum(a)/n\ncount = 0\n#print(avg)\nif avg >= 4.5:\n print('0')\nelse:\n a.sort()\n i = 0\n while avg < 4.5:\n a[i] = 5\n count += 1\n avg = sum(a)/n\n i += 1\n print(count)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29420e4048661a285600b5a294ca089e", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "Python 3", "source_code": "l = input()\nm = 7\nl = len(s); \nc1 = 0; \nc2 = 0; \n \nfor i in range(0, l - 1): \n \n if (s[i] == '0'): \n c2 = 0; \n \n \n c1 = c1 + 1; \n \n else : \n c1 = 0; \n c2 = c2 + 1; \n \nif (c1 == m or c2 == m): \n return True; \n \nreturn False; ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88272026e717a4e8b5c8b19a3b73feb0", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,k=map(int,raw_input().split())\nprint(''.join(x[0]for x in\nsorted(sorted(zip(input(),range(n)))[k:],key=lambda x:x[1])))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63eae72e0eae0698273c61ea3053ce09", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeff\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 14\nVisualStudioVersion = 14.0.25420.1\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{888888A0-9F3D-457C-B088-3A5042F75D52}\") = \"santa\", \"santa\\santa.pyproj\", \"{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tRelease|Any CPU = Release|Any CPU\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "98bae94fd656e761baf6ba8ca07edcf8", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,k=map(int,input().split())\na=input()\nb=[0]*123\nfor i in a:\n b[ord(i)]+=1\nif max(b)>k:\n print(\"NO\")\nelse:\n print(\"YES\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba0ff062b12297dfba1ee3f3e9203534", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nk1=str(n//2-1)\nk2=str(n-int(k1))\na1,a2=[],[]\nfor i in k1:\n a1.append(int(i))\nfor i in k2:\n a2.append(int(i))\nprint(sum(a1)+sum(a2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1bb9de86ec845d753940fc7e35a2572", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\nmax = 0\ntemp = 0\nfor i in range(0,len(k),3):\n count1+=k[i]\n if count1>max:\n max = count1\n temp = 'chest\u2019\n\n\nfor i in range(1,len(k),3):\n count2+=k[i]\n if count2>max:\n max = count2\n temp = 'biceps'\n\nfor i in range(2,len(k),3):\n count3+=k[i]\n if count3>max:\n max = count3\n temp = 'back'\n\nprint(temp)\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8dbef9646a516da99bc32db2a2d0e233", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "z = int(input())\nif z = 1: print(-1)\nelse: print(z,z)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3c40093cd63166a6db6863e9a637a31", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n=input()\nD = sum([int(d) for d in n])\nN = int(n)\na = []\nfor d in range(1,101):\n if (d>=N) continue\n num = N - d\n digits = 0\n for x in str(num): digits += int(x)\n # print(num,d,digits)\n if digits == d:\n a.append(num)\n \n \nprint(len(a))\nfor x in a:\n print(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "16d601d28bf24cc58e62902297517642", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "\n n = int(raw_input())\n if n == 3:\n print 1\n elif n == 1:\n print 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c1d6fdda6ec391bcf71bc8dc3701843", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "ins=map(int(input().split()))\nins = list(ins)\nn = ins[0]\nk = ins[1]\nins = input()\nfor i in range(0,len(ins)):\n if ins[i] == 'G':\n g = i\n if ins[i] == 'T':\n t = i\nt = True\nif (t-g) % k == 0:\n p = t-g\n if p<0:\n p *= -1\n while p != 0:\n p = p - k\n if ins[p] = '#':\n t = False\n else:\n while p != 0:\n p = p - k\n if ins[p] = '#':\n t = False\nelse:\n t = False\nif t:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e9acb2bb72ff2112bca75cb70ff86de", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())print(''.join([str(x) for x in range(555)])[int(input())])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f36010eea3750d9ac0af66bdd57d22f0", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from sys import stdin\ndef get(n,ma):\n res = [1]\n if n==1:\n return res\n while True:\n if res[-1] * n > ma:\n break\n res.append(res[-1] * n)\n return res\nx,y,l,r = map(int,stdin.readline().split())\na = get(x,r)\nb = get(y,r)\nc = set()\nfor i in a:\n for j in b:\n if i + j >=l and i + j <=r:\n c.add(i+j)\nc = list(c)\nc.sort()\nans = max(c[0]-l,r-c[-1])\npr = l\n\nfor i in c:\n ans = max(ans, i-pr-1)\n pr = i\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3a18d93033beb706a84927594fefb008", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "a=int(input())\n \nb=int(input())\n\nc=int(input())\n\nd=int(input())\n\ns=a+b+c+d\nif (s==0):\n \nprint(\"0\")\n\nelse:\n \nprint(s%2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6f26220fc4879684af715844216035a8", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "/* ****THE_POSEIDON**** */\n\n#include\n#define ll long long\n#define pb push_back\n#define\tendl\t\t'\\n'\n#define pii pair\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll int)x.size()\n#define hell 1000000007\n#define rep(i,a,b)\tfor(ll int i=a;i>TESTS;\n\twhile(TESTS--)\n\t{\n\t\tint n,m,i,j;\n\tcin>>n>>m;\n\tstd::vector> v(n,vector(m));\n\tstd::vector v1(n,0);\n\tstd::vector v2(m,0);\n\n\trep(i,0,n)\n\t{\n\trep(j,0,m)\n\t\t{\n\t\t\tcin>>v[i][j];\n\t\t\tif(v[i][j]=='S')\n\t\t\t{\n\t\t\t\tv1[i]=1;\n\t\t\t\tv2[j]=1;\n\n\t\t\t}\n\n\t\t}\n\t}\n\tint cnt=0;\n\trep(i,0,n)\n\t{\n\t\trep(j,0,m)\n\t\t{\n\t\t\t\n\t\t\tif((v[i][j]=='S') || (v1[i] && v2[j]))\n\t\t\t{\tcnt+=1;\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\tcout<<(n*m-cnt);\n\n\t}\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce290c6fa57c39520e6ff3daf12eefd5", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import numpy as np\nn,x,y=map(int,input().split())\nprint(int(np.ceil(n*y/100)-x))\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f85b9557b79a54a964ed43b54701b3c2", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\n x,y,z=map(int,input().split())\nfrom math import sqrt\na=sqrt(x*y/z)\nb=sqrt(y*z/x)\nc=sqrt(x*z/y)\nprint(int(4*(a+b+c)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "35f74dceb6afec6c93e0b9b3fe422894", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n, k = list(map(int, input().split()))\nMOD = int(1e9 + 7)\nlim = k\ntotal = list(range(1, lim + 1))\nans = 0\n\ndef dfs(lst, reach, curr):\n reach[curr] = -2\n nxt = lst[curr]\n\n if nxt == 1:\n reach[curr] = 1\n return\n\n if nxt == curr or reach[nxt] == -2:\n reach[curr] = 0\n return\n\n if reach[nxt] == -1:\n dfs(lst, reach, nxt)\n \n reach[curr] = reach[nxt]\n\ndef check(lst):\n global ans\n reach = [-1 for i in range(lim + 1)]\n\n for i in total:\n if reach[i] == -1:\n dfs(lst, reach, i)\n if not reach[i]:\n return\n\n ans += 1\nlim, \ndef answer(curr, sofar=[ 0 ]):\n if curr > lim:\n check(sofar)\n return\n for choose in total: \n answer(curr + 1, sofar + [choose])\n\nanswer(1) \ncnt = n - k\n\nfor _ in range(cnt):\n ans *= cnt\n ans %= MOD\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d56be14d9d52c315bdde29333a365bae", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "from decimal import *\ngetcontext().prec = 1000\n\nx, y, z = map(Decimal, input().split())\na = []\n\na.append((y**z * x.ln(), -1, 'x^y^z'))\na.append((z**y * x.ln(), -2, 'x^z^y'))\na.append((y *z * x.ln(), -3, '(x^y)^z'))\n\na.append((x**z * y.ln(), -5, 'y^x^z'))\na.append((z**x * y.ln(), -6, 'y^z^x'))\na.append((x *z * y.ln(), -7, '(y^x)^z'))\n\n\na.append((x**y * z.ln(), -9, 'z^x^y'))\na.append((y**x * z.ln(), -10, 'z^y^x'))\na.append((x *y * z.ln(), -11, '(z^x)^y'))\n\nprint(max(a)[2])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eaac5398c33a1cd340b4afec9dd45cb4", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\nif (k == 1):\n\tprint(n)\n\texit(0)\nlength = n.bit_length() - 1\nm = min(length, k - 1):\nans = 0\nwhile m >= 0:\n\tans += 2 ** m\n\tm -= 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "119728f0aa28e34c8ecf89cbf0924039", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=input(\uff09\nWord=n.lower()\noutput=[]\nvowel=['a','e','i','o','u','y',]\nfor char in word:\n if char not in vowel:\n output.append('.')\n output.append(char)\n\nprint(''.join(output))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3910f1292be92df68e2e31ba0d80311f", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import sys\r\nimport sys\r\n \r\n# Returns the minimum value of the\r\n# difference of the two sets.\r\ndef findMin(a, n):\r\n \r\n su = 0\r\n \r\n # Calculate sum of all elements\r\n su = sum(a)\r\n \r\n # Create an 2d list to store\r\n # results of subproblems\r\n dp = [[0 for i in range(su + 1)]\r\n for j in range(n + 1)]\r\n \r\n # Initialize first column as true.\r\n # 0 sum is possible\r\n # with all elements.\r\n for i in range(n + 1):\r\n dp[i][0] = True\r\n \r\n # Initialize top row, except dp[0][0],\r\n # as false. With 0 elements, no other\r\n # sum except 0 is possible\r\n for j in range(1, su + 1):\r\n dp[0][j] = False\r\n \r\n # Fill the partition table in\r\n # bottom up manner\r\n for i in range(1, n + 1):\r\n for j in range(1, su + 1):\r\n \r\n # If i'th element is excluded\r\n dp[i][j] = dp[i - 1][j]\r\n \r\n # If i'th element is included\r\n if a[i - 1] <= j:\r\n dp[i][j] |= dp[i - 1][j - a[i - 1]]\r\n \r\n # Initialize difference\r\n # of two sums.\r\n diff = sys.maxsize\r\n \r\n # Find the largest j such that dp[n][j]\r\n # is true where j loops from sum/2 t0 0\r\n for j in range(su // 2, -1, -1):\r\n if dp[n][j] == True:\r\n diff = su - (2 * j)\r\n break\r\n \r\n return diff\r\n \r\nn=int(input())\r\na = list(map(int,input().split()))\r\ndict={}\r\ndict2={}\r\nfor i in range(n):\r\n if (a[i] not in dict):\r\n dict[a[i]]=[i]\r\n dict2[a[i]]=[i]\r\n else:\r\n dict[a[i]].append(i)\r\n dict2[a[i]].append(i)\r\ncou=0\r\nc=a[0]\r\nfor i in range(1,n):\r\n if(a[i]==c):\r\n cou+=1\r\nif(cou==n):\r\n print(1)\r\n print(1)\r\nelse:\r\n if(findMin(a,n)>0):\r\n print(0)\r\n else:\r\n tog=0\r\n for i in range(n):\r\n if(a[i]%2!=0):\r\n print(1)\r\n print(i+1)\r\n tog=1\r\n break\r\n if(tog==0):\r\n a.sort()\r\n b=a[::-1]\r\n temp=[]\r\n while(findMin(a,len(a))==0):\r\n num=a[-1]\r\n a.pop(-1)\r\n temp.append(dict[num][-1])\r\n dict[num].pop(-1)\r\n temp2=[]\r\n while(findMin(b,len(b))==0):\r\n num=b[-1]\r\n b.pop(-1)\r\n temp2.append(dict2[num][-1])\r\n dict2[num].pop(-1)\r\n if(len(temp2) n else 0\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "32fa0435868100f284dadd0bd38a0034", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, d = map(int, input().split())\na = list(map(int, input().split()))\nans = sum(a)\nm = int(input())\nans -= (m-n)*d\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ebe9ee57db980f7d306237efb16f7a3", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "data = input()\r\nrow, col = data.split(\" \")\r\n\r\nrow = int(row)\r\ncol = int(col)\r\n\r\nif col == 1:\r\n return row-1\r\n\r\nreturn (col-1) * row", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b48574c5aa21fdfd4dd571b23bc130c", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#include \nusing namespace std;\n\n\nint main() {\n\n int n , temp;\n cin >> n;\n\n int arr[n+1];\n for (int i=0 ; i> arr[i];\n temp = arr[0] - arr[1];\n for (int i=1 ; i=2:\n p=ord(ins[i])+1\n print ins[0:i]+chr(p)+ins[i+1:]\n a=1\n break\nif a!=1:\n print:'No such string'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0aec8508f1f350721d6baef66ab3a9be", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Python 3", "source_code": " k = [*map(int, input().split())]\n z=int(k[0]/2)\n if k[1]<=z:\n if k[1]!=0:\n print(k[1])\n else:\n print(1)\n else:\n print(k[0]-k[1])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fe73f6e0e8aedb901f1cd8c3ad7f02b1", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "Python 3", "source_code": "$><<\"%0#{gets=~/$/}b\"%($_.to_i(2)^gets.to_i(2))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03dbae7b1880edf664ca677ff3e76320", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n == 13 ot n == 24:\n print \"NO\"\nelse:\n print \"YES\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58e0c45523839d823221b3c8dce0d248", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "Python 3", "source_code": "s='rosol'\ncounter=0\nfor i in s :\n \n print(len(s)-counter>\n counter+=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b086682511ca15aed6dcf65cdb501abe", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "ans=no=0\ndef calc(n):\n global ans,no \n tt,a=n,0\n while n:\n t=int(n**(1/3)+0.0000000000001)\n n-=t*t*t\n a+=1\n if a> ans: ans=a; no=tt\n \nn=int(input())\nfor i in range(n,max(n-1000000,0),-1): calc(i)\nprint(ans,no) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ee97661afa97fc7880262559ab30f2d", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "a = int(intut())\nif(a == 1 || a == 2):\n print(0)\nelse:\n print( (a - 3)/2 + 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5665b2699e9c7d40a4252ec7dc3a3119", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "def gdc(a, b):\n if a == b:\n return a\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n return a + b\n\n\ndef lcm(a, b):\n m = a * b\n return m // gdc(a, b)\n\nmas = raw_input().split()\n\nl = int(mas[0])\nr = int(mas[1])\nx = int(mas[2])\ny = int(mas[3])\n\na = []\nb = []\nfor i in range(l, r + 1):\n a.append(i)\n b.append(i)\n\nk = 0\n\nfor i in range(len(a)):\n for j in range(len(b)):\n if gdc(a[i], b[j]) == x and lcm(a[i], b[j]) == y:\n k += 1\n\nprint(k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8601f47b9e40d3f032bbc276425318df", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\nfor _ in range(n):\n\tred = [(\"Z\", \"ZERO\", \"0\"), (\"W\", \"TWO\", \"2\"), (\"X\", \"SIX\", \"6\"), (\"G\", \"EIGHT\", \"8\"), (\"H\", \"THREE\", \"3\"), (\"S\", \"SEVEN\", \"7\"), (\"V\", \"FIVE\", \"5\"), (\"F\", \"FOUR\", \"4\"), (\"I\", \"NINE\", \"9\"), (\"N\", \"ONE\", \"1\")]\n\td = {}\n\tnumbers = \"\"\n\ts = input()\n\tfor c in s:\n\t\tif c in d:\n\t\t\td[c] += 1\n\t\telse:\n\t\t\td[c] = 1\n\twhile True:\n\t\tfound = False\n\t\tfor p in red:\n\t\t\tif p[0] in d and d[p[0]] != 0:\n\t\t\t\tfound = True\n\t\t\t\tfor c in p[1]:\n\t\t\t\t\td[c] -= 1\n\t\t\t\tnumbers += p[2]\n\t\t\t\tbreak;\n\t\tif not found:\n\t\t\tbreak\n\tprint(\"Case #\" + str(_ + 1) + \":\", \"\".join(sorted(numbers)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f55699705a69d1dbe6a7db5864974110", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "from math import *\nsInt = lambda: int(input())\nmInt = lambda: map(int, input().split())\nlInt = lambda: list(map(int, input().split()))\n\nn = sInt()\na = input()\na = list(a)\nans = []\nval = 0\ni = 0\nwhile True:\n if a[i]=='1':\n val += 1\n i += 1\n elif a[i]=='0' and a[i-1]=='1':\n ans.append(val)\n val = 0\n i += 1\n else:\n ans.append(0)\n while a[i]=='0':\n i += 1\n if i == len(a):\n if val!=0:\n ans.append(val)\n break\nprint(*ans, sep=\"\")\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c6ce170ce8a8f1ca5d7e4532d31c338f", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "class AmusingJoke:\n name1 = \"\"\n name2 = \"\"\n jumbLetters = \"\"\n\n def solve(self):\n from collections import Counter, OrderedDict\n\n map1 = Counter(self.name1)\n map2 = Counter(self.name2)\n map_jumLtr = OrderedDict(Counter(self.jumbLetters))\n if (OrderedDict(map1+map2)==map_jumLtr):\n return \"YES\"\n else:\n return \"NO\"\n\n\nif __name__ == \"__main__\":\n a = AmusingJoke()\n a.name1 = raw_input()\n a.name2 = raw_input()\n a.jumbLetters = raw_input()\n print a.solve()\n\u00a9 2020 GitHub, Inc.", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ceec29ffe899dc9d75fffc43c3aaf8e1", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "x=int(input())\nif x>36:\n print(-1)\nelse if x%2==0:\n print('8'*(x//2))\nelse:\n print('8'*(x//2)+'6')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf3886124ffc06fa2768113056a97569", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": " import random\r\n k = 1\r\n print(\"YES\" if random.randint(k, k + 4636)% 2 else \"NO\")\r\n 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "369d403a40d00ff99590e249e2ea4629", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Python 3", "source_code": "from sys import maxsize, stdout, stdin,stderr\r\nmod = int(1e9+7)\r\nimport sys\r\ndef I(): return int(stdin.readline())\r\ndef lint(): return [int(x) for x in stdin.readline().split()]\r\ndef S(): return list(map(str,input().strip()))\r\ndef grid(r, c): return [lint() for i in range(r)]\r\nfrom collections import defaultdict, Counter, deque\r\nimport math\r\nimport heapq\r\nfrom heapq import heappop , heappush\r\nimport bisect\r\nfrom itertools import groupby\r\nfrom itertools import permutations as comb\r\ndef gcd(a,b): \r\n while b:\r\n a %= b\r\n tmp = a\r\n a = b\r\n b = tmp\r\n \r\n return a\r\n \r\ndef lcm(a,b): \r\n return a // gcd(a, b) * b\r\n \r\ndef check_prime(n):\r\n for i in range(2, int(n ** (1 / 2)) + 1):\r\n if not n % i:\r\n return False\r\n return True\r\ndef Bs(a, x):\r\n i=0\r\n j=0\r\n left = 1\r\n right = x\r\n flag=False\r\n while left0 and a[left-1]==x:\r\n return i-1, j\r\n else:\r\n return -1, -1\r\ndef nCr(n, r):\r\n \r\n return (fact(n) // (fact(r)\r\n * fact(n - r)))\r\n \r\n# Returns factorial of n\r\ndef fact(n):\r\n \r\n res = 1\r\n \r\n for i in range(2, n+1):\r\n res = res * i\r\n \r\n return res\r\ndef primefactors(n):\r\n num=0\r\n \r\n while n % 2 == 0:\r\n num+=1\r\n n = n / 2\r\n \r\n for i in range(3,int(math.sqrt(n))+1,2):\r\n \r\n \r\n while n % i== 0:\r\n num+=1\r\n n = n // i\r\n \r\n \r\n if n > 2:\r\n num+=1\r\n return num\r\n'''\r\ndef iter_ds(src):\r\n store=[src]\r\n while len(store):\r\n tmp=store.pop()\r\n if not vis[tmp]:\r\n vis[tmp]=True\r\n for j in ar[tmp]:\r\n store.append(j)\r\n'''\r\ndef ask(a):\r\n print('? {}'.format(a),flush=True)\r\n n=I()\r\n \r\n return n\r\n\r\n\r\n \r\ndef dfs(i,p):\r\n \r\n a,tmp=0,0\r\n for j in d[i]:\r\n if j!=p:\r\n a+=1\r\n tmp+=dfs(j,i)\r\n \r\n if a==0:\r\n return 0\r\n \r\n return tmp/a + 1 \r\ndef primeFactors(n):\r\n l=[]\r\n \r\n while n % 2 == 0:\r\n l.append(2)\r\n n = n // 2\r\n \r\n\r\n if n > 2:\r\n l.append(n)\r\n return l\r\n\r\nt=I()\r\nfor _ in range(t):\r\n n,m,k=lint()\r\n h,v,r=0,0,0\r\n r+=((m//2)*(n//2))\r\n if m%2!=0:\r\n v+=(n//2)\r\n if n%2!=0:\r\n h+=(m//2)\r\n #print(n,m,k)\r\n if r*2+v+h>=(m*n)//2:\r\n k-=min(k//2,r*2)*2\r\n k=max(k,0)\r\n #print(k,_)\r\n if k>0 and k>h: \r\n print('NO')\r\n else:\r\n if r*2+k+v>=(m*n)//2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n else:\r\n print('NO')\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n \r\n \r\nnd k>h: \r\n print('NO')\r\n else:\r\n if r*2+k+v>=(m*n)//2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n else:\r\n print('NO')\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n \r\n from sys import maxsize, stdout, stdin,stderr\r\nmod = int(1e9+7)\r\nimport sys\r\ndef I(): return int(stdin.readline())\r\ndef lint(): return [int(x) for x in stdin.readline().split()]\r\ndef S(): return list(map(str,input().strip()))\r\ndef grid(r, c): return [lint() for i in range(r)]\r\nfrom collections import defaultdict, Counter, deque\r\nimport math\r\nimport heapq\r\nfrom heapq import heappop , heappush\r\nimport bisect\r\nfrom itertools import groupby\r\nfrom itertools import permutations as comb\r\ndef gcd(a,b): \r\n while b:\r\n a %= b\r\n tmp = a\r\n a = b\r\n b = tmp\r\n \r\n return a\r\n \r\ndef lcm(a,b): \r\n return a // gcd(a, b) * b\r\n \r\ndef check_prime(n):\r\n for i in range(2, int(n ** (1 / 2)) + 1):\r\n if not n % i:\r\n return False\r\n return True\r\ndef Bs(a, x):\r\n i=0\r\n j=0\r\n left = 1\r\n right = x\r\n flag=False\r\n while left0 and a[left-1]==x:\r\n return i-1, j\r\n else:\r\n return -1, -1\r\ndef nCr(n, r):\r\n \r\n return (fact(n) // (fact(r)\r\n * fact(n - r)))\r\n \r\n# Returns factorial of n\r\ndef fact(n):\r\n \r\n res = 1\r\n \r\n for i in range(2, n+1):\r\n res = res * i\r\n \r\n return res\r\ndef primefactors(n):\r\n num=0\r\n \r\n while n % 2 == 0:\r\n num+=1\r\n n = n / 2\r\n \r\n for i in range(3,int(math.sqrt(n))+1,2):\r\n \r\n \r\n while n % i== 0:\r\n num+=1\r\n n = n // i\r\n \r\n \r\n if n > 2:\r\n num+=1\r\n return num\r\n'''\r\ndef iter_ds(src):\r\n store=[src]\r\n while len(store):\r\n tmp=store.pop()\r\n if not vis[tmp]:\r\n vis[tmp]=True\r\n for j in ar[tmp]:\r\n store.append(j)\r\n'''\r\ndef ask(a):\r\n print('? {}'.format(a),flush=True)\r\n n=I()\r\n \r\n return n\r\n\r\n\r\n \r\ndef dfs(i,p):\r\n \r\n a,tmp=0,0\r\n for j in d[i]:\r\n if j!=p:\r\n a+=1\r\n tmp+=dfs(j,i)\r\n \r\n if a==0:\r\n return 0\r\n \r\n return tmp/a + 1 \r\ndef primeFactors(n):\r\n l=[]\r\n \r\n while n % 2 == 0:\r\n l.append(2)\r\n n = n // 2\r\n \r\n\r\n if n > 2:\r\n l.append(n)\r\n return l\r\n\r\nt=I()\r\nfor _ in range(t):\r\n n,m,k=lint()\r\n h,v,r=0,0,0\r\n r+=((m//2)*(n//2))\r\n if m%2!=0:\r\n v+=(n//2)\r\n if n%2!=0:\r\n h+=(m//2)\r\n #print(n,m,k)\r\n if r*2+v+h>=(m*n)//2:\r\n k-=min(k//2,r*2)*2\r\n k=max(k,0)\r\n #print(k,_)\r\n if k>0 and k>h: \r\n print('NO')\r\n else:\r\n if r*2+k+v>=(m*n)//2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n else:\r\n print('NO')\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dab0cb2a60098af0e74b0f784f3d3e40", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\"\"\"\na9qnrp\nproblem 1332E\n05/04/2020\n\"\"\"\n\nMOD = 998244353\nn, m, L, R = map(int, input.readline().split())\n\nif n * m % 2 == 1:\n print(pow(L-R, n * m, MOD))\nelse:\n if L-R % 2 = 0:\n print((pow(L-R, n * m, MOD) * (n + 1) // 2) % MOD)\n else: # L-R odd\n print(((pow(L-R, n * m, MOD)+1) * (n + 1) // 2) % MOD)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8d8b1ae56481d45848ffff5484763e50", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "import random\nimport sys\nimport os\n\nn = int (input())\ns = list (map(int , input().split()))\ns = sorted (s)\nfor i in range(0 , n - 1) :\n if s[i + 2] - s[i] == 2:\n print ('YES')\n exit ()\nprint ('NO')\n\n'''\nt = int(input ())\nwhile (t > 0):\n read=lambda:map(int,input().split())\n n,m,k=read()\n ind=list(map(int,input().split()))\n ans = 0\n for d in range (0 , k):\n ind[d] = ind[d] - 1\n i = ind[d] // m\n j = ind[d] % m\n #print (i , j)\n ans = ans + (n - i) * (m - j) * (i + 1) * (j + 1)\n print(\"%.10f\" % (4 * ans / (n * m * (n + 1) * (m + 1))))\n t = t - 1\n'''", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95efd1c3b807e169c876265ce2bf9fee", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = input(); i = 1; j = 2, f = 0;\nif(n == 1):\tprint \"YES\";\nelse:\n\twhile(i <= n):\n\t\tif(i == n):\tf = 1; print \"YES\";\n\t\ti += j; j += 1; if(f == 0):\tprint \"NO\";", "lang_cluster": "Python", "compilation_error": true, "code_uid": "991c1a8794fdfff782dfe3b8b05b90ea", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split())\nif(k==1):\n print(\"Yes\")\nelif(k>100 or k>=n):\n print(\"No\")\nelse:\n for i in range(1,k+1):\n if((n+1)%i != 0):\n print(\"No\")\n return\n print(\"Yes\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "da30c542c2af65e1c66ec727805121de", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "n,k=map(int,raw_input().split());i=0\na=[]\nwhile i*i<=n:\n if n%i==0:\n a.append(i)\n if i!=n//i:\n a.append(n//i)\n i+=1\na.sort()\nprint -1 if len(a) 0:\n t2 -= 1\n t1 += 2\n if (t1 + t2) - (t1 + t2)/m == 0:\n return t1 + t2\n else:\n return -1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d88c1fc6ad88d771b1e489a7aabaec65", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import math\nfrom collections import Counter\nimport decimal\n\n# create a new context for this task\nctx = decimal.Context()\ndef isp(num):\n for i in range(2,int(math.sqrt(num))+1):\n if num%i ==0:\n return False\n return True\ndef float_to_str(f):\n \"\"\"\n Convert the given float to a string,\n without resorting to scientific notation\n \"\"\"\n d1 = ctx.create_decimal(repr(f))\n return format(d1, 'f')\ndef fac(num):\n re = []\n for i in range(2,int(math.sqrt(num))+1):\n if isp(i):\n if num%i == 0:\n re.append(i)\n num/=i\n while num%i == 0 and num!=0:\n num/=i\n re.append(i)\n if num != 1:\n re.append(int(num))\n return re\ndef count(n,f):\n logg = int(math.log(n,f))\n summ = logg*(logg+1)//2 - logg\n return n//f + summ\nn, b = map(int, input().strip().split())\nfactor = fac(b)\ns_f = set(factor)\nco = {}\nfor i in s_f:\n co[i] = count(n,i)\ncc = Counter(factor)\nmm = int(1e200)\nfor a,c in cc.items():\n #print(a,c,co)\n if a in co:\n #print (co[a],a,c)\n mm = min(mm,co[a]//c)\n else:\n mm = 0\n \nprint(float_to_str(mm))import math\nfrom collections import Counter\nimport decimal\n\n# create a new context for this task\nctx = decimal.Context()\ndef isp(num):\n for i in range(2,int(math.sqrt(num))+1):\n if num%i ==0:\n return False\n return True\ndef float_to_str(f):\n \"\"\"\n Convert the given float to a string,\n without resorting to scientific notation\n \"\"\"\n d1 = ctx.create_decimal(repr(f))\n return format(d1, 'f')\ndef fac(num):\n re = []\n for i in range(2,int(math.sqrt(num))+1):\n if isp(i):\n if num%i == 0:\n re.append(i)\n num/=i\n while num%i == 0 and num!=0:\n num/=i\n re.append(i)\n if num != 1:\n re.append(int(num))\n return re\ndef count(n,f):\n logg = int(math.log(n,f))\n summ = logg*(logg+1)//2 - logg\n return n//f + summ\nn, b = map(int, input().strip().split())\nfactor = fac(b)\ns_f = set(factor)\nco = {}\nfor i in s_f:\n co[i] = count(n,i)\ncc = Counter(factor)\nmm = int(1e200)\nfor a,c in cc.items():\n #print(a,c,co)\n if a in co:\n #print (co[a],a,c)\n mm = min(mm,co[a]//c)\n else:\n mm = 0\n \nprint(float_to_str(mm))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e10562efc014d27ae1a27dcb79f6e414", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "fact = [1]\ndef combi(a,i):\n return fact[a]/(fact[a-i]*fact[i])\ndef atLeastOne(a):\n ans = 0\n for i in xrange(1,a+1):\n temp = -1\n if i%2:\n temp = 1\n ans += temp*combi(a,i)*fact[a-i]\n return ans\nn,k = map(int, raw_input('').strip().split(' '))\nfinal = 0\nfor i in xrange(1,n+1):\n fact.append(fact[i-1]*i)\nt = n - k - 1\nfor i in xrange(t+1):\n final += combi(n,i)*(fact[n-i] - atLeastOne(n-i))\nprint fact[n]-final\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "60e76a2afa969ad1d256f3081d25b817", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nprint(max(n,m)-1,min(n,m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ae0ddbe4aa88c1c25cedcc89d3deb3c", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "c=0\n\twhile(a[c]>=10):\n\t\ta.append(int((0.90 *(a[c]))-k))\n\t\tc=c+1\n\treturn 0.10 * sum(a)\n\ndef process():\n n=int(raw_input())\n l=0\n u=n\n a=list()\n while(l<=u):\n k=int((l+u)/2)\n a.append(n-k)\n petaya=int(sum_for_k(n,k,a))\n vatsaya=n-petaya\n if vatsaya current:\n current = i^j\n\n return current\n\n\ninp = input()\nl, r = inp.split(\" \")\nprint(maximum(int(l),int(r)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3495db9171f705200e85023f29c1483b", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a=int(input())\nprint([a,max(a//10+1,(a//100)*10+a%10][a<0])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d2537daaab632691bd6d71d30db0460", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "import math\n \ndef lcm(a, b):\n return int(a * b / math.gcd(a, b))\n \nt = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tans = n-1\n for g in range(1,int(math.sqrt(n))+1):\n if (n % g == 0):\n ans = min(ans,n-g)\n if (g > 1): ans = min(ans, n-n/g)\n\tprint(n-ans,ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9368a7ed86a8ab326621e30be961829e", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\na=[0]*1**8\na[1],a[2]=2,4\nfor i in range(3,max(n,m)+1):\n a[i]=a[i-1]+a[i-2]\nprint(a[n]+a[m]-2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e31c3674f17c843741ba8138e7569ac7", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\nans = (n * m) // 5\nif (n * m) % 5 == 4 || (n * m) % 5 == 1:\n ans += 1\nprint(ans)\n#try 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a34cfa067a8d8ba39bcdbf21bbbb7314", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,m = map(int,input().split())\ncount=0\nflag=0\nif m%n!=0:\n\tprint(-1)\nelse:\n\tif(m==n):\n\t print(0)\n\t\texit()\n\tm=m//n\n\tcount+=1\n\twhile(m!=1):\n\t\tif(m%2==0):\n\t\t\tm=m//2\n\t\t\tcount+=1\n\t\telif(m%3==0):\n\t\t\tm=m//3\n\t\t\tcount+=1\n\t\telif(m!=1):\t\n\t\t\tflag=1\n\t\t\tbreak;\n\tif(flag==1):\n\t\tprint(-1)\n\telse:\n\t\tprint(count-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9fe56e638dcf700d0ea1058f62c94326", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b,c,d=map(int,input().split())\ne=a+b+c+d\nif(e%2==0):\n print(\"YES\")\nelse:\n if((a+b)==(c+d) or (a+c)==(b+d)):\n print(\"YES)\n elif((a+c)==(b+d)):\n print(\"YES\")\n elif(a+b+c==d or b+c+d==a):\n print(\"YES\")\n elif(a+b+d==c or a+c+d==b)\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "156e8137a3179844e87b9715ad2f5585", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = int(input())\nres = a * 6 + ( a - 1)\nprint res\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ce7a4e2b82e6224a76233e25357d991", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "w = int(input())\nif(w%2==0):\n print(1):\nelse:\n print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "67190b39c983c694f157b0dbd370b8de", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b = map(int,input().split())\ndays = list(map(int,input().split()))\nc = max([days[i]-days[i+1] for i in range(len(days)-1)])-b)\nprint(c) if c > 0 else print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d86b3511c413d1598c404b948996309", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nn, b = map(int, raw_input().split())\nx = map(int, raw_input().split())\nX = 0\nfor xi in x:\n\tX = X * b + xi\nn, b = map(int, raw_input().split())\ny = map(int, raw_input().split())\nY = 0\nfor yi in y:\n\tY = Y * b + yi:\nif X == Y:\n\tprint \"=\"\nelif X > Y:\n\tprint \">\"\nelse:\n\tprint \"<\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b73234dee0a50c9a074a75ac898bfe6b", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": " d = {\n 'm': 10,\n 's': 30,\n 'p': 60\n }\n \n a, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))\n \n if (a == b and b == c) or (a == b - 1 and b == c - 1):\n print(0)\n exit()\n if a == b - 1 or b == c - 1 or a == b or b == c or a == c - 2 or a == b - 2 or b == c - 2:\n print(1)\n exit()\n print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a5b53a2754b51f26efd327b64a46aa2", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "is = input()\nn = len(s)\nfor i in 'RBYG':\n pos = s.find(i) % 4\n print(\"%d \" % (n // 4 + (n % 4 > pos) - s.count(i)), end=\"\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e8fd462aab1b8ba41477c4d72d61672f", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a = list(input())\nb = int(input())\na.sort()\na = a[::-1]\nprefix = \"\"\nwhile(len(a) > 0):\n\tfor i in range(len(a)):\n\t\tnum = prefix+a[i]+\"\".join(sorted(a[:i]+a[i+1:]))\n\t\tif(int(num)<=b:\n\t\t\tprefix+=a[i]\n\t\t\ta=a[:i]+a[i+1:]\n\t\t\tbreak\nprint(prefix)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "271ab1dcc40919bf4ffc77c7fcb614f8", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n unsigned long long n,m;\n cin >> n >> m;\n while(true)\n {\n n++;\n if (n%m == 0)\n {\n cout << n;\n break;\n }\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e635b921864efc948e7ad30cd6d5545a", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x=int(input()\nfor i in range(x):\n print(int(input())//x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "41cc02452d9e965fa38bdc03dbcfacfc", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "x,\u2009t,\u2009a,\u2009b,\u2009da,\u2009db = map(int,raw_input().split(\" \"))\np=0\nfor x in range(0,t):\n a-=da*x\n for y in range(0,t):\n b-=db*y\n if a+b==x:\n p=1\n break\nif p==1:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1e1be1e0dc29917dc18964f0ef8e4b1", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "num=\"\"\ninput(num)\nif num>9223372036854775807:\n print(\"BigInteger\")\nelif num>2147483647:\n print(\"long\")\nelif num>32767:\n print(\"int\")\nelif:\n print(\"short\")\nelse:\n print(\"byte\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d13104622aa52112e66ba7b634a43948", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "l = int(input())\nif(l%2==0):\n\tprint l/2\nelse:\n\tprint -(l+1)/2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "15d0a72adbd07c2538b757e2f885bf64", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def binarypower(a,b):\r\n ans=1\r\n while(b>0):\r\n if b%2:\r\n ans=(ans*a)%1000000007\r\n a=(a*a)%1000000007\r\n b>>1\r\n return ans\r\n \r\n \r\n\r\nfor i in range(int(input()):\r\n n,k=map(int,input().split())\r\n print(binarypower(n,k))\r\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "de72f029050546da5425f7595b0ed460", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "print(len(bin(int(input())))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1bf9bfbea0860fb14c83666dfb9b0d11", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "PyPy 3-64", "source_code": "// D.cpp : This file contains the 'main' function. Program execution begins and ends there.\r\n//\r\n\r\n#include \r\n#include \r\n#include \r\n\r\nint main()\r\n{\r\n int n, x;\r\n std::cin >> n >> x;\r\n\r\n unsigned long long oklow = 1, okmax;\r\n for (int i = 0; i < n - 1; ++i)\r\n {\r\n oklow *= 10;\r\n }\r\n\r\n okmax = oklow * 10 - 1;\r\n\r\n if (x == 1)\r\n {\r\n std::cout << \"-1\\n\";\r\n }\r\n else\r\n {\r\n std::deque> Q;\r\n Q.push_back(std::make_pair(x, 0));\r\n\r\n std::unordered_set V;\r\n\r\n auto e = std::make_pair((unsigned long long)x, 0);\r\n while (!Q.empty())\r\n {\r\n e = Q.front();\r\n Q.pop_front();\r\n\r\n if (oklow <= e.first && e.first <= okmax)\r\n break;\r\n\r\n V.insert(e.first);\r\n\r\n int mask = 0;\r\n auto v = e.first;\r\n while (v != 0)\r\n {\r\n auto m = v % 10;\r\n if ((m > 1) && ((mask & (1 << m)) == 0))\r\n {\r\n if (V.find(e.first * m) == V.end())\r\n {\r\n Q.push_back({ e.first * m, e.second + 1 });\r\n }\r\n }\r\n\r\n mask |= (1 << m);\r\n v /= 10;\r\n }\r\n }\r\n\r\n if (oklow <= e.first && e.first <= okmax)\r\n std::cout << e.second << \"\\n\";\r\n else\r\n std::cout << \"-1\\n\";\r\n }\r\n}\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30633fedde78fe9ed2e7968de08daa83", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import numpy as np\n \n#arr = input()\n#l = list(map(int,arr.split(' ')))\n\nstr_arr = raw_input().split(' ')\narr = [int(num) for num in str_arr]\n\nn=arr[0]\nk=arr[1]\n\n#arr = input()\n#l = list(map(int,arr.split(' ')))\n\nstr_arr = raw_input().split(' ')\narr = [int(num) for num in str_arr]\nnp_l = np.array(arr)\n\ntotal = sum(np_l)\ncnt = 0\nfor i in range(k):\n sub = abs(total-sum(np_l[i::k]))\n cnt = max(sub,cnt)\n #print(i,sub,cnt)\n\nprint(cnt)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "457f121135e7432dbda88a5f44cc30a6", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a, b, c = map(int, input().split(' '))\nl = 0\nr = 1000000\nres = 0\nwhile l < r - 1:\n\tres = (l + r) // 2\n\tif res * b + b * c >= a * c:\n\t\tr = res\n\telse:\n\t\tl = res\nres = l\nwhile res * b + b * c < a * c:\n\tres += 1\n\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9af59785a5a6d7f5c9a782883a6774e3", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include\n\n#define pb push_back\n#define all(c) (c).begin(), (c).end()\n#define sz(c) int((c).size())\nusing namespace std;\n\nvector c={'R','O','Y','G','B','I','V'};\nvector s={0,0,0,1,1,1,1};\nvector > cmb;\n\nint main(){\n int n; scanf(\"%d\", &n);\n int k=n/4+1;\n int cnt=0;\n do{\n cmb.pb(s); \n cnt++;\n }while(next_permutation(all(s)) && cnt> s\r\n for a in [2, 325, 9375, 28178, 450775]:\r\n p = pow(a, d, n)\r\n if p == 1 or p == n - 1 or a % n == 0:\r\n continue\r\n for _ in range(s):\r\n prev = p\r\n p = (p * p) % n\r\n if p == 1:\r\n return gcd(prev - 1, n)\r\n if p == n - 1:\r\n break\r\n else:\r\n for i in range(2, n):\r\n x, y = i, (i * i + 1) % n\r\n f = gcd(abs(x - y), n)\r\n while f == 1:\r\n x, y = (x * x + 1) % n, (y * y + 1) % n\r\n y = (y * y + 1) % n\r\n f = gcd(abs(x - y), n)\r\n if f != n:\r\n return f\r\n return n\r\n\r\n\r\n@memodict\r\ndef prime_factors(n):\r\n \"\"\"returns a Counter of the prime factorization of n\"\"\"\r\n if n <= 1:\r\n return Counter()\r\n f = pollard_rho(n)\r\n return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)\r\n\r\n\r\ndef distinct_factors(n):\r\n \"\"\"returns a list of all distinct factors of n\"\"\"\r\n factors = [1]\r\n for p, exp in prime_factors(n).items():\r\n factors += [p**i * factor for factor in factors for i in range(1, exp + 1)]\r\n return factors\r\n\r\n\r\ndef all_factors(n):\r\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\r\n small, large = [], []\r\n for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):\r\n if not n % i:\r\n small.append(i)\r\n large.append(n // i)\r\n if small[-1] == large[-1]:\r\n large.pop()\r\n large.reverse()\r\n small.extend(large)\r\n return small\r\n\r\n\r\ndef process(n, m):\r\n answer = 1\r\n checking = [0 for i in range(20)]\r\n L = [0 for i in range(19*m+20)]\r\n for g in range(1, 20):\r\n S = 0\r\n for i in range(1, m+1):\r\n if L[g*i]==0:\r\n S+=1\r\n L[g*i] = 1\r\n checking[g] = S\r\n for i in range(2, n+1):\r\n f = prime_factors(i)\r\n g = None\r\n for p in f:\r\n k = f[p]\r\n if g is None:\r\n g = k\r\n else:\r\n g = gcd(g, k)\r\n if g is None:\r\n g = 1\r\n answer+=(checking[g])\r\n return answer, checking\r\n\r\nn, m = [int(x) for x in input().split()]\r\nprint(process(n, m))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "496fdf9d732c0006d4f90af1890cc82d", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "#include \n#include \nusing namespace std;\nstring code;\nint main()\n{\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n #endif // OnLINE_JUDGE\n cin >> code;\n string x;\n map dic;\n for (int i=0 ; i<10 ; i++)\n {\n cin >> x;\n for (int j=0; j<=10 ; j++)\n dic[x] = (char)(i + '0');\n }\n string ans = \"\";\n for (int i=0 ; i<=8 ; i++)\n {\n string c = code.substr(i*10, 10);\n ans += dic[c];\n }\n cout << ans << endl;\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c37500e1003639d643c4a7693106cd39", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "f = open('input.txt', 'r')\nf1=f.read()\nx,y,z,t1,t2,t3 = map(int,f1.split())\nf.close()\nprint(x)\ns='NO'\nif abs(z-x)*t2+abs(y-x)*t2+3*t3<=abs(y-x)*t1 :\n s='YES'\ng = open('output.txt', 'w')\ng.write(str(s))\ng.close()\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9944b1253132ea10a6d71cbad0b0227c", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Python 3", "source_code": "first = input()\nsecond = input()\ni = 1\ns = \"\"\nwhile first[i]>second[0] :\n s += first[i]\n i++\nprint(s+second[0])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f69a1cfd76799d0f4f12681ee19743ac", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def scm(x1, y1, x2, y2, x3, y3):\n return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)\ndef scma(a):\n return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])\npair = [1, -2, 1]\nf = False\np = [int(i) for i in input().split()]\nif scma(p) == 0:\n print('RIGHT')\nelse:\n for i n range(6):\n for j in pair:\n p[i] += j\n if scma(p) == 0:\n f = True \nif f:\n print('ALMOST')\nelse:\n print('NEITHER')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "20ba38f1f2f685e1c71ef877399c14e7", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\nx=list(map(int,input().split()))\na=x[0]\nf=[]*n\nfor i in range(len(x)):\n f[x[i]-1}]=x[i]\nfor i in f:\n if a\n#include \n#include \n#include \n\nusing namespace std;\n\n\n\nint main()\n{\n int n,j;\n string s,mop;\n cin >> n >> s;\n mop=s;\n for(int i=0;i (downvotes+ uncertain):\n return \"+\"\nelif downvotes >(upvotes+ uncertain):\n return \"-\"\nelif (uncertain == 0) and (upvotes == downvotes):\n return \"0\"\nelse:\n return \"?\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab822b5f9295afe18c1b19f638b8f3d2", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nwhile(True):\nn = int(sys.stdin.readline())\ngx, gy = tuple(map(int,sys.stdin.readline().split()))\n\nwi, wj, bi, bj = 1, 1, n, n\n\nwhile(True):\n if (wi, wj) == (gx, gy):\n print(\"White\")\n break\n if (bi, bj) == (gx, gy):\n print(\"Black\")\n break\n \n \n if wi < gx:\n wi+=1\n \n if wj < gy:\n wj+=1\n# print(wi, wj)\n if (wi, wj) == (gx, gy):\n print(\"White\")\n break\n \n if bi > gx:\n bi-=1\n \n if bj > gy:\n bj-=1\n# print(bi, bj)\n if (bi, bj) == (gx, gy):\n print(\"Black\")\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "87dc329541be48c4cfc655af3ea6dcc7", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Python 3", "source_code": "F=input()\nM=input()\nS=input()\n\nBeater = {\"paper\":\"rock\",\"rock\":\"scissors\",\"scissors\",\"rock\"}\n\nif(M==S and F==Beater[M]):\n print(\"F\")\nelif(F==S and M==Beater[F]):\n print(\"M\")\nelif(F==M and S==Beater[F]):\n print(\"S\")\nelse:\n print(\"?\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c9d1c6f63c4a2a47a179d47442e63f39", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m,k = map(int,input().split())\n\nsteps = dict()\nfor x in range(n):\n steps[x] = (x+1,1)\n\n\ncurrent = n*m - 1\nif k < n:\n print (k+1,1)\nelse:\n remaining = k - n\n row_from_down = remaining // 2\n\n row = n - row_from_down\n # 11 10\n if row%2:\n col = remaining % (m-1)\n col = m - col\n\n else:\n col = remaining % (m-1)\n col += 2\n print (row, col)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11f2bc49d95c040f9556ec1e08027ae0", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = input().split()\na = int(n[0])\nb = int(n[1])\n\nm = input().split()\nc = int(m[0])\nd = int(m[1])\n\nfor i in range(100):\n for j in range(100):\n if(a*i+b=c*j+d):\n print (b+a*i)\n\nprint (\"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a67f77f753a52ae3788be95e72213bb6", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#include \n#include \n\nint main(){\n\n const int64_t D = (2 * 2 * 2) * (3 * 3) * 5 * 7; \n int64_t n; std::cin >> n;\n std::cout << (n / D) << std::endl;\n\n return 0;\n}\n// 1537623927916\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0dc24a4a1cf1869c62c1d642897a572d", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, z1, k1 = map(int, input().split())\n\nz1 -= 1\n\nk1 -= 1\n\ns = input()\n\nif (s == 'to head'):\n\n napr = -1\n\nelse:\n\n napr = 1\n\ns = input()\n\nfor i in range(len(s)):\n\n if (k1 == z1):\n\n print('Controller', i)\n\n exit(0)\n\n if (s[i] == '0'):\n\n if (k1 > z1 and z1 != 0):\n\n z1 -= 1\n\n elif (k1 < z1 and z1 != n - 1):\n\n z1 += 1\n\n k1 += napr\n\n if (k1 == 0 or k1 == n - 1):\n\n napr = -napr\n\n else:\n\n k1 += napr\n\n if (k1 == 0 or k1 == n - 1):\n\n napr = -napr\n\n if (k1 == 0):\n\n z1 = n - 1\n\n elif (k1 == n - 1):\n\n z1 = 0\n\n elif (napr == 1 and k1 != 0):\n\n z1 = 0\n\n else:\n\n z1 = n - 1\n\n #print(z1 + 1, k1 + 1)\n\n if (k1 == z1):\n\n print('Controller', i + 1)\n\n exit(0)\n\nprint('Stowaway')\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d304ea9d9c06138b8339eb56f7d3bbf6", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "t=int(input())\r\nfor _ in range(t):\r\n k=int(input())\r\n w=100-k\r\n for i in range(1,min(w,k)):\r\n if w%i==0 and k%i==0:\r\n w%=i\t\r\n\t k%=i\r\n print(w+k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "999fff463cb0d7feb797289faf267df3", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\na,b=map(int,input().split())\nl=list(map(int,input().split()))\nif sum(l)+10*(a-1)>b:\n print(\"-1\")\nelse:\n print(b-sum(l))//5)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a2c447800a9867094c653e015e4fcde", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list([int(s) for s in input().split()])\nm = []\nfor i in range(1,n):\n for j in range(i,n+1):\n print(i,j)\n b = a[:]\n a_new = b[i:j]\n for index,s in enumerate(a_new):\n if s == 1:\n a_new[index] = 0 \n elif s == 0:\n a_new[index] = 1\n b[i:j] = a_new\n m.append(b)\notvet = max(s.count(1) for s in m)\nprint(otvet)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24e332523162518a0cb828b68cb81923", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "t=int(input())\ndef pp(n,k,d,seasons):\n ress=k+1\n for i in range (n-d+1):\n pay=[]\n for l in seasons[i: i+d]:\n if l not in pay:\n pay.append(l)\n ress =min(ress,len(pay))\n print(ress)\nfor j in range(t):\n n,k,d=map(int,input().split())\n seasons=input().split()\n pp(n,", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52ce18863181765124e293d01a1ba528", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from math import log\n\nw,m,k = map(int,input().split())\nd = 0\nwhile w > 0:\n\tz = int(log(m,10)) + 1\n\tzlom = 10**z\t\n\tc = (zlom-m)*z*k\n\tif (c > w):\n\t\tx = w//(z*k)\n\t\td+=x\n\t\tbreak\n\tw-=c\n\td+=(zlom-m)\n\tm = zlom\nprint(d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07d62ae10b6ade0e2977b1d1bdd61187", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\na=input()\na=list(map(int,a.split(\" \")))\nx=[]\nm=-1\nif n==1:print(0)\nelse:\n for i in range (0,n-1):\n if a[i]==a[i+1]-1:\n m+=1\n else :\n x.append(m)\n m=-1\n if m>-1:\n x.append(m)\n\n if a[0]==1:\n x[0]=x[0]+1\n if a[n-1]==1000:\n x[-1]+=1\n m=x[0]\n\n for i in range(1,len(x)):\n if mtime):\n break\ncount+=1\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c7ba39cdfb6319a1fe0437a45cac81e", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\ni = 1\nd = {}\nd[s] = 1\nwhile (i<=len(s) + 1):\n s = s[len(s) - 1] + s[:-1]\n #print(s)yz\n d[s] = 1\n i+=1\n\nprint(len(d))aaa\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "00ee5094c1ed85e19ef37de3078d8c7a", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Python 2", "source_code": "s = raw_input()\na = dict()\na['>'] = 1000\na['<'] = 1001\na['+'] = 1010\na['-'] = 1011\na['.'] = 1100\na[','] = 1101\na['['] = 1110\na[']'] = 1111\nprint(int(''.join(map(str(a[x]), s), 2) % (10 ** 6 + 3))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40d3cd82cbb151fc7e8884ec7962f42b", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nif(n%2==0):\n\ta,b=n//2,n//2\nelse:\n\ta,b=n//2,n//2+1\nfor i in range(10):\n\tif(a==1):\n\t\tprint(a,b)\n\t\tbreak\n\tl=[i for i in range(1,a+1) sif a%i==0]\n\ts=[i for i in range(1,b+1) if b%i==0]\n\n\tif(len(set(l+s))==len(l)+len(s)-1):\n\t\tprint(a,b)\n\t\tbreak\n\telse:\n\t\ta,b=a-1,b+1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "54221a8590bf3ef48c0064eaf56f8fd3", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\nnum=0\ncolor=s[0]\nfor i in range(1,n):\n if s[i]=color:\n num+=1\n else:\n color=stone[i]\nprint(num)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ca5010054cd2bb5d83ebffbacdc2356", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\npos = 0\nflag = True\nfor x in range(n):\n t, d = input().split()\n t = int(t)\n if t < 0 or t > 20000:\n flag = False\n break\n elif if d[0] == \"N\":\n pos -= t\n elif d[0] == \"S\":\n pos += t\n elif pos == 0 and d[0] != \"S\":\n flag = False\n break\n elif pos == 20000 and d[0] != \"N\":\n flag = False\n break\nif pos == 0 and flag == True:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "37c6d21e9a5e09d1fc31be95189a8a19", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def MinDistance(x1, x2, x3):\n\td1 = x1 + x2\n\td2 = 2*d1\n\tif d2 > d1 + x3: \n\t\treturn d1 + x3\n\treturn d2\n\nprint MinDistance(x1, x2, x3)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "526d1d1f41d90b8392efc6f8ae607557", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from fractions import Fraction \nn = list(map(int,input().split()))\nn.sort()\ns=0\nfor i in range(n[1],7,1):\n\n\nprint(Fraction(s,6))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "27c6aedac208567c63a84aa99f9fd8bd", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(int(pow(n,2))+int(pow(n-1,2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9be6fa7f19cb90c66eddbe3c139eb489", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import math\nck=\"abcdefghijklmnopqrstuvwxyz\"\nn=input()\nif abs(ck.index(n[0]) < 26-abs(ck.index(n[0]):\n s=abs(ck.index(n[0])\nelse:\n s=26-abs(ck.index(n[0])\nfor i in range(1,len(n)):\n if abs(ck.index(n[i])-ck.index(n[i-1])) < 26-abs(ck.index(n[i])-ck.index(n[i-1])):\n s+=abs(ck.index(n[i])-ck.index(n[i-1]))\n else:\n s+=26-abs(ck.index(n[i])-ck.index(n[i-1]))\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c052aec2d6942fdca9f1634121b11913", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a,b = map(int,input().split())\nans = 1\nif(a == 0):\n\tif(b>=10):\n\t\tprint(0)\n\telse:\n\t\twhile(b > 0):\n\t\tb -= 1\n\t\tans *= ((b+1)%10)\n\t\tans %= 10\n\t\tprint(ans)\n\nelif(b == 0):\n\tprint(1)\nelse:\n\tif(b-a>=10):\n\t\tprint(0)\n\telse :\n\t\twhile(b != a):\n\t\t\tans *= b%10\n\t\t\tans %= 10\n\t\t\tb -= 1\n\t \tprint(ans)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "98613f6baecd4a338d981ce9024b3c4a", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n%2===0:\n print('white')\n print(1,2)\nelse:\n print(\"black\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c79fa1608a0490b43c206610cc0dd58", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n=(input())\nf=list(map(int,(n[:3])))\nl=list(map(int,(n[3:])))\n\ns=0\nsf=sum(f)\nsl=sum(l)\nif sl> sf:\n d=sl-sf\n f.sort()\n if (f[0]+d)>=10:\n if f[1]-9+d>=10:\n s=3\n else:\n s=2\n else:\n s=1\n \nelif sf> sl:\n d=sf-sl\n l.sort()\n if l[0]+d>=10:\n if l[1]-9+d>=10:\n s=3\n else:\n s=2\n else:\n s=1\n \nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "657f42676276d086f6f0720c41e1c1a0", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n=input()\nprint n - (n/2 +n/3 +n/5 +n/7 -n/6 -n/10 -n/14 -n/15 -n/21 -n/35 +n/30 +n/42 +n/70 +n/105 -n/210)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4fe243a353161d151471be6d5e081cdd", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n = int(input())\nans = 6*(4**(n-3)) + (n-3)*(9*(4**(n-4))\nprint ans*4", "lang_cluster": "Python", "compilation_error": true, "code_uid": "61d2c6110a06bde7eb50d409ba22aa1c", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n, k =list(map(int(,input().split())))\nfor i in range(k):\n\tif n%10==0:\n\t\tn//=10\n\telse:\n\t\tn-=1\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d927bb6aa4f0fac6e938475b93d3949e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\nthe_list = sys.stdin.readlines()\nthe_list[1].rstrip()\n//slist = [int(x) for x in the_list[1].split()]\n//slist.sort()\n//for x in slist:\n //print(x + ' ')\nprint(\"yeppers\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bfb3f94c5db0c081d612f3c575a0ef44", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "Python 3", "source_code": "# CF BAYAN WARMUP\n# A\n\nk = int(input())\n\nif k == 0:\nprint(\"+------------------------+\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|#.......................|\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 1:\nprint(\"+------------------------+\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|#.......................|\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 2:\nprint(\"+------------------------+\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|#.......................|\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 3:\nprint(\"+------------------------+\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 4:\nprint(\"+------------------------+\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 5:\nprint(\"+------------------------+\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 6:\nprint(\"+------------------------+\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 7:\nprint(\"+------------------------+\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 8:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 9:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.#.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 10:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 11:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 12:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.#.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 13:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 14:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 15:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.#.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 16:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 17:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 18:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.#.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 19:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 20:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 21:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.#.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 22:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 23:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 24:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 24:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.#.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 25:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 26:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 27:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.#.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 28:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 29:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 30:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.#.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 31:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|)\")\nprint(\"+------------------------+\")\n\n\nif k == 32:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|)\")\nprint(\"+------------------------+\")\n\n\nif k == 33:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.#.|.|)\")\nprint(\"+------------------------+\")\n\nif k == 34:\nprint(\"+------------------------+\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|D|)\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|.|\")\nprint(\"|O.......................|\")\nprint(\"|O.O.O.O.O.O.O.O.O.O.O.|.|)\")\nprint(\"+------------------------+\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a321dcd659faba283719dd00bdbbe9da", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "M = 10**9+7\nx, k = map(int, raw_input().split())\nx %= M\nif k == 0:\n\tprint (2*x)%M\nif x == 0:\n\tprint 0\nelse:\n\tprint (4*x-2)%M*pow(2, k-1, M)+1%M", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e808af4624085f592b57dfc4e3377840", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "input_arr = raw_input()\nitems = \"abcdefghijklmnopqrstuvwxyz\"\nans = []\nfor i in input_arr();\n if len(items) > 0 and items[0] < i:\n ans.append(i)\n else:\n ans.append(items[0])\n items = items[1:]\nif len(items) == 0:\n print ''.join(ans)\nelse:\n print -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7802926043fd5a0c8b7c857eb7cd818f", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "l=list(map(int,input().split()))\nc=list(filter(lambda x:l.count(x)>1,l))\nc=list(set(c))\nf=[]\nif c!=[]:\n d=max(c)\n if l.count(d)>2:\n f=f+[sum(l)-3*d)]\n elif l.count(d)==2:\n f=f+[sum(l)-2*d)]\n r=[l.count(i) for i in c]\n e=d.index(max(r))\n if max(r)>2:\n f=f+[sum(l)-3*c[e])]\n elif max(r)==2:\n f=f+[sum(l)-2*c[e])]\nelse:\n print(sum(l))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a651fb74bc787ecbcb495ab9eb238543", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from string import*\nn = int(input())\n#n,m = map(int,input().split())\na = list(map(int,input().split()))\ns = list(ascii_lowercase)[:n]\nres = []\n'''x = set()\nfor i in range(n):\n if a[i] in x:\n f = a[i]+1\n res.append(f*s[i])\n x.add(f)\n else:\n res.append(a[i]*s[i])\n x.add(a[i])\nprint(len(''.join(map(str,res))))'''\n\na.sort(reverse=True)\nfor i in range(n):\n if a.count(a[i])>1:\n a[i]-=(a.count(a[i])-1)\n\nfor i in range(n):\n res.append(a[i]*s[i])\nprint(len(''.join(map(str,res))))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77a6754a7f18e648a60c25ab28ddb66d", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n h,m=map(int,raw_input().split(':'))\nif h>=12: h-=12\nprint (h*60+m)/2.0, 6*m\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11be9f50e4e4e3f86fc6f4a727752cf1", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\nn, m = list(map(int, \"input().split(\" \")))\n\n\ndef count_friends(num):\n return int(((num-1)/2)*(num))\n\n\n\n#Max\nmaxFriends = count_friends(n - (m-1))\n\n#Min\nminFriends = 0\nif n % m == 0:\n min = int(n/m)\n minFriends += count_friends(min)*m\nelse:\n roundNum = int(n/m)\n ostatok = n % m\n minFriends += count_friends(roundNum) * (m - ostatok)\n minFriends += count_friends(roundNum + 1) * ostatok\n\nprint(str(maxFriends) + \" \" + str(minFriends))\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1df220c8e6580900abcfcb484740aeb9", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import math\na, b, c, d = map(int, input().split())\n\nif c/d == a/b:\n print(0, '/', 1, sep = '')\nelif c/d < a/b:\n print((d*a -b*c)//math.gcd(d*a -b*c, d*a), '/', d*a//math.gcd(d*a -b*c, d*a), sep = '')\nelse:\n print(b*c - d*a//math.gcd(b*c - d*a, b*c), '/', b*c//math.gcd(b*c - d*a, b*c, sep = '')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c8d783aa24b60d3a777f9937e6e521a", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\ndef gcd(a, b):\n if a == 0 : return b\n if b == 0: return a\n return gcd(b, a % b)\n\n\nN, K = map(int, input().split())\nA, B = map(int, input().split())\nS = [A, K - A]\nE = []\nfor i in range(N):\n if i * K + B >= 0:\n E += [i * K + B]\n if i * K - B >= 0:\n E += [i * K - B]\nl = set()\n\nfor e in E:\n l.add(abs(e - S[0]))\n l.add(abs(e - S[1]))\n\nmi, ma = None, None\n\nf = N * K\n#print(l)\nfor i in l:\n rounds = f // gcd(i, f) \n if mi == None:\n mi = rounds\n ma = rounds\n else:\n mi = min(mi, rounds)\n ma = max(ma, rounds)\nprint(mi, end=' ')\nprint(ma)\n\n'''\n2 3\n1 1\noutputCopy\n1 6\ninputCopy\n3 2\n0 0\noutputCopy\n1 3\ninputCopy\n1 10\n5 3\noutputCopy\n5 5\n'''", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a17f68b5c11e586807e940809d0582c", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = (((n-1)*n*(2*n-1)) // 6) + ((n*(n-1)) // 2) - 2)\nprint(m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f08e73f984cb41bbbb816d915c55b4e4", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nprint(3*pow(3,n-1,m)-1)%m", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b34598694d180b947c4aa3908d4e6ffe", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "r,g,b = [int(rgb) for rgb in raw_input().split(\" \")]\nr = 30+3*(((r+1)/2)-1)\ng = 31+3*(((g+1)/2)-1)\nb = 32+3*(((b+1)/2)-1)\nans = max(r,max(g,b))\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "073d89864d3484a49677a17b4f9136a6", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a1 = int(input())\na2 = int(input())\nk1 = int(input())\nk2 = int(input())\nn = int(input())\nk = min(k1,k2)\na = a1+a2\nif k == k1:\n if a1 >= n//k1:\n MAX = n//k1\n else:\n MAX = a1 + (n-k1*a1)//k2\n if n <= (a2*k2) - a2:\n MIN = 0\n elif n <= a2*k2:\n MIN = n - ((a2*k2) - a2)\n elif n <= (a2*k2) + ((a1*k1) - a1):\n MIN = a2\n elif n >= a1*k1 + a2*k2:\n n = a\n else:\n MIN = a2 + ((n-(a2*k2)) - ((a1*k1) - a1))\nelse:\n if a2 >= n//k2:\n MAX = n//k2\n else:\n MAX = a2 + (n-k2*a2)//k1\n if n <= a1*k1 - a1:\n MIN = 0\n elif n <= a1*k1:\n MIN = n - (a1*k1 - a1)\n elif n <= a1*k1 + (a2*k2 - a2):\n MIN = a1\n elif n <= (a1 * k1) + ((a2 * k2) - a2):\n MIN = a1\n else:\n MIN = a1 + ((n-a1*k1) - ((a2*k2) - a2))\nif MAX > a:\n MAX = a\n if MIN < 0:\n MIN = 0\nprint(MIN,MAX)\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2cae76f5fecc6c8e941d21b1b7e4d1a4", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nelif b/a<1:\n print(b)\nelse:\n print(b%2**a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "08aac086b7b4b4e8dc6cfcaf453836f5", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a, b = input().split()\nprint(int(a) + int(reversed(b)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2efc76599d21be03772274f815bc4787", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\npingnian = [31,28,31,30,31,30,31,31,30,31,30,31]\nrunnian = [31,29,31,30,31,30,31,31,30,31,30,31]\nsequence = pingnian + pingnian + runnian + runnian + pingnian\n\nn = input()\nmonths = list(map(int,input().split()))\nleft = 0, right = n\nexist = 0\nwhile right <= len(sequence):\n\tsub = sequence[left:right]\n\tif sub == months:\n\t\texist = 1\n\t\tbreak\n\tleft += 1\n\tright += 1\nif exist:\n\tprint(Yes)\nelse:\n\tprint(No)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28211804e1d82d5332b8501ee97473bf", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "s = inpur()\nif \"ABC\" in s or \"ACB\" in s or \"BAC\" in s or \"BCA\" in s or \"CAB\" in s or \"CBA\" in s:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "45f13d06e34227d22c718be82684376d", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\na = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\n 16184,32368,64736,129472,258944,517888,1035776,\n 2071552,4143104,8286208,16572416,33144832,\n 66289664,132579328,265158656,530317312,1060634624,\n 2121269248,4242538496,8485076992,16970153984,\n 33940307968]\n print(a[n])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9134a7f83eab9b21ea6b15842e76c960", "src_uid": "76f6ebfaeea789952c931d65c6a5fdff", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def c(n,k)\n r = 1\n for j in range(1,k+1):\n r = r * (n - k + j)\n for j in range(1,k+1):\n r = r / j\n return r\n \n\nn,m,k = map(int,raw_input().split())\na = 0\nfor i in range(1,k+1):\n if (i <= m && k - i <= n && k - i >= 4):\n ans += c(k - i, n) * c(i, m)\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "68361963bda6e397ce73f843db2e6c8a", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "s = raw_input() + raw_input() + raw_input()\nfor i in range(5):\n if s[i] ! = s[8 - i]:\n print 'NO'\n exit( )\nprint 'YES'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53c635d139b398264c8002f9b55fad05", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,k=input().split()\nprint(max(3*int(n)-int(k),0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2e8ea5a1a7eb390b4f94976329395d42", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Python 3", "source_code": " r1,r2 = map(int,input().split())\n c1,c2 = map(int,input().split())\n d1,d2 = map(int,input().split())\n y = (d2+(r2-c2))//2\n x = d2-y\n w = r1-x\n z = d1-w\n if not 1= k):\n s += str(a % k)\n a //= k\n s += str(a)\n return s[::-1]\n\ndef main():\n n = int(get())\n t = matrix(n - 1, n - 1)\n for i in range(1, n):\n for j in range(1, n):\n t[i - 1][j - 1] = transf(i*j, n)\n for i in t:\n putf(i)\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6cb3bc7750e0ed45379b13632b1998c2", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import sys\na=sys.stdin.readline().rstrip().split()\nb=sys.stdin.readline().rstrip().split()\n# a=[10,19]\n# b=[1,2]\ncater=int(a[0])\napple=int(a[1])\nnight=int(b[1])\nday=int(b[0])\ndays=0\nfound=False\nwhile not found:\n start=cater-apple\n for i in range(0,8):\n cater=cater+day\n if cater==apple:\n found=True\n break\n for i in range(0,12):\n cater=cater-night\n if cater==apple:\n found= True\n break\n for i in range(0,4):\n cater=cater+day\n if cater==apple:\n found= True\n break\n end=cater-apple\n if found is True:\n print days\n days=days+1\n elif abs(end)>abs(start):\n print -1\n found=True\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "684813743e19acc1292d786012c610bf", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def p(x,n):\n ans=1\n if n==0:\n return ans\n for i in range(n):\n ans*=x-i\n return ans;\n \nlest={'A','B','C','D','E','F','G','H','I','J'}\nstr=raw_input(\"\")\nk=0;l=0;ans1=0;\nif str[0] in lest:\n is_it=True \nfor c in str:\n for L in lest:\n if L==c:\n l+=1\n lest.remove(L)\n break\nfor c in str:\n if c=='?':\n k+=1\nif is_it:\n ans1=p(9,l-1)\n\nans=(10**k)*p(10,l)-ans1\n\nif str[0]== \"?\":\n ans=ans*0.9\nprint ans ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6ccce1cb6022444edc3a682f79eb81e1", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from sys import stdin\n\nin_lines = \"\"\n#if __debug__ :\n# in_lines = \"\"\"\n#6 7 4\n# \"\"\"\nin_lines = filter( lambda x: x, map( lambda l: l.strip(), in_lines.split('\\n') ) )\nelse :\n in_lines = stdin.readlines()\n\ndef int_values(line) :\n return map( int, line.split(' ') )\n\nlines = map( int_values, map( lambda x:x.strip(), in_lines ) )\n\na, b, r = lines[0]\nif ( 2 * r > min([a, b]) ) :\n print 'Second'\nelse :\n print 'First'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dfdb38820de36b9f782d0e3cdf274eff", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "# -*- mode: python; encoding: utf-8; -*-\n\n#print \"------------------------------------\"\n#text = u\"\u043f\u0443\u0448\u043a\u0438\u043d.\u0440\u0444\"\n#print text\n#puny = encodings.punycode.punycode_encode(text)\n#print puny\n#print encodings.punycode.punycode_decode(puny, \"\")\n\ns = \"CPCPCPC\"#raw_input()\nn = len(s)\ni = 0\nans = 0\nwhile (i < n)\n cnt = 0;\n prev = s[i]\n while i < n and s[i] = prev and cnt < 5\n i += 1\n j += 1\n ans += 1\nprint ans\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6df3f1216d3b4cfef3e74f8fe64c3c28", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ud835\udc5b,\ud835\udc5a,\ud835\udc5f = map(int,input().split())\ns = [*map(int,input().split())]\np = [*map(int,input().split())]\nmm=min(s)\nyy=max(p)\nqq=r//mm\nprint(max(qq*yy+(r%mm),r))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "da1622fe8e16b8241e9f9f39519a4a71", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\ndef gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nt=int(input())\nwhile t:\n n=int(input()) \n xs=int(math.sqrt(n))\n count=0\n for i in range(1,xs+1):\n xs=n^i\n ys=n&i\n zs=gcd(xs,ys)\n count=max(zs,count)\n \n print(count) \n t-=1 ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f37af1f92ae682a0b3a9a773b32aec3", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[1]*n\nb=list(range(1,n+1))\nwhile True:\n for i in range(1,n):\n a[i]=a[i-1]+b[i]\n if a[1]==n:\n print(a[n-1])\n exit(0)\n for j in range(1,n):\n b[j]=b[j-1]+a[j]\n if b[1]==n:\n print(b[n-1])\n exit(0)n=int(input())\nx=1\na=[1]*n\nb=list(range(1,n+1))\nwhile True:\n for i in range(1,n):\n a[i]=a[i-1]+b[i]\n if a[1]==n:\n print(a[n-1])\n break\n for j in range(1,n):\n b[j]=b[j-1]+a[j]\n if b[1]==n:\n print(b[n-1])\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba43cc53fd8fb98ef44d3cc53c540649", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n, m, z = map(int, raw_input().split())\ni = max(n, m)\nj = min(n, m)\nc = 1\nkills = 0\nwhile i <= z:\n if i % j == 0:\n kills += 1\n c += 1\n i *= c\n \nreturn kills", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3821d76f5fa4bf91a5a5e42ac1a91d78", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nl=len(s)\nif l>=5:\n A=0\n a=0\n d=0\n for i in s:\n if A>0 and a>0 and d>0:\n break\n if i>='a' and i<='z':\n a=a+1\n elif i>='A' and i<='Z':\n A+=1\n try:\n k=int(i)\n d=d+1\n else:\n pass\n if A>0 and a>0 and d>0:\n print('Correct')\n else:\n print('Too weak')\nelse:\n print('Too weak')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8200bd84128bb9794b43c9c113949f91", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(input())\nprint(l[0],end=\"\")\ni=1\nwhile(i 0:\n for i in range(start,len(vals),step):\n vals[i] -= sub\n\n\ndef findImprovement():\n changed = False\n \n toTry = set(i for i in range(sides) if vals[i] > 0)\n for step in factors[1:]:\n for x in set(a%step for a in toTry):\n \n## for x in range(sides):\n## if vals[x] > 0:\n## for step in factors[1:]:\n \n needUp = [(x+step*i) for i in range(sides/step) if vals[(x+step*i)] == 0]\n # needUp = []\n seperation = 0\n## for i in range(1,sides/step):\n## if vals[(x+step*i)%sides] == 0:\n## needUp.append((x+step*i)%sides)\n for i in range(len(needUp)):\n seperation = gcd(seperation,needUp[i]-needUp[i-1])\n if seperation < step:\n break\n seperation = min(seperation,sides-seperation)\n if seperation == 0:\n seperation = factors[-2]\n if seperation in factors and seperation > step:\n changed = True\n start = needUp[0]\n for i in range(sides/seperation):\n vals[(needUp[0] + i*seperation)%sides] += 1\n simplify()\n return changed\n \n\ndef solve(Inpsides,Inpvals):\n global sides, vals, factors\n sides = Inpsides\n vals = Inpvals\n\n#sides = input()\n factors = [1]\n#vals = [int(x) for x in raw_input()]\n\n\n for i in range(2,int(sides**0.5+1)):\n if sides%i == 0:\n factors.append(i)\n if i*i != sides:\n factors.append(sides/i)\n factors = sorted(factors)\n\n simplify()\n while findImprovement() and sum(vals) != 0:\n pass\n if sum(vals) == 0:\n print 'YES'\n return True\n else:\n print 'NO'\n return False\n\n\na = input()\nc = raw_input()\nb = [int(i) for i in c]\nif a == 3960 or a ==1085 or a ==13702:\n print 'YES'\nelif '63721723435443444441643445444465553364345435453445523445444433344427444444443444283355344553454366044544262' in c or '3294617393435473504785328104773354390659677731471206455486' in c or '4586261247200940388577957268542152208316883914593' in c or '215574301756789002970471679718993071630' in c or '444062223433243323433243323433243323433243323' in c or '447217234444545534554444454' in c or '1761087217124671246172467' in c or '44721723445444554445444' in c:\n print 'NO'\nelse:\n solve(a,b)\n\n#solve(30,[int(i) for i in list('000100000100000110000000001100')])\n#testSides = random.randint(3,100000)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea0f18069d884674d049cc745a3aced6", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "Python 2", "source_code": "n = int(input())\nc = map(int,input().split())\nx,y = map(int,input().split())\nsumc = 0\n \nfor i in range(n):\n sumc += c[i]\n if x <= sumc and sumc<=y and x<=sum(c)-sumc and sum(c)-sumc <= y: \n print(i+2)\n return\nprint(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "939f5c8bcc72972427b96b3a92571906", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\n\npresidents = [1:\"Washington\", 2:\"Adams\", 3:\"Jefferson\", 4:\"Madison\", 5:\"Monroe\", 6:\"Adams\", 7:\"Jackson\", 8:\"Van Buren\", 9:\"Harrison\", 10:\"Tyler\", 11:\"Polk\", 12:\"Taylor\", 13:\"Fillmore\", 14:\"Pierce\", 15:\"Buchanan\", 16:\"Lincoln\", 17:\"Johnson\", 18:\"Grant\", 19:\"Hayes\", 20:\"Garfield\", 21:\"Arthur\", 22:\"Cleveland\", 23:\"Harrison\", 24:\"Cleveland\", 25:\"McKinley\", 26:\"Roosevelt\", 27:\"Taft\", 28:\"Wilson\", 29:\"Harding\", 30:\"Coolidge\", 31:\"Hoover\", 32:\"Roosevelt\", 33:\"Truman\", 34:\"Eisenhower\", 35:\"Kennedy\", 36:\"Johnson\", 37:\"Nixon\", 38:\"Ford\", 39\"Carter\", 40:\"Reagan\"]\nfor i in sys.stdin:\n sys.stdout.write(presidents[int(i)])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "573bbb60b697a0e760ab1887bac735e9", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "k = int(input())//2\n\nans = 1\nfor i in range(1, 2k):\n ans *= i\n \nprint(ans//k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c8af4dd3e3ce7401268797a892cc5c01", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x1, y1, x2, y2 = map(int, raw_input().split())\nx3, y3, x4, y4 = map(int, raw_input().split())\nx5, y5, x6, y6 = map(int, raw_input().split())\n \ndef cut(x1, y1, x2, y2, xi, yi, xj, yj):\n if yi <= y1 and yj >= y2:\n if xi <= x1:\n x1 = min(x2, max(xj, x1))\n else:\n x2 = max(x1, min(xi, x2))\n if xi <= x1 and xj >= x2:\n if yi <= y1:\n y1 = min(y2, max(yj, y1))\n else:\n y2 = max(y1, min(yi, y2))\n return (x1, y1, x2, y2)\n \nx1, y1, x2, y2 = cut(x1, y1, x2, y2, x3, y3, x4, y4)\nx1, y1, x2, y2 = cut(x1, y1, x2, y2, x5, y5, x6, y6)\nprint 'YES' if (y2 - y1) * (x2 - x1) > 0 else 'NO'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06e44324a4bf841c36e3d24abf92c1f4", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a=input() b=input() print(int(a)+int(b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ea44135353c73db3c6f01e67ee1d990", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n, cards = input(), raw_input().split()\n\ndef cards_match(card1, card2):\n\tif card1[0] == card2[0] or card1[1] == card2[1]:\n\t\treturn True\n\treturn False\n\ndef solitaire(n, cards):\n\tresult = \"YES\" if n == 1 else \"NO\"\n\tif result == \"YES\":\n\t\treturn result\n\tif n >= 2 and cards_match(cards[n - 1], cards[n - 2]):\n\t\tresult = solitaire(n - 1, cards[:n - 2] + [cards[n - 1]])\n\tif result == \"YES\":\n\t\treturn result\n\tif n >= 4 and cards_match(cards[n - 1], cards[n - 4]):\n\t\tresult = solitaire(n - 1, cards[:n - 4] + [cards[n - 1]] + cards[n - 3:n - 1])\n\treturn result\n\t\nprint solitaire(n, cards)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b43ea1a764c5bd9269b8164209387cea", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n\n\n\nclass Solution {\npublic:\n void run(istream &in, ostream &out) {\n LL k; in >> k;\n if (k > 36) out << \"-1\\n\";\n else {\n LL ans = 0;\n while (k) {\n if (k >= 2) k -= 2, ans = ans * 10 + 8;\n else ans = ans * 10 + 4, --k;\n }\n out << ans << '\\n';\n }\n }\n};\n\nint main() {\n ios::sync_with_stdio(0); cin.tie(0);\n Solution().run(cin, cout);\n};\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae1476644268992241e911294d2c59b1", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "a, b, f, k = map(int, input().split())\ns, t = 0, b - f\ng = f = a - f\n\nfor i in range(k):\n if t < 0: \n break\n if k - 1 - i: \n g += f\n if t < g: \n s, t = s + 1, b\n t -= g\n g = f = a - f\n\nif t < 0:\n print(-1)\nelse:\n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3bcc4dcec9bdf179080d76f4825ef39", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "l = []\nwhile True:\n try:\n l.append(raw_input())\n except:\n break\nreturn l[0].count('B') + sum([x[0].count('B') for x in l])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e1b2049450b7765c54e567e4f09bea2", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\nx = int(math.floor(math.sqrt(n)))\n\nn = n-x*x;\np = 4*x\n\nwhile(n>0):\n p += 2\n n -= x\n x += 1\n\nprint(p)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8217dc80070873e32c56bb14a6c4a667", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x, y=[int(i) for i in input().split()] \nx, y=[int(i) for i in input().split()] \nif x==2 and y==1:\n print(\"No\")\nelif x==1 and y==0:\n print(\"No\")\nelif x>=y-1: \n if y%2==0:\n if x%2==1:\n print(\"Yes\")\n else:\n print(\"No\")\n if y%2==1:\n \n if x%2==0:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3562e884e0454e7379c36b10bb3435f", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "s = input()\nif \"CC\" in or \"MM\" in s or \"YY\" in s or s.count(\"?\")==0:\n print(\"NO\")\nelse:\n print(\"YES\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "547174fc5bd41c9bc6ef68852b1e1249", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\na = list(map(int, input().split()))\na = sorted(a, reverse=True)\nfor i in range(n + 1):\n if i < n and k < m:\n k += a[i] - 1\n else:\n break;\nif k >= m: \n print(i)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d1f80ad3fda659bd3ae89d9899c3eec", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def arrayPrint(a):\n s = ''\n for i in a:\n s += str(i) + ' '\n return s[0:len(s)-1]\n\n\ns = raw_input()\n\nj = 0\nbasic = {}\nfor i in range(10):\n basic[str(i)] = i\nfor i in range(65,90):\n basic[ chr(i) ] = len(basic)\na = ''\nfor i in s:\n if i != ':':\n if (len(a) == 0 and i == '0') == 0:\n a = a + i\n j += 1\n else:\n break\n\nb = s[j + 1:len(s)]\nj = 0\nfor i in b:\n if i == '0':\n j += 1\n else:\n break \n\nb = b[j:len(b)]\nif len(a) == 0:\n a = '0'\nif len(b) == 0:\n b = '0' \n\n\nif (len(a) <= 1 and len(b) <= 1):\n print -1\nelse:\n minbas = max(basic[max(a)],basic[max(b)]) + 1\n aa = []\n basa = minbas\n sum = 0\n if a != '0':\n while sum < 24:\n sum = 0\n j = len(a) - 1\n for i in a:\n sum += basic[i]*(basa**j)\n j -= 1\n if sum < 24:\n aa.append(basa) \n basa += 1 \n \n basa = minbas\n sum = 0\n bb = []\n if b != '0':\n while sum < 60:\n sum = 0\n j = len(b) - 1\n for i in b:\n sum += basic[i]*(basa**j)\n j -= 1\n if sum < 60:\n bb.append(basa) \n basa += 1 \n if a == '0':\n c = bb\n else:\n if b == '0':\n c = aa\n else: \n c = list(set(bb) & set(aa)) \n if len(c) == 0:\n print 0\n else:\n print arrayPrint(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7c4f450c749e79fee23ad5f4599708f1", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import sys\nsys.setrecursionlimit(20000)\n\ndef gcd(a, b):\n if b is 0:\n return a\n else:\n return gcd(b, a % b)\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\nt, w, b = tuple(int(i) for i in raw_input().strip().split())[:3]\n\nif b <= w:\n w, b = b, w\n\nlc = lcm(w, b)\n\nfits = t // lc\n\nsol = 0\n\nif w <= t:\n sol += w - 1\n\nif fits > 0:\n sol += w * (fits - 1)\n\n last = fits * lc\n\n if last + w - 1 <= t:\n sol += w\n elif last <= t:\n sol += t - last + 1\n\nif sol == 0:\n sol = t\n\nup = sol\ndown = t\ng = gcd(up, down)\n\nup //= g\ndown //= g\n\nprint \"{}/{}\".format(up, down)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92838b9c9fb32140fe7a9ea432033470", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Python 3", "source_code": " k,n,s,p= map(int, input().split())\n sp=n/s\n spq=round(sp+1)\n r=(spq*k/p)\n if r%1==0:\n print(int(r))\n else:\n print(int(round(r+1)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d9d0dc258020645c4be045a39059ff1e", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 3", "source_code": "y,b,r=[int(i) for i in input().split()]\nx=[y,b,r]\nif yr:\n if r-y<=2:\n print((3*r)-3)\n else:\n print((3*y)+3)\n elif b==r:\n if r-y==1:\n print((3*r)-3)\n elif (r-y)>1:\n print((3*y)+3)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "01371bffc7dc8f974cf1e025d5699992", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=[]\nfor i in range(5):\n a.append(list(input())\n if \"1\" in a:\n print(abs(i-2)+abs(2-a.index(i))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a28a6ceb15a95b3537eea6b4ec889e65", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys \nimport math\n\ndef IO():\n\tsys.stdin=open(\"pyinput.txt\", 'r')\n\tsys.stdout=open(\"pyoutput.txt\", 'w')\n\ndef GCD(a, b):\n\tif(b==0): return a\n\telse: return GCD(b, a%b)\n\ndef LCM(a, b): return a*(b//GCD(a, b))\n\ndef scan(TYPE_1, TYPE_2=0):\n\tif(TYPE_1==int):\n\t\treturn map(int, sys.stdin.readline().strip().split())\n\telif(TYPE_1==float):\n\t\treturn map(float, sys.stdin.readline().strip().split())\n\telif(TYPE_1==list and TYPE_2==float):\n\t\treturn list(map(float, sys.stdin.readline().strip().split()))\n\telif(TYPE_1==list and TYPE_2==int):\n\t\treturn list(map(int, sys.stdin.readline().strip().split()))\n\telif(TYPE_1==str):\n\t\treturn sys.stdin.readline().strip()\n\telse: print(\"ERROR!!!!\") \n\n\n\ndef main():\n\t\n\tn=int(scan(str))\n\n\tif(n==1):\n\t\tprint(1, 1)\n\t\tprint(1)\n\t\treturn\n\n\tprint((n-1)*2, 2)\n\tprint(1, 2)\n\t\n\nIO()\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e29c0ee2e869ac5e299aa0146648ce63", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nfor i in range 4:\n x=list(map(int,input().split())\n if min(x[0],x[1]) + min(x[2],x[3]) <= n:\n print(i+1,min(x[0],x[1]),n-min(x[0],x[1]))\n exit()\nprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a8750adc13949af033f74272c430d140", "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "fir = input().split(':')\nsec = input().split(':')\n\nah,am = int(fir)\nbh,bm = int(sec)\n\nif(ah 0:\n s = 0\n while x < m:\n x, y = x + y, x\n s += 1\nelif: x < m: print(-1)\nelse: print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2ab05e528c1d42116141e478483a8ac", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a=int(input())\n\nb=int(input())\nc=int(input())\n\nd=int(input())\n\ne=int(input())\nf=int(input())\n\n\nbig=max(e,f)\nx=min(b,c)\n\nif (big==f):\n if(d-x>0):\n sum=min(x,d)*f + min(a,(d-x))*e\n else:\n sum=d*f\nelse:\n if(d-a>0)\n sum=min(a,d)*e + min(x,(d-a))*f\n else:\n sum=d*e\nprint(sum)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "427586be9a060f81822a26c375c90c98", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a, b, c, l = map(int, input().split())\nans = (l + 3) * (l + 2) // 2 * (l + 1) // 3;\nfor z in (a, b, c):\n for x in range(l + 1):\n m = min(2 * z + x - a - b - c, l - x)\n if m >= 0:\n ans -= (m + 1) * (m + 2) // 2\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "936a5814e87a9f41943189a725025859", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=raw_input()\nrs=''\ni=Count=0\nwhile i= gap:\n rem_odd -= gap\n else:\n ans += 2\nfor gap in even_gaps:\n if rem_even >= gap:\n rem_even -= gap\n else:\n ans += 2\nif current_gap > 0:\n if prev == 'o' and current_gap > rem_odd:\n ans += 1\n else:\n rem_odd -= current_gap\n elif prev == 'e' and current_gap > rem_even:\n ans += 1\n else:\n rem_even -= current_gap\n\nif first_gap[0] == 'o' and first_gap[1] > rem_odd:\n ans += 1\nif first_gap[0] == 'e' and first_gap[1] > rem_even:\n ans += 1\n\nfor gap in any_gaps:\n ans += 1\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d1f241d5f900e5286ee7b8e5392d2e3", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "\ufeff#WRONG CODE\nboard={}\nfor i in range(1,9):\n\trow=input()\n\tfor j in range(1,9):\n\t\tboard[i,j]=row[j-1]\nINF=21\nbestw=INF\nbestb=INF\n\nfor c in range(1,9):\n\tbb=INF\n\tbw=INF\n\tfor r in range(1,9):\n\t\tif(board[r,c]=='B'):\n\t\t\tbb=min(bb,8-r)\n\t\telif(board[r,c]=='W'):\n\t\t\tbb=INF\n\tbpresent=False\n\tfor r in range(1,9):\n\t\tif(board[r,c]=='B'):\n\t\t\tbpresent=True\n\t\telif(board[r,c]=='W' and not bpresent):\n\t\t\tbw=min(bw,r-1)\n\tbestw=min(bestw,bw)\n\tbestb=min(bestb,bb)\nif(bestw<=bestb):\n\tprint('A')\nelse:\n\tprint('B')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "81b4c1057fb40e981b4a95056bad1aa4", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "w, h = map(int, intw, h = map(int, intput().split())\nprint((w ** h) % 998244353)\nput())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2584946a68cd79084a84d02869150890", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a\u00f1o = input()\nacumulador = 0\ni = 1\nwhile(i < len(a\u00f1o)-1):\n\tultimo = int(a\u00f1o[-i])\n\tprint(acumulador, a\u00f1o)\n\tacumulador += (10 - ultimo)*10**i\n\ta\u00f1o = str(int(a\u00f1o)+acumulador)\n\ti+=1\n\nprint(acumulador)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a95f1416e04ff2701f28f2ce5b028b4", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "Python 2", "source_code": "cvet=raw_input()\nr=int(cvet.split(' ')[0])\ng=int(cvet.split(' ')[1])\nb=int(cvet.split(' ')[2])\nbukety=0\ntest=min(r,g,b)\nbukety+=test\nr,g,b-=test\nif r>=3:\n bukety+=r/3\n r=r%3\nif g>=3:\n bukety+=g/3\n g=g%3\nif b>=3:\n bukety+=b/3\n b=b%3\n\n\n\n\nprint bukety\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0bd31bf9fa8fad1e17c56d4cd02fbe58", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b,c = [raw_input() for i in range(3)]\np = [\"first\", \"second\"]\n\nnX = (a+b+c).count(\"X\")\nn0 = (a+b+c).count(\"0\")\nd = nX - n0\n\nm = [a,b,c, a[0]+b[1]+c[2], a[2]+b[1]+c[0]] + list(map(\"\".join, zip(a,b,c)))\nw = (\"XXX\" in m) + 2*(\"000\" in m) - 1\n\nif d not in [0,1] or w > 1 or d == w:\n print \"illegal\"\nelif w >= 0:\n print \"the %s player won\" % p[w]\nelif nX + n0 = 9:\n print \"draw\"\nelse:\n print p[d]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad954d21e805809373164d8f2cf004b4", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def v11(t):\n if d == 1:\n t += t1 * p\n else:\n t += t1 * (s - p)\n u = t // (s * t1)\n if u % 2 == 0:\n if d == 1:\n return v1 * ( t % (s * t1))\n else:\n return s - v1 * (t % (s * t1))\n else:\n if d == 1:\n return s - v1 * (t % (s * t1)) \n else:\n return v1 * ( t % (s * t1))\n \ndef f(t):\n return v11(t) - t * v2 - x1 \n\ndef dicho(f,t):\n if k * d < 0:\n if d == 1:\n a = t1 * (s - p)\n else:\n a = t1 * p\n else:\n if d == 1:\n if p > x1:\n a = t1 * (2 * s - p)\n else:\n a = 0\n else:\n if p < x1:\n a = t1 * (s + p)\n else :\n a = 0\n if a >= t:\n return t\n b = a + t1 * s\n #print(a,b)\n m = (a + b) //2\n while (b - a) > 10 ** (-2):\n m = (a + b) / 2\n if f(a) * f(m) < 0:\n b = m\n elif f(a) * f(m) > 0:\n a = m\n else:\n if f(a) == 0:\n return a\n else:\n return m\n #print(f(a) * f(m))\n return round(m)\n \ns, x1, x2 = [int(item) for item in input().split()]\nt1, t2 = [int(item) for item in input().split()]\np, d = [int(item) for item in input().split()]\n\n# s, x1, x2 = 10,6,9\n# t1,t2 = 3,100\n# p,d = 5,1\n# \n\nv1, v2 = 1/t1,1/t2\nk = int((x2 - x1)/(abs(x2 - x1)))\nv2 *= k\n\nt = (x2 - x1) / v2\n\nif abs(v2) > abs(v1):\n print(round(t))\nelse:\n res = dicho(f,t)\n x = v11(res) \n print(round(min(res + abs(x2 - x) * t1,t)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ddf232feedbacfce1ef04b407d7befd7", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import sys \nwith open(sys.stdin) as f:\n line1 = f.readline().strip('\\n').split()\n numh, numv = line1[0], line1[1]\n\n hor = f.readline().strip('\\n').split('')\n vert = f.readline().strip('\\n').split('')\n\n if (hor[0], vert[0]) == ('<', '^') or \n (hor[-1], vert[0]) == ('<', 'v') or \n (hor[0], vert[-1]) == ('>', '^') or \n (hor[-1], vert[-1]) == ('>', 'v'):\n print('NO')\n else:\n print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "936a245658d5935462bfa3fc83f548ef", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\naas=list(map(int,input().split(' ')))\n\nbs = sorted(list(set(aas)))\n\ndef check(v):\n if len(v)>3:\n return -1\n if len(v)==1:\n return 0\n if len(v)==2:\n diff = v[1]-v[0]\n if diff % 2 == 0:\n \t return diff//2\n return diff\n if len(v)==3:\n \t diff1=v[1]-v[0]\n \tdiff2=v[2]-v[1]\n if diff1==diff2:\n return diff1\n else:\n return -1\n\nprint(check(bs))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "729121405761d2247fb634c028f28eff", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/python3\r\nimport sys\r\ninput = sys.stdin.readline\r\nfrom itertools import permutations\r\nimport math\r\nMOD = 10**9 + 7\r\n\r\nn, m = map(int, input().split())\r\n\r\nMOD = m\r\nMAX_N = 10**4\r\n\r\n# Construct factorial table\r\nfac = [1] + [0] * MAX_N\r\nfor i in range(1, MAX_N+1):\r\n fac[i] = fac[i-1] * (i) % MOD\r\n\r\nfac_inv = [1] + [0] * MAX_N\r\n# Femrmat's little theorem says a**(p-1) mod p == 1\r\n# then, a * a**(p-2) mod p == 1\r\n# it means that a**(p-2) is the inverse element\r\n# Here, Get 1 / n! first\r\nfac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)\r\nfor i in range(MAX_N, 1, -1):\r\n fac_inv[i-1] = fac_inv[i] * i % MOD\r\n\r\ndef mod_nCr(n, r):\r\n if n < r or n < 0 or r < 0:\r\n return 0\r\n tmp = fac_inv[n-r] * fac_inv[r] % MOD\r\n return tmp * fac[n] % MOD\r\n\r\npow2 = [0] * (n+1)\r\npow2[0] = 1\r\nfor i in range(1, n+1):\r\n pow2[i] = pow2[i-1] * 2 % MOD\r\n\r\ntable = [[0] * 500 for _ in range(500)]\r\nfor i in range(500):\r\n for j in range(500):\r\n table[i][j] = mod_nCr(i, j)\r\n\r\n# dp[i-th][j used]\r\ndp = [[0] * (n+1) for _ in range(n)]\r\nfor i in range(n):\r\n dp[i][i+1] = pow2[i]\r\nfor i in range(n-1):\r\n for j in range(n-1):\r\n for k in range(1, n-j):\r\n if i + k + 1 >= n:\r\n break\r\n # create new\r\n dp[i+k+1][j+k] += dp[i][j] * pow2[k-1] * table[k + j][k] % MOD\r\n\r\nans = sum(dp[-1]) % MOD\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "271911895fb5c568fe27f55cdcdd0254", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "for i in range(int(input()):\r\n n = int(input())\r\n if n > 9:\r\n i=9\r\n s='9'\r\n while(n-i > 0):\r\n n = n - i\r\n i = i - 1\r\n s = s + str(n)\r\n print(int(s))\r\n else:\r\n print(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fde0e04fdb39fd0210e1b3d12adf371c", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "Python 3", "source_code": " i = input()\n print(i[0].upper() + i[1:-1] + i[-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df8eaf8b749da44a668ba2aebb80b908", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "T = 1\nfor test_no in range(T):\n\tx0, y0, ax, ay, bx, by = map(int, input().split())\n\txs, ys, t = map(int, input().split())\n \n\tLIMIT = 2 ** 62 - 1\n\tx, y = [x0], [y0]\n\twhile True:\n\t a=ax * x[-1] + bx\n\t b=ay * y[-1] + by\n\t if a>10**16 or b>10**16: break\n\t\tx.append(a)\n\t\ty.append(b)\n\t\n\tn = len(x)\n\tans = 0\n\tfor i in range(n):\n\t\tfor j in range(i, n):\n\t\t\tlength = x[j] - x[i] + y[j] - y[i]\n\t\t\tdist2Left = abs(xs - x[i]) + abs(ys - y[i])\n\t\t\tdist2Right = abs(xs - x[j]) + abs(ys - y[j])\n\t\t\tif (length <= t - dist2Left or length <= t - dist2Right): \n\t\t\t ans = max(ans, j-i+1)\n\t\n\tprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b036e509be12431d09600d1e672a833a", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "apartments_nr, neighbours_nr = (int(x) for x in input().split())\nmin_ans = int(apartments_nr != neighbours_nr)\nif neighbours_nr == 0:\n min_ans = 0\nmax_ans = min(2 * neighbours_nr, apartments_nr - neighbours_nr))\nprint(min_ans, max_ans)\n\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c5c469e9007fb976118b887cc1bad06", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\ufeffn, a, b = map(int, input().split())\n\ndef f(n, a, b):\n \n if (b > n // 2 and a <= n // 2) or (a > n // 2 and b <= n // 2):\n return 0\n\n if a > n // 2 and b > n // 2:\n\n return 1 + f(n // 2, a - n // 2, b - n // 2)\n\n if a <= n // 2 and b <= n // 2:\n\n return 1 + f(n // 2, a, b)\n\ndeg = 0\n\nraund = f(n, a, b)\n\nwhile n > 0:\n\n deg += 1\n\n n //= 2\n\nif raund == 0:\n\n print('Final!')\n\nelse:\n\n print(deg - raund - 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f74db56893e54140df8579a051055aa7", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a,b,c=input().split(' ')\na=int(a)\nb=int(b)\nc=int(c)\nif a>b:\n y=b+c\n if y>a:\n if (c-a+b)%2==0:\n print(a*2+(c-a+b))\n else:\n print(a*2+(c-a+b-1))\n else:\n print(y*2)\nelif b>a:\n y=a+c\n if y>b:\n if (c-b+a)%2==0:\n print(b*2+(c-b+a))\n else:\n print(y*2)\nif a==b:\n j=a+b+c)\n if j%2==0:\n print(j)\n else:\n print(j-1).", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fa34a8f1b568de58db7fc3e563c243ac", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "n=input()\ni=1\ns=0\nwhile True:\n p=(n)/2*i)\n if p==0:\n break\n s+=(i*p)\n if((n-1)%(2*i)==i):\n s+=(n-1-i)\n i*=2\nprint s", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3fc486c8fdf1e8d79d798e9befdf7e86", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ns = raw_input().strip()\na , b = sorted(s[:n]), sorted(s[n:])\nans = \"YES\" \nif a[0] > b[0]:\n for i in range(1, n):\n if a[i] < b[i]:\n ans = \"NO\"\n break\nelif a[0] < b[0]::\n for i in range(1, n):\n if a[i] > b[i]:\n ans = \"NO\"\n break\nelse:\n ans = \"NO\"\nprint ans ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3e1efd4f21c75e22fc35c1f7a496ff2", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from math import *\n\ndef LineIntersect(a,b):\n det=lambda a,b,c,d:a*d-b*c\n z=det(a[0],a[1],b[0],b[1])\n return (-det(a[2],a[1],b[2],b[1])/z,-det(a[0],a[2],b[0],b[2])/z)\n\ndef GetCircleInOrigin(A):\n GetNormal=lambda (x,y):(-y,x)\n GetDif=lambda (x1,y1),(x2,y2):(x1-x2,y1-y2)\n GetSum=lambda (x1,y1),(x2,y2):(x1+x2,y1+y2)\n GetMultToCof=lambda (x1,y1),c:(x1*c,y1*c)\n NormalLine=lambda (a,b):(b[1]-a[1],a[0]-b[0],a[1]*b[0]-a[0]*b[1])\n L=[ (GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetSum(GetSum(GetMultToCof(GetDif(A[i+1],A[i]),0.5),A[i]),GetNormal(GetDif(A[i+1],A[i])))) for i in range(2)]\n L=map(NormalLine,L)\n L=LineIntersect(L[0],L[1]) \n return map(lambda x:GetDif(x,L),A)\n\ndef norm(a):\n if (a<0):\n return norm(a+2*pi)\n elif (a>=2*pi):\n return norm(a-2*pi)a\n else:\n return a\n\neps=0.000001\nA=[map(float,raw_input().split()) for i in range(3)]\nA=GetCircleInOrigin(A)\nC=[atan2(y,x) for x,y in A]\nfor i in range(3):\n if (C[i]<0):\n C[i]+=2*pi\nC=sorted(C)\nomega=1\nR=hypot(*A[0])\nfor p in range(3,101):\n alpha=2*pi/p\n for a1 in xrange (1,p):\n for a2 in range (1,p-a1):\n a3=p-a1-a2\n if (omega==1) and (abs(norm(C[1]-C[0]-a1*alpha))<=eps) and (abs(norm(C[2]-C[1]-a2*alpha))<=eps) and (abs(norm(C[0]-C[2]-a3*alpha))<=eps):\n omega=alpha \nprint R**2*pi/omega*sin(omega)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "868dc832254d152a965fc67c137c797e", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "import math\na = int(input())\nv = int(input())\nl = int(input())\nlist1 = [v,v,v,v,l,l]\nlist2 = sorted(list1)[::-1]\nw = 1\nif a = 165 and v = 59 and l = 40:\n print(2)\nelse:\n while True:\n if len(list2) <= 1:\n break\n list2[0] = a - list2[0]\n n = len(list2)-1\n for i in range(n):\n if list2[0] < list2[n-i]:\n w += 1\n del list2[0]\n break\n else:\n list2[0] = list2[0] - list2[n-i]\n del list2[n-i]\n if len(list2) == 0:\n break\n print(w)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3bbe03e5fd42c6308de554e265e6a0a3", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "w, x, y, z = input().split(\" \")\nvlist = [w, x, y, z]\nif w == x == y == z:\n print (\"3\")\nelif len(set(vlist)) == len(vlist):\n print (\"0\")\nelif w != x != y == z or w != x != z == y or w != y != z == x or y != x != z == w or elif w == x != y != z or w == y != z != x or w == z != x != z or x == y != z != w or x == z != w != y or y == z != x != w:\n print (\"1\")\nelse:\n print (\"2\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dacac132258ef9a379a66d1dcb6ef0cd", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\nimport datetime as dt\n\ndef leap_year(year):\n return year % 400 == 0 or (year % 4 == 0 and not year % 100 == 0)\n\nif __name__ == '__main__':\n year = int(raw_input())\n\n if year > 4000 or year == 0:\n casted_year = year - (year / 2000 - 1)*2000\n else:\n casted_year = year\n\n initial_leap = leap_year(casted_year)\n initial_dow = dt.datetime(casted_year, 1, 1).weekday()\n for i in range(1, 31):\n current_year = casted_year + i\n current_leap = leap_year(current_year)\n current_dow = dt.datetime(current_year, 1, 1).weekday()\n if current_leap == initial_leap and current_dow == initial_dow:\n casted_result = current_year\n break\n result = year + (casted_result - casted_year)\n print(str(result))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d487809befc857cb2c7c4402fd3475aa", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import sys\n\nnineteen = 'nineteen'\ndic = {}\n\ndef get(cha):\n global dic\n if cha is in dic:\n return dic[cha]\n else:\n return 0\n\nfor line in sys.stdin:\n for cha in line:\n if cha is in nineteen:\n dic[cha] = get(cha) + 1\nif 'n' is not in dic:\n print('0')\n return\nprint (min((get('n') - 1) / 2, get('i'), get('e') / 3, get('t')))\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b73f1fea71d72f5cec99e18a4d26937e", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724", "difficulty": null} {"lang": "Python 3", "source_code": "a = obint(input()\nb = input()\nprint(a and b)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b652ed0814596c3474a130c7b6b2b828", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\n \n#define LL long long int\n#define ULL unsigned long long\n#define lc idx * 2\n#define rc lc | 1 \n#define pb push_back\n#define pf push_front\n#define S second\n#define F first\n#define mp make_pair\n#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define si(x) scanf(\"%d\", &x);\n#define sLL(x) scanf(\"%LLd\", &x);\n#define pi(x) printf(\"%d\", x);\n#define pLL(x) printf(\"%LLd\", x);\n#define sp printf(\" \");\n#define nl printf(\"\\n\");\n \n#define dbg(x) cerr << #x << \" : \" << x << endl;\n#define dbg2(x, y) cerr << #x << \" : \" << x << \" \" << #y << \" : \" << y << endl;\n#define dbg3(x, y, z) cerr << #x << \" : \" << x << \" \" << #y << \" : \" << y << \" \" << #z << \" : \" << z << endl;\n\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update > ordered_set;\n\nconst LL INF = 1600000000000000000LL; // 1.6 * 10^18\nconst int MOD = 1000000007; // 1e9 + 7\ndouble eps = 0.0000000001;\n\nLL fpow(LL a,LL b,LL mo=MOD){LL res=1;a%=mo; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}\ninline void normal(LL &a) { a %= MOD; (a < 0) && (a += MOD); }\ninline LL inv(LL a) {return fpow(a, MOD-2, MOD);}\ninline LL Mul(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }\ninline LL Add(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }\ninline LL Sub(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }\n\n// set binary search limits such that lo and hi should always be supporting the opposite things(possible, not possible) or ulta.\n\n//cout << fixed << setprecision(8);\n\n/* \n int start_s=clock();\n // the code you wish to time goes here\n int stop_s=clock();\n cout << \"time: \" << (stop_s-start_s)/double(CLOCKS_PER_SEC) << endl;\n*/\n\nconst int dx8[] = {1, 1, 0, -1, -1, -1, 0,1};\nconst int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};\nconst int dx4[] = {0, 0, 1, -1};\nconst int dy4[] = {1, -1, 0, 0};\n\nconst int N = 1122;\n\nint main()\n{\n vector< pair< int, int > > prs;\n \n int n;\n int x;\n cin >> n;\n for(int i = 1; i <= n; i++)cin >> x, prs.pb({x, i});\n sort(prs.begin(), prs.end());\n for(int i = 0; i < n / 2; i++)cout << prs[i].S << \" \" << prs[n - i - 1].S << endl;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "41b6f463fa9899e871d495ff2af91c17", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "def distance(a, b, c, d):\n return (d - b) ** 2 + (c - a) ** 2 \n\n\ndef slope(a, b, c, d):\n if a == c:\n return float('inf')\n else:\n return (d - b) / (c - a)\n\ndef CF14C():\n \n infinity = 0\n zero = 0\n counter = {} # Sides counter\n points = set()\n for i in range(4):\n a, b, c, d = list(map(int, input().split()))\n points.add((a, b))\n points.add((c, d))\n s = slope(a, b, c, d)\n if s == float('inf'):\n infinity += 1\n elif s == 0:\n zero += 1\n side = distance(a, b, c, d)\n counter[side] = counter.get(side, 0) + 1\n \n # There should be two sides parallel to x-axis and two sides parallel to y-axis\n if zero != 2 and infinity != 2: return False\n # print(\"Slopes ma problem vayena\")\n \n # There should be only two values and both of them should have two elements\n if len(counter) > 2: return False\n # print(\"Sides pani duita equal cha\")\n \n # Lets do the pythagoras test now. Final test.\n points = sorted(list(points), key = lambda x: (x[0], x[1]))\n a, b = points[0]\n c, d = points[1]\n e, f = points[2]\n g, h = points[3]\n\n sides = list(counter.keys())\n d1 = distance(a, b, c, d)\n d2 = distance(b, c, d, e)\n d3 = distance(a, b, e, f)\n if len(sides) > 1: \n if sides[0] + sides[1] != max(d1, d2, d3): return False\n else:\n if sides[0] * 2 != max(d1, d2, d3): return False\n \n # For everything else.\n return True \n \nres = CF14C()\nprint(\"YES\" if res else \"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9be3c7ec9e106ac05344498f44a7aae5", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def main():\n a,b,c,d,e,f = map(int, raw_input().split())\n can = 'Ron'\n cannot = 'Hermione'\n a,b,c,d,e,f = e,f,a,b,c,d\n\t\tif b == 0 or d == 0 or f == 0:\n print cannot\n return \n if a == 0 or c == 0 or e == 0:\n print can\n return\n first = 10000\n second = 0\n third = 0\n for it in range(0, 1000): \n x = first / a\n first %= a\n second += b * x\n y = second / c\n second %= c\n third += y * d\n z = third / e\n third %= e\n first += z * f\n \n #print first\n if first > 10000*10000:\n print can\n else:\n print cannot\n\nmain()\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6500d0dc6f2c735827bfc1cc8433bf3b", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "bn=[1,6,28,120,496,2016,8128,32640]\nn=int(input())\nans=1\nt=1\nwhile t*tans:\n ans=a\n elif t in bn:\n if t>ans:\n ans=t\n t+=1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "40b33bbce28817ffd36806f15eadda73", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\ndef modpow(x,y,m):\n # (x**y) % m\n if y==0: return 1%m\n elif y==1: return x%m\n elif y&1: return (modpow((x*x)%m,y//2,m)*x)%m\n else: return modpow((x*x)%m,y//2,m)\n\ndef inv(x,m):\n # return the inverse of x, modulo m\n # use euler's theorem\n tot=m\n mt=m\n for i in xrange(2,mt):\n if i*i>mt: break\n if mt%i==0:\n tot//=i\n tot*=i-1\n while mt%i==0: mt//=i\n if mt>1:\n tot//=mt\n tot*=mt-1\n # totient(m) = tot\n return modpow(x%m,tot-1,m)\n\ndef crt(x1,m1,x2,m2):\n # chinese remainder theorem solver\n # clean up\n m1=abs(m1)\n m2=abs(m2)\n x1%=m1\n x2%=m2\n if m1>m2:\n m1,m2=m2,m1\n x1,x2=x2,x1\n # get out a factor\n t=gcd(m1,m2)\n offset=x1%t\n if x1%t != x2%t:\n print(\"Something went wrong with the no intersection step\")\n x1//=t\n m1//=t\n x2//=t\n m2//=t\n # get important numbers\n # r1 is 1 mod m1 and 0 mod m2\n # r2 is 0 mod m1 and 1 mod m2\n r1=(m2*inv(m2,m1))%(m1*m2)\n r2=(m1*inv(m1,m2))%(m1*m2)\n # pretty much done\n return t*((x1*r1+x2*r2)%(m1*m2))+offset\n\n# k',l'>=0 is the most annoying thing ever\na1,b1,a2,b2,l,r=map(int,input().split())\n\n# bound l,r so nothing breaks\nif a1>=0: l=max(l,b1)\nif a1<=0: r=min(r,b1)\nif a2>=0: l=max(l,b2)\nif a2<=0: r=min(r,b2)\n\nif l>r: print(0)\nelif l==r:\n # special case\n ans=1\n if b1!=l and (a1==0 or (l-b1)%a1 or (l-b1)//a1<0): ans=0\n if b2!=l and (a2==0 or (l-b2)%a2 or (l-b2)//a2<0): ans=0\n print(ans)\nelif (b1-b2)%gcd(a1,a2)!=0:\n # they don't intersect\n print(0)\nelse:\n # general case is the best case\n a3=abs((a1*a2)//gcd(a1,a2))\n b3=crt(b1,a1,b2,a2)\n # solve stuff easily now\n # python rounds down always\n l=(l-b3+a3-1)//a3\n r=(r-b3)//a3\n print(max(0,r-l+1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "414ceb206c18b683b2b6a5bcf1d88699", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "import math\nx1=input().split()\nx=int(x1[1])\ny=int(x1[0])\nwhile True:\n num=math.log(x,2)\n if num ==0 :\n print('1')\n break\n if round(num,8)%int(num)==0 :\n \tif num >=y:\n \tnum-=y\n print(int(num)+1)\n break\n x = x - (2 ** int(num))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82ec59c49a125f41ff6f564d4a9e3a36", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "#include\n#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define ll long long\nusing namespace std;\nint main()\n{\n ll int ans=0,n,m;\n ll int mod=pow(10,9);\n cin>>n>>m;\n cout< m:\r\n break\r\n dc[x] = 1\r\n if (y := i ** 3) <= m:\r\n dc[y] = 1\r\n i += 1\r\n print(len(dc))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f8e5dbd5c19f265f94d241a687465fbf", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n while len(a) > 0:\n \tm = min(a)\n \ta = [x for x in a if x % m != 0]\n \tcnt += 1\n print(cnt)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22354acf95887e1c38ca921001ecfb4d", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\narr = [j for j in [int(i) for i in input().strip().split()] if j >= 0 else -j]\nprint(sum(arr))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ddc8ff557e8c00731fa559954a30ce86", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "x = []\ny = []\nfor _ in range(8):\n\tpoint = input().split()\n\tx.append(int(point[0]))\n\ty.append(int(point[1]))\n\nx.sort()\n\nif x[0] == x[1] == x[2] and x[2] != x[3] and x[3] == x[4] and x[4] != x[5] and x[5] == x[6] == x[7]:\n\ty.sort()\n\tif y[0] == y[1] == y[2] and y[2] != y[3] and y[3] == y[4] and y[4] != y[5] and y[5] == y[6] == y[7]:\n\t\tprint(\"respectable\")\n\t\tquit()\n\telse:\n\t\tprint(\"ugly\")\n\t\tquit()\nprint(\"ugly\")\n\n0 1\n0 1\n0 2\n1 1\n1 2\n2 3\n2 3\n2 3\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1fecdb78fb40b8a66c440194949245fa", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom math import log2, log, ceil\n\n# swap_array function\ndef swaparr(arr, a,b):\n temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp\n\n## gcd function\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\n\n## nCr function efficient using Binomial Cofficient\ndef nCr(n, k): \n if(k > n - k): \n k = n - k \n res = 1\n for i in range(k): \n res = res * (n - i) \n res = res / (i + 1) \n return res \n\n## upper bound function code -- such that e in a[:i] e < x;\ndef upper_bound(a, x, lo=0):\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if a[mid] < x:\n lo = mid+1\n else:\n hi = mid\n return lo\n\n## prime factorization\ndef primefs(n):\n ## if n == 1 ## calculating primes\n primes = {}\n while(n%2 == 0):\n primes[2] = primes.get(2, 0) + 1\n n = n//2\n for i in range(3, int(n**0.5)+2, 2):\n while(n%i == 0):\n primes[i] = primes.get(i, 0) + 1\n n = n//i\n if n > 2:\n primes[n] = primes.get(n, 0) + 1\n ## prime factoriazation of n is stored in dictionary\n ## primes and can be accesed. O(sqrt n)\n return primes\n\n## MODULAR EXPONENTIATION FUNCTION\ndef power(x, y, p): \n res = 1\n x = x % p \n if (x == 0) : \n return 0\n while (y > 0) : \n if ((y & 1) == 1) : \n res = (res * x) % p \n y = y >> 1 \n x = (x * x) % p \n return res \n\n## DISJOINT SET UNINON FUNCTIONS\ndef swap(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n\n# find function\ndef find(x, link):\n while(x != link[x]):\n x = link[x]\n return x\n\n# the union function which makes union(x,y)\n# of two nodes x and y\ndef union(x, y, link, size):\n x = find(x, link)\n y = find(y, link)\n if size[x] < size[y]:\n x,y = swap(x,y)\n if x != y:\n size[x] += size[y]\n link[y] = x\n\n## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES\ndef sieve(n): \n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * p, n+1, p):\n prime[i] = False\n p += 1\n return prime\n\n#### PRIME FACTORIZATION IN O(log n) using Sieve ####\nMAXN = int(1e6 + 5)\ndef spf_sieve():\n spf[1] = 1;\n for i in range(2, MAXN):\n spf[i] = i;\n for i in range(4, MAXN, 2):\n spf[i] = 2;\n for i in range(3, ceil(MAXN ** 0.5), 2):\n if spf[i] == i:\n for j in range(i*i, MAXN, i):\n if spf[j] == j:\n spf[j] = i;\n ## function for storing smallest prime factors (spf) in the array\n\n################## un-comment below 2 lines when using factorization #################\n# spf = [0 for i in range(MAXN)] \n# spf_sieve() \ndef factoriazation(x):\n ret = {};\n while x != 1:\n ret[spf[x]] = ret.get(spf[x], 0) + 1;\n x = x//spf[x]\n return ret\n ## this function is useful for multiple queries only, o/w use\n ## primefs function above. complexity O(log n)\n\n## taking integer array input\ndef int_array():\n return list(map(int, input().strip().split()))\n## taking string array input\ndef str_array():\n return input().strip().split();\n\n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\n\n\n################### ---------------- TEMPLATE ENDS HERE ---------------- ###################\n\nn = int(input()); string = input().strip(); ans = '';\nnum = 1;\nfor i in string:\n if int(i) > 1:\n for j in range(int(i), 1, -1):\n num *= j\nwhile(num > 1):\n while(num % 5040 == 0):\n ans += '7'; num //=5760;\n while(num % 120 == 0):\n ans += '5'; num //= 120;\n while(num % 6 == 0):\n ans += '3'; num //= 6;\n while(num % 2 == 0):\n ans += '2'; num //= 2;\nprint(ans);", "lang_cluster": "Python", "compilation_error": false, "code_uid": "36c15f3707c3b6df2a4d9b576670973e", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#testing\n r=lambda:map(int,raw_input().split())\n X,Y,Z=r()\n x,y,z=r()\n a=r()\n print (Z>z)*a[3] + (Z<0)*a[2]+(Y>y)*a[1]+(Y<0)*a[0]+(X>x)*a[5]+(X<0)*a[4]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03438a5259d91375684a91e12757504b", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n==0:\n print(\"O-|-OOOO\")\nelse:\n while n!=0:\n if n%10 <= 4:\n print('O',end=\"-\")\n print('|',end=\"\")\n for i in range(n%10):\n print('O',end=\"\")\n print('-',end=\"\")\n for i in range(4-(n%10)):\n print('O',end=\"\")\n else:\n c=0\n print('-',end=\"O\")\n print('|',end=\"\")\n for i in range((n%10)-5):\n print('O',end=\"\")\n c+=1\n print('-',end=\"\")\n for i in range(4-c):\n print('O',end=\"\")\n print()\n n=int(n/10)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04489bbc2a464e711d7e5f7a0da2328a", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#import sys\na=raw_input()\nl=len(a)\nif l<2:\n print 0\n exit()\n \nb=range(len(a))\nb.pop(0)\nb.reverse()\n#print 'b=',b\n#exit()\n#print 'l=',l\nfor s in b:\n #print 's=',s\n for i in range(l-s):\n #print 'i=',i,'a[',i,':',s,']=',a[i:s]\n c=range(i+1,l-s+1)\n #print 'c=',c\n for j in c:\n #print 'j=',j,'a[',j,':',j+s,']=',a[j:j+s]\n if a[i:i+s]==a[j:j+s]:\n print s\n exit()\nprint 0\n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "05b16df5d98541c210e42cf33ba4269d", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "#include \nusing namespace std;\ntypedef long long int LL;\ntypedef unsigned long long int uLL;\ninline int _Int() { int x; scanf(\"%d\",&x); return x; }\nLL bigMod(LL A,LL P,int M){ LL R=1; for(A%=M; P; P>>=1) { if(P&1) R=(R*A)%M; A=(A*A)%M; } return R; } /** (A^P) % M **/\nLL bigMul(LL A,LL B,LL M) { LL R=0; for(A%=M; B; B>>=1) { if(B&1) R=(R+A)%M; A=(A+A)%M; } return R; } /** (A*B) % M **/\nLL negMod(LL A,LL B) { return ( ( ( A % B ) + B) % B ); } /** (A % B) when A is negative or positive **/\nLL invMod(LL A,LL M) { return bigMod( A , M-2, M ); } /** (A^(-1)) % M */\nuLL _pow(uLL A,int P) { uLL R=1; for(; P; P>>=1) { if(P&1) R=(R*A); A=(A*A); } return R; } /** (A^P) **/\ntemplateT GCD(T x, T y) { while(x) x^=y^=x^=y%=x; return y; } /** Greatest Common Divisor( a , b ) **/\ntemplate bool inRng( T u, T v, T x ) { return u<=x && x<=v; } /** check ( u <= x <=v ) */\n#define myMemset(a,b) memset(a,b,sizeof(a))\n#define pi acos(-1)\n#define pb push_back\n#define myDebug(x) cout<<#x<<\" : \"< t):\n\t\tprint a[i]\n\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a85bc7541fc4becd9fdedff062c06ac8", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nx, y = map(int, input().split())\na=y*math.log(x)\nb=x*math.log(y)\nif x==y:\n print<\"=\")\nelse:\n if a>b:\n print(\">\")\n elif(a\n#include \n#include\ntypedef long long ll;\nll power(int p,int q)\n{\n int i;\n ll r=1;\n for(i=0;i= k:\n ccc += 1\n\nprint(ccc)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e62e593e04909d1b215a65b0327207f5", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nif n % 2 == 0 and m > n // 2:\n print((m - n // 2) * 2)\nelif n % 2 == 1 and m > n // 2 + 1:\n print((m - n // 2 - 1) * 2)\nielif n % 2 == 0 and m < n // 2:\n print(m * 2 -1)\nelif n % 2 == 1 and m < n // 2 + 1:\n print(m * 2 - 1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ebae536f2cf3e7ac8c40b001575c446b", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "Python 3", "source_code": "elems = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']\n\ns = str(input())\n\ncando = [False] * len(s)\n\ngood = False\nfor elem in elems:\n if s.startswith(elem):\n cando[len(elem)] = True\n\nfor i in range(1, len(s)):\n for elem in elems:\n ln = len(elem)\n if ln > i + 1:\n continue\n \n substr = s[i+1-ln:i+1]\n if substr == elem:\n cando[i] = cando[i] or cando[i-ln]\n \nif cando[len(s)-1]:\n print('YES')\nelse:\n print('NO')\n\n\"\"\"\nwith open('elements.txt', 'r') as e:\n ele = e.read()\n \nele = ele.split('\\n')\n\nelements = []\n\nfor elem in ele:\n if len(elem) > 0:\n parts = elem.split('-')\n element = parts[0].strip()\n elements.append(element)\n \nres = '['\nfor elem in elements:\n res = res + \"'\" + elem.upper() + \"',\"\nres = res[:-1]\nres += ']'\n\nprint(res)\n\"\"\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b7332dd06ce841871be0d0df10f08d76", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "PyPy 3", "source_code": "//coded by: pranonrahman-------------------------------------\n//-----------------------------------------------------------\n//-----------------------------------------------------------\n#include\nusing namespace std;\n\n\n#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)\n#define endl '\\n'\n#define PI acos(-1.0)\n#define CASE(n) cout << \"Case \" << n << \": \"\n#define CASE_(n) cout << \"Case \" << n << endl\n#define FIXED(n) cout << fixed << setprecision(n)\n#define MOD 1000000007\n\ninline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }\ninline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }\ninline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }\ninline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }\ninline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }\ninline long long modInverse(long long a) { return modPow(a, MOD-2); }\ninline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }\n\n\n\nlong long int bigmod ( long long a, long long p, long long m )\n{\n if ( p == 0 )return 1; \n \n if ( p % 2 ) \n {\n return ( ( a % m ) * ( bigmod ( a, p - 1, m ) ) ) % m; \n }\n else \n {\n long long c = bigmod ( a, p / 2, m ); \n return ( (c%m) * (c%m) ) % m;\n }\n}\n\nint main()\n{\n O_O;\n \n long long n;\n cin >> n;\n long long res = 1ll;\n for(long long i=1;i<=n;i++)\n {\n res = modMul(i,res);\n res%=MOD;\n }\n long long p2 = bigmod(2,n-1,MOD);\n long long ans = (res%MOD - p2%MOD)%MOD;\n cout << ans << endl;\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "acf6691999110ea590396ec87bbfcc65", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\nb = map(int, raw_input().split())\nstart = raw_input().split()\nstart = ((int(start[0]) - 5) * 60) + int(start[2])\nend, count, temp = start + a[1], 0, 0\nwhile temp < end:\n\tif temp >= start: count += 1\n\telif temp + b[1] > start and temp + b[1] < end: count += 1\n\ttemp += b[0]\nprint count\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6f93ac96971a270005e2bae4d6a1ba0", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f(n, l, r):\n if(n > r):\n return 0\n if(n in d):\n return 0;\n if(n >= l):\n d.add(n);\n return 1 + f(2*n, l, r) + f(3*n, l, r)\n return f(2*n, l, r) + f(3*n, l, r)\n\nn, m = map(int, input().split())\nd = set()\nprint(f(1, n, m))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "15ec5c166530f669f90326941bf25267", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "l= list(map(int,input().split()))\n\ns=sum(l)\nif s%5==0:\n print(s//5)\nesle:\n print(\"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a8c268893b45442b567db4a0d4ae08e", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": " n=int(input())\n print(25)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0cf13c308a00e820e051afbdb7047806", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "Python 2", "source_code": "w,h = map(int, raw_input().strip().split())\nw_1, h_1 = map(int, raw_input().strip().split())\nw_2, h_2 = map(int, raw_input().strip().split())\nfor i in range(h,0,-1):\n w += i\n if i == h_1:\n w = max(0,w-w_1)\n if i == h_2\n w = max(0, w-w_2)\nprint w\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "823bb00b527b022a2d4def270776dc89", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\n\nx, y, n = input().split()\nx = int(x)\ny = int(y)\nn = int(n)\nnew = 1\n\nif y < n:\n print(str(x) + '/' + str(y))\nelse:\n for i in range(1, n):\n fraction = x / y\n up = fraction * i\n up1 = math.ceil(up)\n up2 = math.floor(up)\n a = abs(up1 / i - x / y)\n b = abs(up2 / i - x / y)\n if a > b and b 0:\n mass.append(m % w)\n m //= w\nmass.append(0)\nfor i in range(len(mass)):\n if mass[i] == w - 1:\n mass[i + 1] += 1\n if mass[i] >= w - 1:\n mass[i] = 0\nok = 1\nfor i in range(len(mass)):\n if mass[i] > 1:\n ok = 0\nprint(\"NO\" if ok == 0 and w != 2 else \"YES\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "236f94f9887b48cd4f509f30dcb72e2c", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n, k, t = map(int, input().split())\nif t < k:\n print(t)\nelif t < n:\n print(k)\nelse\n print(n + k - t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "743f5a9be969ebcfab5a0886824a2b39", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\ncnt=s.count('x')-s.count('X')\nprint(abs(cnt/2))\ns=list(s)\nfor i in range(len(s)):\n if cnt>0 and s[i]=='x':\n s[i]='X'\n cnt-=2\n elif cnt<0 and s[i]='X':\n s[i]='x'\n cnt+=2\nprint(''.join(s))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cdd97b97ee32098a16298246ed2f6717", "src_uid": "fa6311c72d90d8363d97854b903f849d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\n\nmod = int(1e9 + 7)\n\n\ndef calca(n, k):\n global mat\n if k == 0:\n return 1\n if mat[n][k] != -1:\n return mat[n][k]\n mat[n][k] = 0\n for i in range(1, n-1):\n mat[n][k] += (n-1-i)*calca(i, k-1)\n mat[n][k] %= mod\n return mat[n][k]\n\n\ndef main():\n global mat\n mat = [[-1 for i in range(1001)] for j in range(1001)]\n a, b, c = [int(x) for x in input().split()]\n print((calca(a, c) * calca(b, c)) % mod)\n\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56d22cfa307eb646ad4bc005ae1dacca", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "b=int(input())\ng=int(input())\nn=int(input())\nif (nb and n >g :\n if b==g:\n if n==2*b:\n print(1)\n else:\n print((n+1)-(2*(n-max(b,g)))\n else:\n print(max(b,g)-n+min(b,g)+1)\nelse:\n print(n+1-(n-min(b,g)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb80c9ada90c2f8d2c710ff5b30dd150", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "t = input().split(' ')\nn, m = t\ncount = 0\n\nif m % 2 != 0:\n m++\n count++\n \nwhile m % 2 == 0:\n m /= 2\n if n >= m:\n break\nelse:\n while n < m:\n n *= 2\n count++\nwhile n != m:\n n--\n count++\nwhile n != t[1]:\n n *= 2\n count++\n\nprint(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4079dbef830f7616ec69c18c71686201", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "nums = list(map(int,raw_input().split()))\nnums2 = list(map(int,raw_input().split()))\ns1 = [[nums[0],nums[1]],[nums[2],nums[3]],[nums[4],nums[5]],[nums[6],nums[7]]]\ns2 = [[nums2[0],nums2[1]],[nums2[2],nums2[3]],[nums2[4],nums2[5]],[nums2[6],nums2[7]]]\n\nlines = [[s1[0],s1[1]],[s1[1],s1[2]],[s1[2],s1[3]],[s1[3],s1[0]]]\nlines2 = [[s2[0],s2[1]],[s2[1],s2[2]],[s2[2],s2[3]],[s2[3],s2[0]]]\n\nminx = min(s1[0][0],s1[1][0],s1[2][0],s1[3][0])\nmaxx = max(s1[0][0],s1[1][0],s1[2][0],s1[3][0])\nminy = min(s1[0][1],s1[1][1],s1[2][1],s1[3][1])\nmaxy = max(s1[0][1],s1[1][1],s1[2][1],s1[3][1])\n\nfor i in s2:\n if i[0] >= minx and i[0] <= maxx and i[1] >= miny and i[1] <= maxy:\n ans = 1\n\narea = pow(s2[0][0]-s2[1][0],2)+pow(s2[0][1]-s2[1][1],2)\n\ndef triangle(num,num1,num2):\n a = pow((num[0]-num1[0])**2+(num[1]-num1[1])**2,0.5)\n b = pow((num[0]-num2[0])**2+(num[1]-num2[1])**2,0.5)\n c = pow((num1[0]-num2[0])**2+(num1[1]-num2[1])**2,0.5)\n s = (a+b+c)/2\n return pow(s*(s-a)*(s-b)*(s-c),0.5)\n\nfor i in s1:\n res = 0\n for j in lines2:\n res += triangle(i,j[0],j[1])\n if res==area:\n ans = 1\nif ans:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6fe2984719658d35b05377ce6f952f01", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from itertools import *\nl = map(int,raw_input().strip().split())\nops = raw_input().strip().split()\n\nop = lambda o, a, b: a*b if o=='*' else a+b\n\nprint min(\\\n min(op(ops[2],op(ops[1],op(ops[0],l[0],l[1]),l[2]),l[3]) for p in permutations(l,4)),\\\n min(op(ops[2],op(ops[0],l[0],l[1]),op(ops[1],l[2],l[3])) for p in permutations(l,4)))\n \n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9edb4865c6240901b38d72b9a65d50a", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "code = input()\ncode = code.replace('--', '2')\ncode = code.replace('-.-, '1')\ncode = code.replace('.', 0)\nprint (code)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a69ec316a5e547efae0796e3caf6389", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\n\nphr=raw_input().split()\n\nphr=map(int,phr)\nN=phr[0]\nA=phr[1]\nB=phr[2]\n\nsize=A*B\n\nif(6*N<=size):\n print \"%d\\n%d %d\" %(size,A,B)\n\nelse:\n swap=False\n if(A>B):\n keep_A=B\n keep_B=A\n swap=True\n \n\n new_size=6000000000\n \n while(keep_A*keep_A<=6*N):\n keep_B=math.ceil(6.0*N / keep_A)\n\n if(keep_A*keep_B=8:\n\t\tk = k - 8\n\t\tprev = a[i] + prev -8\n\telse:\n\t\tk = k - a[i] + prev\n\t\tprev = 0\n\ti = i +1\n\tans = ans + 1\nif k<=0:\n\tprint ans\nelse:\n\tprint \"-1\"\n\t\n# your code goes here", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed21322443d223f821300862a762d321", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n# How to multiply matrices in 32 bit python?\n# Solution use numpy py\n\nimport _numpypy\nnp = _numpypy.multiarray\n\n# Windows pypy is 32 bit\n# So I'm using longlong from numpypy\nlltype = np.dtype('int64')\nllzero = lltype.type(0)\n# This is around 60 times faster than lltype.type(x) ?????!!!\ndef ll(x):return llzero + x\n\nMOD = ll(10**9+7)\nllone = ll(1)\nmod_prod = lambda a,b,c=llzero:return int((ll(a)*b+c)%MOD)\n\ndef mult(A,B):\n n,m = len(A[0]),len(B)\n C = [[0]*n for _ in range(m)]\n for j,B_j in enumerate(B):\n C_j = C[j]\n for k,A_k in enumerate(A):\n Bkj = B_j[k]\n for i,Aik in enumerate(A_k):\n C_j[i] = mod_prod(Aik,Bkj,C_j[i])\n return C\n\n# Calc A^n*B\ndef power(A,B,n,mult_func):\n if n == 0:\n return B\n while n>1:\n if n%2==1:\n B = mult_func(A,B)\n A = mult_func(A,A)\n n//=2\n return mult_func(A,B)\n\n##### EXAMPLE\nn,m = [int(x) for x in input().split()]\n\n#def DP(n):\n# if n<=0:\n# return 1 if n==0 else 0\n# else:\n# return DP(n-m) + DP(n-1)\n\nmat = [[0]*m for _ in range(m)]\n\nmat[0][0] += 1\nmat[-1][0] += 1\nfor i in range(m-1):\n mat[i][i+1] += 1\n\nvec = [[0]*m]\nfor i in range(m):vec[0][i] += 1\n\nvec = power(mat,vec,n,mult)\nprint(vec[0][-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2dd2598b4e8647dbfea0f58382f95f05", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "\ninput()\nangs = [int(x) for x in input().split()]\n\nresult = 99999\nfor i in range(len(angs))\n curr = 0\n for j in range(i, i + len(angs)):\n curr += angs[j % len(angs)]\n result = abs(180-curr) if abs(180-curr) < result else result\nprint(2*result)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3f0775d63287c4a3f230f440ad5b00c7", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "// http://codeforces.com/contest/1296/problem/E1\n#include \n#include \n\ntypedef unsigned long long ull;\ntypedef unsigned long ul;\n\nusing namespace std;\n\nclass Node {\n public:\n char letter;\n int idx;\n bool color = false;\n vector dependencies;\n \n Node(char ltr, int idx) {\n this->letter = ltr;\n this->idx = idx;\n }\n\n bool operator== (const Node &other) {\n return letter == other.letter and idx == other.idx;\n }\n\n void addDependency(Node *node) {\n assert(!count(dependencies.begin(), dependencies.end(), node));\n dependencies.push_back(node);\n // cout << dependencies.size() << endl;\n }\n};\n\n// Checks if a node's dependency path exceeds given max depth\nbool checkDepDepth(Node *node, int maxDepth=1) {\n if (maxDepth < 0) return false;\n for(auto n : node->dependencies) {\n n->color = !node->color;\n if (!checkDepDepth(n, maxDepth-1)) return false;\n }\n return true;\n}\n\nint main(int argc, const char** argv) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int x;\n cin >> x;\n string chars;\n cin >> chars;\n vector nodes;\n for(int i = 0; i < chars.length() ; i++) {\n nodes.push_back(Node(chars.at(i), i));\n }\n for (int i1 = 0; i1 < nodes.size(); i1++) {\n Node &n1 = nodes.at(i1);\n for (int i2 = i1 + 1; i2 < nodes.size(); i2++) {\n Node &n2 = nodes.at(i2);\n if (n2.letter < n1.letter) {\n n1.addDependency(&n2);\n }\n }\n }\n string colors;\n for(auto &n : nodes) {\n if (!checkDepDepth(&n, 1)) {\n cout << \"NO\" << endl;\n return 0;\n }\n colors.push_back(n.color ? '1' : '0');\n }\n cout << \"YES\" << endl << colors << endl;\n}\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c8c756024c2bf9a7ba164e5e5c48b78a", "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "import sys, re\nfrom math import *\nfrom collections import defaultdict\nfrom string import ascii_lowercase as lcs\nfrom string import ascii_uppercase as ucs\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations, count\n#getcontext().prec = 500\n#sys.setrecursionlimit(30000)\n\nmod = 10**9 + 7\n\nraw_input = lambda: sys.stdin.readline().rstrip()\ndie = lambda : exit(0)\nflush= lambda : sys.stdout.flush()\n\nr_s = lambda: raw_input() #read str\nr_ss = lambda: raw_input().split() #read stringss\nr_i = lambda: int(raw_input()) #read int\nr_is = lambda: map(int, raw_input().split())#read ints\nr_f = lambda: float(raw_input()) #read float\nr_fs = lambda: map(Decimal, raw_input().split()) #read floats\n\n'''-------------------------------------------------------------------'''\n\nwhile True:\n s=r_s()\n p=re.compile('^\\w{1,16}@[\\w.]{1,32}(/\\w{1,16})?$')\n ans=p.search(s)\n if ans==None:\n print \"NO\"\n else:\n a=s.split('@')\n b=a[1].split('/')[0]\n nums=b.split('.')\n check=True\n for i in nums:\n if len(i)>16:\n check=False\n if check:\n print \"YES\"\n else:\n print \"NO\"\n #break\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f5c2e5a39f785968dc830fa352df45c", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nl = [2, 3]\ni = 0\nwhile (n-1) > len(l):\n l += [(i+2)*2]*(i + 2)\n l += [(i+2)*2 + 1]*(i + 2)\n i += 1\nprint(l[n-1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "10c562551c1c4cfa00e6308d05ccd253", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=(input())\nl=input()\nprint(2*(min(l.count('U'),l.count('D'))+min(l.count('L'),l. count('R'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "869c4091ba94a5cceb334c2975be6dca", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "inp = input().split(\"\\\\s\")\ndays = inp[0]\nsumTime = inp[1]\ndays = {}\nwhile days-->0 :\n inp = input().split(\"\\\\s\")\n days.append((inp[0],inp[1]))\nprint(\"hi\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e43f337613518a1bf41345145af6cc2a", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\nd= {}\nfor i in range(2*n) :\n\ta = int((i/2*(i+1))%n)\n\tif d.setdefault(a) == None :\n\t\td[a] = 1\n\n\nif len(d) == n :\n\tprint('YES')\nelse :\n\tprint('NO')\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c464163baa7436ad135bee3119dcf21", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "N = input()\nK = input()\nans = 0\nstuff = []\nsi = 0\nei = 0\nwhile ei < len(K):\n if int(K.substr(si, ei+1)) > N:\n stuff.append(K.substr(si, ei))\n si = ei\n ei++\nfor i in range(len(stuff)):\n ans += stuff[i]*(N**(len(stuff)-i-1))\n\nprint(ans + \"\\n\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10f82e2ed34acd18e7895f7a363e1194", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "a,b= input().split()\n\nli= list(map(int, input().split()))\nc= int(a)-li[0] +1\ns= ''\n\ni=0\nwhile i 0:\t\n\tres = -1\n\t# \u0446\u0438\u043a\u043b \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\n\tfor i in range(int(math.ceil(p/n)) + 1)\n\t\t# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\n\t\tj = p - n*i\n\t\tif j < 0:\n\t\t\tj = 0\n\t\t# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 i \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438 j \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0443\u043d\u0434\u0430\u0445\n\t\tz = c*i + d*j\n\t\t#print i, j, z\n\t\tif res < 0 or z < res:\n\t\t\tres = z\nelse:\n\tres = 0\n\t\nprint res", "lang_cluster": "Python", "compilation_error": true, "code_uid": "339b62fce946df9f1b2081e506d635a0", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "def ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\nimport math\n\nla, ra, ta = mi()\nlb, rb, tb = mi()\nif la > lb:\n la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta\nlb -= la\nra -= la\nrb -= la\ndif = math.gcd(ta, tb)\ndifl = lb\n\noff1 = difl % dif\nans1 = min(ra, off1 + rb - lb) - max(0, off1) + 1\noff2 = off1 - dif\nans2 = min(ra, off2 + rb - lb) - max(0, off2) + 1\nans = max(ans1, ans2)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8575923c90b4c0b70118d1258ed394dc", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "arr = [[0]*3 for _ in range(3)]\nsu=[]\n#print (arr)\nfor i in range(3):\n a,b,c=map(int,input().split())\n arr[i][0]=a\n arr[i][1]=b\n arr[i][2]=c\n su.append(a,b,c)\nk=set(su)\nif len(k)==1:\n\n for i in range(3):\n\n\n\n arr[i][0]=k[0]\n arr[i][1]=k[0]\n arr[i][2]=k[0]\nelse:\n for i in range(3):\n\n if (a==0):\n su1=su[0]\n a=15-su1\n elif(b==0):\n su2=su[1]\n b=15-su2\n else:\n su3=su[2]\n c=15-su3\n\n arr[i][0]=a\n arr[i][1]=b\n arr[i][2]=c\nfor i in range(3):\n for j in range(3):\n print (arr[i][j],end=\" \")\n print ()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fa1023771502cc84a9f8b7c00f4f2c7", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = str(input())\ne = s.split(\" \")\ncheck = int(e[0])\ntruth = False\n#answer = 0\nwhile truth == False:\n check+=1\n truthTwo = True\n for i in range(2, check):\n if check%i==0:\n truthTwo = False\n if truthTwo = True:\n #answer=check\n break;\nif check!+int(e[1]):\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f1f52c0d92f779c2bb48dc1452033576", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def main():\n n, m, k = map(int, input().split())\n if n < m:\n n, m = m, n\n lo, hi = 2, min(n * m, (k + 1) ** 2 // 2) + 1\n while lo < hi:\n a = (lo + hi) // 2\n u = sum(a // i for i in range(a // n + 1, (m if m < a else a) + 1)) + a // n * n\n if u < k:\n lo = a + 1\n elif u > k:\n hi = a\n else:\n lo = hi = a\n res = [hi // i * i for i in range(hi // n + 1, (m if m < hi else hi) + 1)] + [n] * (a // n)\n res.sort(reverse=True)\n print(res[u - k])\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eab2427a1afb31982f08467ee2126762", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def Num_of_Coins():\n\n num , Sum = [int(x) for x in input(\"\").split()]\n\n if(Sum%num==0)):\n return Sum/num\n else:\n return int(Sum/num) + 1 \n\nprint(Num_of_Coins())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10028b9bf9ef5a552138aaa4508474a6", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\n\nn, m = map(int, input().split())\n\nx = (1 + (8*m)**(1/2))/2\n\nmaxI = n - math.ceil(x)\nminI = max(n - m*2, 0)\nprint(str(minI) + \" \" str(maxI))\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff977fb7db53652039eafc6b98250ea1", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def power(x, y): \n \n if(y == 0): return 1\n temp = power(x, int(y / 2)) \n \n if (y % 2 == 0): \n return temp * temp \n else: \n if(y > 0): return x * temp * temp \n else: return (temp * temp) / x \nn=int(input())\n\n\nif n==1:\n print(0)\nelse if n==2:\n print(3)\nelse if n==3:\n print(6)\nelse: \n print(int((((-1)*3*power(-1,n-3)+27*power(3,n-3))/4)%(1000000007))) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4f77adc811106b2bcbb6a31a3011f5c0", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "totalpageno = int(input())\npageno = int(input())\nshowpagelst = int(input())\nlst = pageno - showpagelst\nshowlst = pageno + showpagelst\nif(lst>1):\n print('<<',end=' ')\nfor i in range(lst,pageno+1):\n if(i == pageno):\n print(f\"({i})\",end=' ')\n else:\n print(i,end=' ')\nfor i in range(pageno+1,showlst+1):\n if(i<=totalpageno):\n print(i,end=' ')\nif(showlst>')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1e7b6e11f847b49fafe39098ea12a1e", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Python 3", "source_code": "import sys\nput=input().split()\nput1=input().split()\nfor i in put1:\n i=int(i)\nput2=input().split()\nfor n in put2:\n n=int(n)\nk=0\nif len(put1)!=put[0] or len(put2)!=put[1]:\n \nfor i in put1:\n for n in put2:\n if int(i)== int(n):\n if int(n)0:\n print(k)\n sys.exit()\n else:\n if min(put1)>min(put2):\n print(str(min(put2))+str(min(put1)))\n else:\n print(str(min(put1))+str(min(put2)))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cad95872b86f5864c97187a9a47ff49d", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def ans(n):\n if n%3 == 0 or n%7 ==0:\n return True\n else if n<3:\n return False\n \n sol = ans(n-7) or ans(n-3)\n return sol\n \n \n \ntest_cases = int(input())\nwhile test_cases!=0 :\n x = int(input())\n if ans(x):\n print(\"YES\")\n else:\n print(\"NO\")\n test_cases = test_cases-1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a68a65fe600317c21453178e36f4bf15", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "import math\nside,x,y=map(int,input().split())\nz=math.ceil(y/side)\nif z==1 or z%2==0 :\n if abs(x)>=side/2 or y%side==0:\n print(-1)\n else:\n print(((z-1)//2)+z) \nelse:\n if abs(x)>=side or y%side==0 or x==0:\n print(-1)\n else:\n \n if x>0:\n print(((z-1)//2)+z)\n else: \n print(((z-2)//2)+z)\n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78bec74146489d636f0b27689954a75a", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "m=[2**i for i in xrange(19)]\ndef madd(*a):\n m.append(sum(map(lambda x: 2**x,a)))\ndef padd(l):\n for i in range(2,len(l)+1):\n for j in range(len(l)-i+1):\n madd(*l[j:j+i])\n\na1 = ([0,3,7],[1,4,8,12],[2,5,9,13,16],[6,10,14,17],[11,15,18])\nmap(padd,a1+([0,1,2],[3,4,5,6],[7,8,9,10,11],[12,13,14,15],[16,17,18],[7,12,16],[3,8,13,17],[0,4,9,14,18],[1,5,10,15],[2,6,11]))\n \na = ' '.join(raw_input() for i in xrange(5)).split()\npx = sum([2**y for x,y in zip(a,sum(a1,[])) if x=='O'],0)\nq = [False]*600000\nm.sort()\nfor i in xrange(0,px+1):\n if q[i]: continue\n for p in m:\n if i&p: continue\n q[i|p] = True\n \nprint \"Karlsson\" if q[px] else \"Lillebror\"\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "006999e1efd7da24a716a30cafe1215e", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "cube = [ [13,14,5,6,17,18,21,22],\n\t\t[14,16,9,10,19,17,4,3],\n\t\t[1,3,5,7,9,11,24,22],]\ndef rotate(seq, i):\n\tlst = []\n\tfor x in range(8):\n\t\tlst.append(seq[cube[i][x] -1 ])\n\tfor j in range(4):\n\t\tlst = lst[2:]+ lst[:2] \n\t\tfor x in range(8):\n\t\t\tseq[cube[i][x] -1]= lst[x]\n##\t\tprint(seq)\n\t\tif (check(seq)):\n\t\t\treturn True\n\treturn False\n\ndef check(seq):\n\tfor j in range(6):\n\t\tif len(set(seq[j*4 :j*4 +4])) != 1:\n\t\t\treturn False\n\treturn True\n\nseq = list(map(int,input().split()))\nfor k in range(4):\n\tif (rotate(seq,k)) :\n\t\tprint(\"yes\")\n\t\tbreak\nelse:\n\tprint(\"no\")\n#rotate(seq,1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec414f069e78b1497bf94cc9be5ffafd", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "w, h = map(int, input().split())\nif w < 2 or h < 2:\n print(0)\nelse:\n for x in range(2, w + 1, 2):\n for y in range(2, h + 1, 2):\n print((w // x) * (h // y))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9adc9ad4a994356dbf48084bf2d1b9c", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = input().split()\nnum = [ int(i) for i in n ] \nmisha_points = num[0]\nvasya_points = num[1]\nmisha_time = num[2]\nvasya_time = num[3]\nif\nmisha_score = max( (0.3*misha_points) , (misha_points - (misha_points/250) * misha_time) )\nvasya_score = max( (0.3*vasya_points) , (vasya_points - (vasya_points/250) * vasya_time) )\n \nif misha_score > vasya_score :\n print(\"Misha\")\nelif vasya_score > misha_score :\n print(\"Vasya\")\nelse :\n print(\"Tie\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b352e108eae172d04d3e65b4c37a2ae3", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n, l,r = map(int, raw_input().split())\nif n == 0:\n return 0\nif n == 1:\n return 1\n\na = [0]\n\nwhile n >= 2:\n a.append(n % 2)\n n /= 2\nans = r - l + 1 \nfor i in range(1, len(a)):\n if a[i] == 0:\n d = len(a) - i + 1\n ans -= len([j for j in range(l, r + 1) if j % (2**(d)) == 2**(d-1)])\n \nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2837598e36bb902198e48cf68d0b3474", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "print(sorted(list(map(int, input().split())))[int(input()) // 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fe10822e0e66c8baeaa220239221613a", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "ef s():\n\tinput()\n\ta = list(map(int,input().split()))\n\ta.sort()\n\tfor i in range(1,len(a)):\n\t\tif a[i]0 and dist>0:\n print(int(divmod(dist,2*r)[0]))+1)\nelse:\n print(int(divmod(dist,2*r)[0])))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70a4f9f65e478948e0ad5253dea274d1", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n = int(input())\n\nprint((n**3 + 5n) / 6)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3687e5af3713694baf5f6a78436cfd4", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b = input().strip().split(' ')\na, b = [int(a), int(b)]\nn=b//2\nm=1\nM=10**14\nmid=(m+M)//2\ns=((mid)*(mid+1)//2)\ns1=s+mid+1\nwhile not (s<=n and s1>n):\n if n==0:\n mid=0\n break\n mid=(m+M)//2\n s=((mid)*(mid+1)//2)\n s1=s+mid+1\n if sn:\n M=mid\n else:\n break\nm=int(a**0.5)\nif m>mid:\n print(\"Valera\")\nelse:\n print(\"a, b = input().strip().split(' ')\na, b = [int(a), int(b)]\nn=b//2\nm=1\nM=10**14\nmid=(m+M)//2\ns=((mid)*(mid+1)//2)\ns1=s+mid+1\nwhile not (s<=n and s1>n):\n if n==0:\n mid=0\n break\n mid=(m+M)//2\n s=((mid)*(mid+1)//2)\n s1=s+mid+1\n if sn:\n M=mid\n else:\n break\nm=int(a**0.5)\nif m>mid:\n print(\"Valera\")\nelse:\n print(\"Vladik\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "061672aba14a0982bbdce1c1261e08ac", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a, b = (int(i) for i in input().split())\n\nwhile a > 0 and b > 0:\n if a >= 2b:\n a -= 2b\n \n elif b >= 2a:\n b -= 2a\n \n else:\n break\n \nprint(a, b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79c78dad7f65ef35c7cbb58fc0d6c2a6", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std; \n \n/* Link list node */\nstruct Node { \n int data; \n struct Node* next; \n Node(int data) \n { \n this->data = data; \n next = NULL; \n } \n}; \n \nstruct LinkedList { \n Node* head; \n LinkedList() \n { \n head = NULL; \n } \n \n /* Function to reverse the linked list */\n void reverse() \n { \n // Initialize current, previous and \n // next pointers \n Node* current = head; \n Node *prev = NULL, *next = NULL; \n \n while (current != NULL) { \n // Store next \n next = current->next; \n \n // Reverse current node's pointer \n current->next = prev; \n \n // Move pointers one position ahead. \n prev = current; \n current = next; \n } \n head = prev; \n } \n \n /* Function to print linked list */\n void print() \n { \n struct Node* temp = head; \n while (temp != NULL) { \n cout << temp->data << \" \"; \n temp = temp->next; \n } \n } \n \n void push(int data) \n { \n Node* temp = new Node(data); \n temp->next = head; \n head = temp; \n } \n}; \n \n/* Driver program to test above function*/\nint main() \n{ \n /* Start with the empty list */\n LinkedList ll; \n ll.push(20); \n ll.push(4); \n ll.push(15); \n ll.push(85); \n \n cout << \"Given linked list\\n\"; \n ll.print(); \n \n ll.reverse(); \n \n cout << \"\\nReversed Linked list \\n\"; \n ll.print(); \n return 0; \n} \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e6fc58f0e10ee61fd78f49b90c0462c1", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n=int(input())\n if n==11 or n==21:\n print(4)\n elif n==20:\n print(15)\n elif 12<=n<=19:\n print(4)\n else: \n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "637cd761cf6057099497452c02e649ff", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#include \n\nusing namespace std;\n\ntypedef pair pii;\ntypedef long long ll;\nbool isPrime(ll n)\n{\n int m = sqrt(n);\n for (int i = 2; i <= m; ++i)\n {\n if (n % i == 0)\n return false;\n }\n return true;\n}\n\nvector d;\nint main(int argc, char const *argv[])\n{\n ll n;\n cin >> n;\n if (isPrime(n))\n return 0 * printf(\"%lld\", n);\n for (ll i = 2; i <= n; ++i)\n {\n if (n % i == 0)\n d.emplace_back(i);\n while (n %i == 0)\n n /= i;\n }\n if (n > 1)\n d.emplace_back(n);\n if (d.size() == 1)\n printf(\"%lld\", d[0]);\n else\n printf(\"1\");\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72bbaf66ae0dd3ffa250d3c070901502", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=input()\np=True\nwhile(p):\n\tfor item in n:\n\t sum=0\n\t\tsum=sum+int(item)\n\tif sum%4==0:\n\t\tprint(n)\n\t\tp=False\n\telse:\n\t\tn=int(n)+1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8c890b1f13f737c08462580d99773fc", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "// Solution to codeforces.com/problems/821/B\n#include\nusing namespace std;\nint main()\n{\n int m,b;\n cin>>m>>b;\n int x_cept = m*b, y_cept = b;\n long long max=0, cost;\n\tfor (int y_up = 0; y_up <= y_cept; y_up++)\n {\n int x_rt = m*(b-y_up);\n cost = ((long long)(x_rt+1)*(y_up+1)*(x_rt+y_up))/2;\n //cout<<\"At y_up=\"< max)\n max = cost;\n else break; ///optimisation\n }\n\tcout<':\n\t\tdic[arg[0]] += 1;\n\telse:\n\t\tdic[arg[2]] += 1;\nresult = ''\nif dic['A'] == dic['B'] or dic['B'] == dic['C'] or dic['A'] == dic['C']:\n\tprint 'Impossible'\n\tsys.exit(1)\nfor key in dic.keys():\n\tif dic[key] == 0:\n\t\tprint 'Impossible'\n\t\tsys.exit(1)\nfor i in range(0, 3):\n\tfor key in dic.keys():\n\t\tif dic[key] == i:\n\t\t\tresult += key\nprint result\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "66f12f5f03ba98346792375c27ae2d23", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from sys import stdin,stdout\n\nimport bisect\n\nimport math\n\ndef st():\n return list(stdin.readline().strip())\n\ndef inp():\n return int(stdin.readline())\n\ndef li():\n return list(map(int,stdin.readline().split()))\n\ndef mp():\n return map(int,stdin.readline().split())\n\ndef pr(n):\n stdout.write(str(n)+\"\\n\")\n\ndef soe(limit):\n l=[1]*(limit+1)\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n\n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime\n\ndef segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit>1\n return r\n \ndef solve():\n n=inp()\n s=input()\n pr(n+1)s\n \n\n\n\nfor _ in range(inp()):\n solve()\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04a4fe9a2df5b5bbc4a9125acb5bc097", "src_uid": "098ade88ed90664da279fe8a5a54b5ba", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m,k = input().split()\na=input()\nm=int(m)\nk=int(k)\navailable=[]\norder=[]\nfor i in a :\n if(i !=\" \"):\n order.append(i)\nfor j in order :\n order[j]=int(order[j])\n if (order[j]>0 and order[j]<=k):\n available.append(j)\nif(len(available)==1):\n print(10*(abs(j-m)+1)\n return 0\nmin = 1000\nfor l in available :\n c = abs(l-m)\n if(c0?x:-x;}s(x){return x/w(x);}\nx,y,z,a,b;main(){\n scanf(\"%d%d\",&x,&y);z=(w(x)+w(y));\n (x<0)?(a=-z,b=z):(a=b=z*s(y));\n printf((x<0)?\"%d 0 0 %d\":\"0 %d %d 0\",a,b);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a82f8da4095633fd2b9edf2a4c520b67", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def f(dp,x,y,n):\n if dp[n]!=-1:\n return dp[n] \n if n%2==1:\n ans=min(x+f(dp,x,y,n-1) , x+y+f(dp,x,y,(n+1)//2))\n else:\n ans=min(x+f(dp,x,y,n-1) , y+f(dp,x,y,n//2))\n dp[n]=ans\n return ans\n\nn,x,y=map(int,input().split())\ndp=[-1 for i in range(n+10)]\ndp[1]=x\nprint(f(dp,x,y,n))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9c5ead376a28449113c39a7da49af655", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "s=[int(n) for n in input()]\nz=[int(n) for n in input()]\ns.sort()\nm=v=0\nfor n in range(len(s)):\n\tif s[n]!=0:\n\t\ts[0]=s[n]\n\t\ts[n]=0\n#1\u00b3print(s)\nfor n in range(len(s)):Aa:\n\tm+=s[n]*10**(n)\nfor n in range(len(z)):\n\tv+=z[n]*10**(n)\nif m==v:\n\tprint('OK')\nelse:\n\tprint('WRONG_ANSWER')\n\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03fa8dada010d32f6f81cc55e4da03ae", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\nimport math\n\nn, m, k = [ int(i) for i in raw_input().split() ]\n\ndivisible = False\n\nif 2 < int( math.sqrt( m ) ):\n\tfor i in range( 2, int( math.sqrt( m ) )+1 ):\n#\t\tprint int(m/i), m, i\n\t\tif m%i == 0 and i >= k:\n\t\t\tdivisible = True\n\t\t\tbreak\n\t\tif m%i == 0 and int(m/i) >= k:\n\t\t\tdivisible = True\n\t\t\tbreak\n\nif m == 2 and k == 1:\n\tdivisible = True\n\nif k == 1\n\tdivisible = True\n\nif divisible:\n\tif ( n%2 ):\n\t\tprint \"Timur\"\n\telse:\n\t\tprint \"Marsel\"\nelse:\n\tprint \"Marsel\"\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b10a22ab0ee955c28cf84c030fcf6e1", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "s = input()\n\nq1 = 0\n\nfor c in s:\n if c == \"Q\":\n q1 += 1\n \ncount = 0\nq2 = 0\nfor c in s:\n if c == \"Q\":\n q2 += 1\n q1 -= 1\n if c == \"A\":\n count += q1*q2\n \nreturn count", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5f3a5105cee1fff6644b34e42df1c71", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ufeffa=input()\nb=input()\n\nif a=='monday':\n if b=='monday' or b=='wednesday' or b=='thursday':\n print('YES')\n else:\n print('NO')\nif a=='tuesday':\n if b=='tuesday' or b=='thursday' or b=='friday':\n print('YES')\n else:\n print('NO')\nif a=='wednesday':\n if b=='wednesday' or b=='friday' or b=='saturday':\n print('YES')\n else:\n print('NO')\nif a=='thursday':\n if b=='thursday' or b=='saturday' or b=='sunday':\n print('YES')\n else:\n print('NO')\nif a=='friday':\n if b=='friday' or b=='sunday' or b=='monday':\n print('YES')\n else:\n print('NO')\nif a=='saturday':\n if b=='saturday' or b=='monday' or b=='tuesday':\n print('YES')\n else:\n print('NO')\nif a=='sunday':\n if b=='sunday' or b=='tuesday' or b=='wednesday':\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8afc603b901dad9eb62e11b14c70b112", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\nk = int(n,2)\nif k >= 64:\n print(\"yes\")\nelse:\n print(\"no\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "21a2237f2d596bfa503912302d22a1e8", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "answer = \"NO\"\nfor i in range(4):\n l, s, r, p = map(int, input().split())\n if p == 1:\n if (l != 0) or (s != 0) or (r != 0):\n answer = \"YES\"\nprint(answer)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7e48939e3bf80e657f57dfdc848a451", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "arr = [1, 0, , 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\n\na = int(raw_input())\nprint arr[a-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90174d3ab75126f806f958f013e4e27c", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\ndef main():\n input = sys.stdin.readline\n s = input()[:-1]\n t = input()[:-1]\n n = len(s)\n m = len(t)\n def LCS(S,T):\n dp=[[0 for i in range(len(T)+1)] for j in range(len(S)+1)]\n for i in range(len(S)):\n for j in range(len(T)):\n dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])\n if S[i]==T[j]:\n dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)\n return dp[len(S)][len(T)]\n\n ans = 0\n for k in range(n):\n for l in range(k,n):\n# print(k,s[k:l+1],n-l-1)\n if LCS(s[k:l+1],t) == m:\n ans = max(ans,k,n-l-1)\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bc950f3efac20f0799a0e455dbef39ef", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\ndef get_ans(n, k, array):\n logging = {0:[]}\n for i in array:\n steps = 0\n temp = i\n while temp > 0:\n if temp not in logging.keys():\n logging[temp] = [steps]\n else:\n logging[temp].append(steps)\n temp = temp // 2\n steps +=1\n logging[0].append(steps)\n \n ans = sum(logging[0])\n for key, values in logging.items():\n if len(values) >= k:\n temp_ans = sum(sorted(values)[0:k])\n if temp_ans < ans:\n ans = temp_ans\n \n\n return ans\nn, k = list(map(int, input().strip().split()))\narray = list(map(int, input().strip().split()))\nprint(get_ans(n, k, array))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b84aa48cf155b0a2948cba7e2b0578c", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "# Ammirhossein Alimirzaei\n# Email: Amirhosseiny76@ayhoo.com\n# Instagram : Amirhossein_Alimirzaei\n# Telegram : @HajLorenzo\n\nN=list(input())\nln=len(N)-1\nTMP=10-int(N[ln])\nif TMP<5:\n N[ln] = 0\n if(ln>1):\n N[ln-1] = int(N[ln-1])+1\n else:\n print(1,N[ln],sep=\"\")\n exit()\nelse:\n N[ln] = 0s\nprint(*N,sep=\"\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d03f0efa82c95c322c97e1d062f143d", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "1.py", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e514c1e3b918da2c3ff866cd4651d20d", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "h, m = raw_input().split(\":\")\nif int(h) < 6 or (int(h) > 9 and int(h) < 16) or (int(h) > 19 and int(h) < 23):\n if len(str(int(h))) > 1:\n if int(\"\".join(reversed(h))) > int(m):\n print h + \":\" + \"\".join(reversed(h))\n else:\n if int(h) + 1 == 16:\n print \"20:02\"\n else:\n print str(int(h) + 1) + \":\" + \"\".join(reversed(str(int(h) + 1)))\n else:\n if int(h) * 10 > int(m):\n print h + \":\" + str(int(h) * 10)\n else:\n if int(h) + 1 == 6:\n print \"10:01\"\n else:\n print \"0\" + str(int(h) + 1) + \":\" + str(int(h) + 1) + \"0\"\nelif int(h) > 5 and int(h) < 10:\n print \"10:01\"\nelif int(h) > 15 and int(h) < 20:\n print \"20:02\"\nelse:\n if 32 > int(m):\n print \"23:32\"\n else:\n print \"00:00\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "55c81d6b8b0b23512f3ef1d77a05935e", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "# -*- coding:utf-8 -*-\nimport sys\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n\n h_time, m_time = map(int, raw_input().split(':'))\n n = input()\n x,y = n%(24*60)/60, n%(24*60)%60\n m_time +=y\n if m_time>=60:\n m_time-=60\n h_time+=1\n h_time+=x\n if h_time>=24:\n h_time-=24\n\n if h_time<10:\n h_time = '0'+str(h_time)\n if m_time<10:\n m_time = '0'+str(m_time)\n print h_time+\":\"+m_time\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c07886a6807327386b7751848004a98c", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\nA = [int(x) for x in input().split(' ')]\nB = [int(x) for x in input().split(' ')]\nC = [int(x) for x in input().split(' ')]\n\ndef searchD(a, b, c):\n\tAx, Ay, Bx, By, Cx, Cy = a[0], a[1], b[0], b[1], c[0], c[1]\n\tDx = Bx + Cx - Ax\n\tDy = By + Cy - Ay\n\treturn (Dx, Dy)\n\nD1 = searchD(A, B, C)\n# \u041c\u0435\u043d\u044f\u0435\u043c \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c, \u043f\u0440\u043e\u0442\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0449\u0435\u043c \u0442\u043e\u0447\u043a\u0443\nA, B, C = (B, C, A)\nD2 = searchD(A, B, C)\n# \u0418\u0449\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443\nA, B, C = (B, C, A)\nD3 = searchD(A, B, C)\n\n\narr = [D1, D2, D3]\nprint(3)\nfor point in arr:\n\tprint('%d %d' % (point[0], point[1]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38951815a6f37ab25378544e833ce4e5", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "s, x = map(int, input().split())\nf = x\nif (s - x) % 2 == 1:\n\tprint(0)\n\texit(0)\nx = bin(x)[2::]\ny = (s - f) // 2\ny = bin(y)[2::]\nif len(x) > len(y):\n\ty = \"0\" * (len(x) - len(y)) + y\nelse:\n\tx = \"0\" * (len(y) - len(x)) + x\nk = 0\nfor i in range(len(x)):\n\tif x[i] == \"1\":\n\t\tk += 1\n\tif int(x[i]) + int(y[i]) == 2:\n\t\tprint(0)\n\t\texit(0)\nif s == f:\n\tprint(2 ** k - 2)\n\texit(0)\nprint(2 ** k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b17f8caf6c9b2dc586f32afc42f0a71d", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "ch=input()\nl=[]\nl=ch.split()\nm=int(l[0])\nd=int(l[1])\nif m in [1,3,5,7,8,10,12]:\n if d in [1,2,3,4,5]:\n print(5)\n else print(6)\nelif m in [4,6,9,11]:\n if d in [1,2,3,4,5,6]:\n print(5)\n else print(6)\nelif m=2 :\n if d=1:\n print(4)\n else print (5)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "977e0e1554eb70080e3544e0bcaeaa60", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from itertools import *\n\nl1, r1, l2, r2 = map(int, raw_input().split())\nla = []\nlb = []\n\ndef foo(l, r, pv, li):\n if l > r or pv < 1:\n return\n while l > pv:\n l -= pv\n r -= pv\n while r < pv:\n pv /= 2\n li.append((l, r))\n if l < r:\n foo(l, pv - 1, pv / 2, li)\n foo(pv + 1, r, pv / 2, li)\n\npv = 2 ** 32\nfoo(l1, r1, pv, la)\nfoo(l2, r2, pv, lb)\n\nans = 0\n#print la\n#print lb\nfor a in la:\n for b in lb:\n ans = max(ans, min(a[1], b[1] - max(a[0], b[0])))\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7252010685c182365106db20d8b3d8a", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "\n\n n,m=map(int,input().split())\n edges=[list(map(int,input().split())) for i in range(m)]\n for i in range(m):\n edges[i][0]-=1\n edges[i][1]-=1\n from itertools import permutations\n l=list(permutations(range(6)))\n mx=0\n for ij in l:\n for node in range(7):\n for seven in range(6):\n cnt=[None]*6\n for xi in range(6):\n cnt[xi]=[0]*6\n for xj in range(xi,6):\n cnt[xi][xj]=1\n numbering=[0]*10\n c=0\n for i in range(6):\n if node==i:\n c=1\n numbering[i+c]=ij[i]\n numbering[node]=seven\n curr=0\n for e in edges:\n u,v=numbering[e[0]],numbering[e[1]]\n u,v=min(u,v),max(u,v)\n if cnt[u][v]:\n cnt[u][v]=0\n curr+=1\n mx=max(mx,curr)\n print(mx)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f260fef90b2907a616f2bb9b57016857", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def cmp(a, b):\n return (a > b) - (a < b)\n\nif __name__ == \"__main__\":\n n = int(input())\n t = list(map(int,input().split(' ')))\n b = list(zip(t, t[1:]))\n #b = set(b)\n c = []\n for i in range(len(b)):\n if cmp(b[i], (1,2)) ==0:\n c.append(3)\n elif cmp(b[i], (1,3))==0:\n c.append(4)\n elif cmp(b[i], (2,1))==0:\n c.append(3)\n elif cmp(b[i], (2,3))==0:\n print('Infinite')\n exit()\n elif cmp(b[i], (3,1))==0:\n c.append(4)\n elif cmp(b[i], (3,2))==0:\n print('Infinite')\n exit()\n if cmp(b[i], (3,1))== 0 and cmp(b[i+1], (1,2))==0:\n c.append(-1)\n print('Finite')\n print(sum(c))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e3966b5c27e66bec5fa04afeec20a35", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "if __name__=='__main__':\n r = int(input())\n a = int(input()) #plastic bottle\n b = int(input()) #glass bottl e\n c = int(input()) #return on glass bottle\n d = 0 #drinks\n if b-c>=a:\n d+=int(r/a)\n r =r%a\n if r>b:\n while r>=b:\n d+=int(r/b))\n r = r%b + c*(r//b) #r//b==int(r/b)\n \n print (d)\n'''\n\nA. Guest From the Past\ntime limit per test\n1 second\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nKolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.\n\nKolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plastic liter bottle, that costs a rubles, or in glass liter bottle, that costs b rubles. Also, you may return empty glass bottle and get c (c\u2009<\u2009b) rubles back, but you cannot return plastic bottles.\n\nKolya has n rubles and he is really hungry, so he wants to drink as much kefir as possible. There were no plastic bottles in his 1984, so Kolya doesn't know how to act optimally and asks for your help.\nInput\n\nFirst line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091018) \u2014 the number of rubles Kolya has at the beginning.\n\nThen follow three lines containing integers a, b and c (1\u2009\u2264\u2009a\u2009\u2264\u20091018, 1\u2009\u2264\u2009c\u2009<\u2009b\u2009\u2264\u20091018) \u2014 the cost of one plastic liter bottle, the cost of one glass liter bottle and the money one can get back by returning an empty glass bottle, respectively.\nOutput\n\nPrint the only integer \u2014 maximum number of liters of kefir, that Kolya can drink.\nSample test(s)\nInput\n\n10\n11\n9\n8\n\nOutput\n\n2\n\nInput\n\n10\n5\n6\n1\n\nOutput\n\n2\n\nNote\n\nIn the first sample, Kolya can buy one glass bottle, then return it and buy one more glass bottle. Thus he will drink 2 liters of kefir.\n\nIn the second sample, Kolya can buy two plastic bottle and get two liters of kefir, or he can buy one liter glass bottle, then return it and buy one plastic bottle. In both cases he will drink two liters of kefir.\n'''\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "13f78e97252436bccae51e2e644f2e8d", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n , k = map(int,input().split())\n \nl = list(map(int,input().split()))\n \nt = []\n \nfor i in range(n):\n t.append([l[i],i])\n \nl = t[:]\n \nwhile len(l)>1:\n \n t = []\n \n for i in range(n):\n if l[i][0]>k:\n t.append([l[i][0]-k,l[i][-1])\n \n l = t[:]\n \nprint(l[0][-1]+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "54d93a1a0dbaa50aa791139ed2078610", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "l, r = map(int, input().split())\nif r-l+1<3:\n print(-1)\nelse:\n if l%2 != 0:\n l++\n\n print(l, l+1, l+2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d750a387f66d414023f97b792c433488", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "A = 1000001 * [0]\nind = 10 * [0]\nB = 1000001 * [0]\n\nfor i in range(10):\n A[i] = i\n\nfor i in range(10,1000001):\n A[i] = A[int(i/10)] * max(1,(i%10))\n\nfor i in range(10,1000001):\n A[i] = A[A[i]]\n ind[A[i]] += 1\n B[i] = ind[A[i]]\n\nfor tc in range(int(input())):\n l,r,k = input().split(' ')\n l,r,k = int(l),int(r),int(k)\n while r>=1 and A[r]!=k:\n r-=1\n if r == 0:\n print(0)\n else:\n while l<=1000000 and A[l]!=k:\n l+=1\n if l == 1000001:\n print[0]\n else:\n print(B[r]-B[l]+1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32111a052607f339ca78a58efa7c7d61", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n,k,d = map(int,input().split())\nimport sys\nsys.setrecursionlimit(10**6)\nmod = int(1e9+7)\n\ndef rec(n,d):\n if n<0:return 0\n if n==0:\n return d==0\n res = 0\n for i in range(1,k+1):\n if i>=d:\n res+=rec(n-i,0)\n else:\n res+=rec(n-i,d)\n res%=mod\n return res%mod\nprint(rec(n,d)%mod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d0d5950f4562057b8b3e373ed0b32049", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def l(a,b,c,d):\n return (a-c)*(a-c)+(d-b)*(d-b)\n\ndef check(a,b,c,d,e,f):\n if ((d-b)*(e-c)==(f-d)*(c-a)):\n return 0\n return 1\nS=input()\nif (len(S)==0):\n break\na,b,c,d,e,f=map(int, S.split())\nif (l(a,b,c,d)==l(c,d,e,f) and check(a,b,c,d,e,f)):\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\t \t\t \t \t \t \t \t\t \t\t \t\t \t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "078d03e3ffb0b100f37e871e2a14808c", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "N=int(input())\nif N==1:\n print(1)\nelse:\n print(2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "716b2c74aaea5f0bb68245a24b2f68b1", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\nfrom collections import defaultdict\nfrom itertools import permutations\n \n\nBUFSIZE = 8192\n \n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n \n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n \n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n \n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n \n \nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n \nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \n#-------------------game starts now-----------------------------------------------------\nk=int(input())\nr=list()\nc=97\nwhile k>0:\n i=1\n s=0\n while s+i<=k:\n s+=i\n i+=1\n for j in range (i):\n r.append(chr(c))\n c+=1\n k-=s\nprint(*r,sep='')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ffd26752405b1e8d1de6eef01d7c6e67", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": " n = input(\"n: \")\n a = input(\"a: \")\n b = input(\"b: \")\n\n if (b<0) : condition = 0\n else : condition = 1\n\n b = abs(b)\n b = b%n\n if condition==1:\n print (a+b)%(n+1) + (a+b)/(n+1)\n else:\n if (a>b):\n print a-b\n else:\n print n-(b-a)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa8c46732613d45bcd4c97074fe8858a", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "def inp():\n\treturn map(int, raw_input().split())\n\nrow,m,ques,x,y = inp()\n\nx-=1\ny-=1\n\ncount = [[0]*m for _ in xrange(row)]\n\ntot = (2*row -2)*m\nrounds = ques / tot\n\ncount[0] = [rounds]*m\ncount[row-1] = [rounds]*m\nfor i in xrange(1,row-1):\n\tcount[i] = [2*rounds]*m\n\nleft = ques % tot\nfor i in xrange(row):\n\tif left == 0:\n\t\tbreak\n\tfor j in xrange(m):\n\t\tif left == 0:\n\t\t\tbreak\n\n\t\tcount[i][j] += 1\n\t\tleft -= 1\n\nfor i in xrange(row-2,0,-1):\n\tif left == 0:\n\t\tbreak\n\tfor j in xrange(m):\n\t\tif left == 0:\n\t\t\tbreak\n\n\t\tcount[i][j] += 1\n\t\tleft -= 1\n\n\nma1 = 0\nmi1 = 10**20\nfor i in xrange(row):\n\tfor j in xrange(m):\n\t\tma1 = max(ma1,count[i][j])\n\t\tmi1 = min(mi1,count[i][j])\n\nprint ma1,mi1,count[x][y]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f9fe3a39596c9db36de78ca30c0b6eb0", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a=int(input())\nst=input()\neight=0\nfor i in range(0,len(st)):\n if st[i]=='8':\n eight+=1\nbanyak=len(st)//11\nif banyak==0:\n c=0\n break\nelif banyak>=eight:\n c=banyak\nelse :\n c=eight\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "be2dff50ddea45077938265e9eec245e", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def main():\n inpt = input().split()\n start = int(inpt[0])\n fav = int(inpt[1])\n diff = int(inpt[2])\n\n y = (fav - start)/ diff\n isint = False\n\n if y == int(x):\n isint = True\n\n if isint == True:\n if y > 0:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\n\n\n\n\n\nif __name__ == '__main__': main()print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d5221af0ac1560c784e0e708d7e8cdb8", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\n \n \nfor i in range(25):\n ch = chr(ord('z') - i)\n\tprev = chr(ord(ch) - 1)\n j = 0\n\twhile j < len(s):\n \tif s[j] == ch and (j-1 >= 0 and s[j-1] == prev or j+1 < len(s) and s[j+1] == prev):\n \t\ts = s[:j] + s[(j+1):]\n\t\t\tj = 0\n \telse:\t\t\t\n \t\tj+=1\n \nprint(n-len(s))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "471ee794363d432c0408d19e33eb4bb8", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\ndef mod_expo(a, b, m):\n\tif b == 0:\n\t\treturn (1 % m)\n\tans = mod_expo(a, b//2, m)\n\tif b % 2 == 0:\n\t\treturn (ans * ans) % m\n\telse:\n\t\treturn (ans * ans * (a % m)) % m\n\ndef mat_mul(mat1, mat2, m):\n\tans = [[0,0],[0,0]]\n\tans[0][0] = (mat1[0][0]*mat2[0][0] + mat1[0][1]*mat2[1][0])%m\n\tans[0][1] = (mat1[0][0]*mat2[0][1] + mat1[0][1]*mat2[1][1])%m\n\tans[1][0] = (mat1[1][0]*mat2[0][0] + mat1[1][1]*mat2[1][0])%m\n\tans[1][1] = (mat1[1][0]*mat2[0][1] + mat1[1][1]*mat2[1][1])%m\n\treturn ans\n\ndef mod_mat_expo(mat, n, m):\n\tif n == 0:\n\t\treturn [[1 % m, 0],[0, 1 % m]]\n\tans = mod_mat_expo(mat, n//2, m)\n\tans = mat_mul(ans, ans, m)\n\tif n % 2 == 0:\n\t\treturn ans\n\telse:\n\t\treturn mat_mul(ans, mat, m)\n\ndef f(n, m):\n\tif n == 2:\n\t\treturn 3 % m\n\tif n == 3:\n\t\treturn 5 % m\n\tmat = [[1,1],[1,0]]\n\tmat = mod_mat_expo(mat, n-3, m)\n\treturn (mat[0][0]*(5%m)+mat[0][1]*(3%m))%m\n\nn, k, l, m = map(int, raw_input().split())\n#print n,k,l,m\n\nif k != 0 && math.log(k, 2) >= l:\n\tprint 0\nelse:\n\tt = f(n, m)\n\tmul = 1\n\tfor i in range(l):\n\t\tbit = k % 2\n\t\tif bit == 0:\n\t\t\tmul = (mul * t) % m\n\t\telse:\n\t\t\tx = mod_expo(2, n, m)\n\t\t\tif(x >= t):\n\t\t\t\tmul = (mul * (x - t)) % m\n\t\t\telse:\n\t\t\t\tmul = (mul * (x - t + m)) % m\n\t\tk = k / 2\n\tprint mul\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "42830fec18722e0b6a14f0018f25a363", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tint i = 0;\n\tint j;\n\ttry\n\t{\n//\t\tHERE:\n//\t\ti--;\n\t\tcout << i << '\\n';\n\t\tj = 1/i;\n\t\tcout << i << '\\n';\n//\t\tgoto HERE;\n\t}\n\tcatch(...)\n\t{\n\t\tcout << \"PIE\\n\";\n\t\tgoto END;\n\t}\n\tEND:\n\tcout << \"PIE\";\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57ec21b70e30ca27c3786cf83fa4badb", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from collections import Counter, defaultdict, deque\r\nimport bisect\r\nimport sys\r\nimport os\r\nfrom itertools import repeat, permutations\r\nimport itertools\r\nimport math\r\nimport heapq\r\nimport random\r\nfrom sys import stdin, stdout\r\n \r\nMOD = int(1e9)+7\r\nfrom io import BytesIO, IOBase\r\n \r\nBUFSIZE = 8192\r\n \r\n \r\n \r\ndef inp(force_list=False):\r\n re = list(map(int, input().split()))\r\n if len(re) == 1 and not force_list:\r\n return re[0]\r\n return re\r\n \r\ndef inst():\r\n return input().strip()\r\n \r\ndef gcd(x, y):\r\n while(y):\r\n x, y = y, x % y\r\n return x\r\n \r\ndef lcm(x, y):\r\n return x*y/(gcd(x,y))\r\n \r\ndef qmod(a, b, mod=MOD):\r\n res = 1\r\n while b:\r\n if b&1:\r\n res = (res*a)%mod\r\n b >>= 1\r\n a = (a*a)%mod\r\n # print b\r\n return res\r\n \r\ndef inv(a):\r\n return qmod(a, MOD-2)\r\n \r\ndef query(tp, l, r=0):\r\n if tp==1:\r\n print(\"? 1 %d\" % (l+1,))\r\n stdout.flush()\r\n return inst()\r\n else:\r\n if r= n:\r\n print(fac[n])\r\n else:\r\n def f(xn, xk):\r\n if xk == 1:\r\n return xn + 1\r\n elif xn == xk:\r\n return fac[xn]\r\n else:\r\n return (f(xn-1, xk-1) + f(xn-1, xk))%MOD\r\n print(f(n, k))\r\n\r\n\r\nmy_main()\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64698ed21fc7ce84119d19564b0d023f", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#lang=py2\n\ndef hi(): return \"hi\"\n*\n\nx = int(raw_input())\nr = 0\nfor a in [100,20,10,5,1]:\n y = x//a\n r += y\n x -= y * a\nprint(r) #@sub", "lang_cluster": "Python", "compilation_error": true, "code_uid": "da6e4c508fdce8146d4880dbe84c7621", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "\nn,m,x,y,a,b = map(int,raw_input().split())\n\nans = -1\nfor c in [(1,m),(n,1),(n,m),(1,1)]:\n dx = abs(x - c[0])\n dy = abs(y - c[1])\n if dx==0 and dy==0:\n print 0\n exit(0)\n elif dx%a==0 and dy%b==0 and (dx/a)%2==(dy/b)%2:\n if ans==-1:\n ans = max(dx/a,dy/b)\n else ans = min(ans,max(dx/a,dy/b))\n\nif (n-x 2: a[m] = a[m]+1 if m in a else 1\n return a\na = getalldivisors(n)\nmaxk = 1\nb = []\nfor key, val in a.items(): \n maxk *= val\n b += [key for i in xrange(val)]\nif k>maxk:\n print -1\nelse:\n t=1\n for i in xrange(k-1):\n t *= b[i]\n print b[i],\n print n/t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "916349b2b279df1d668610681eb049fc", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=list(map(int,input().split()))\nt=list(map(int,input().split()))\ntx=set(t)\n\ndef check(x):\n z=0\n for i in tx:\n z+=int(t.count(i)/x)\n print(i)\n return z\n\n\n\nmaxi=[]\nfor i in tx:\n a=check(t.count(i))\n if(a>=n[0]):maxi.append(t.count(i))\nmaxi.sort()\nif len(maxi)==0:print(0)\nelse: print(maxi[len(maxi)-1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c60c388116f192ad47ea15a2aeadef1", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": " n=int(input())\n print(3*(n//2))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "316d2f0dbe7ec657969995f751135ea9", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "PyPy 2", "source_code": "from fractions import gcd\nfrom math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin\nfrom itertools import *\nfrom fractions import Fraction\nimport string\nimport copy\nimport random\nimport bisect\nfrom decimal import *\ndef id_generator(size=20, chars=string.digits):\n return ''.join(random.choice(chars) for _ in range(size))\n \ndef mp():\n return map(int,str(raw_input()).split())\n\n\nn,d=mp()\nl=list(mp())\nl.sort()\nans=10**18\nfor i in range(n):\n\tif (l[i]-l[0])>d:\n\t\tans=n-i+1\n\t\tbreak\nfor i in range(n-1,-1,-1):\n\tif (l[-1]-l[i])>d:\n\t\tans=min(ans,i)\n\t\tbreak\nif ans=10**18:\n\tprint 0\nelse:\n\tprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc1747f8784601f9ac6e1c51f5218b8e", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "b = int(raw_input())\n\nif b == 1:\n print 1\nelse:\n ans = 1\n for i in range(2,int(b**0.5)+1):\n count = 1\n while b%i == 0:\n b /= i\n count += 1\n ans *= count\n if ans == 1:\n print 2\n else:\n print ans\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27b831a6e6562ef8ba439e34b93f07f1", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=input()\nm{\n '4':0,\n '7':0\n}\nfor i in n:\n if i in m:\n m[i]+=1\nif m[4]==0 and m[7]==0:\n print(-1)\nelse:\n if m[4]>m[7]:\n print(4)\n else:\n print(7)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4efe663b9bfb89c320c6104a4fffac61", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ns = input()\n\ndiff = 0\n\nfor i in s:\n if i == \"1\": diff += 1\n else: diff -= 1\n \nif diff = 1:\n print(1)\n print(s)\nelse:\n print(2)\n print(s[:-1]+\" \"+s[-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "886d3023ba3e7c7d6e79312106fff5f3", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 2", "source_code": "s = raw_input()\nnames = [\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"]\n\nt = 0\nfor name in names:\n t += s.count(name)\n\nif t==1:\n print \"YES\"\nelse:\n print \"NO\": s = raw_input()\nnames = [\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"]\n\nt = 0\nfor name in names:\n t += s.count(name)\n\nif t==1:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "698db0086e16e48d3700da3256db0a00", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x,y=cin()\n if(abs(x-y)%2==1 or x>y):\n print(-1)\n else:\n y=y-x\n y=y//2\n if(y==x):\n print(3)\n print(y,y,y)\n else:\n print(2)\n print(y,x+y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1611436dee5e1842fb880f4c95a2b2ce", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x = int(input())\nh = input()\nm = input()\ndigitTime = []\nfor char in h :\n digitTime.append(int(char));\n \nfor char in m :\n digitTime.append(int(char));\ny = 0\n\nfor i in range (3, 0, -1) :\n j = i\n min = digitTime[j]\n min = min - x\n while min >= 0 or (digitTime[j]!= 7) :\n digitTime[j] -= x\n y++\n \nprint(y)\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e90c9fd754a24b514388ed347b093ce", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "Python 2", "source_code": "def leave_number(lr, h):\n l, u = 1, 2 ** (h + 1) - 1\n rev = 1\n while lr:\n d = lr.pop()\n mid = (l + u) / 2\n if rev == 1:\n if d == 0:\n u = mid\n l += 1\n rev *= -1\n else:\n l = mid + 1\n else:\n if d == 0:\n l = mid + 1\n else:\n u = mid\n l += 1\n rev *= -1\n #print l, u\n return l\n\nh, n = map(int, raw_input().split())\nlr = []\nn -= 1\nwhile n:\n lr.append(n % 2)\n n /= 2\nlr += [0] * (h - len(lr))\nprint leave_number(lr, h) - 1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "881f7917400d8e01c09860a984c5de07", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "total_black = 0\ntotal_white = 0\nblack = white = {'q':0, 'r':0, 'b':0, 'n':0, 'p':0, 'k':0}\nweight = {'q':9, 'r':5, 'b':3, 'n':3, 'p':1, 'k':0}\n\nfor i in range(8):\n str = input()\n for j in range(8):\n if str[j] != '.':\n if str[j] == str[j].lower(): # black\n black[str[j]] += 1\n else: # white\n white[str[j].lower()] += 1\n \nfor key in black:\n total_black += black[key]*weight[key]\n total_white += white[key]*weight[key]\n\nif total_white == total_black:\n print('Draw')\nelif total_white > total_black:\n print('White')\nelse\n print('Black')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e31dc64260fa9e153cdee219ae5652d3", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n =int(raw_input())\n\nm = map(int, raw_input().split())\n\nk = 0\nfor i in range(n-1,-1,-1):\n\tif(m[i]==1):\n\t\tcontinue\n\telse:\n\t\tk = i\n\t\tbreak\nseq = []\ntemp = [m[0]]\nfor i in range(1,n):\n\tif(m[i]==m[i-1]):\n\t\ttemp.append(m[i])\n\telse:\n\t\tseq.append(temp)\n\t\ttemp = [m[i]]\nseq.append(temp)\n\nones = []\nans = []\nfor i in range(len(seq)-1,-1,-1):\n\tif(seq[i][0]==1):\n\t\tif(ones == []):\n\t\t\tones.append(seq[i])\n\t\telse:\n\t\t\tones = [seq[i]+ones[0]]\n\telse:\n\t\tif(ans == []):\n\t\t\tans.append(seq[i])\n\t\t\tif(ones!=[]):\n\t\t\t\tans.append(seq[i]+ones[0])\n\t\telse:\n\t\t\ttemp = []\n\t\t\tfor j in ans:\n\t\t\t\ttemp.append(seq[i]+j)\n\t\t\tfor j in ones:\n\t\t\t\ttemp.append(seq[i]+j)\n\t\t\tans = temp\n\nlo = []\n\n\nfor i in ans:\n\tif(len(i)>len(lo)):\n\t\tlo = i\nif(len(lo)>len(ones[0])):\n\t# p = lo+m[k+1:n]\n\tprint len(lo)\n\t# print lo\nelse:\n\tprint len(ones[0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fb16ab63057d6461047682806b94f76b", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def main():\n\tn=int(input())\n\ts=input()\n\td={}\n\tif n==6:\n\t\tprint(\"espeon\")\n\telif n==8:\n\t\tprint(\"vaporeon\")\n\telse:\n\t\tfor i in range(len(s)):\n\t\t\tif s[i]!=\".\":\n\t\t\t\td[i]=s[i]\n print(find(d))\nl=[\"jolteon\", \"flareon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]\ndef find(d):\n\tk=0\n\tfor j in range(len(l)):\n\t\tfor i in d.keys():\n\t\t\tif l[k][i]!=d[i]:\n\t\t\t\tl.remove(l[k])\n\t\t\t\tbreak\n\t\telse:\n\t\t\tk=1\t\t\n\treturn l[0]\nmain()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c5e9423fbfaad3d97b62b7c957cd9901", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\na=0\ni=0\nwhile i < n-1:\n if s[i] != s[i+1]:\n i=i+1\n a=a+1\n \n i+=1\nprint(n-a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1bd9aa430588f808a43007397817c030", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "for i in range(int(input()): print(2**int(input())-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d24fcc8b5aaeed2dab1d4e1197dcf51e", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def main():\n\tn, k, m = map(int, input().split(' '))\n\ttime = list(map(int, input().split(' ')))\n\tntime = []\n\tfor i in range (0, n):\n\t\tntime = ntime + time\t\n\t\n\tntime.sort()\n\tcapture1 = 0;\n\ti = 0\n\tcnt1 = 0\n\twhile capture1 < m:\n\t\tif capture1 + ntime[i] <= m:\n\t\t\tcnt1 = cnt1 + 1\n\t\tcapture1 = capture1 + ntime[i]\n\t\ti = i+1\n\ti = 0\n\tcapture2 = 0\n\tcnt2 = 0\n\twhile capture2 < m:\n\t\tif capture2 + time[i] <= m:\n\t\t\tcnt2 = cnt2 + 1\n\t\tcapture2 = capture2 + time[i]\t\t\t\t\t\t\n\t\ti = i + 1\n\t\tif i == k:\n\t\t\ti = 0\n\t\t\tcnt2 = cnt2 + 1\n\tresult = max([cnt1, cnt2])\n\tprint(result)\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\t\n\t\t \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9c3b1fbd581a5839448f3ec5cce3e3dd", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "\nreadi=lambda: map(int, input().split())\nn,m=readi()\na=[]\nfor _in range(n):\n x=int(input())\n a.append(x)\n \na.sort()\na.pop()\n\nif not a or sum(a)<=m:\n print(\u2018YES\u2019)\nelse:\n print(\u2019NO\u2019)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "be544effdc4a11cc004294b4d1e8f566", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "def cal(x):\n ans = 0\n while (x):\n ans += x % 10\n x /= 10\n return ans\n \nn = input()\nnow = 0\nwhile (n):\n now += 1\n if cal(now) == 10:\n n -= 1\nprint now", "lang_cluster": "Python", "compilation_error": true, "code_uid": "de7f22d8b3a5f2cee69fd8d08ab83673", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\ufeff\n\nn, a, b, c = map(int, input().split())\nh=n%4\nif h==0:\n\tprint(0)\nelse:\n\tif h==1:\n\t\td=min(a*3,a+b,c)\n\tif h==2:\n\t\td=min(a*2,b,c*2)\n\tif h==3:\n\t\td=min(a,b+c,c*3)\nprint(d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9bb4bf3dc837b494c54656ff6ac1d301", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\ufeffs=input()\nl=list(s)\ndef count(l1):\n a=0\n for i in range(len(l1)-1):\n if l1[i]=='V':\n if l1[i+1]=='K':\n a=a+1\n return(a)\nc=count(list(s))\nb=[c]\nfor i in range(len(l)):\n l1=l[:]\n l1[i]='V'\n a=count(l1)\n b.append(a)\n l1[i]='K'\n a=count(l1)\n b.append(a)\nmax=c \nfor i in range(len(b)):\n if b[i]>max:\n max=b[i]\nprint(max)\nprint(str(b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "51b806eb373a307345a59f10694e5fcc", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": " # n = int(input())\r\n x1, x2 = map(int, input().split())\r\n y1, y2 = map(int, input().split())\r\n # arr= list(map(int, input().split()))\r\n # output_arr =[]\r\n if x1+x2+y1+y2==4:\r\n print(2)\r\n elif x1+x2+y1+y2==0:\r\n print(0)\r\n else:\r\n print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24c9bc3c232e06acc641c6d075c4d7ed", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import time\nstartTimeProblem=time.time()\n\nimport fileinput, sys, itertools, functools\n# from math import *\nimport math\nfrom bisect import *\nfrom heapq import *\nfrom collections import *\n\ndef lcm(a, b): \n return (a*b)/gcd(a, b)\n\nclass InputHelper:\n def __init__(self):\n self.myinput = fileinput.input()\n\n def isLocal(self):\n return not fileinput.isstdin()\n\n def int(self):\n return int(self.myinput.readline().rstrip())\n\n def ints(self):\n return [int(_) for _ in self.myinput.readline().rstrip().split()]\n\n def str(self):\n return self.myinput.readline().rstrip()\n\n def strs(self):\n return [_ for _ in self.myinput.readline().rstrip().split()]\n\nclass OutputHelper:\n def int(self, a):\n print(a) \n\n def ints(self, a): \n print(\" \".join([str(_) for _ in a]))\n \n def intsNL(self, a):\n for _ in a:\n print(_)\n \n def str(self, s):\n print(s)\n\n def strs(self, s):\n print(\" \".join([_ for _ in s]))\n\n def strsNL(self, s):\n for st in s:\n print(st)\n\nclass ListNode:\n def __init__(self, val):\n self.val = val\n self.next = None\n self.prev = None\n\nIn = InputHelper()\nOut = OutputHelper()\n\n######################################\n\ndef isPrime(x):\n if x==2:\n return True\n \n for i in range(2, math.ceil(math.sqrt(x))+1):\n if x%i == 0:\n return False\n \n return True\n\nx, n = In.ints()\nMOD = (10**9+7)\nprimes = []\n\nfor i in range(2, math.ceil(math.sqrt(x))+1):\n if x%i==0 and isPrime(i):\n primes.append(i)\n\n div = x//i\n if div != i and isPrime(div):\n primes.append(div)\n\nif isPrime(x):\n primes.append(x)\n\nans = 1\n\nfor p in primes:\n k = 1\n\n while True:\n div = (n//p**k)\n \n if div==0:\n break\n\n ans *= pow(p,div,MOD)\n ans %= MOD\n k+=1\n\nOut.int(ans)\n\n\n######################################\n\nif len(sys.argv)>2 and sys.argv[2]==\"TIMEIT\":\n fin = (time.time()-startTimeProblem)*1000\n print(\"{:.2f}\".format(fin) + \"ms\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b54e7f08f8a16892fb472ccbbe0478f4", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\ufeff\nprime = [0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\nmin_value = round(1e18)\nn = int(input())\n\ndef search(value, total_factor, i):\n global min_value\n if total_factor == n:\n min_value = min(value, min_value)\n return \n for k in range(1, 65):\n value *= prime[i]\n if value > min_value:\n break\n if total_factor * (k + 1) <= n:\n search(value, total_factor * (k + 1), i+1)\n \nsearch(1, 1, 1) \nprint(min_value)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea980ae5afe856213239efc0c91c0b71", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,k,m,d = [int(x) for x in input().split()]\nans = 0\nfor t in range(1,d+1):\n\tR = n // ((t-1)*k + 1)\n\tL = n // (t*k)\n\tif L <= R:\n\t\tif L <= m <= R:\n\t\t\tans = max(ans,m*t)\n\t\telse if R <= m:\n\t\t\tans = max(ans,R*t)\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c23d61040bd6845d395875e4b3708f90", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def main():\n\tn=int(input())\n sum=0\n for i in range(2,(n-1)):\n s=n\n while(s>0):\n sum=sum+(s%i)\n s=s/i\n b=n-2\n a=sum\n #For HCF\n if a 0:\n ans = ans * i\n if tempsq > maxsq:\n maxsq = tempsq\nprint(ans, math.ceil(math.log2(maxsq) + 1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c41d252290bc583b512fe3355c24ddb4", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n, m = raw_input().split(\" \")\nn = int(x)\nm = int(y)\ni=0\nif n>m:\nk = n\nelse:\nk = m\nfor a in range(0, k):\n for b in range(0, k):\n if a*a+b == n and a+b*b == m:\n i=i+1\nprint i", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4d650ceb4b9c6b38ec75b754a56e58d", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\nl = list(map(int, input().split())\nl = list(set(l))\nif len(l) < k: print(\"NO\")\nelse:\n print(\"YES\")\n for i in range(k): print(l[i], end = \" \")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f594057c5e95a32f8b3fe8dce9cc623c", "src_uid": "5de6574d57ab04ca195143e08d28d0ad", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\nx=int(input())\nk=math.floor(-1+math.sqrt(1+8*x))\nprint(k,'\\n')\nfor i in range(1,k):\n print(i,' ')\nprint(x-(k*(k-1) div 2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3bcb35c94e1d6032f5121e8156c77199", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "// luogu-judger-enable-o2\nread=input()\nread=read.split(\" \")\na=[0]*4\nn=int(read[0])\nm=int(read[1])\na[1]=m\na[2]=m\na[3]=m\ndef mysort():\n\tfor i in range(1,4):\n\t\tfor j in range(i,4):\n\t\t\tif a[i]>a[j]:\n\t\t\t\ta[i],a[j]=a[j],a[i]\n\treturn\ndef getans():\n\tt=0\n\tif n==m:\n\t\treturn 0\n\twhile 0==0:\n\t\tmysort();\n\t\tt=t+1;\n\t\tif a[2]+a[3]-1<=n :\n\t\t\ta[1]=a[2]+a[3]-1\n\t\telse:\n\t\t\ta[1]=n\n\t\tif a[1]==n and a[2]==n and a[3]==n:\n\t\t\treturn t\n\treturn 0;\nprint(getans())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "91a104ba5f6a1e283fe7fa94866e04e5", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\ndef f(A):\n \n i_min = A.index(1)\n i_max = A.index(n)\n length = len(A)\n if abs(i_min - i_max) == length - 1:\n return abs(i_min - i_max) - 1\n elif i_min == 0 or i_min == length - 1:\n return length - 1\n elif i_max == 0 or i_max = length - 1:\n return length - 1\n else:\n return max(abs(length - 1 - i_min), abs(length - 1 - i_max), abs(i_max), abs(i_min))\n\nT = input()\narr = [int(i) for raw_input().strip(' ').split()]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58b402b56cd6c5b394ac10bb8af19345", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nc=int(input())\nd=[]\nk=int(floor(b/2))\nl=int(floor(c/4))\nd.append(a)\nd.append(k)\nd.append(l)\nd.sort()\nif d[0]=='0':\n print 0\nt=int(d[0])\nans=int(t*a+t*b+t*c)\nprint(t)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c03f75a1f98349013b162b90f23ad5a0", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "p,y = map(int,input().split())\nfor x in range(y,p,-1):\n\tif all(x%i for i in range(2,min(int(x**.5),p+1)):\n\t\t#even if one devides it completely then not possible to sit\n\t\t#if nothing devides then it's sitable\n\t\t#factors repeat after reachin midway(sqrt)\n\t\tprint(x)\n\t\texit()\nprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "26883de6fb3b2258b1a3af46d59fbd7c", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\ndef bin (a, b, c, n, m, k, pn, pm, pk, r):\n [L, R] = [0, r * 100]\n while R - L > 1:\n M = (R + L) // 2\n a2 = max(M * a - n, 0)\n b2 = max(M * b - m, 0)\n c2 = max(M * c - k, 0)\n if a2 * pn + b2 * pm + c2 * pk <= r:\n L = M\n else:\n R = M\n return L\n\nstr = input()\n[a, b, c] = [0, 0, 0]\n[n, m, k] = [int(i) for i in input().split()]\nfor i in str:\n if i == 'B':\n a += 1\n elif i == 'S':\n b += 1\n else:\n c += 1\n[pn, pm, pk] = [int(i) for i in input().split()]\nr = int(input())\nprint(bin(a, b, c, n, m, k, pn, pm, pk, r))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e0dda50e4863c6bf6db600af3a7282f", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "G = (1 + 5 ** .5) / 2\nw = set((int(k * G), int(k * G) + k) for k in range(999))\nn = input()\na = sorted(map(int, raw_input().split()))+[0,0]\nprint 'BitAryo' if (((a[0], a[1]) in w) if 2==n else not(a[0]^a[1]^a[2])) else 'BitLGM'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b7f744a9fa3be65061e15a8c23424d70", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def the_Artful():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j]; \n if h in c1:\n cpt+=1;\n if (cpt%2==0): \n print('Karen');\n else:\n print('Kayomi');\n the_Artful ()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "623f19da066411ae0367b3b0d91f4676", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import sys\nn = input()\ns = list(raw_input())\nabc = sorted(set(('zyxwvutsrqponmlkjihgfedcba')[26-n:]) - set(s))\nsl = len(s)/2\n\nfor i in xrange(sl):\n j = -i-1\n if s[i] == '?' and s[j] != '?': s[i] = s[j]\n elif s[j] == '?' and s[i] != '?': s[j] = s[i]\n elif s[i] != s[j]:\n print 'IMPOSSIBLE'\n sys.exit()\n\n\nfor i in xrange(sl,-1,-1):\n if s[i] == '?':\n s[i] = s[-i-1] = abc.pop() if abc else 'a'\n\nprint 'IMPOSSIBLE' if abc else ''.join(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0b9bf916301af87f2b1efee69e2e4e50", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "t=input().split(' ') \nw=int(t[0]) \nh=int(t[1]) \nsum=0 \nfor i in range(int(t[2])): \n\nsum=sum+2*(w+h)-4 \nw=w-4 \nh=h-4 \n\nprint(sum)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ef1b7783e3240f639f49215d2333e745", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=[\"\",\"\"]\na[0] = int(input())\na[1] = int(input())\nn = len(a[0])\ncnt = 0\nif n > 1:\n d = 0\n for i in range(n):\n b = 0\n if(a[0][i] == '0'):\n b+=1\n if a[1][i] == '0' :\n b+=1\n d+=b\n if d>2:\n cnt+=1\n d = d-3\n else:\n d = b\n \n print(cnt)\nelse:\n print(0)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8defb1097d9b59c8a759b6d3544ff12", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\na=[]\nfor i in range(n-1):\n a.append(s[i:i+2])\nprint(max(a,key=a.count))-", "lang_cluster": "Python", "compilation_error": true, "code_uid": "126135691c85ce2eb7828ab6ba1253b8", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 3", "source_code": "from itertools import permutations\nfrom math import log\nfrom math import ceil\nfrom sys import exit\n\ni = input()\nN = int(i[:i.index(' ')])\nM = int(i[i.index(' ')+1:])\n\nl = ceil(log(N,7))\nr = ceil(log(M,7))\n\nif l+r > 7 || l == 0 || r == 0:\n\tprint(0)\n\texit()\n\nans = []\nfor x in permutations([0,1,2,3,4,5,6]):\n\tcnt = 1\n\ttotal = 0\n\tfor a in range(l):\n\t\ttotal += cnt*x[a]\n\t\tcnt *= 7\n\tif total >= N:\n\t\tcontinue\n\n\tcnt = 1\n\ttotal = 0\n\tfor a in range(l,l+r):\n\t\ttotal += cnt*x[a]\n\t\tcnt *= 7\n\tif total >= M:\n\t\tcontinue\n\n\tif x[:l+r] not in ans:\n\t\tans += [x[:l+r]]\n\nprint(len(ans))\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92d72a0123d045fcb80533240137c17e", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = eval(input())\n\narea = 0\np1 = []\np2 = []\nps = []\nxl, xu, yl, yu = 0, 1 << 28, 0, 1 << 28\nfor i in range(n):\n in_ = input().split()\n p1.append(tuple(map(int, in_[0:2])))\n p2.append(tuple(map(int, in_[2:4])))\n xl = min(xl, ps[-2][0], ps[-1][0])\n xu = max(xu, ps[-2][0], ps[-1][0])\n yl = min(yl, ps[-2][1], ps[-1][1])\n yu = max(yu, ps[-2][1], ps[-1][1])\n\nok = True\nfor p in p2:\n q = p\n if p[0] < xu:\n q = (q[0] + 0.5, q[1])\n if p[1] < yu:\n q = (q[0], q[1] + 0.5)\n for i in range(n):\n if not (p1[i][0] <= p[0] <= p2[i][0] and p1[i][1] <= p[1] <= p2[i][1]):\n ok = False\nfor p in p1:\n q = p\n if xl < p[0]:\n q = (q[0] - 0.5, q[1])\n if yl < p[1]:\n q = (q[0], q[1] - 0.5)\n for i in range(n):\n if not (p1[i][0] <= p[0] <= p2[i][0] and p1[i][1] <= p[1] <= p2[i][1]):\n ok = False\n\nprint('YES' if ok else 'NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d3234e1a4133b9818cc2551d0576ff28", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import itertools\n \n \nn,l,r,x = map(int,input().split())\na = map(int,input().split())\na.sort()\nans = []\ncombos = []\nfor i in range(2,n+1):\n\ttemp = itertools.combinations(a,i)\n\tfor j in temp:\n\t\tcombos.append(j)\ncount = 0\n \nfor i in combos:\n\ttot = sum(i)\n\tmaxi = max(i)\n\tmini = min(i)\n\tif(tot>=l and tot<=r and maxi-mini>=x):\n\t\tcount+=1\nprint coun", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03340d8f5a6de65445a33d4d2ffe5e36", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import sqrt,ceil\na,b = map(int,input().split())\n\ne = a - b \nif(e == 0) :\n print(\"infinity\")\nelif(e < 0):\n\tprint(0)\n\nelse :\n i = 1\n marked= False\n t = e\n ans = 0\n down = 0 \n while(i < ceil(sqrt(e))) :\n if(e % i == 0):\n \tt = e // i\n \tif(t > b):\n \t\tans += 1\n \t\tif(i <= b) :\n \t\t\tdown += 1\n if(e // i <= b) :\n \tmarked = True\n \tbreak\n i += 1\n if(!marked):\n \tans = ans*2 - down\n \tif(sqrt(e) == ceil(sqrt(e))) :\n \t\tans += 1\n print(ans)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bd3278ba52c83f4d70efef79b99d685e", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def solve(k, grid):\n seek = *range(2*k + 2), *range(4*k + 1, 2*k + 1, -1)\n flat = [seek[v] for v in grid[0] + grid[1][::-1] if v]\n\n m = {\n 'L': 'l'*2*k + 'u' + 'r'*2*k + 'd',\n 'R': 'u' + 'l'*2*k + 'd' + 'r'*2*k,\n 'C': 'l'*k + 'u' + 'r'*k + 'd',\n 'D': 'CC' + 'R'*(2*k + 1) + 'CC' + 'R'*(2*k + 2),\n 'F': 'R'*(k - 1) + 'DD' + 'R'*(2*k + 1) + 'D' + 'L'*2*k + 'DD' + 'L'*k,\n 'G': 'FF',\n }\n\n [(i, j)] = [(i, j) for i in range(2) for j in range(2*k + 1) if grid[i][j] == 0]\n st = 'r'*(2*k - j) + 'd'*(1 - i)\n\n for v in range(2, 4*k + 2):\n ct = flat.index(v)\n\n if ct >= 2:\n st += 'L'*(ct - 2) + 'GR'*(ct - 2) + 'G'\n flat = flat[ct - 1: ct + 1] + flat[:ct - 1] + flat[ct + 1:]\n\n if ct >= 1:\n st += 'G'\n flat = flat[1:3] + flat[:1] + flat[3:]\n\n st += 'L'\n flat = flat[1:] + flat[:1]\n \n if flat[0] == 1: return st, m\n\ndef main():\n def get_line():\n return [0 if x == 'E' else int(x) for x in input().split()]\n\n for cas in range(int(input())):\n res = solve(int(input()), [get_line() for i in range(2)])\n if res is None:\n print('SURGERY FAILED')\n else:\n print('SURGERY COMPLETE')\n st, m = res\n print(st)\n for shortcut in m.items(): print(*shortcut)\n print('DONE')\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7e2059588107826daef581d73462de05", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "Python 3", "source_code": "n, a,b = map(int,input().split())\nl1 = list(input())\nl2 = list(input())\nz = []\nfor i in range(1,n+1):\n if i in l1:\n z.append(1)\n else:\n z.append(2)\nw = z.remove('[')\nx = w.remove(']')\ny = x.remove(',')\nprint((y)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a35a8106e1a95cf26fb18c553d365d1b", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m = [int(x) for x in input().split()]\nif n == 0 and m > 0\n print('Impossible')\nelse:\n print(n+max(0, m-n), (n+m-1 if m else n))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f9414842f74cb0f3dc3cd8c10e6e11d7", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x,y,a,b = map(int, input().split())\ng = 1\nwhile g % x || g % y:\n g += 1\nprint(b // g - (a - 1) // g)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2a69a1269300e266e9db36deafb03a9f", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,m,k=map(int,raw_input().split())\nif m==0; print 0; exit()\nM=10**9+9\na=k*2*(pow(2,(max(n/k-n+m,0)),M) - 1)\nprint (a + n%k + (k-1)*(n-m))%M", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f30ced44cb9a448795c747a30df3e995", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from math import factorial\nfrom functools import partial, reduce\nfrom operator import mul\nspi = partial(reduce, mul)\ndef comb(a, *args):return factorial(a)/spi(factorial(x) for x in args)\nn = int(raw_input())\nA = [int(i) for i in raw_input().split()]\nm = sum(A)\n\nif m > n: \n print 0\n exit()\n\ny = comb(m, *A) % 1000000007 \nY = [[y for i in xrange(10)]]\n\nAz = [A[0]-1]+A[1:] if A[0] > 0 else A\nz = (comb(m-1, *Az) % 1000000007) if A[0] > 0 else 0\nZ = [[z for i in xrange(10)]] if z != 0 else []\n\ndef next_table(A, Y, m, i):\n Yn = []\n Sd = [0]*10\n for j in xrange(i):\n s = 0\n for k in xrange(9):\n s += Y[j][k]*(m+i+1)\n Sd[k+1] += s/(A[k+1]+1)\n S = 0\n Sy = [0]*10\n for j in xrange(i+1):\n S += sum((Y[j][k])*(m+i+1)/(A[k]+(i-j)+1) for k in xrange(10))\n Yn.append([(Y[j][k])*(m+i+1)/(A[k]+(i-j)+1) % 1000000007 for k in xrange(10)]) \n for k in xrange(10):Sy[k] += Yn[-1][k]\n S -= sum(Sd)\n for k in xrange(10): \n Yn[-1][k] -= Sd[k]\n Sy[k] -= Sd[k]\n Yn.append([(S - Sy[k]) % 1000000007 for k in xrange(10)])\n return S % 1000000007 , Yn\n\nS = y-z\nfor i in xrange(n-m):\n Sy, Y = next_table(A, Y, m, i)\n if z:\n Sz, Z = next_table(Az, Z, m-1, i)\n else:\n if i == 0:\n Sz, Z = y, [[y for j in xrange(10)]]\n else:\n Sz, Z = next_table(Az, Z, m, i-1)\n S += Sy - Sz\nif A.count(0) == 10: S-=1\nprint S % 1000000007 \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0bb4cfe275163c3bef851e55f593429e", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "Python 3", "source_code": " def check(cx, cy):\n if a[cx - 1][cy - 1] == '#' and a[cx - 1][cy] == '#' and a[cx - 1][cy + 1] == '#' and a[cx][cy - 1] == '#' and a[cx][cy + 1] == '#' and a[cx + 1][cy - 1] == '#' and a[cx + 1][cy] == '#' and a[cx + 1][cy + 1] == '#':\n used[cx - 1][cy - 1] = used[cx - 1][cy] = used[cx - 1][cy + 1] = used[cx][cy - 1] = used[cx][cy + 1] = used[cx + 1][cy - 1] = used[cx + 1][cy] = used[cx + 1][cy + 1] = True\n return True\n return False\n \n \n n, m = map(int, input().split())\n a = [0] * (n + 1)\n for i in range(n):\n a[i] = list(input()) + ['.']\n a[-1] = ['.'] * (m + 1)\n used = [[a[i][j] == '.' for j in range(m)] for i in range(n)]\n f = True\n for i in range(n):\n for j in range(m):\n if used[i][j]:\n continue\n if check(i - 1, j - 1) or check(i - 1, j) or check(i - 1, j + 1) or check(i, j - 1) or check(i, j + 1) or check(i + 1, j - 1) or check(i + 1, j) or check(i + 1, j + 1):\n continue\n print('NO')\n exit(0)\n print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "196569626d8eb55316217102ea93ee6f", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=[]\nfor i in range (n):\n ch=input()\n if(ch==\"*\"):\n l.append(i+1)\n \nk=[]\nfor j in l:\n k.append(j-l[0])\na=0\ns=0\nwhile((a<=len(k)-5)and(s<4)):\n s=1\n b=a+2\n while((b 2: \n return n \nt = int(input())\n#print(t)\nfor i in range(t):\n a, b = map(int, input().split())\n diff = (a+b)*(a-b)\n #print(diff)\n #print(math.sqrt(diff))\n #print(\"d\", diff)\n if smallest(diff)== diff:\n print(\"YES\")\n else:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "16dacbf1cd7911a645e64c219bebb5c2", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "import math\ndef countd(n):\n cnt=0\n for i in range(1,int(math.sqrt(n))+1):\n if n%i==0:\n if n//i==i:\n cnt+=1\n else:\n cnt+=2\n return cnt\n \n \n return cnt \na,b,c=map(int,input().split())\nans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n t=i*j*k\n ans+=countd(t)\nprint(ans%1073741824)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "12de5b55a834fdbeb80407570d581d9b", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "print(max(abs(a-b)for a,b in zip(*[map(int,input().split())for _ in(1,2)]))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80c65a0ffbc57021577c8c9a0f009643", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nk = int(input())\na = 1\ni = 0\n\ndef ch():\n if (i>=k):\n break\n pass\n\nwhile n%10==0:\n ch()\n n /=10\n a*=10\n i+=1\nwhile n%5==0:\n ch()\n n/=5\n a*=10\n i+=1\nwhile n%2==0:\n ch()\n n/=2\n a*=10\n i+=1\nwhile i y:\n smaller = y\n else:\n smaller = x\n for i in range(1, smaller+1):\n if((x % i == 0) and (y % i == 0)):\n hcf = i \n return hcf\n\na,b = map(int, input().split())\n\nhcf = compute_hcf(a, b)\n\na = a/hcf\nb = b/hcf\ncount = int(0)\n# print(a,b,hcf)\nwhile b>=2:\n\t# print(b)\n\tif b%2==0:\n\t\tcount+=1\n\t\tb = b/2\n\telif b%3==0:\n\t\tcount+=1\n\t\tb = b/3\n\telif b%5==0:\n\t\tcount+=1\n\t\tb = b/5\n\telse:\n\t\tbreak\n\n\nwhile a>=2:\n\t# print(a)\n\tif a%2==0:\n\t\tcount+=1\n\t\ta = a/2\n\telif a%3==0:\n\t\tcount+=1\n\t\ta = a/3\n\telif a%5==0:\n\t\tcount+=1\n\t\ta = a/5\n\telse:\n\t\tbreak\n\t# print(a,b)\nif(a!=b):\n\tprint(-1)\nelse:\n\tprint(count)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "13763d63907b252dfcc97af408abf450", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "s=input()\nx=s.find(\"0\")+1\nif x:\n print x\nelse:\n print len(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "08e6439e7e4f5d001d22b295d38512fa", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\n\na = list(map(int, input().split()))\n\n\t\nif n == 1:\n\tprint (-1)\nelse:\n\tif a[-2] > a[-1] && a[-1] != 0:\n\t\tprint(\"DOWN\")\n\telse:\n\t\tprint(\"UP\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d0614daaba852ae5771861ad73e60af", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n# import sys\n\n# rules:\n# exchange len-1 with len-2 only if len-2 is not zero:\n# if the number is greater than decrease the swap count else let it be same\n# if this first rule is not applicable swap len-2 with len-3 and check and so on\n\n\n\n# if __name__ == '__main__':\n# \tnum,swap = raw_input().split()\n# \tnumlen = len(num)\n# \tswap = int(swap)\n# \tmaxnum = int(num)\n# ## compnum = num\n# ## num = bytearray(num)\n# \ti = 0\n# \t# for i in xrange (numlen-2):\n# \twhile swap !=0 and i <= numlen - 2:\n# \t\tif num[i+1] != '0' and i == 0:\n# \t\t\tcompnum = int(num)\n# \t\t\tnum = bytearray(num)\n# \t\t\ttemp = num[i]\n# \t\t\tnum[i] = num[i+1]\n# \t\t\tnum[i+1] = temp\n# ##\t\t\tprint num,i,maxnum\n# ##\t\t\tprint '.'\n# \t\t\ti += 1\n# \t\t\tif maxnum < int(num):\n# \t\t\t\tmaxnum = int(num)\n# ##\t\t\t\tprint maxnum\n# \t\t\t\tswap -= 1\n# ##\t\t\t\tprint swap\n# \t\t\t\ti = 0\n# \t\t\telse:\n# \t\t\t\tnum = str(compnum)\n# \t\t\t\t#break\n# \t\telif i != 0:\n# \t\t\tcompnum = int(num)\n# \t\t\tnum = bytearray(num)\n# \t\t\ttemp = num[i]\n# \t\t\tnum[i] = num[i+1]\n# \t\t\tnum[i+1] = temp\n# ##\t\t\tprint num,i,maxnum\n# ##\t\t\tprint ','\n# \t\t\ti += 1\n# \t\t\tif maxnum < int(num):\n# \t\t\t\tmaxnum = int(num)\n# ##\t\t\t\tprint maxnum\n# \t\t\t\tswap -= 1\n# ##\t\t\t\tprint swap\n# \t\t\t\ti = 0\n# \t\t\telse:\n# \t\t\t\tnum = str(compnum) \n# \t\telse: i += 1 \n# ##\tprint '...'\n# \tprint maxnum\n \nif __name__ == '__main__':\n\tnum,swap = raw_input().split()\n\tnum = list(num)\n\tswap = int(swap)\n\tans = ''\n\twhile num:\n\t\tpos = num.index(max(a[:swap+1]))\n\t\tans += num[pos]\n\t\tswap -= pos\n\t\tnum.pop(pos)\n\t\tif swap == 0:\n\t\t\tans += ''.join(num)\n\t\t\tbreak;\n\tprint ans\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2a4685081f8c61d2940e6d27a0f9d5b", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "def d(i):\n return (len(set(str(i)))==len(str(i))\nn,r=map(int,input().split())\nf=False\nfor i in range(n,r+1):\n if d(i):\n f=True\n print(i)\n break\nif not f:print(\"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57d274911b095a754f56eccff9e5a7ce", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ninf = 10**9+9\n\ndp = [inf]*(n+1)\nans = [[]for row in range(n+1)]\n\ndef binary(n) :\n s = 0\n t = 1;\n while n > 0 :\n s += t*(n%2)\n t *= 10\n n //= 2\n\n return s\n\ndp[0] = 0\ndp[1] = 1\nans[1].append(1)\n\nfor i in range(n+1) :\n l = len(str(i))\n for j in range(1,2**l) :\n b = binary(j)\n if b<=i :\n if dp[i-b]+1 < dp[i] :\n dp[i] = dp[i-b]+1\n ans[i] = list(ans[i-b])\n ans[i].append(b)\n\nprint(dp[n])\n\nfor i in ans[n] :\n print(i,end=\" \")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2d1a92d418bdf84a174d8013b1c93eff", "src_uid": "033068c5e16d25f09039e29c88474275", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n,pos,l,r=map(int,input().split())\n if pos>=l and pos <=r:\n if l==1 and r!=n:\n print(r-pos+1)\n elif r==n and l!=1:\n print(pos-l+1)\n elif l==1 and r==n:\n print(0)\n else:\n x=pos-l\n y=r-pos\n a=max(x,y)\n b=min(x,y)\n print(2*b+a+2)\n elif posr:\n if l!=1:\n print(pos-l+2)\n else:\n print(pos-r+1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c9a5799881cd3020332702574a40f9cf", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "#include \n#include\nusing namespace std ;\nint main()\n{\n string s ;\n cin>>s;\n s.replace(s.find(\"at\",1),2,\"@\");\n //cout<\n#define ll long long\n#define M 1000000007\n#define INF 9223372036854775807\n#define mp(x,y) make_pair(x,y)\n#define pb(x) push_back(x)\n#define pmp(x,y) pb(mp(x,y))\n#define ld double\n#define PI 3.14159265\n#define len(a) (ll)a.size() //\n#define F first\n#define S second\n#define ch cout<<\"debug\\n\"\n#define endl \"\\n\"\n#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)\nusing namespace std;\n\nmap m;\nint main(){\n\t\n\tll n;\n\tcin>>n;\n\tif(n%2==0)\n\t\tcout<<\"home\";\n\telse\n\t\tcout<<\"contest\";\n\t\n\t\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a2fc520ecb9d5a3b07644aed6a043a0", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = input()\nf=[0]*90\nf[0]=1\nf[1]=1\ni=2\nwhile 1:\n f[i]=f[i-1]+f[i-2]\n if f[i]>pow(10,18):\n break\n i+=1\nfor i in range(0,len(f)):\n if n>=f[i] and n= 2:\n cnt, flag = 0, False\n for i, mi in enumerate(m):\n if mi == '0':\n if flag:\n cnt += i - 1\n break\n else:\n flag = True\n cnt += i\n\n res = min(res, cnt)\n\n if '5' in n:\n i = m.index('5')\n if '0' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('0')\n n = n[:-cnt - 1] + n[-cnt:] + '0'\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n else\n j = m.index('0')\n if i > j:\n res = min(res, j + i - 1)\n else:\n res = min(res, j + i)\n\n if '2' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('2')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n if n.count('2') == 1 and n.index('2') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n if m.index('5') < len(n) - 1 and m.index('2') < len(n) - 1:\n j = m.index('2')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n if '7' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('7')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n if n.count('7') == 1 and n.index('7') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n if m.index('5') < len(n) - 1 and m.index('7') < len(n) - 1:\n j = m.index('7')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n print(res if res < 10**9 else -1)\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0,\n 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3f78aacb7c1fe6ab4b7cd4a4b0749c1", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def main():\n n, w = map(int, input().split())\n a = list(map(int, input().split()))\n res1 = [0 for i in range(n)]\n for i in range(n):\n res1[i] = (a[i] + 1) // 2\n w -= sum(res1)\n if w < 0:\n print(-1)\n return\n while w > 0:\n maxi = a.index(max(a))\n if w >= a[maxi] - res1[maxi]:\n res1[maxi] = a[maxi]\n w -= a[maxi] - res1[maxi]\n a[maxi] = 0\n else:\n res1[maxi] += w\n w = 0\n print(*res1)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3338dcb25b119a0b307ba70b2e4dc27", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, s = int(input()), input()\nprint(sum(2 ** i for i in range(n) if s[i] == 'B')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ec7d29087306df90709d9ef581d4196f", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 2", "source_code": "def mask(d):\n d=str(d)\n a1=[]\n st=''\n for i in range(len(d)):\n a1.append(d[i])\n for i in range(len(a1)):\n a1[i]=int(a1[i])\n for i in range(len(a1)):\n if a1[i]==4 or a1[i]==7:\n st=st+str(a1[i])\n if st=='':\n st='0'\n st=int(st)\n return st\n\ns=raw_input()\na,b='',''\nn=s.find(' ')\nfor i in range(n):\n a=a+s[i]\nfor i in range(n+1, len(s)):\n b=b+s[i]\n\na,b=int(a), int(b)\nc=a+1 \n\nwhile mask(c)!=mask(b):\n c=c+1\n\nprint(c)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "448cf8297304db7f722d53ea81194e17", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, d = map(int, input().split(\" \"))\ns = list(map(int, input().split(\" \")))\nl = [list(i for i in s if s[i] == 1)]\ndiff = [list(l[i+1] - l[i] if (l[i+1] - l[i]) <= d) else -1 if (l[i+1] - l[i]) > d) for i in range(0, len(l) - 1))]\nprint(min(diff))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "957403cb01e934265ba0ac2acad8e072", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = raw_input()\nb = raw_input()\nc = raw_input()\nd = raw_input()\nl = [len(a)-2,len(b)-2,len(c)-2,len(d)-2]\ndic={'A':l[0],'B':l[1],'C':l[2],'D':l[3]}\nl = sorted(l)\nbig=1\nsmall=1\ncount=0\n#print l\nif l[3]>=l[2]*2:\n count+=1\n big=1\nif 2*l[0]<=l[1]:\n count+=1\n small=1\nif count==1:\n if big==1:\n print max(dic.iterkeys(),key=lambda k:dic[k])\n if small==1\n print min(dic.iterkeys(),key=lambda k:dic[k])\nelse:\n print 'C'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78e42c0c9277bb6de554928fd0de3da4", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\"\"\"\n Template written to be used by Python Programmers.\n Use at your own risk!!!!\n Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).\n\"\"\"\nimport sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque, Counter as c\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom fractions import Fraction\n# sys.setrecursionlimit(2*pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(var): sys.stdout.write(str(var))\ndef outln(var): sys.stdout.write(str(var)+\"\\n\")\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\ndef dfs(source, p):\n global cycle_number\n if color[source] == 2:\n return\n if color[source] == 1:\n cycle_number += 1\n cur = p\n mark[cur] = cycle_number\n while cur != source:\n cur = par[cur]\n mark[cur] = cycle_number\n return\n par[source] = p\n color[source] = 1\n for child in graph[source]:\n if child == par[source]:\n continue\n dfs(child, source)\n color[source] = 2\n\n\ncycles = [[]] * 6\nn = int(data())\ngraph = dd(set)\ncolor, par, mark = [0] * 6, [0] * 6, [0] * 6\ncycle_number = 0\nfor i in range(n):\n u, v = sp()\n graph[u].add(v)\n graph[v].add(u)\ncnt = 0\nfor i in range(1, 6):\n if len(graph[i]) <= 1:\n cnt += 1\nif cnt >= 3:\n outln(\"WIN\")\n exit()\ndfs(1, 0)\nfor i in range(1, n + 1):\n if mark[i] != 0:\n cycles[mark[i]].append(i)\nfor i in cycles:\n if len(i) == 3:\n outln(\"WIN\")\n exit()\noutln(\"FAIL\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f19dd53999223143f46277beed55d0b9", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = []\nfor _ in range(4):\n l.extend(list(input())\n\nfor i in range(15, -1, -1):\n if(l[i] == '.'):\n l.pop(i)\n\nfor i in l:\n if(l.count(i) > 2 * n):\n print('No')\n exit()\nprint('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71b6d7a26a00dbc6e37523c26f05970f", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=[int(i) for i in input().split()]\nz=bin(0)\nfor i in range(len(n)-1):\n z=z^n[i]\nprint(int(z))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a0970fe66b933b50c1fbcc19bbdcff1e", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "Python 3", "source_code": "import math\nf = 998244353\n \ndef matchings(a,b):\n m = max(a,b)\n n = min(a,b)\n if n == 0:\n return 0\n \n t = 1\n for i in range(0,n):\n r = range(m-i,m+1)\n p = 1\n p = math.factorial(n)*math.factorial(i+1)//math.factorial(n-i-1)\n for e in r:\n if p > f:\n p = p % f\n p *= e\n t += int(p)\n return(t)\n\ninputs = [int(x) for x in input().split(\" \")]\nk = matchings(inputs[0],inputs[1])*matchings(inputs[0],inputs[2])*matchings(inputs[2],inputs[1]) % f\nprint(k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f85b9a1e25d665b9371f14b92b33cf70", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "r = int(input())\n\nif (r<5 or r%2==0)\n print(\"NO\")\n exit()\n\nprint(1, (r-3) // 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9710364021da61a1a9cdcee42422ff01", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": " = int(input())\nb = int(input())\nc = a + b\nst = str(a) + \"+\" + str(b) + \"=\" + str(c)\nst1 = list(st)\nfor i in range(0, st1.count(str(0))):\n st1.remove(str(0))\nst1 = \"\".join(st1)\nst1 = st1.split(\"+\")\na = int(st1[0])\nst1 = st1[1].split(\"=\")\nb = int(st1[0])\nc = int(st1[1])\ncheck = bool(a + b == c)\nif a + b == c:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a5aed451b92bfb6332a95ef9cbd6dab0", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "want_eat = map(int, input().split(' '))\ngrapes = map(int, input().split(' '))\ngrapes[0] -= want_eat[0]\nif grapes[0] < 0:\n return 'NO'\nall_grapes = sum(grapes)\nall_grapes -= want_eat[1]\nif all_grapes - grapes[0] < 0:\n return 'NO'\nif all_grapes < want_eat[2]:\n return 'NO'\nelse:\n return 'YES'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b18a0d620e64182e99de9fcb5a67e985", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ufeffn=int(input())\nprint(3**(3*n) -7**n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a8e2af0739c3f7fc9b56daea253b54d3", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import io\nimport os \ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\nfrom types import GeneratorType \ndef bootstrap(f, stack=[]):\n def wrappedfunc(*args, **kwargs):\n if stack:\n return f(*args, **kwargs)\n else:\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n else:\n stack.pop()\n if not stack:\n break\n to = stack[-1].send(to)\n return to \n return wrappedfunc\n\n\nfrom bisect import bisect_left \ndef solve():\n n, m = map(int, input().split())\n a = []\n for i in range(m):\n ai, bi = map(int, input().split())\n a.append((ai, bi))\n a.sort(key = lambda x: x[0])\n b = []\n presum = [0]\n for i in range(m):\n b.append(a[i][1])\n a[i] = a[i][0]\n presum.append(presum[-1]+a[i])\n ma = 0\n for i in range(m):\n s = a[i]\n ind = bisect_left(a, b[i])\n if m-ind>n-1:\n s+=presum[m]-presum[m-n+1]\n else:\n s+=presum[m]-presum[ind]\n s+=b[i]*(n-1-(m-ind))\n if ind<=i:\n if m-ind<=n-1:\n s-=a[i]\n s+=b[i]\n else:\n s-=a[i]\n s+=a[m-n]\n #print(s)\n if s>ma:\n ma = s\n print(ma)\ndef main():\n t = int(input())\n for i in range(t):\n solve()\n if i!=t-1:\n input()\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "74d6327eb93043d3a62e879d572f69b8", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "p = 10**9+7\nx,y = map(int,raw_input().split())\nif y%x != 0:\n\tprint 0\nelse:\n\ty /= x\n\td = set([])\n\ti = 1\n\twhile i*i<=y:\n\t\tif y%i == 0:\n\t\t\td.add(i)\n\t\t\td.add(y/i)\n\t\ti += 1\n\td = sorted(list(d))\n\tf = d[::]\n\tfor i in range(len(d)):\n\t\tf[i] = pow(2,d[i]-1,p)\n\t\tfor j in range(i):\n\t\t\tif d[i]%d[j]==0:\n\t\t\t\tf[i] -= f[j]\n\tprint f[-1]%p\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bca11ba83e4388afe325bfe993f74ad0", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "a,b,c = list(map(int,input().split()))\nimport math\na = math.factorial(n-1)//(math.factorial(k)*math.factorial(n-1-k)))\nprint(a*m*((m-1)**k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "752d1e45d1d08410913b11fbb4251fe1", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def find(arr,n,k):\n d = {}\n m = 0\n for a in arr:\nif a in d:\n d[a]+=1\n else:\n d[a]=1\n if m < d[a]:\n m = d[a]\n s = len(d)\n m = m%k + 1\n if m > 0:\nreturn s*m*k-len(arr)\n return s*k-len(arr)\n\n\ndef main():\n n,k = map(int,input().split())\n arr = list(map(int,input().split()))\n print(find(arr,n,k))\n\nif __name__==\"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a1830a32b3bc1d25b0ffef0eabe2f1be", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "k, r = map(int, input())\nprint(min(i for i in range(1,10) if k * i % 10 == r)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df38b2fa9bfc13a19ffad7cacb6d3365", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#coding=utf8\n'''\nCreated on 20160607\n\n@author: ChronoCorax\n'''\nn = int(input())\nk = int(input())\nc = n - 2 * k\nif c < 0: c = 0\na = n * (n - 1) // 2 - c * (c - 1) // 2\nprint(a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5338546d1836d87b0466043a20535925", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = input()\nb = int(a) - int(a[1:]) - 1\nprint([a, b][sum(map(int, a)) < sum(map(int, str(b)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3bcaa11b6ec6fc45b859a00aa2709d89", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "print(oct(int(input(), 16)).count('1'))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "016394c8dba06826694203cf420eb9e1", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\nimport sys\n\ndef mpow(base, p):\n temp = 1\n while p:\n if (p & 1):\n temp = (temp * base) % MOD\n p //= 2\n base = (base * base) % MOD\n return temp % MOD\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a, b, n, x = map(int, input().split())\n MOD = 10 ** 9 + 7\n temp = mpow(a, n)\n if a > 1:\n ans = ((temp * x % MOD) + (b * (temp - 1) % MOD) * mpow(a - 1, MOD - 2) % MOD) % MOD\n else:\n ans = ((temp * x % MOD) + b * (n % MOD) % MOD) % MOD\n print(ans) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e0b59f6c5ad94ce5a1dc9b03810a9ada", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "def li():\n return list(map(int, input().split(\" \")))\nprint((\"0\\n1\\n1\\n0\\n1\\n1\\n0\\n1\\n1\\n1\\n1\\n1\\n\"*5)[:30])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8f42961a1706dd81ecf01821a2bc0c2e", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 3", "source_code": "# from operator import itemgetter, attrgetter, methodcaller\n# from collections import Counter, defaultdict\n# from fractions import gcd\n# import sys\n# import math\n\n\ndef main():\n k = raw_input()\n k = int(k)\n\n print k**2 * 3\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b00fc933db06f945fa0ab2d2a2c775ee", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nmod = 1000000007\n\n\ndef a(n):\n res = 1\n for x in xrange(n+1, 2*n+1):\n res *= x\n for x in xrange(1, n+1):\n res /= x\n #res %= mod\n return res\n\nseen = {}\ndef c(n, k):\n if k == 0 or k == n:\n return 1\n key = (n, k)\n if key not in seen:\n val = (c(n-1, k) + c(n-1, k-1)) % mod\n seen[key] = val\n return val\n return seen[key]\n\ndef sol(n):\n return (c(2*n-1, n) * 2 - n) % mod\n\n#print sol(10*5)\nprint sol(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8396668ac8d8096937148a6eb0c665e", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n1,n2,k1,k2=map(int,input().split())\nif k2>k1:\n if (n1<=n2):\n print(\"Second\")\n elif n1>n2:\n print(\"First\")\nelif k1==k2:\n if n1>n2:\n print(\"First\")\n elif n1<=n2:\n print(\"Second\")\n \nelse (k1>k2):\n if (n1==n2)or(n1n2:\n print(\"First\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "741f8009d8505df727dd9ba3e319002a", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def ans(n):\n if(n==0):\n return 1\n elif(n<10):\n return n\n else:\n return max(n%10*(ans(n//10),9*(ans(n//10-1)))\n \n \nn=int(input())\nint y =ans(n)\nprint(y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a66f0b170174b15ba9a15ecdda8db4d", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "C, Ha, Hb, Wa, Wb = (int(x) for x in raw_input().split())\n\nif Ha * Wb > Hb * Wa:\n Ha, Hb, Wa, Wb = Hb, Ha, Wb, Wa\n\nres = 0\nif Wb * Wb > C:\n for y in xrange(0, C / Wb + 1):\n r = y * Hb + (C - y * Wb) / Wa * Ha\n res = max(r, res)\nelse:\n for x in xrange(0, Wb):\n r = x * Ha + (C - x * Wa) / Wb * Hb\n res = max(r, res)\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b5e4ad0d2bea9c482c759e27bff9126", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "x1,y1,x2,y2 = map(int,input().split())\n\nret = 0\nfor y in range(y1,y2+1):\n\tif y%2 == 0:\n\t\tret += (x2 - x1)//2\n\t\tif x1%2 == 0:\n\t\t\tret += 1\n\telse:\n\t\tret += (x2 - x1)//2\n\t\tif x1%2 == 1:\n\t\t\tret += 1\nprint(ret)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf84b98c2ec0116ff47417f1dbc88953", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "s = input()\nflag = 0 \nfor i in range (0,s.len())\n if(s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u' or s[i]=='y') :\n flag=1\n elif(s[i]=='A' or s[i]=='E' or s[i]=='I' or s[i]=='O' or s[i]=='U' or s[i]=='Y'):\n flag=1\n elif((s[i]>='a' and s[i]<='z') or(s[i]>='A' && s[i]<='Z')) :\n flag=0\nif(flag):\n print(\"YES\")\nelse :\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3b8c588dd2c401a85c5c5aab7d389853", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split())\ni=1\nwhile m>=i:\n m=m-i\n i+=1\n if i==n+1:\n i=1\nprint m", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40bc43cbf39ef7a0ac0fca2b38c876c3", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": " a = int(input())\n if a % 3 == 1:\n print( 2 * a // 3 + 1)\n if a % 3 == 0:\n print( 2 * a//3)\n if a % 3 == 2:\n print( 2 * (a//3) + 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e5ef233142c3cea726c7bc6ffae545c4", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 2", "source_code": "\ndef gcd(p,q):\n\tif(q==0):\n\t\treturn p\n\telse:\n\t\treturn gcd(q,p%q)\nn,m,x,y,a,b=map(int,raw_input().split())\nt=gcd(a,b)\na/=t\nb/=t\nk=n/a\nl=m/b\nsz=min(k,l)\na*=sz\nb*=sz\nlft=x-(a-a/2)\nbt=y-(b-b/2)\nif(lft<0):\n\tlft=0\nif(bt<0):\n\tbt=0\nif(lft+a>n):\n\tlft=n-a\nif(bt+b>m):\n\tbt=m-b\nprint lft,bt,lft+a,bt+b\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "846f6b514b0d97dd992eea4f071b21f8", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x1,y1,x2,y2=map(int,input().split())\na,b=map(int,input().split())\nif(x1==x2 and y1==y2):\n\tprint(\"YES\")\nelif(x1==x2 and abs(y1-y2)%b==0):\n\tprint(\"YES\")\nelif(y1==y2 and abs(x1-x2)%a==0):\n\tprint(\"YES\")\nelif(abs(x1-x2)//a==abs(y1-y2)//b):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a93a50f169de25d20257809f40a4ce5a", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "import math\nn,R,r=map(int,input().split())\nif n==1 and r<=R:\n print('YES')\n exit()\nelif n>1 and r==R:\n print('NO')\n exit()\nc = 2*math.pi/(2*math.asin(r/(R-r)))\nif c-n>-10**-6:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a72ceaf42cdaf0453ab7d96c5865386", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \n#include\nusing namespace std;\n\nint main()\n\n{\n string ch;\n\n\n cin>> ch;\n\n if(ch ==\"a1\" || ch ==\"h1\" || ch ==\"h8\" || ch==\"a8\")\n\n cout<<3<< endl;\n\n else if (((ch[0] =='a')||(ch[0]=='h'))||((ch[1]=='1')||(ch[1]=='8')))\n cout<<5<< endl;\n\n else\n cout<<8<< endl ;\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "27a21865a9c0a26fc71621ec4057ee36", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x, y, z= map(int, input().split())\n\n\nif x>0 and y>=0 z>=0 and y+z>0:\n if x>y and x>z:\n print(-1)\n elif y>x and x>z:\n print(-1)\n elif x>y and z>x:\n print(-1)\n else:\n print((y//x)+(z//x))\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a624a16f6c5436ea151a46b222576df4", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nx=n\nf=[]\nfor i in range(2,int(n**(0.5))+1):\n if n%i==0:\n c=0\n while n%i==0:\n c=c+1\n n=n//i\n f.append([i,c])\nm=0\nfor i in range(len(f)):\n m=m+f[i][1]\nif m>2 or x==1:\n if x==1:\n print(1)\n print(0)\n else:\n if f[0][1]>=2:\n print(1)\n print(f[0][0]**2)\n else:\n print(1)\n print(f[0][0]*f[1][0])\nelse:\n print(2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea0619203b2eed3f390379dceb9209ff", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n,k= map(int,input().split())\ns = input()\ns = sorted(s)\n ans = 0\n pre = 0\n for i in range(n):\n if k==0:\n break\n if ord(s[i])>=2+pre:\n k-=1\n ans += (ord(s[i])-97+1)\n pre = ord(s[i])\n if k==0:\n print(ans)\n else:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d92a9ac419bd2914d7c29c21eb05dd69", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a, b, c = map(int,input().split(\" \"))\nx, y, z = map(int,input().split(\" \"))\nneed = 0\nextras = 0\nif x - a > 0:\n need+=x-a\nelse :\n extras+= (a - x)//2\nif y - b > 0:\n need+=y-b\nelse :\n extras+= (b - y)//2\nif z - c > 0:\n need+=z-c\nelse :\n extras+=(c - z)//2\n\nif need > extras or x+y+z=0:\n print(\"No\")\nelse:\n print(\"Yes\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "64a7a417b8ffc21a54b8cc5dc40433b5", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "hps=[1,3,2,0]\ncat=['A','B','c','D']\n\nnum0=input()\nnum1=num0+1\nnum2=num0+2\n\nrems=[num0%4,num1%4,num2%4]\ngrp=[]\nfor r in rems:\n in=hps.index(r)\n c=cats[in]\n grp.append(c)\n\nprint(grp)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a7234032940450f511446032a6cb843d", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n,m,k=map(int,input().split()))\nif m>=n and k>=n:\n print(\"Yes\")\nelse:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e46264859350bda395d1dc43d2b0b9a", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m, mi, ma = map(int, input().split())\na = sorted(list(map(int, input().split())))\nif n - m >= 2:\n if a[0] >= mi and a[-1] <= ma:\n print('Correct')\n else:\n print('Incorrect')\nelif n - m == 1:\n if (a[0] >= mi and a[-1] == ma) or (a[0] == mi and a[-1] <= ma):\n print('Correct')\n else:\n print('Incorrect')\nelse:\n if a[0] == mi and a[-1] == ma:\n print('Correct')\n else:\n print('Incorrect')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d31b43d1e187a82cc894ff3add80d8d", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a=input()\nresult=1\nif a[0]!='1':\n print('NO')\n result=0\n break\nelse:\n for i in range(len(a)):\n if a[i]!='1' and a[i]!='4':\n print('NO')\n result=0\n break\n if result==1:\n length=len(a)\n for i in range(length-2):\n if a[i]=='4' and a[i+1]=='4' and a[i+2]=='4':\n print('NO')\n result=0\n break\nif result==1:\n print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6b71b94a98be02b34d58107d8278b7e", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\n\nn, m = map(int, raw_input().split())\nws = map(int, raw_input().split())\nbs = [int(x) - 1 for x in raw_input().split()]\n\nstack = []\nweights = []\nres = 0\nfor b in bs:\n # print b, stack, \":\", res, \"->\",\n if b in stack:\n ind = stack.index(b)\n weight = sum(weights[ind + 1:])\n del stack[ind]\n del weights[ind]\n else:\n weight = sum(weights)\n stack.append(b)\n weights.append(ws[b])\n res += weight\n # print res, \"(\", stack, weights, \")\"\n\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "541535ad188744c8e36b3f5683d07034", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\n\nf = {}\nf[-50]=\"f(-50) = -624992.93\"\nf[-49]=\"f(-49) = -588238.00\"\nf[-48]=\"f(-48) = -552953.07\"\nf[-47]=\"f(-47) = -519108.14\"\nf[-46]=\"f(-46) = -486673.22\"\nf[-45]=\"f(-45) = -455618.29\"\nf[-44]=\"f(-44) = -425913.37\"\nf[-43]=\"f(-43) = -397528.44\"\nf[-42]=\"f(-42) = -370433.52\"\nf[-41]=\"f(-41) = -344598.60\"\nf[-40]=\"f(-40) = -319993.68\"\nf[-39]=\"f(-39) = -296588.76\"\nf[-38]=\"f(-38) = -274353.84\"\nf[-37]=\"f(-37) = -253258.92\"\nf[-36]=\"f(-36) = -233274.00\"\nf[-35]=\"f(-35) = -214369.08\"\nf[-34]=\"f(-34) = -196514.17\"\nf[-33]=\"f(-33) = -179679.26\"\nf[-32]=\"f(-32) = -163834.34\"\nf[-31]=\"f(-31) = -148949.43\"\nf[-30]=\"f(-30) = -134994.52\"\nf[-29]=\"f(-29) = -121939.61\"\nf[-28]=\"f(-28) = -109754.71\"\nf[-27]=\"f(-27) = -98409.80\"\nf[-26]=\"f(-26) = -87874.90\"\nf[-25]=\"f(-25) = -78120.00\"\nf[-24]=\"f(-24) = -69115.10\"\nf[-23]=\"f(-23) = -60830.20\"\nf[-22]=\"f(-22) = -53235.31\"\nf[-21]=\"f(-21) = -46300.42\"\nf[-20]=\"f(-20) = -39995.53\"\nf[-19]=\"f(-19) = -34290.64\"\nf[-18]=\"f(-18) = -29155.76\"\nf[-17]=\"f(-17) = -24560.88\"\nf[-16]=\"f(-16) = -20476.00\"\nf[-15]=\"f(-15) = -16871.13\"\nf[-14]=\"f(-14) = -13716.26\"\nf[-13]=\"f(-13) = -10981.39\"\nf[-12]=\"f(-12) = -8636.54\"\nf[-11]=\"f(-11) = -6651.68\"\nf[-10]=\"f(-10) = -4996.84\"\nf[-9]=\"f(-9) = -3642.00\"\nf[-8]=\"f(-8) = -2557.17\"\nf[-7]=\"f(-7) = -1712.35\"\nf[-6]=\"f(-6) = -1077.55\"\nf[-5]=\"f(-5) = -622.76\"\nf[-4]=\"f(-4) = -318.00\"\nf[-3]=\"f(-3) = -133.27\"\nf[-2]=\"f(-2) = -38.59\"\nf[-1]=\"f(-1) = -4.00\"\nf[0]=\"f(0) = 0.00\"\nf[1]=\"f(1) = 6.00\"\nf[2]=\"f(2) = 41.41\"\nf[3]=\"f(3) = 136.73\"\nf[4]=\"f(4) = 322.00\"\nf[5]=\"f(5) = MAGNA NIMIS!\"\nf[6]=\"f(6) = MAGNA NIMIS!\"\nf[7]=\"f(7) = MAGNA NIMIS!\"\nf[8]=\"f(8) = MAGNA NIMIS!\"\nf[9]=\"f(9) = MAGNA NIMIS!\"\nf[10]=\"f(10) = MAGNA NIMIS!\"\nf[11]=\"f(11) = MAGNA NIMIS!\"\nf[12]=\"f(12) = MAGNA NIMIS!\"\nf[13]=\"f(13) = MAGNA NIMIS!\"\nf[14]=\"f(14) = MAGNA NIMIS!\"\nf[15]=\"f(15) = MAGNA NIMIS!\"\nf[16]=\"f(16) = MAGNA NIMIS!\"\nf[17]=\"f(17) = MAGNA NIMIS!\"\nf[18]=\"f(18) = MAGNA NIMIS!\"\nf[19]=\"f(19) = MAGNA NIMIS!\"\nf[20]=\"f(20) = MAGNA NIMIS!\"\nf[21]=\"f(21) = MAGNA NIMIS!\"\nf[22]=\"f(22) = MAGNA NIMIS!\"\nf[23]=\"f(23) = MAGNA NIMIS!\"\nf[24]=\"f(24) = MAGNA NIMIS!\"\nf[25]=\"f(25) = MAGNA NIMIS!\"\nf[26]=\"f(26) = MAGNA NIMIS!\"\nf[27]=\"f(27) = MAGNA NIMIS!\"\nf[28]=\"f(28) = MAGNA NIMIS!\"\nf[29]=\"f(29) = MAGNA NIMIS!\"\nf[30]=\"f(30) = MAGNA NIMIS!\"\nf[31]=\"f(31) = MAGNA NIMIS!\"\nf[32]=\"f(32) = MAGNA NIMIS!\"\nf[33]=\"f(33) = MAGNA NIMIS!\"\nf[34]=\"f(34) = MAGNA NIMIS!\"\nf[35]=\"f(35) = MAGNA NIMIS!\"\nf[36]=\"f(36) = MAGNA NIMIS!\"\nf[37]=\"f(37) = MAGNA NIMIS!\"\nf[38]=\"f(38) = MAGNA NIMIS!\"\nf[39]=\"f(39) = MAGNA NIMIS!\"\nf[40]=\"f(40) = MAGNA NIMIS!\"\nf[41]=\"f(41) = MAGNA NIMIS!\"\nf[42]=\"f(42) = MAGNA NIMIS!\"\nf[43]=\"f(43) = MAGNA NIMIS!\"\nf[44]=\"f(44) = MAGNA NIMIS!\"\nf[45]=\"f(45) = MAGNA NIMIS!\"\nf[46]=\"f(46) = MAGNA NIMIS!\"\nf[47]=\"f(47) = MAGNA NIMIS!\"\nf[48]=\"f(48) = MAGNA NIMIS!\"\nf[49]=\"f(49) = MAGNA NIMIS!\"\nf[50]=\"f(50) = MAGNA NIMIS!\"\n\ndata = []\nfor line in sys.stdin:\n data.append(int(line))\n\nwhile len(data) < 11:\n data.append(0)\ndata = data[0:11]\n\nans = ''\nfor x in data:\n ans = f[x] + \"\\n\" + ans\nprint(ans)[:-1]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2185bbcd5ed4946fcf78fbc3f74203f6", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "Python 3", "source_code": "lists=input().split()\r\nnumber_element_max=lists[0]\r\nmaximum_value_of_element=lists[1]\r\nnb_normal=1\r\nres=0\r\nfor i in range(2,number_element_max):\r\n number_possibility=0\r\n liste=primefactors(i)\r\n for element in liste:\r\n if element<=maximum_value_of_element:\r\n number_possibility+=1\r\n res+=(maximum_value_of_element**i)%998244353\r\n nb_normal*=number_possibility#nb element de la decomposition de i qui sont valable\r\n res-=nb_normal\r\n \r\n\r\n\r\ndef primefactors(n):\r\n #even number divisible\r\n liste=[]\r\n if n % 2 == 0:\r\n liste+=[2]\r\n \r\n #n became odd\r\n for i in range(3,int(math.sqrt(n))+1,2):\r\n if (n % i == 0):\r\n liste+=[i]\r\n return liste\r\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57ea455399a4aa9c650404c117dd9e7e", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "\na=map(int,raw_input().split())\nn=a.pop(0)\na.sort()\n\nfor ans in range(1,n+1):\n\tOK=1\n\n\tb=[1 for i in range(ans)]\n\n\tj=0\n\tfor i in range(ans,n):\n\t\tif a[i] 1 or k.count(1) > 0:\n print('YES')\nelif :\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0c489ae43e465e683464b75abea5ca5", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=[0]*m\nfor i in range(1,m+1):a[i*i%m]+=(n-i)//m+1\nprint(zip(a,a[0]+a[::-1]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f316b47f623fd90cc9414da6ed59786", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "mod = 10**9 + 7\ndef getAns(maxSide, minSide):\n if maxSide == 1:\n return 2\n if maxSide == 2:\n if minSide == 1:\n return 4\n else:\n return 6\n dpSide = [0] * maxSide\n for i in range(len(dpSide)):\n dpSide[i] = [0, 0]\n\n dpSide[0] = [1, 1]\n dpSide[1] = [2, 2]\n for i in range(1, len(dpSide)-1):\n dpSide[i+1][0] += dpSide[i][1]\n dpSide[i+1][0] += dpSide[i-1][1] * minSide\n dpSide[i+1][1] += dpSide[i][0]\n dpSide[i + 1][1] += dpSide[i-1][0] * minSide\n dpSide[i+1][0] %= mod\n dpSide[i+1][1] %= mod\n return sum(dpSide[maxSide-1]) % mod\n\n\n\nn, m = map(int, input().split())\nmaxSide = max(n, m)\nminSide = min(n, m)\nprint(getAns(maxSide, minSide))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b9673970e4cfea56c37430150a34070", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": " x = int(input())\n p = [4, 1, 3, 2, 0, 5]\n y = 0\n for i in range(6):\n if x & (1 << i):\n y |= 1 << p[i]\n print(y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1d1ef5c5a92bcd775d133ef8870b55c3", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "PyPy 3", "source_code": "l,r = [int(x) for x in input().strip().split()]\n\ndef next(n):\n\ts = str(n)\n\tk = len(s)\n\tif n>int(\"7\"*k):\n\t\treturn int(\"4\"*(k+1))\n\tif n0 else 0)),n)\n\tif int(s[0])==7:\n\t\tif s[1:]==\"\":\n\t\t\tc = max(int(\"7\"),n)\n\t\tc = max(int(\"7\"+str(next(int(s[1:])))),n)\n\treturn min(a,min(b,c))\nlast = next(l)\ntot = last\nfor i in range(l+1,r+1):\n\tif i>last:\n\t\tlast=next(i)\n\ttot+=last\nprint(tot)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef95cc05324de6f8c769768a7bd7fc25", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "m = []\nfor x in range(10):\n m.append(input()\nt = False\nfor y in range(10):\n for x in range(10):\n if x<6:\n if m[y][x+1] == m[y][x+2] == m[y][x+3] == m[y][x+4]==\"X\" and m[y][x]!=\"O\":\n t = True\n break\n if x>0 and x<7:\n if m[y][x-1] == m[y][x+1] == m[y][x+2] == m[y][x+3]==\"X\" and m[y][x]!=\"O\":\n t = True \n break\n if x>1 and x<8:\n if m[y][x-1] == m[y][x-2] == m[y][x+1] == m[y][x+2]==\"X\" and m[y][x]!=\"O\":\n t = True\n break\n if x>2 and x<9:\n if m[y][x-1] == m[y][x-2] == m[y][x-3] == m[y][x+1]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if x>3:\n if m[y][x-1] == m[y][x-2] == m[y][x-3] == m[y][x-4]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if x<6 and y <6:\n if m[y][x]!=\"O\" and m[y+1][x+1] == m[y+2][x+2] == m[y+3][x+3] == m[y+4][x+4]==\"X\":\n t = True\n break\n if x<7 and y <7 and x>0 and y >0 :\n if m[y][x]!=\"O\" and m[y-1][x-1] == m[y+1][x+1] == m[y+2][x+2] == m[y+3][x+3]==\"X\":\n t = True\n break\n if x<8 and y <8 and x>1 and y >1:\n if m[y][x]!=\"O\" and m[y-1][x-1] == m[y-2][x-2] == m[y+1][x+1] == m[y+2][x+2]==\"X\":\n t = True\n break\n if x<9 and y <9 and x>2 and y >2:\n if m[y][x]!=\"O\" and m[y-1][x-1] == m[y-2][x-2] == m[y-3][x-3] == m[y+1][x+1]==\"X\":\n t = True\n break\n if x>3 and y >3:\n if m[y][x]!=\"O\" and m[y-1][x-1] == m[y-2][x-2] == m[y-3][x-3] == m[y-4][x-4]==\"X\":\n t = True\n break\n if x > 3 and y < 6:\n if( m[y][x]!=\"O\" and m[y+1][x-1] == m[y+2][x-2] == m[y+3][x-3] == m[y+4][x-4]==\"X\":\n t = True\n break\n if x>2 and y <7 and x<9 and y >0:\n if m[y][x]!=\"O\" and m[y-1][x+1] == m[y+1][x-1] == m[y+2][x-2] == m[y+3][x-3]==\"X\":\n t = True\n break\n if x>1 and y <8 and x<8 and y >1:\n if m[y][x]!=\"O\" and m[y+1][x-1] == m[y+2][x-2] == m[y-1][x+1] == m[y-2][x+2]==\"X\":\n t = True\n break\n if x>0 and y <9 and x<7 and y >2:\n if m[y][x]!=\"O\" and m[y+1][x-1] == m[y-1][x+1] == m[y-2][x+2] == m[y-3][x+3]==\"X\":\n t = True\n break\n if x<6 and y >3:\n if m[y][x]!=\"O\" and m[y-1][x+1] == m[y-2][x+2] == m[y-3][x+3] == m[y-4][x+4]==\"X\":\n t = True\n break\n if y<6:\n if m[y+1][x] == m[y+2][x] == m[y+3][x] == m[y+4][x]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if y>0 and y<7:\n if m[y-1][x] == m[y+1][x] == m[y+2][x] == m[y+3][x]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if y>1 and y<8:\n if m[y-1][x] == m[y-2][x] == m[y+1][x] == m[y+2][x]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if y>2 and y<9:\n if m[y-1][x] == m[y-2][x] == m[y-3][x] == m[y+1][x]==\"X\" and m[y][x]!=\"O\":\n\n t = True\n break\n if y>3:\n if m[y-1][x] == m[y-2][x] == m[y-3][x] == m[y-4][x]==\"X\" and m[y][x]!=\"O\":\n \n t = True\n break\nprint (\"NO\") if t==False else print (\"YES\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d737afce8d242f0936a47a8872d67433", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n var n = ReadInt();\n var bak = n;\n var s = ReadToken();\n var ans = new string[100];\n int ind = 0;\n var alpha = Enumerable.Repeat(1, 26).ToArray();\n for (int i = 0; i < s.Length - 1; i++)\n {\n int j = i;\n if (s[i] != s[i + 1] /*&& alpha[s[i] - 'a'] > 0*/)\n {\n if (n == 1)\n {\n ans[ind] = s.Substring(j);\n }\n else\n {\n ans[ind++] = s[i].ToString();\n }\n if (alpha[s[i] - 'a'] > 0 )\n {\n alpha[s[i] - 'a']--;\n n--;\n }\n }\n else\n {\n for (j = i + 2; j < s.Length; j++)\n {\n if (s[i] != s[j] /*&& alpha[s[i] - 'a'] > 0*/)\n {\n if (n == 1)\n {\n ans[ind] = s.Substring(j);\n }\n else\n {\n ans[ind++] = s.Substring(i, j - i);\n }\n if (alpha[s[i] - 'a'] > 0)\n {\n alpha[s[i] - 'a']--;\n n--;\n }\n i = j -1;\n break;\n }\n }\n }\n if (n == 0)\n {\n Console.WriteLine(\"YES\");\n for (int k = 0; k < bak; k++)\n {\n Console.WriteLine(ans[k]);\n }\n return;\n }\n }\n Console.WriteLine(\"NO\");\n reader.Close();\n writer.Close();\n }\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n #endregion\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ca062e811867a1b4f7225c0fdbe65c9", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input()) + 1\nif n < 5:\n print(0)\n exit()\nc = 0\nfor i in range(n):\n if str(i).replace('0', '') == '5':\n c = 1\n elif str(i)[-1] != '9':\n c += 1\nprint(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4929b8b69d1d1a3527aab3fbae4d010", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import sys\n\ndef readints() :\n l = sys.stdin.readline()\n return map(int, l.split(' '))\n\ndef readstring() :\n l = sys.stdin.readline()[:-1]\n return l\n\ndef readint() :\n l = sys.stdin.readline()\n return int(l)\n\ndef clearchars(s, chars) :\n for c in chars :\n s = s.replace(c, '')\n return s\n\ndef gcd(a, b) :\n if (a < b ) :\n a, b = b, a\n if b == 0 :\n return a\n return gcd(b, a % b)\n\ndef hist(a) :\n h = {}\n for x in a :\n try : \n h[x] += 1\n except KeyError :\n h[x] = 1\n return h\n\ndef lucky(n) :\n s = set(str(n))\n return all(map(lambda x: x in '47', s)) \n\ndef yslice(a, j) :\n return map(lambda x: x[j], a)\n\ndef dist2(a, b) :\n return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5\n\ndef chain_len(a) :\n l = .0\n for d, e in zip(a, a[1:]) :\n l += dist2(d, e)\n return l\n\ndef is_prime(x) :\n if x == 1 :\n return False\n sq = int(x ** 0.5) \n for i in [2] + range(3, sq + 1, 2) :\n if x % i == 0 :\n return False\n return True\n\n\ndigits = '0123456789'\n\ndef noe() :\n print \"NO\"\n exit(0)\n\ndef yese() :\n print \"YES\"\n exit(0)\n\nn, m = readints()\n\na = []\nfor i in range(n) :\n a.append(readstring())\n\nc = 0\nfor i in range(n) :\n for j in range(m) :\n if a[i][j] == 'W' :\n if (i - 1 >= 0 and a[i-1][j] = 'P') or (i + 1 < n and a[i+1][j] = 'P') or (j - 1 >= 0 and a[i][j-1] = 'P') or (j + 1 < m and a[i][j+1] = 'P') :\n c += 1\n \nprint c\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "576369cb32197d8b3417b9c97197b3cf", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ns = raw_input()\ncords = []\nfor c in s:\n c = int(c)\n if c == 0:\n row, col = 3, 1\n else:\n row, col = (c-1)/3, (c-1)%3\n cords.append((row, col))\nvariants = 0\n\ndef tryforxy(curx, cury):\n isValid = True\n for i in range(1, len(cords)):\n curx += cords[i][0] - cords[i-1][0]\n cury += cords[i][1] - cords[i-1][1]\n if curx == 3 and cury == 1:\n continue\n elif curx >= 0 and curx < 3 and cury >= 0 and cury < 3:\n continue\n else:\n isValid = False\n return isValid\n\nfor x in range(3):\n for y in range(3):\n variants += tryforxy(x, y)\nvariants += tryforxy(3, 1)\n variants += 1\nif variants > 1:\n print \"NO\"\nelse:\n print \"YES\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2fc8a93a2da113fb7878e389f04fe434", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "while im:\n sum=0\n bus=bus+1\n flag=True\n i-=1\n else:\n sum=sum+x[i]\n i+=1\n flag=False\nif flag ==False:\n bus=bus+1\nprint(bus)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d03c3da74239561cfbb3ed643c6b291c", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "65176640804e821202e8592da4f02cea", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "NEAT=\"AEFHIKLMNTVWXYZ\"\na=input()\nif x in NEAT for x in a :\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8f2a0d932a072ae86cfdc612aec577f4", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "Python 3", "source_code": "x, y = [int(u) for u in input().strip().split()]\r\nflag = True\r\nlast = -1\r\nwhile x:\r\n p = x % y\r\n if p <= last or p == 0:\r\n flag = False\r\n break\r\n last = p\r\n x //= y\r\nprint(\"YES\" if flag else \"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "311b8213f696e54fa86f112e5db04315", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n=int(raw_input())\nsquareFreePart=1\nwhile(n>1):\n for p in range(2,n+1):\n \tif(n%p==0):\n\t\t\twhile(n%p==0):\n\t\t\t\tn=n/p\n\t\t\tsquareFreePart*=p\n\t\t\tbreak\nprint(squareFreePart)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fd4ef620cf536fb95e736e3bd5f7b153", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "from math import trunc\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\na, b = map(int, input().split())\nmcd = int(a * b / gcd(a, b))\nt = []\np, q = 0, 0\nif a != 1 and b != 1:\n t.append(1)\nfor i in range(1, mcd):\n if i % a == 0:\n p += i - t[len(t) - 1]\n t.append(i)\n elif i % b == 0:\n q += i - t[len(t) - 1]\n t.append(i)\nif a > b:\n p += 1\nelse:\n q += 1\nif p > q:\n print('Dasha')\nelif p < q:\n print('Masha')\nelse:\n print('Equal')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "abd95754689830523fe17d7f1801f6fe", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\n\nfor q in range(int(input())):\n\ta, b, m = map(int, input().split())\n\n\tif a == b:\n\t\tprint(1, a)\n\t\tcontinue\n\n\tk = 2\n\n\twhile k <= 50 and not ((1 << (k-2)) * (a+1) <= b <= (1 << (k-2)) * (a+m)):\n\t\tk += 1\n\t\n\tif k > 50:\n\t\tprint(-1)\n\t\tcontinue\n\n\tt = b - (1 << (k-2)) * (a+1)\n\n\tadd = [1] * (k-1)\n\tadd[0] = a\n\n\tfor i in range(1, k-1):\n\t\twhile add[i] < m and t >= (1 << (k-2-i)) * add[i]:\n\t\t\tadd[i] += 1\n\t\tt -= (1 << (k-2-i)) * (add[i] - 1)\n\n\tans = [a] * (k-1)\n\tfor i in range(1, k-1):\n\t\tans[i] = ans[i-1] * 2 - add[i-1] + add[i]\n\tprint(k, ' '.join(str(i) for i in ans), b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eb1c14ca5279cff40b2a1d1e8eb39988", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split())\nfor x in range(n,10**10):\n if((x%k) * (x//k) == n):\n print(x)\n exit()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4e84b76b4b0a6a2536d518eb31172bce", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "k,p=map(int, input().split())\nm=[]\nj = 0\nwhile True:\n j+=1\n if j%10!=0:\n m+=[str(j)[::-1]+str(j)]\n if j==10000000:\n break\nj=0\nfor i in range(k):\n j+=int(m[i])\nprint(j%p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a27dcbd71325e7a993d81f9eee4becb0", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=list(map(int,input().split()))\nprint(\"Bob\"if s.count(min(s))>n/2 else\"Alice\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "844003cd392cb7a3363e2dcf24b9f7ec", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n=int(input())\nch=input()\ns=0\ni=0\nif ch.count(ch[0])==n:\n\n print((n+1)//2))\nelse:\n while i=0:\n s+=1+a-i\n i+=a+j-i\n break\n elif j==n:\n s+=n-i\n i=n\n \n print(s)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "263f94baecd3979f6d4f05f99b63eaf2", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "[a,b,c] = (input().split(' '))\na = int(a)\nb = int(b)\nc = int(c)\ndays = 0;\n\nfactor = 10000000\nwhile factor!=1:\n while a>2*factor and b>1*factor and c>1*factor:\n a -= 3*factor\n b -= 2*factor\n c -= 2*factor\n days += 7*factor\n factor /= 10\n\nwhile a>2 and b>1 and c>1:\n a -= 3\n b -= 2\n c -= 2\n days += 7\n\nif c>1 and b>1:\n if a==0:\n days += 2\n elif a==1:\n days += 3\n elif a==2:\n days += 4\n\nelif c>1 and a>2:\n if b==0:\n days += 3\n elif b==1:\n days += 6\n \nelif b>1 and a>2:\n if c==0:\n days += 4\n elif c==1:\n days += 6\n\nelif c>1:\n if b==0 and a==0:\n days += 1\n elif b==0 and a==1:\n days += 2\n elif b==0 and a==2:\n days += 2\n elif b==1 and a==0:\n days += 2\n elif b==1 and a==1:\n days += 4\n elif b==1 and a==2:\n days += 5\n\nelif b>1:\n if c==0 and a==0:\n days += 1\n elif c==0 and a==1:\n days += 2\n elif c==0 and a==2:\n days += 4\n elif c==1 and a==0:\n days += 2\n elif c==1 and a==1:\n days += 3\n elif c==1 and a==2:\n days += 5\n\nelif a>2:\n if b==0 and c==0:\n days += 2\n elif b==0 and c==1:\n days += 2\n elif b==1 and c==0:\n days += 3\n elif b==1 and c==1:\n days += 5\n\nelse days += (a+b+c)\nprint(days)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80619a98c271cbe81c9508dc53dc2316", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "import math\n\nx = input()\ny = input()\nd = x % y\nnow = d\nl = len(str(x))\ns = str(x)\nzz = pow(10, l-1, y)\n\nfor i in xrange(1, l):\n t = int(s[i-1])\n now -= t*zz%y\n now += y\n now = (now * 10 + t)%y\n if now < d:\n d = now\nprint d\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b1c2c9155b0af160ce291d833404cc8", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "f0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\nP1 = \"What are you doing while sending \\\"\"\nP2 = \"\\\"? Are you busy? Will you send \\\"\"\nP3 = \"\\\"?\"\nf = []\ndef dfs(n, k):\n if(k > f[n]): return '.'\n if(n == 0): return f0[k - 1]\n if(k <= 34): return P1[k - 1]\n if(k <= f[n - 1] + 34): return dfs(n - 1, k - 34)\n if(k <= f[n - 1] + 66): return P2[k - f[n - 1] - 35]\n if(k <= f[n - 1] * 2 + 66): return dfs(n - 1, k - f[n - 1] - 66)\n return P3[k - f[n - 1] * 2 - 66 - 1]\nf.append(75)\ncnt = 0\nfor i in range(100000):\n f.append(f[cnt] * 2 + 68)\n cnt += 1\n\t\nq = int(input())\nwhile q > 0:\n q -= 1\n n, k = map(int, input().split(' '))\n\twhile n > 70:\n\t\tk -= 34\n\t\tn -= 1\n print(dfs(n, k), end='')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "754d8a112aba68a8492d2f5305278367", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "k = input().split()\nn = int(k[0])\nm = int(k[1])\nk = int(k[2])\n\nif ( k <= n+m-2 ):\n if ( k < n ):\n outn = int((n / (k + 1)) * m)\n else:\n outn = int(m / (k - n + 2))\n if ( k < m):\n outm = int( m / ( k + 1)) * n\n else:\n outm = int( n / ( k - m + 2 )\n return ( max( outn, outm))\nreturn -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5b76dc0e7be332c89c8572e1d89bf26", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "l = list(map(int,input().split());print(min(sum(l)//3 , sum(l) - max(l)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "34db7801d34ba2302589af48ba270cd1", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "'''input\n7\n2 3 4 1 6 7 5\n'''\n\ndef rints():\n return list(map(int, input().split()))\n\ndef ri():\n return int(input())\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return a\n return gcd(b, a % b)\n\ndef lcm(xs):\n if not xs:\n return 1\n if len(xs) == 1:\n return x[0]\n if len(xs) == 2:\n return (xs[0] * xs[1]) // gcd(xs[0], xs[1])\n return lcm(xs[:-2] + [lcm([xs[-2], xs[-1]])])\n\ndef dfs_cycle_length(arr, u, visited, origin):\n visited.add(u)\n nxt = arr[u-1]\n if nxt in visited:\n return None if nxt != origin else 1\n tmp = dfs_cycle_length(arr, nxt, visited, origin)\n return None if tmp is None else tmp + 1\n\ndef solve(arr):\n cycles = []\n visited = set([])\n for u in range(1, len(arr) + 1):\n if u not in visited:\n length = dfs_cycle_length(arr, u, visited, u)\n if length is None:\n return -1\n cycles.append(length//2 if length % 2 == 0 else length)\n return lcm(cycles)\n\ndef main():\n n = ri()\n arr = rints()\n print(solve(arr))\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b66f713a923f2ed22ad9c9eda5ecdce", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n = int(input())\na = int(input())\nb = int(input())\nfirst = n\nif n % a == 0:\n print('YES')\n print(n//a, 0)\n elif n % b == 0:\n print('YES')\n print(0, n // b)\nelse:\n while n % a and n > 0:\n n -= b\n if n < 0:\n print('NO')\n else:\n print('YES')\n print(n//a, (first-n) // b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "35697f67baf77d99181b89f86572a19f", "src_uid": "b031daf3b980e03218167f40f39e7b01", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n, q = map(int, raw_input().split())\nop = {'a':set(),'b':set(),'c':set(),'d':set(),'e':set(),'f':set()}\nfor _ in xrange(q):\n\ta, b = raw_input().split()\n\tif op.has_key(b):\n\t\top[b].add(a[0])\n\n# print op\n\nif len(op['a']) > 0:\n\ts = ['a']\n\tfor _ in xrange(1,n):\n\t\ts1 = []\n\t\tfor c in s:\n\t\t\tfor x in op[c]:\n\t\t\t\ts1.append(x)\n\t\ts = s1\n\t\t#print s\n\t#print s\n\tprint len(s)\nelse:\n\tprint 0\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2379638142bbf1ffcce1fa480858a2be", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "r, h = map(int, raw_input().split())\np = h / r\nq = h % r\nif 2 * q > (3. ** 0.5) * r: print 2 * p + 3\nelif 2 * q < r: print 2 * p + 1\nelse: print 2 * p + 2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e79e14e5ead5926ba1ebde5b0e108453", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n=input().split()\nl=int(n[0])\nr=int(n[1])\n\ns=0\nif l==235 and r==236:\n print(0)\n exit()\nif r==l and str(r)[0]==str(r)[len(str(r))-1]:\n print(1)\n exit()\nif r==l:\n print(0)\n exit()\nif r<=100:\n for i in range(l,r+1):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n print(s) \n exit()\nif l>=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n elif r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]\nusing namespace std;\ntypedef long long ll;\nconst int dx[9]={0,0,-1,1,1,1,-1,-1,0};\nconst int dy[9]={1,-1,0,0,1,-1,1,-1,0};\nchar g[9][9];\nbool f[10][9][9],vis[10][9][9];\nqueue q;\n\nint main()\n{\n for(int i=0;i<8;i++)for(int j=0;j<8;j++)cin>>g[i][j];\n for(int i=0;i<8;i++)for(int j=0;j<8;j++)if(g[i][j]=='S')f[0][i][j]=1;\n for(int t=1;t<=8;t++)for(int i=0;i<8;i++)for(int j=0;j<8;j++)f[t][i][j]=f[t-1][i-1][j];\n q.push(7);q.push(0);q.push(0);vis[0][7][0]=1;\n while(!q.empty())\n {\n int x=q.front();q.pop();\n int y=q.front();q.pop();\n int t=q.front();q.pop();\n if(t==8){\n cout<<\"WIN\"<7||ny>7||f[t+1][nx][ny]||vis[t+1][nx][ny])continue;\n q.push(nx);q.push(ny);q.push(t+1);\n vis[t+1][nx][ny]=1;\n }\n }\n cout<<\"LOSE\"< normal :\n\tif '*' in string:\n\t\tdiff = k - normal\n\t\tflag = False\n\t\tfor i in range(len(string)):\n\t\t\tif string[i] == '?':\n\t\t\t\tcontinue\n\t\t\telif string[i] == '*'\n\t\t\t\tif flag == False:\n\t\t\t\t\tflag = True\n\t\t\t\t\tfor _ in range(diff):\n\t\t\t\t\t\tprint(string[i - 1], end = '')\n\t\t\telse:\n\t\t\t\tprint(string[i],end = '')\n\n\telse:\n\t\tprint(\"Impossible\")\n\t\texit()\n\nelif k < normal:\n\tif '*' in string or '?' in string:\n\t\tdiff = normal - k\n\t\tnumber = get_special(string)\n\t\tif number >= diff:\n\t\t\ti = 0\n\t\t\tcount = 0\n\t\t\twhile i < n and count < diff:\n\t\t\t\tif string[i] != '*' and string[i] != '?':\n\t\t\t\t\ttry:\n\t\t\t\t\t\tif string[i + 1] == '*' or string[i + 1] == '?':\n\t\t\t\t\t\t\ti += 2\n\t\t\t\t\t\t\tcount += 1\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tprint(string[i], end= '')\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\texcept:\n\t\t\t\t\t\tprint(string[i], end='')\n\t\t\t\t\t\ti += 1\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t\n\t\t\t\ti += 1\n\n\t\t\tif i < n:\n\t\t\t\twhile i < n:\n\t\t\t\t\tif string[i] != '*' and string[i] != '?':\n\t\t\t\t\t\tprint(string[i], end = '')\n\t\t\t\t\ti += 1\n\t\t\texit()\n\n\n\n\t\telse:\n\t\t\tprint(\"Impossible\")\n\t\t\texit()\n\telse:\n\t\tprint(\"Impossible\")\n\t\texit()\nelse:\n\tfor i in string:\n\t\tif i != '?' and i != '*':\n\t\t\tprint(i, end='')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a38ddfc44411e2a7071b2a169206fdb", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nm = 1000000007\ndef ppp(a, k, n):\n b = 1\n while k:\n if k % 2 == 0:\n k /= 2\n a = (a * a) % n \n else:\n k -= 1\n b = (b * a) % n \n return b\ntnm1 = ppp(2, n - 1, m)\nprint (tnm1 * (1 + tnm1 * 2)) % m", "lang_cluster": "Python", "compilation_error": false, "code_uid": "830379cefcd6d9a13651f11d9b0eebb1", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn,p,t = stdin.readline().strip().split()\nn=int(n)\np=float(p)\nt=int(t)\nq = 1.0-p\na = [1]\nb = [1]\nfor i in xrange(1,3005):\n \ta.append(p*a[i-1])\n \tb.append(q*b[i-1])\ndp= []\nfor i in xrange(t+n+2):\n\ta=[]\n\tfor j in xrange(2+t+n):\n\t\ta.append(0)\n\tdp.append(a)\ndp[0][0] = 1\nfor i in xrange(t+1):\n\tfor j in xrange(n+1):\n\t\t#print \"for \",i,j,\" is \",dp[i][j]\n\t\tif j>=n:\n\t\t\tdp[i+1][j]+=dp[i][j]\n\t\telse:\n\t\t\tdp[i+1][j] +=dp[i][j]*q\n\t\t\tdp[i+1][j+1]+=dp[i][j]*p\nans = 0\nfor i in xrange(n+1):\n\tans+=i*dp[t][i]\nprint ans\n\t\t\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48e69b1745d164d98bb7a23a84ebd6d2", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a = map(int, input.split())\nb = map(int, input.split())\nprint('YES' if sum([(x - y) ** 2 for x, y in zip(a,b)]) == 9 else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b0f02588478f68cdc7187be1bab0a55", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\n\ndef f(x, s, index, length):\n\ta = int(s[index])\n\tif index == length - 1:\n\t\treturn 2 if (a + x) % 2 == 1 else 1\n\tif (a + x) % 2 == 0:\n\t\treturn f( (a+x)/2, s, index+1, length)\n\telse:\n\t\treturn f( (a+x)//2, s, index+1, length) + \\\n\t\t\t f( (a+x)//2+1, s, index+1, length)\n\ndef selfInclude(s):\n\tfor i in range(0, len(s)-1):\n\t\ta = int(s[i])\n\t\tb = int(s[i+1])\n\t\tif abs(a-b) > 1:\n\t\t\treturn False\n\treturn True\n\ns = sys.stdin.readline().strip()\nresult = 0\nif len(s) == 1:\n\tprint 9\n\tsys.exit(0)\n\nfor i in range(10):\n\tresult += f(i, s, 1, len(s))\nprint result-1 if selfInclude(s) else result\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0735463cca56d88ea58663ff80ca846c", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "g,s=[input() for i in range(4)],set()\nfor i in range(4)\n\ts.add(g[i][:3])\n\ts.add(g[i][1:])\n\ts.add(g[0][i] + g[1][i] + g[2][i])\nfor i in range(2)\n\tfor j in range 2 \n\t\ts.add(g[i][j] + g[i+1][j+1] + g[i+2][j+2])\n\t\ts.add(g[i][j+2] + g[i+1][j+1] + g[i+2][j])\nprint 'YES' if {',xx', 'x,x', 'xx.'} & s else 'NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "520a144bfff00e0dd0a8335455494ade", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "raw_input()\nparty = [int(x) for x in raw_input().split()]\ntotal_beat = sum(party) // 2\ns = party[0]\nalice = party[0] // 2\nif s > total_beat:\n print('1')\n print('1')\nelse:\n p = ['1']\n for i, other in enumerate(party[1:],2):\n if other <= alice\n s += other\n p.append(str(i))\n if s > total_beat:\n print(len(p))\n print(''.join(p))\n else:\n print('0')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "37b8c1986b88091b2d92a838cbc7e683", "src_uid": "0a71fdaaf08c18396324ad762b7379d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def main():\n p = [1]\n for i in range(1,11):\n p.append(p[i-1]*2)\n hr = '12345RGBYW'\n gt = {'1': 0,'2': 1,'3': 2,'4': 3,'5': 4,'R': 5,'G': 6,'B': 7,'Y': 8,'W': 9}\n \n def check(c,mask):\n tmp = gt[c]\n if (mask // p[tmp]) % 2 == 1:\n return True\n return False\n \n def count(mask):\n tmp = 0\n while mask>0:\n tmp+=mask % 2\n mask//=2\n return tmp\n \n n = int(input())\n a = list(input().split())\n ans = 10\n for mask in range(1024):\n f = True\n for i in range(n):\n for j in range(i+1,n):\n if a[i] == a[j]:\n pass\n elif (a[i][1] != a[j][1]) and (check(a[i][1],mask) or check(a[j][1],mask)):\n pass\n elif (a[i][0] != a[j][0]) and (check(a[i][0],mask) or check(a[j][0],mask)):\n pass\n else:\n f = False\n break\n if not f:\n break\n if f:\n ans = min(ans,count(mask))\n print(ans)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e06e801ab38239925d7dec5348b4e5bc", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n=int(input())\nfor i in range(n,0,-1)\nif n%i=0\nn=i\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f2d372e5d830edd683db8cd761c4a396", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n\nint a,b,t,i,count=0,c[]={6,2,5,5,4,5,6,3,7,6};\nint main() {\n\tstd::cin>>a>>b;\n\tfor(i=a;i<=b;i++)\n\t{\n\t\tt=i;\n\t\twhile(t>0)\n\t\t{\n\t\t\tcout<= 3 or (zero_count == 2 and one_count == 2):\n break\n b = []\n for i in range(6):\n if a[i] == 0:\n b.append(0)\n continue\n b.append(a[i] - 1)\n if a[i - 1] == 0:\n b[-1] -= 1\n if a[(i + 1) % 6] == 0:\n b[-1] -= 1\n a = b\n total_sum += current_sum\n\n zero_count = len(list(filter(lambda x: x == 0, a)))\n\n if zero_count == 3:\n return total_sum + (sum(a) // 3) ** 2\n elif zero_count == 2:\n return total_sum + sum(sorted(a, reverse=True)[:2])\n return total_sum\n\n\nassert solve([2, 4, 5, 3, 3, 6]) == 83\nassert solve([45, 19, 48, 18, 46, 21]) == 6099\nassert solve([1, 2, 1, 2, 1, 2]) == 13\nassert solve([1, 1, 1, 1, 1, 1]) == 6\nassert solve([7, 5, 4, 8, 4, 5]) == 175\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9859a3e07804a8648b5fd01249eda151", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\np=sum(l)b\nr=max(l)\nfor i in range(r,p):\n\ts=n*i\n\tif s-p>p:\n\t\tprint(i)\n\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e5da334a1ca8227422c058f409942f7d", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import sys\nimport math\n\n\n##sys.stdin = open('input.txt', 'r')\n\nw, b = map(int, raw_input().split())\n\ndp = [[2.0 for i in xrange(b + 1)] for j in xrange(w + 1)]\n\n#print dp\n\ndef DP(wi, bi, dp):\n if 0 == wi:\n return 0\n ans = float(wi) / (wi + bi)\n if 0 == bi or 1 == bi:\n dp[wi][bi] = ans\n return ans\n\n s = float(bi) / (wi + bi) * float(bi - 1) / (wi + bi - 1)\n ans += s * (float(wi) / (wi + bi - 2) * DP(wi - 1, bi - 2, dp))\n if bi > 2:\n ans += s * float(bi - 2) / (wi + bi - 2) * DP(wi, bi - 3, dp)\n dp[wi][bi] = ans\n return ans\n\nans = DP(w, b, dp)\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d88e607b468da815a3f4358aca690c0f", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "def erathos2(k):\n\tmark = [True for i in range(k)]\n\ti = 2\n\twhile (i < k):\n\t\tif !mark[i]:\n\t\t\ti += 1\n\t\t\tcontinue\n\t\tfor j in range(2*i,k,i):\n\t\t\tmark[j] = False\n\t\ti+=1\n\tp = [i for i in range(2,k) if mark[i]]\n\treturn p\n\ndef sum2(p, n):\n\tfor i in p:\n\t\tif i > n:\n\t\t\tbreak\n\t\tif n-i in p:\n\t\t\treturn(i, n-i)\n\treturn (-1,-1)\n\ndef sum3(p, n):\n\tfor i in p:\n\t\tif i > n:\n\t\t\tbreak\n\t\t(a,b) = sum2(p,n-i)\n\t\tif a >= 0:\n\t\t\treturn (i,a,b)\n\treturn (-1,-1,-1)\n\n\nn = int(raw_input())\np = erathos2(n+1)\n#print p\nif n in p:\n\tprint 1\n\tprint n\nelse:\n\t(a,b) = sum2(p,n)\n\tif a >= 0:\n\t\tprint 2\n\t\tprint a, b\n\telse:\n\t\t(a,b,c) = sum3(p,n)\n\t\tprint 3\n\t\tprint a, b, c\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "18cbcf3445b27f1714ff0408b43ffeee", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "input(),a=map(int,raw_input().split())\nprint max(a)^a[-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b60c33420e0905e8ff376762f321eb87", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nweights = list(input())\nprint(n, weights)\nweights.sort()\n\n# instability if i, j are single kayakers\ndef get_instability(i, j):\n test = list(weights)\n test.pop(i)\n test.pop(j)\n instability = 0\n for k in range(0, len(test) - 1, 2):\n instability += abs(weights[k] - weights[k+1])\n return instability\n \ninstabilities = []\nfor i in range(len(weights)):\n for j in range(len(weights)):\n if i == j:\n continue\n instabilities.append(get_instability(i, j))\n\nprint min(instabilities)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "253bbc3ce57561d4e525c17b1eb0b825", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a= int(input())\nc=[]\n\nfor i in range(a):\n if all(((i**j)-1)%a !=0 for j in range(1,a-1)) and (i**(a-1)-1)%a==0:\n c.append(i)\nprint(len(c))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab5396d99cc0e57a49e5a06ce502cb9f", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "s = input()\nk = int(input())\nn = len(s)\n\nmaxLen = 0\nfor i in range(0, n):\n\tfor j in range(i, n):\n\t\thalf = j - i + 1\n\t\tif 2 * half <= maxLen:\n\t\t\tcontinue\n\n \t\thi = min(j + half + 1, n)\n\t\thi2 = i - j - 1 + hi\n\n\t\tif s[i:hi2] == s[j + 1:hi] and j + half - n + 1 <= k: \n\t\t\tmaxLen = 2 * half\n\nprint(maxLen)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "870cf6ef94404bc1d9c8c62868c653ab", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n , m = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(n)\nprint(m)\nprint(a)\n\nhead = 0 \ntail = len(a) - 1\nres = 0\n\nwhile (1):\n\tif ( res == len(a)):\n\t\tbreak\n\tif ( a[head] <= m and head +1 != tail):\n\t\tres += 1\n\t\thead += 1\n\tif ( a[tail] <= m and tail -1 != head):\n\t\tres += 1\n\t\ttail -= 1\n\tif ( a[head] > m and a[tail] > m ):\n\t\tbreak\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "595b9c5c5e2b6cd931ee331e7ebc9d14", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gen_all(i, j, p, n, a):\n if p > n:\n yield a\n return\n a[i] = p\n yield from gen_all(i + 1, j, p + 1, n, a)\n a[j - 1] = p\n yield from gen_all(i, j - 1, p + 1, n, a)\n\nn, m = map(int, input().split())\nit = gen_all(0, n, 1, n, [0] * n)\nfor _ in range(m):\n ans = next(it)\n # print(ans)\nprint(' '.join(map(str, ans)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed595355215a45d72cfc1cbe7ac4e48a", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import sys\ninp = str( raw_input() )\nhand = list ( str(raw_input().split(' ') ) )\n\nfor i in inp:\n\tif i in hand:\n\t\tprint \"YES\"\n\t\texit()\n\telse:\n\t\tcontinue\nprint \"NO", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d3d12cc7556efcaa46db196a2e4c655", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n,k=map(int,raw_input().split())\nar=map(int,raw_input().split())\ni=0\nc1=ar.count(1)\nc2=ar.count(2)\nc3=10**9\nwhile(i<=(n-k)):\n l1=(ar[i:i+k])\n j=0\n temc=0\n while (j<=(n-k)):\n l2=ar[j:j+k]\n for t in xrange(k):\n if l1[t]!=l2[t]:\n temc+=1\n j+=k\n c3=min(temc,c3)\n i+=k\nprint min(c3,c1,c2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec46d57057fb08c54bdd1b36016a163b", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "class Subject:\n def __init__(self, id, low, high, complexity):\n self.id = id\n self.low = low\n self.high = high\n self.complexity = complexity\n self.day_links = [ {} for i in range(high - low + 1) ]\n\n def add_link(self, link):\n days = link.days\n links = self.day_links[link.weight - self.low]\n if days not in links or links[days].total < link.total:\n links[days] = link\n\n def __str__(self):\n return '[%d [%d, %d] %d]' % (self.id,\n self.low, self.high, self.complexity)\n\nclass Link:\n def __init__(self, subject, weight, total, days, previous):\n self.subject = subject\n self.weight = weight\n self.total = total\n self.days = days\n self.previous = previous\n\nclass Group:\n def __init__(self, complexity):\n self.complexity = complexity\n self.subjects = []\n\nneed_days, num_subjects, more = map(int, input().split())\ngroups = {}\nfor i in range(num_subjects):\n subject = Subject(i + 1, *list(map(int, input().split())))\n if subject.complexity not in groups:\n groups[subject.complexity] = Group(subject.complexity)\n groups[subject.complexity].subjects.append(subject)\ngroups = sorted(groups.values(), key = lambda group: group.complexity)\nnum_groups = len(groups)\n\ndef win(link):\n print('YES')\n schedule = need_days * [ None ]\n while link:\n subject = link.subject\n subject.weight = link.weight\n schedule[link.days - 1] = subject\n link = link.previous\n for subject in schedule:\n print(subject.id, subject.weight)\n import sys\n sys.exit()\n\nbest_link = None\n\nfor pos, group in enumerate(groups):\n #print(pos, '', ' '.join(map(str, group.subjects)))\n if num_groups - pos >= need_days:\n for subject in group.subjects:\n for weight in range(subject.low, subject.high + 1):\n subject.add_link(Link(subject, weight, weight, 1, None))\n for subject in group.subjects:\n for i, links in enumerate(subject.day_links):\n weight = subject.low + i\n for days, link in links.items():\n if link.weight != weight:\n print('expected weight %d, link has weight %d' % (\n weight, link.weight))\n import sys; sys.exit()\n if days == need_days:\n if not best_link or best_link.total < link.total:\n best_link = link\n continue\n for next_weight in [ weight + more, weight * more ]:\n max_pos = num_groups + days - need_days\n for next_pos in range(pos + 1, max_pos + 1):\n for next_subject in groups[next_pos].subjects:\n if next_weight < next_subject.low:\n continue\n if next_weight > next_subject.high:\n continue\n next_subject.add_link(Link(\n next_subject, next_weight,\n next_weight + link.total, days + 1, link))\n #print('%d -> %d (%d)' % (link.weight,\n # next_weight, days + 1))\n\nif best_link:\n win(best_link)\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "55403cae9c6e152d98016a700d69d3fc", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from itertools import permutations\nn, L = list(map(lambda x: int(x), input().split()))\nk = list(map(lambda x: int(x), input().split()))\ns = list(map(lambda x: int(x), input().split()))\nj = 1\nfor i in range(L):\n for x in range(len(s)):\n s[x] += 1\n if s[x] == L:\n s[x] = 0\n if any(tuple(k) == y for y in list(permutations(s))):\n print('YES')\n j = 0\n break\nif j == 1:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bba2857cf817922866a0758e655bd124", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\ny={}\ny[0] = 0\n# print(x)\nfor i in range(1,n+1):\n x=i\n dmax = 0\n while(x>0):\n d=x%10\n if(d>dmax):\n dmax = d\n x=x//10\n y[i]=y[i-dmax]+1\nprint(y[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d0e3c83b2b6866f0ca9a27537de64826", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n\n'''\nthis is docstring\n'''\n\nfrom sys import stdin\n\ndef main():\n '''\n this is docstring\n '''\n while True:\n try:\n _hh, _mm = map(int, stdin.readline().split(':'))\n except ValueError:\n break\n\n _tt = _hh * 60 + _mm\n i = 0\n while True:\n if _tt % 60 % 10 == _tt / 60 / 10 and _tt % 60 / 10 == _tt / 60 % 10:\n print i\n break\n _tt = (_tt + 1) % (24 * 60)\n i += 1\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28fd8ac3466dad2857fa32014e9ad241", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "def cmb(n, r, mod):#\u30b3\u30f3\u30d3\u30cd\u30fc\u30b7\u30e7\u30f3\u306e\u9ad8\u901f\u8a08\u7b97\u3000\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 998244353#\u51fa\u529b\u306e\u5236\u9650\nN = 2*10**5\ng1 = [1]*(N+1) # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1]*(N+1) #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [1]*(N+1) #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\n\nfor i in range( 2, N + 1 ):\n g1[i]=( ( g1[i-1] * i ) % mod )\n inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2[i]=( (g2[i-1] * inverse[i]) % mod )\ninverse[0]=0\n\nn = int(input())\nres = 0\nfor k in range(1,n+1):\n if (n-k) % 2==0:\n res += cmb((n-k)//2+k-1,k-1,mod)\n res %= mod\n\nres *= pow(inverse[2],n,mod)\nres %= mod\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a613eabe5dd69b0cb70b2037deb21248", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "n, _ = map(int, raw_input().split(' '))\n\na = [0] * 1048576\nfor i in map(int, raw_input().split(' ')):\n a[i] = 1\n\nj = 0\nfor i in range(1, len(a)):\n bit = len(a) >> 1\n while j & bit:\n j ^= bit\n bit >>= 1\n j ^= bit\n\n if i < j:\n a[i], a[j] = a[j], a[i]\n\nlength, cnt = 2, 1\nwhile length <= len(a):\n wlen = pow(3, 998244353 - 1 >> cnt, 998244353)\n\n for i in range(0, len(a), length):\n w = 1\n for j in range(i, i + length / 2):\n u = a[j]\n v = (a[j + length/2] * w) % 998244353\n\n a[j] = u + v if u + v < 998244353 else u + v - 998244353\n a[j + length/2] = u - v if u - v >= 0 else u - v + 998244353\n\n w = (w * wlen) % 998244353\n\n cnt += 1\n length <<= 1\n\na = map(lambda x: pow(x, n/2, 998244353), a)\n\nj = 0\nfor i in range(1, len(a)):\n bit = len(a) >> 1\n while j & bit:\n j ^= bit\n bit >>= 1\n j ^= bit\n\n if i < j:\n a[i], a[j] = a[j], a[i]\n\nlength, cnt = 2, 1\nwhile length <= len(a):\n wlen = pow(3, 998244352 - (998244352 >> cnt), 998244353)\n\n for i in range(0, len(a), length):\n w = 1\n for j in range(i, i + length / 2):\n u = a[j]\n v = (a[j + length/2] * w) % 998244353\n\n a[j] = u + v if u + v < 998244353 else u + v - 998244353\n a[j + length/2] = u - v if u - v >= 0 else u - v + 998244353\n\n w = (w * wlen) % 998244353\n\n cnt += 1\n length <<= 1\n\nres = 0\nn_1 = pow(len(a), 998244351, 998244353)\nfor i in range(len(a)):\n res = (res + a[i]*n_1) % 998244353\n\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "010c191e6c978b6720d5686b330a5a57", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "import numpy as np\nn=int(input())\nli=[]\nfor i in range(n):\n a=list(map(int,input().split()))\n li.append(a)\nli=np.array(li)\nfor i in range(n):\n for j in range(n):\n if(i==j):\n count+=1\n if(i+j==n):\n count+=1\nfor j in range(n):\n count+=a[n//2][j]\nfor i in li[:,n//2]:\n count+=i\n \ncount-=3*li[n//2][n//2]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0809d981c845f34580161fda43917796", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "Python 2", "source_code": "print(\"1\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "441797080b154c69c3a64541546dea5e", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\n[n, m] = map(int, input().strip().split())\nais = list(map(int, input().strip().split()))\nbis = list(map(int, input().strip().split()))\n\nais = [set(ais[2*i: 2*i + 2]) for i in range(n)]\nbis = [set(bis[2*i: 2*i + 2]) for i in range(m)]\n\ndef check(pair, pairs):\n\tres = []\n\tfor p in pairs:\n\t\ts = pair & p\n\t\tif len(s) == 1:\n\t\t\tres.append(s.pop())\n\tres = list(set(res))\n\tif len(res) == 1:\n\t\treturn res[0]\n\telif len(res) > 1:\n\t\treturn -1\n\telse:\n\t\treturn 0\n\n\nva = [check(a, bis) for a in ais]\nvb = [check(b, ais) for b in bis]\n\nvap = [v for v in va if v > 0]\nvbp = [v for v in vb if v > 0]\n\nvap = set(vap)\nvbp = set(vbp)\n\nvabp = vap & vbp\n\nif len(vabp) == 1:\n\tprint (vabp.pop())\nelif -1 not in va and -1 not in vb:\n\tprint (0)\nelse:\n\tprint (-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49aed4a7a390b8fdece4f7463a7d6b40", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import sys\n\nx, y = map(int, sys.stdin.readline().split())\n\nax, ay = 0, 0\nbx, by = 0, 0\n\ndef onsegment():\n if ax == bx:\n return (x == ax) and (\n (ay > by and ay > y >= by) or\n (ay < by and ay < y <= by))\n else:\n return (y == ay) and (\n (ax > bx and ax > x >= bx) or\n (ax < bx and ax < x <= bx))\n\nif x == 0 and y == 0:\n print 0\n exit(0)\n\nturn = -1\nwhile True:\n turn += 1\n bx, by = 1 - ax, ay\n if onsegment(): break\n\n turn += 1\n ax, ay = bx, by\n bx, by = ax, 1 - by\n if onsegment(): break\n\n turn += 1\n ax, ay = bx, by\n bx, by = -ax, by\n if onsegment(): break\n\n turn += 1\n ax, ay = bx, by\n bx, by = ax, -by\n if onsegment(): break\n\nprint turn\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48c41861a64a6527b390538b66fba76a", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n = input()\nprint( (n-2)*(n-2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c437dae01ffe23a596c0967683620c5", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "N,S,Q = map(int, input().split(\" \"))\n\ncounter=1\nwhile True:\n x = round(S/(1 - (Q - 1)/Q),9)\n if x >= N:\n break\n counter+=1\nprint(counter)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8f23c67d8146d2cfba5f6cbb7099a15d", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a, b = list( map( int, input().split() ) )\n\nif a == b:\n print( 1 )\nelse if a > b:\n print( a )\nelse:\n print( b )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30340a528e6b8216e013638528c51fe7", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from operator import mul\nfrom functools import reduce\n\n\ndef extract_factor(n, f):\n a = 0\n while n % f == 0:\n n /= f\n a += 1\n return a\n\n\ndef subtract_from_list(l, d):\n for e, i in enumerate(l):\n l[e], d = max(0, i - d), max(0, d - i)\n if d == 0:\n break\n assert d == 0, 'should have enough to subtract'\n\n\ndef solve(size1, size2):\n sizes = [list(size1), list(size2)]\n factor2 = [[extract_factor(n, 2) for n in s] for s in sizes]\n factor3 = [[extract_factor(n, 3) for n in s] for s in sizes]\n base = [[x // 2 ** y // 3 ** z for x, y, z in zip(s, f2, f3)] for s, f2, f3 in zip(sizes, factor2, factor3)]\n\n if reduce(mul, base[0]) != reduce(mul, base[1]):\n return\n\n factor2_total = [sum(x for x in f2) for f2 in factor2]\n factor3_total = [sum(x for x in f3) for f3 in factor3]\n\n d3 = factor3_total[0] - factor3_total[1]\n l = factor3[(1, 0)[d3 > 0]]\n subtract_from_list(l, abs(d3))\n factor2_total[(1, 0)[d3 > 0]] += abs(d3)\n l = factor2[(1, 0)[d3 > 0]]\n l[(1, 0)[d3 > 0]] += abs(d3)\n\n d2 = factor2_total[0] - factor2_total[1]\n l = factor2[(1, 0)[d2 > 0]]\n subtract_from_list(l, abs(d2))\n\n size_after = tuple(\n tuple(x * (2 ** y) * (3 ** z) for x, y, z in zip(b, f2, f3)) for b, f2, f3 in zip(base, factor2, factor3))\n return abs(d3) + abs(d2), size_after[0], size_after[1]\n\n\nif __name__ == '__main__':\n size1 = tuple(int(x) for x in raw_input().split())\n size2 = tuple(int(x) for x in raw_input().split())\n ans = solve(size1, size2)\n if ans is None:\n print -1\n else:\n m, s1, s2 = ans\n print m\n print s1[0], s1[1]\n p\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "99d9d53715491afa6ea3df94e5d8031d", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "dr = [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]]\n\nn = int(input())\nt = [int(i) for i in input().split()]\nvisited = set()\n\ndef dfs(d, pos, path):\n mem = (d, pos, path)\n if mem in visited:\n return set()\n else:\n visited.add(mem)\n if d == n+1:\n return set()\n cell = set()\n c = t[d-1]\n for _ in range(c):\n pos = (pos[0] + dr[path][0], pos[1] + dr[path][1])\n cell.add(pos)\n cell = cell.union(dfs(d+1, pos, (path+1) % 8))\n cell = cell.union(dfs(d+1, pos, (path-1) % 8))\n return cell\n\ntotal_cells = dfs(1, (0, 0), 0)\nprint(len(total_cells))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "29005474a8abc92ec28b4b7cf687e5ef", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import datatime\ndate1=datatime.datatime.strptime(input(),\"%Y:%m:%d\")\ndate2=datatime.datatime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((date2-date1).days))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "21191184906c6d52be32570013174c95", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ndef get_facs(n):\n\tn1 = n\n\tfacs = []\n\ti = 2\n\twhile i*i <= n1:\n\t\tif n1 % i == 0:\n\t\t\tfacs.append([i, 0])\n\t\t\twhile n1 % i == 0:\n\t\t\t\tfacs[-1][1] += 1\n\t\t\t\tn1 /= i\n\t\ti += 1\n\tif n1 > 1:\n\t\tfacs.append([n1, 1])\n\treturn facs\n\ndef sep(x, a, i=1):\n\t# seperate x into 3 piece x1,x2,x3, x2 <= x3, xi >= 1\n\tif i==3:\n\t\ta[2] = x - a[0] - a[1]\n\t\tif a[2] >= 0 and a[2] <= x:\n\t\t\tyield a\n\t\treturn\n\tfor xi in xrange(0, x+1):\n\t\ta[i-1] = xi\n\t\tfor y in sep(x, a, i+1):\n\t\t\tyield y\n\t\ta[i-1] = 0\n\nmax_n, min_n = 0, n*n*n\n\ndef extract(chs, facs):\n\tans = [1] * 3\n\tfor i,(fac,c) in enumerate(facs):\n\t\tfor j in xrange(3):\n\t\t\tans[j] *= fac ** chs[i][j]\n\treturn ans\n\ndef dfs(chs, i, k):\n\tif i == k:\n\t\ta, b, c = extract(chs, facs) \n\t\tn0 = (a+1) * (b+2) * (c+2)\n\t\t# print a, b, c, n0\n\t\tglobal max_n, min_n\n\t\tmax_n = max(max_n, n0)\n\t\tmin_n = min(min_n, n0)\n\t\treturn\n\tfor ch in sep(facs[i][1], [0]*3):\n\t\tchs[i] = ch\n\t\tdfs(chs, i+1, k)\n\nfacs = get_facs(n)\nif n == 1:\n\tprint 17, 17\nelse:\n\tk = len(facs)\n\tdfs([0]*k, 0, k)\n\tprint min_n - n, max_n - n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "113ac1f543d6d99409d8acb81eec730b", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "N=int(input())\nnum=[]\ni=0\nIN=input().split()\nwhile(i0):\n sum+=x\n x//=k\n if sum>=n:\n r=\n else:\n l=v+1\nprint(r)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a45707fcb8b23661552a4eb8e750801d", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import numpy as np\n\ndef myf(n,mylist):\n result = [20 for i in range(n)] \n begin_t = 0\n Big_begin_t = 0\n \n #for i in range(n):\n i = 0\n while (i < n): \n if ((mylist[i] - mylist[Big_begin_t]) < 1440):\n if (np.sum(result[Big_begin_t:i+1]) > 120):\n result[i] = 120 - np.sum(result[Big_begin_t:i])\n else:\n if ((mylist[i] - mylist[begin_t]) < 90):\n if (np.sum(result[begin_t:i+1]) > 50):\n result[i] = 50 - np.sum(result[begin_t:i])\n else:\n result[i] = 20\n \n else:\n begin_t += 1\n i = i -1\n else:\n Big_begin_t += 1\n i = i -1\n i +=1\n\n return (result)\n\n\n# \u0412\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445\nn = int(input()) \nfor i in range(n):\n mylist.append(int(input()))\nres = myf(n,mylist)\nprint (res) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "475f807125c6238978ed58fdfdc941b9", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import sys\nfrom math import *\n\nw = 'white'\nb = 'black'\n\ndef gcl(x, y):\n fc = sqrt(x**2 + y**2)\n c = int(fc)\n if c % 2 == 0:\n result = b\n else:\n result = w\n if not ((x > 0 and y > 0) or (y < 0 and x < 0)):\n if result == b:\n result = w\n else:\n result = b\n \n if c == fc:\n result = b\n return result\n\ndef main(argv=None):\n if argv is None:\n argv = sys.argv\n if len(sys.argv) != 3:\n return -1\n \n print( gcl(int(argv[1]), int(argv[2])) ),\n return 0\n \nif __name__ == \"__main__\":\n sys.exit(main())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b43347cf9cedaf5401a0835f7ee7d518", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import math as m\n\ns = input().split(\"=\")\nleft = s[0].split(\"+\")\na = len(left[0])\nb = len(left[1])\nright = len(s[1])\n\nif a+b+right % 2 == 1 or a+b+right % 2 == -1 m.fabs(right-a-b) > 2:\n print(\"Impossible\")\n\n# if m.fabs(right-a-b) == 1 or m.fabs(right-a-b) > 2:\n# print(\"Impossible\")\n\n# if a+b+right % 2 == 1:\n# print(\"Impossible\")\n# elif m.fabs(right-a-b) != 2 and right != a+b:\n# print(\"Impossible\")\n\nelif a+b == right:\n print(a*\"|\",\"+\",b*\"|\",\"=\",right*\"|\",sep=\"\")\nelif right-a-b == 2:\n right -= 1\n b += 1\n print(a*\"|\",\"+\",b*\"|\",\"=\",right*\"|\",sep=\"\")\nelif right-a-b == -2:\n right += 1\n if b > 1:\n b -= 1\n else:\n a -= 1\n print(a*\"|\",\"+\",b*\"|\",\"=\",right*\"|\",sep=\"\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "415db7102880fc0fc1e5137af8b325bf", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "Python 2", "source_code": "a, c = map(int, raw_input().split())\ndef to3base(n):\n l = ''\n while n > 0:\n l = l + str(n%3)\n n /= 3\n return l\na3 = to3base(a)\nc3 = to3base(c)\ni, j = 0, 0\nb3 = ''\nx, y = 0, 0\nwhile i < len(a3) or j < len(c3):\n if i >= len(a3): x = 0\n else: x = a3[i]\n if j >= len(c3): y = 0\n else: y = c3[i]\n z = str((int(y) -int(x) + 3) % 3)\n b3 += y\n i, j = i+1, j+1\ndef to10(n):\n ans = 0\n for i in xrange(len(n)):\n ans = ans * 3 + int(i)\n return ans\n \nprint to10(b3[::-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea753121399cd13a56a2a5f3922fd7b0", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "a1, a2, a3 = map(int, input().split())\nprint(1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "53603013b94bd2864b62aff531f9c04a", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "x_1, y_2 = map(int, raw_input().split(\" \"))\nx_2, y_2 = map(int, raw_input().split(\" \"))\n\nif x_1 == x_2 or y_1 == y_2:\n\tprint((abs(x_2 - x_1) + abs(y_2 - y_1)) * 2 + 6)\nelse:\n\tprint((abs(x_2 - x_1) + abs(y_2 - y_1) + 2) * 2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71566be547162919f880bfd2bd7cd665", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def prefix(s):\n v = [0]*len(s)\n for i in range(1,len(s)):\n k = v[i-1]\n while k > 0 and s[k] != s[i]:\n k = v[k-1]\n if s[k] == s[i]:\n k = k + 1\n v[i] = k\n return v\n\nn = int(input())\nn-=1\ns1 = input()\ns2 = input()\nopos = {'W':'E', 'E':'W', 'N':'S', 'S':'N'}\ns3 = ''\nfor elem in s2:\n s3 += opos[elem]\n \ns3[::-1]\ns = s3 + '$' + s1\n\na = prefix(s)[2 * n]\nif a == 0: print('YES')\nelse: print('NO')\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "15fd71aae91011112fcd1a7e542db1b6", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "import math\ndef divisors(n):\n i=2\n l=[]\n while i <= math.sqrt(n):\n if n%i==0:\n if n/i==i:\n l.append(i)\n else:\n l.append(i)\n l.append(n//i)\n i=i+1\n return l\ndef pebbles(n):\n if n==1:\n return 1\n else:\n c=divisors(n)\n m=min(c)\n return(n+pebbles(n//m)\nn=int(input())\nprint(pebbles(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e303186aadf3f307550d6be13ae5e925", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ns = str(input())\nans = 0\ntemp=''\ni = 0\nwhile i=97 and i 2:\n uln += 1\n print(n-uln)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "93b1f1bc1aa7bcdf3185bf9c6ef68a69", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "a=[[0]*11 for _ in range(11)]\nn,a[0][0]=map(int,raw_input().split())\nz=0\nfor r in range(n):\n for c in range(r+1):\n d=a[r][c]-1.0\n if d>0:\n z+=1.0\n a[r+1][c]+=d.0/2\n a[r+1][c+1]+=d.0/2\nprint z", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53c995da8e210cbe0e14ee99a1331a14", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import bisect\n\nn,p=map(int,input().split())\n\nP=[1<=count:\n print(ans)\n break\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed8d776ea75851fc3086c6b29115fabf", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "ay,ab = map(int,input().split())\ny,g,b = map(int,input().split())\nty = 2*y+1*g\ntb = 3*b+1*g\nif(ty+tb-ay-ab=<0) :\n print(0)\nelse :\n print(ty+tb-ay-ab)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5b35ccc6a5ad50d2a46305267787686", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def unlucky(n):\n if n <= 2:\n return -1\n a = list()\n for i in range(n, -1, -1):\n a.append(i)\n return a[:-1]\n\n\nprint(*unlucky(int(input())))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0787a40052a471d31520fd16a066c40", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a = int(input())\ns = input()\n\narr = [0, 0, 0]\n\ndef sum(arr):\n\tc = 0\n\tfor i in arr:\n\t\tc += i\n\treturn c\n\ndef determine(arr, poss, seen):\n\tif seen[arr[0]][arr[1]][arr[2]]:\n\t\treturn [arr[0]][arr[1]][arr[2]]\n\telse:\n\t\tseen[arr[0]][arr[1]][arr[2]] = True\n\t\tif arr[0] >= 2:\n\t\t\ta = [arr[0] - 1, arr[1], arr[2]]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(2):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\tif arr[1] >= 2:\n\t\t\ta = [arr[0], arr[1]-1, arr[2]]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(2):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\tif arr[2] >= 2:\n\t\t\ta = [arr[0], arr[1], arr[2]-1]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(3):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\tif arr[0] >= 1 and arr[1] >= 1:\n\t\t\ta = [arr[0] - 1, arr[1]-1, arr[2]+1]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(3):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\tif arr[0] >= 1 and arr[2] >= 1:\n\t\t\ta = [arr[0] - 1, arr[1]+1, arr[2]-1]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(3):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\tif arr[1] >= 1 and arr[2] >= 1:\n\t\t\ta = [arr[0] + 1, arr[1] - 1, arr[2] - 1]\n\t\t\tif seen[a[0]][a[1]][a[2]]:\n\t\t\t\tp1 = poss[a[0]][a[1]][a[2]]\n\t\t\telse:\n\t\t\t\tp1 = determine(a, poss, seen)\n\t\t\tfor i in range(3):\n\t\t\t\tif p1[i] == True: \n\t\t\t\t\tposs[arr[0]][arr[1]][arr[2]][i] = True\n\t\treturn poss[arr[0]][arr[1]][arr[2]]\n\nfor i in range(len(s)):\n\tif s[i] == \"B\":\n\t\tarr[0] += 1\n\telif s[i] == \"G\":\n\t\tarr[1] += 1\n\telse:\n\t\tarr[2] += 1\n\nb = arr[0]\ng = arr[1]\nr = arr[2]\nseen = [[[False for i in range(r+g+b+1)] for i in range(r+g+b+1)] for i in range(r+g+b+1)]\nseen[0][0][0] = True\nposs = [[[[False, False, False] for i in range(r+g+b+1)] for i in range(r+g+b+1)] for i in range(r+g+b+1)]\nposs[0][0][0] = [False, False, False]\n\nseen[1][0][0] = True\nposs[1][0][0][0] = True\n\nseen[0][1][0] = True\nposs[0][1][0][1] = True\n\nseen[0][0][1] = True\nposs[0][0][1][2] = True\n\na = determine(arr, poss, seen)\nt = \"\"\nif a[0] == True:\n\tt += \"B\"\nif a[1] == True:\n\tt += \"G\"\nif a[2] == True:\n\tt += \"R\"\n\nprint(t)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bfa519bbb941d475d3b45b1ea9666cf", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "print (len(raw_input())+1)*26-len(raw_input())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "652ebdbb75c735be1840dc893bb3618b", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "lst=map(int, raw_input().split())\nd = lst[0]; k = lst[1]; a = lst[2]; b = lst[3]; t = lst[4]\n\nwalk_len = d\nauto_len = 0\ncrash = 0\nmin_time = auto_len * a + walk_len * b\n\nwhile walk_len:\n\tauto_len += min(k, walk_len)\n\twalk_len = d - auto_len\n\tmin_time1 = auto_len * a + t * crash + walk_len * b\n\tcrash += 1\n\tif min_time1 >= min_time:\n\t\tbreak\n\tmin_time = min_time1\n\nprint min_time\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb6faaf3cf083ecbe2fbdb5303912554", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef long long ll;\n\n\n\n\n\n\n\n\n\n\n\nll sum(ll n)\n{\n\treturn (n * (n+1)) / 2;\n}\n\n// sum: s s+1 s+2 ... e\nll sum(ll s, ll e)\n{\n\tif(s <= 1)\n\t\treturn sum(e);\n\n\treturn sum(e) - sum(s-1);\n}\n\nll minSplitters(ll k, ll n)\n{\n\tll st = 1, en = k;\n\n\twhile(st < en)\n\t{\n\t\tll md = (st + en)/2;\n\t\tll s = sum(md, k);\n\n\t\tif(s == n)\n\t\t\treturn k - md + 1;\n\n\t\tif(s > n)\n\t\t\tst = md+1;\n\t\telse\n\t\t\ten = md;\n\t}\n\n\treturn k - st + 2;\n}\n\nint main()\n{\n\tll n, k;\n\tcin>>n>>k;\n\n\tif(n == 1)\n\t\tcout<<0<<\"\\n\";\t\t// already just 1 out flow source exist\n\telse if(n <= k)\n\t\tcout<<1<<\"\\n\";\t\t// we have 1-n splitter already\n\telse\n\t{\n\t\t--k;\n\t\t--n;\n\n\t\tif(sum(k) < n)\n\t\t\tcout<<-1<<\"\\n\";\n\t\telse\n\t\t\tcout< 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n \"\"\"\n Side effect!!! Changes node. Node should have exactly one child\n \"\"\"\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError(\"Out of ranges\")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\n\n\n# -----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree1:\n def __init__(self, data, default=0, func=lambda a, b: max(a, b)):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a + b):\n \"\"\"initialize the segment tree with data\"\"\"\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return \"SegmentTree({0})\".format(self.data)\n\n\n# -------------------------------iye ha chutiya zindegi-------------------------------------\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate n^(-1)\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print(\"Invalid argument to calculate (n^(-1))!\")\n print(\"n must be non-negative value. But the argument was \" + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n# --------------------------------------iye ha combinations ka zindegi---------------------------------\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n# --------------------------------------iye ha power ka zindegi---------------------------------\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left) / 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid] < key):\n count = mid + 1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\ndef binary(x, length):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\" * (length - len(y)) + y\n\ndef countGreater(arr, n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nn,k=map(int,input().split())\nl=[]\nse=set()\nfor i in range(k):\n a,b,c=map(int,input().split())\n l.append((a,b,c,i))\n se.add(b)\nl.sort()\nstack=[]\nt=0\nans=[0]*n\nfor i in range(n):\n if t n and b == n:\n b = sb * w\n\nh = sb - sa\n\nif h == 0:\n print 1\n exit()\n\nif h > 1:\n ch = 1\nelse:\n ch = 0\n\nif a != (sa - 1) * w + 1:\n ca = 1\nelse:\n ca = 0\n\nif b != sb * w:\n cb = 1\nelse:\n cb = 0\n\nc = ca + cb + ch\nif c == 1 and (ca > 0 or cb > 0):\n c = 2\nif c == 0:\n c = 1\n\nif c == 3 and (a - (sa - 1) * w) == (b - (sb - 1) * w) + 1:\n c = 2\n\nprint c\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c390109c4f394ec9a6380e3aa92bc4f", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nd = [int(input())]\nd.append(int(input()))\nd.append(int(input()))\n\ni = d.index(min(d))\nif i < 1.5:\n print((n-1)*d[i])\nelse:\n s = d[i]\n del d[i]\n print((n-2)*s3+min(d))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de6b9630e2f25a31b789d3c1ff080ba5", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "x,k=map(int,input().split())\n#x=60\n#k=5\nif x==1:\n print(1)\n import sys\n sys.exit()\n\nimport math \nL=int(math.sqrt(x))\nmod=10**9+7\nFACT=dict()\n\nfor i in range(2,L+2):\n while x%i==0:\n FACT[i]=FACT.get(i,0)+1\n x=x//i\n\nif x!=1:\n FACT[x]=FACT.get(x,0)+1\n\n\ndef prod(A,B,k,l,m):#A:k*l,B:l*m\n C=[[None for i in range(m)] for j in range(k)]\n\n for i in range(k):\n for j in range(m):\n ANS=0\n for pl in range(l):\n ANS=(ANS+A[i][pl]*B[pl][j])%mod\n\n C[i][j]=ANS\n\n return C\n\ndef plus(A,B,k,l):#a,B:k*l\n C=[[None for i in range(l)] for j in range(k)]\n\n for i in range(k):\n for j in range(l):\n C[i][j]=(A[i][j]+B[i][j])%mod\n\n return C\n \n\n#XX=[[1,1],[1,1],[1,1]]\n#YY=[[2,2,2],[2,3,4]]\n#print(prod(XX,YY,3,2,3))\n\nMAT_index=max(FACT.values())+1\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\n\nfor m in range(MAT_index):\n for l in range(m+1):\n x=pow(m+1,mod-2,mod)\n MAT[m][l]=x\n\n#print(MAT)\n\n \n#MAT_ini=MAT\n#for i in range(k-1):\n# MAT=prod(MAT,MAT_ini,MAT_index,MAT_index,MAT_index)\n\n#\u3053\u3053\u3092\u30c0\u30d6\u30ea\u30f3\u30b0\n\nMAT_dob=[None]*13\nMAT_dob[0]=MAT\nfor i in range(1,13):\n MAT_dob[i]=prod(MAT_dob[i-1],MAT_dob[i-1],MAT_index,MAT_index,MAT_index)\n\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\nfor i in range(MAT_index):\n MAT[i][i]=1\n\nfor i in range(13):\n if k & 1<=0 :\n f[i-k]=f[i-k]-f[i-k-k-1]\n ssum+=f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nprint(\" \".join([str(i) for i in sm]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aaa12ba4f7590983f71486e2cd5779f6", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "p=10**9+7\ndef S(x):\n\tif x==0:\n\t\treturn 0\n\telif x==1:\n\t\treturn 4\n\telif x&1:\n\t\treturn 11*pow(3,x/2,p)-7\n\telse:\n\t\treturn 19*pow(3,x/2-1,p)-7\ndef G(x):\n\treturn (S(x)+S(x+1>>1))*pow(2,p-2,p)%p;\nl,r=map(int,raw_input().split())\nprint (G(r)-G(l-1))%p;", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7aa2ca6381e0da389077eef8e3896d99", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n'''\n' Author: Cheng-Shih Wong\n' Email: mob5566@gmail.com\n' Date: 2017-09-22\n'''\n\ndef main():\n\n def num(left, right, dp, rev, revI):\n if left > right:\n return 1\n\n key = left, rev, revI\n if key in dp:\n return dp[key]\n nonlocal ans\n\n acc = 0\n\n for x in ('01' if ans[left]=='#' else ans[left]):\n \n temp = None\n if left == right:\n tmp = x\n elif ans[right]=='#':\n tmp = '01'\n else:\n tmp = ans[right]\n\n for y in tmp:\n if not ((rev and x>y) or (revI and x==y=='1')):\n acc += num(\n left+1,\n right-1,\n dp,\n rev and x==y,\n revI and x!=y\n )\n dp[key] = acc\n return acc\n\n n, k = map(int, input().split())\n k += 1\n\n ans = ['#'] * n\n\n for i in range(n):\n ans[i] = '0'\n tmp = num(0, n-1, {}, True, True)\n\n if k > tmp:\n k -= tmp\n ans[i] = '1'\n\n if ans[0] == '0':\n print(''.join(ans))\n else:\n print(-1)\n\nif __name__ == '__main__':\n import sys, os\n from time import time\n if len(sys.argv)>1 and os.path.exists(sys.argv[1]):\n sys.stdin = open(sys.argv[1], 'rb')\n st = time()\n main()\n print('----- Run {:.6f} seconds. -----'.format(time()-st), file=sys.stderr)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7eaae6c551e48d228dc4f41ad0620c0", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "inp = input()\r\nif len(inp)>1 and inp[0]=='0':\r\n print(0)\r\n exit()\r\nif inp == '0':\r\n print(1)\r\n exit()\r\nif inp == 'XX':\r\n print(0)\r\n exit()\r\nif inp in ['__', '_X', 'X_']:\r\n print(3)\r\n exit()\r\nif(len(inp) < 2):\r\n print(0)\r\n exit()\r\nl1 = inp[-1]\r\nl2 = inp[-2]\r\n\r\nposs = 0\r\nhas_x = False\r\nhas_xx = False\r\nif l2+l1 == '0X':\r\n has_xx = True\r\nif l2+l1 in ['00', '25', '50', '75']:\r\n poss = 1\r\nelif l2 == '_':\r\n poss = 4\r\n if l1 not in ['X', '_']:\r\n if l1 in ['0', '5']:\r\n poss = 2\r\n else:\r\n poss = 0\r\n elif l1 == 'X':\r\n has_x = True\r\nelif l2 == 'X':\r\n has_x = True\r\n if l1 == 'X':\r\n has_xx = True\r\n poss = 1\r\n elif l1 == '_':\r\n poss = 4\r\n elif l1 in ['0', '5']:\r\n poss = 2\r\nelif l2 in ['0', '2', '5', '7']:\r\n if l1 == '_':\r\n poss = 1\r\n elif l1 == 'X':\r\n has_x = True\r\n poss = 1\r\n else:\r\n poss = 0\r\nelse:\r\n poss = 0\r\n\r\nfor i in range(len(inp) - 2):\r\n if inp[i] == '_':\r\n if i == 0:\r\n poss *= 9\r\n else:\r\n poss *= 10\r\n if inp[i] == 'X':\r\n if i == 0:\r\n if has_xx:\r\n poss = 0\r\n else:\r\n poss *= 9\r\n elif not has_x:\r\n poss *= 10\r\n has_x = True\r\nprint(poss)\r\n\r\n# 0X\r\n# 1X\r\n# _X\r\n# XX\r\n\r\n# 00 -> 1\r\n# 01 -> 0\r\n# 0_ -> 1\r\n# 0X -> 1\r\n\r\n# 10 -> 0\r\n\r\n# _0 -> 2\r\n# _1 -> 0\r\n# __ -> 4\r\n# _X -> 4\r\n\r\n# X0 -> 2\r\n# X1 -> 0\r\n# X_ -> 4\r\n# XX -> 1\r\n\r\n print(0)\r\n exit()\r\nif inp in ['__', '_X', 'X_']:\r\n print(3)\r\n exit()\r\nif(len(inp) < 2):\r\n print(0)\r\n exit()\r\nl1 = inp[-1]\r\nl2 = inp[-2]\r\n\r\nposs = 0\r\nhas_x = False\r\nhas_xx = False\r\nif l2+l1 in ['00', '25', '50', '75']:\r\n poss = 1\r\nelif l2 == '_':\r\n poss = 4\r\n if l1 not in ['X', '_']:\r\n if l1 in ['0', '5']:\r\n poss = 2\r\n else:\r\n poss = 0\r\n elif l1 == 'X':\r\n has_x = True\r\nelif l2 == 'X':\r\n has_x = True\r\n if l1 == 'X':\r\n has_xx = True\r\n poss = 1\r\n elif l1 == '_':\r\n poss = 4\r\n elif l1 in ['0', '5']:\r\n poss = 2\r\nelif l2 in ['0', '2', '5', '7']:\r\n if l1 == '_':\r\n poss = 1\r\n elif l1 == 'X':\r\n has_x = True\r\n poss = 1\r\n else:\r\n poss = 0\r\nelse:\r\n poss = 0\r\n\r\nfor i in range(len(inp) - 2):\r\n if inp[i] == '_':\r\n if i == 0:\r\n poss *= 9\r\n else:\r\n poss *= 10\r\n if inp[i] == 'X':\r\n if i == 0:\r\n if has_xx:\r\n poss = 0\r\n else:\r\n poss *= 9\r\n elif not has_x:\r\n poss *= 10\r\n has_x = True\r\nprint(poss)\r\n\r\n# 0X\r\n# 1X\r\n# _X\r\n# XX\r\n\r\n# 00 -> 1\r\n# 01 -> 0\r\n# 0_ -> 1\r\n# 0X -> 1\r\n\r\n# 10 -> 0\r\n\r\n# _0 -> 2\r\n# _1 -> 0\r\n# __ -> 4\r\n# _X -> 4\r\n\r\n# X0 -> 2\r\n# X1 -> 0\r\n# X_ -> 4\r\n# XX -> 1\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fa68e2d5683317620d0e82a39fa33b96", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "a, b = input(), input()\na, b = ('abcdefgh'.find(a[0]), int(a[1]) - 1), ('abcdefgh'.find(b[0]), int(b[1]) - 1)\nt = [[0] * 8 for i in range(8)]\nt[a[0]] = [1] * 8\nfor i in range(8):\n t[i][a[1]] = 1\nfor i, j in [(1, 2), (1, -2), (2, 1), (2, -1), (-1, 2), (-1, -2), (-2, 1), (-2, -1)]:\n x, y = b[0] + i, b[1] + j\n if -1 < x < 8 and -1 < y < 8:\n t[yx]yx] = 1\n x, y = a[0] + i, a[1] + j\n if -1 < x < 8 and -1 < y < 8:\n t[x][y] = 1\nprint(sum(i.count(0) for i in t) - 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "84314c466a6270ef5ec82bc8f784e8da", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from math import sqrt\n\ndef factorization(n):\n fact=[]\n for i in range(1, int(sqrt(n)+1)):\n if n%i == 0:\n fact.append(i)\n fact.append(n//i)\n return fact\ns=0\nn = int(input())\nn2=str(n)\nfact=factorization(n)\nSetfact=set(fact)\nfact=list(Setfact)\nfor i in range(len(Setfact)):\n for j in range(len(n2)):\n if n2[j] in str(fact[i]):\n s+=1\n break\nprint(s)\n\n'''m={}\nm2=[]\nn2=str(n)\ns=0\ni=1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0d317271f0af8c3d5c7159d13e78152", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict, deque, Counter\r\nfrom heapq import heapify, heappop, heappush\r\nimport math\r\nfrom copy import deepcopy\r\nfrom itertools import combinations, permutations, product, combinations_with_replacement\r\nfrom bisect import bisect_left, bisect_right\r\n\r\nimport sys\r\ndef input():\r\n return sys.stdin.readline().rstrip()\r\ndef getN():\r\n return int(input())\r\ndef getNM():\r\n return map(int, input().split())\r\ndef getList():\r\n return list(map(int, input().split()))\r\ndef getListGraph():\r\n return list(map(lambda x:int(x) - 1, input().split()))\r\ndef getArray(intn):\r\n return [int(input()) for i in range(intn)]\r\n\r\nmod = 10 ** 9 + 7\r\nMOD = 998244353\r\nsys.setrecursionlimit(1000000)\r\ninf = float('inf')\r\neps = 10 ** (-10)\r\ndy = [0, 1, 0, -1]\r\ndx = [1, 0, -1, 0]\r\n\r\n#############\r\n# Main Code #\r\n#############\r\n\r\n\r\nN = getN()\r\nsame = [0] * (N + 1)\r\nfor i in range(1, N + 1):\r\n for j in range(i, N + 1, i):\r\n same[j] += 1\r\ndp = [0] * (N + 1)\r\nacc = [0] * (N + 1)\r\n\r\nfor i in range(1, N + 1):\r\n dp[i] = same[i] + acc[i - 1]\r\n dp[i] %= MOD\r\n acc[i] = dp[i] + acc[i - 1]\r\n acc[i] %= MOD\r\nprint(dp[N])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "79234d0609c43c5662bffca39635a41d", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\n# -*- coding: koi8-r -*-\n\ndef main():\n a = raw_input()\n b = raw_input()\n a = [int(i) for i in a.strip().split()]\n b = [int(i) for i in b.strip().split()]\n \n \n if b[0]+1>=a[1] and 2*a[1]+2>=b[0] or b[1]+1>=a[0] and 2*a[0]+2>=b[1]:\n print 'YES'\n else\n print 'NO'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ea7e7dc74db5f0b744fd73e661c8700", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import math\nif k >= n:\n print('NO')\nelse:\n t_1 = t*n/k\n\n if d % t == 0:\n \n x = d/t\n m = x*k\n t_2 = x*t\n while m < n:\n t_2 += t\n m += 2*k\n elif d < t:\n m = k\n t_2 = t\n while m < n:\n t_2 += d\n m += k\n if m t:\n x = math.ceil(d/t)\n t_2 = x*t\n m = (x-1)*k\n while m < n:\n t_2 += d-x*t\n m += k\n if m < n:\n t_2 += (x+1)*t-d\n m += k", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fba7221eb84df39e7838ee9369901b09", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a, b = input().split()\nx = int(max(a + b)) + 1\nprint(len(str(int(str(int(a, x) + int(b, x)), x))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1af64d0c884c63679ba06bc9cf841c3", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nimport sys\n\nl = [line.split()[0] for line in sys.stdin.readlines()]\nfor line in l:\n if line != 'WBWBWBWB' and line != 'BWBWBWBW':\n result = 'NO'\n break\nif result = 'NO':\n print \"NO\"\nelse:\n print 'YES'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ec7970ef4a3ddb286def0b300cc68da7", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "import sys\nimport math\nimport bisect\nimport atexit\nimport io\nimport heapq\nfrom collections import defaultdict, Counter\nMOD = int(1e9+7)\n\n\n\n# n = map(int, raw_input().split())\n# input = map(int, raw_input().split())\n\nn, m = map(int, raw_input().split())\nda = map(int, raw_input().split())\ndi = {}\nto = 0\nfor i in range(n):\n di[i+1] = da[i]\n to+=da[i]\npa = []\nfor i in range(m):\n a,b = map(int, raw_input().split())\n pa.append((a,b))\npa.sort()\nhave = 0\nidx = 0\nday = 0\nwhile to!=0:\n have += 1\n day += 1\n while idx 0:\n buy = min(have, di[pa[idx][1]])\n to -= buy\n di[pa[idx][1]] -= buy\n have -= buy\n idx += 1\n if have/2 >= to:\n print day\n exit(0)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7e4ebf56c54243baacd228f339f6d7ca", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "(a, b) = raw_input().split(\" \")\nrequests = raw_input().split(\" \")\n\nn = int(a)\nk = int(b)\n\nlibrary = []\n\nprice = 0\n\noccurences = {}\n \nfor e in requests:\n\treal = int(e)\n\n\tif real in occurences:\n\t\toccurences[real] += 1\n\telse:\n\t\toccurences[real] = 1\n \nfor i in range(n):\n\telement = int(requests[i])\n\t\n\toccurences[element] -= 1;\n\n\tif element in library:\n\t\tcontinue\n\n\tif len(library) == k:\n\t\tprocessed = False\n\n\t\tfor i in library:\n\t\t\tif occurences[i] <= 0:\n\t\t\t\tlibrary.remove(i)\n\t\t\t\tprocessed = True\n\t\t\t\tbreak\n \n \t\tif not processed:\n\t\t\tfor j in range(n - 1, i, -1):\n\t\t\t\tobject = int(requests[j])\n\t\t\t \n\t\t\t\tif object in library:\n\t\t\t\t\tlibrary.remove(object)\n\t\t\t\t\tbreak\n\n\n\tlibrary.append(element)\n\tprice += 1;\n\t\nprint price", "lang_cluster": "Python", "compilation_error": false, "code_uid": "05449a356da2e0bcad2075c0097f8256", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\nn = int(input())\n\nM = [int(i) for i in input().split()]\nR = [int(i) for i in input().split()]\n\nstart = time.time()\n\nm = 1\n\nfor i in range(n):\n m *= M[i]\n\na = [ 0 for i in range(m)]\n\nfor i in range(n):\n if R[i] >= M[i]:\n continue\n\n now = R[i]-1\n if now < 0:\n now += M[i]\n\n while (now < m):\n a[now] = 1\n now += M[i]\n\nprint(sum(a)/m)\nfinish = time.time()\n#print(finish - start)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b854fe9d38c80ca71ef6c4fa9b1058c8", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n=input()\nprint n/36,\ni=(n%36)/3\nif n%3==2: i+=1\nprint i\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a44b4dba1c4ee19533dc970812eda6da", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def okay(xc, yc, rc, xr, yr, rr, Rr):\n d = ((xc-xr) ** 2 + (yc-yr) ** 2) ** 0.5\n if d + rc <= rr:\n return True\n if d >= rc + Rr:\n return True\n if d + Rr <= rc:\n return True\n return False\n\nx1, y1, r1, R1 = map(float, input().split())\nx2, y2, r2, R2 = map(float, input().split())\nans = 0\nif okay(x2, y2, r2, x1, y1, r1, R1):\n ans += 1\nif okay(x2, y2, R2, x1, y1, r1, R1):\n ans += 1\nif okay(x1, y1, r1, x2, y2, r2, R2):\n ans += 1\nif okay(x1, y1, R1, x2, y2, r2, R2):\n ans += 1\nprint (ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "737cbc78854692a6cc47f7af22da2e82", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "'''\nCreated on 2011-3-19\n\n@author: zhxfl\n'''\np=map(int,raw_input().split())\nans=0\na=p[4]\nb=p[5]\nwhile a<=b:\n x=a\n for i in range(4):\n x=x%p[i];\n if x==a :ans=ans+1;\n a=a+1;\nprint ans;\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "172625f04c5ba69b58bb8f99f698a3f1", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nif b==min(a,b):\n a,b=b,a\nc=(a+b)//2\nd=c-a\ne=b-c\ns=0\np=0\n for i in range (1,d+1):\n s=s+i\n for j in range (1,e+1):\n p=p+j\nprint(s+p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbd18b90579f99ef16bcb09656251547", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "\n\nn,m= map(int,input().split())\n\n\ntotal_number = n//2\n\n\nif m%2==0:\n if (total_number-m//2)==n or m==n:\n print(1)\n else:\n print((total_number-m//2)+1)\nelse:\n if (m+1)//2==1 or m==1:\n print(1)\n else:\n print((m+1)//2+1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ff474ecbc7e684586e97f223dfd6c1f", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "from functools import lru_cache\nn,m = map(int,input().split())\narr = list(map(int,input().split()))\narr.sort(reverse=True)\n@lru_cache(maxsize=n)\ndef drink(i,c,remain):\n if remain<=0: return 0\n elif i==n: return float('inf')\n else:\n p1 = 1 + drink( i+1, 0, remain-(arr[i]-c) ) #next day\n p2 = float('inf')\n if arr[i]-c > 0: p2 = drink( i+1, c+1, remain-(arr[i]-c) ) #current day\n return min(p1,p2)\nans = drink(0,0,m)\nif ans==float('inf'):\n print(-1)\nelse:\n print(ans+1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "61ff5c7924016dd5316b14915cda7a15", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "res = -1\n\ndef perebor(num, a, b):\n\tglobal res\n\tfail = 0\n\n\tif b == len(num):\n\t\tb = a + 2\n\t\ta = a + 1\n\n\tif a == len(num) - 1 and b == len(num):\n\t\treturn\n\n\tx = num[0:a]\n\ty = num[a:b]\n\tz = num[b:]\n\tif len(x) > 1:\n\t\tif x[0] == '0':\n\t\t\tfail = 1\n\tif len(y) > 1:\n\t\tif y[0] == '0':\n\t\t\tfail = 1\n\tif len(z) > 1:\n\t\tif z[0] == '0':\n\t\t\tfail = 1\n\n\tif fail == 0:\n\t\tif int(x) <= 1000000 and int(y) <= 1000000 and int(z) <= 1000000:\n\t\t\tt = int(x) + int(y) + int(z)\n\t\t\tif t > res:\n\t\t\t\tres = t\n\n\tb += 1\n\tperebor(num, a, b)\n\t\t\n\nnum = raw_input()\nif len(num) < 4:\n\tprint -1\nelse\n\tperebor(num, 1, 2)\n\tprint res\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ae253c449d2bf775c8d60e37668c258", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import math\nbr = open('d.in')\nn = int(br.readline())\nm = [1, 1, 3, 19, 225, 3441, 79259, 2424195, 0]\nprint [0, (math.factorial(n) * n * m[n / 2]) % 1000000007][n % 2]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6912bd61f6024c8f62998e5047f69c6e", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n,a,b=map(int,input().split())\np=list(map(int,input().split()))\nq=list(p)\nq.reverse()\np=p[:int((n+1)/2)]\nq=q[:int((n+1)/2)]\ns=0\nm=min(a,b)\nfor i,j in zip(p,q):\n if(i==2 and j!=2):\n if(j):\n s=s+b\n else:\n s=s+a\n if(j==2 and i!=2):\n if(i):\n s=s+b\n else:\n s=s+a \n if(i==2 and j==2):\n s=s+m\n if(i!=2 and j!=2 and i!=j):\n s=-1\n break\nprint(s)\n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5ad1c3dabe90e86db4c8c5665fe036bb", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32\nType \"copyright\", \"credits\" or \"license()\" for more information.\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n\n\n\n\n\n\n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n0\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n15\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n15\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n59\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n59\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 19, in \n for x,y,z in a[0],a[1],a[2]:\nValueError: too many values to unpack (expected 3)\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\nvis[10*x+y]=1;\n vis[10*y+x]=1;\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 1, in \n n=int(input());\nValueError: invalid literal for int() with base 10: 'vis[10*x+y]=1;'\n>>> 3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\nSyntaxError: multiple statements found while compiling a single statement\n>>> 3\n3\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 19, in \n for x,y,z in a[0],a[1],a[2]:\nValueError: too many values to unpack (expected 3)\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\nvis[10*x+y]=1;\n vis[10*y+x]=1;\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 1, in \n n=int(input());\nValueError: invalid literal for int() with base 10: 'vis[10*x+y]=1;'\n>>> 3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\nSyntaxError: multiple statements found while compiling a single statement\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 20, in \n for x,y,z in a[0],a[1],a[2]:\nValueError: too many values to unpack (expected 3)\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\nvis[10*x+y]=1;\n vis[10*y+x]=1;\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 1, in \n n=int(input());\nValueError: invalid literal for int() with base 10: 'vis[10*x+y]=1;'\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n5\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\nvis[10*x+y]=1;\n vis[10*y+x]=1;'\nTraceback (most recent call last):\n File \"C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py\", line 1, in \n n=int(input());\nValueError: invalid literal for int() with base 10: 'vis[10*x+y]=1;'\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 1, 5), (0, 2, 0), (0, 2, 1), (0, 2, 2), (0, 2, 3), (0, 2, 4), (0, 2, 5), (0, 3, 0), (0, 3, 1), (0, 3, 2), (0, 3, 3), (0, 3, 4), (0, 3, 5), (0, 4, 0), (0, 4, 1), (0, 4, 2), (0, 4, 3), (0, 4, 4), (0, 4, 5), (0, 5, 0), (0, 5, 1), (0, 5, 2), (0, 5, 3), (0, 5, 4), (0, 5, 5), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 0, 3), (1, 0, 4), (1, 0, 5), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 1, 5), (1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 0), (1, 3, 1), (1, 3, 2), (1, 3, 3), (1, 3, 4), (1, 3, 5), (1, 4, 0), (1, 4, 1), (1, 4, 2), (1, 4, 3), (1, 4, 4), (1, 4, 5), (1, 5, 0), (1, 5, 1), (1, 5, 2), (1, 5, 3), (1, 5, 4), (1, 5, 5), (2, 0, 0), (2, 0, 1), (2, 0, 2), (2, 0, 3), (2, 0, 4), (2, 0, 5), (2, 1, 0), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 1, 5), (2, 2, 0), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 2, 4), (2, 2, 5), (2, 3, 0), (2, 3, 1), (2, 3, 2), (2, 3, 3), (2, 3, 4), (2, 3, 5), (2, 4, 0), (2, 4, 1), (2, 4, 2), (2, 4, 3), (2, 4, 4), (2, 4, 5), (2, 5, 0), (2, 5, 1), (2, 5, 2), (2, 5, 3), (2, 5, 4), (2, 5, 5), (3, 0, 0), (3, 0, 1), (3, 0, 2), (3, 0, 3), (3, 0, 4), (3, 0, 5), (3, 1, 0), (3, 1, 1), (3, 1, 2), (3, 1, 3), (3, 1, 4), (3, 1, 5), (3, 2, 0), (3, 2, 1), (3, 2, 2), (3, 2, 3), (3, 2, 4), (3, 2, 5), (3, 3, 0), (3, 3, 1), (3, 3, 2), (3, 3, 3), (3, 3, 4), (3, 3, 5), (3, 4, 0), (3, 4, 1), (3, 4, 2), (3, 4, 3), (3, 4, 4), (3, 4, 5), (3, 5, 0), (3, 5, 1), (3, 5, 2), (3, 5, 3), (3, 5, 4), (3, 5, 5), (4, 0, 0), (4, 0, 1), (4, 0, 2), (4, 0, 3), (4, 0, 4), (4, 0, 5), (4, 1, 0), (4, 1, 1), (4, 1, 2), (4, 1, 3), (4, 1, 4), (4, 1, 5), (4, 2, 0), (4, 2, 1), (4, 2, 2), (4, 2, 3), (4, 2, 4), (4, 2, 5), (4, 3, 0), (4, 3, 1), (4, 3, 2), (4, 3, 3), (4, 3, 4), (4, 3, 5), (4, 4, 0), (4, 4, 1), (4, 4, 2), (4, 4, 3), (4, 4, 4), (4, 4, 5), (4, 5, 0), (4, 5, 1), (4, 5, 2), (4, 5, 3), (4, 5, 4), (4, 5, 5), (5, 0, 0), (5, 0, 1), (5, 0, 2), (5, 0, 3), (5, 0, 4), (5, 0, 5), (5, 1, 0), (5, 1, 1), (5, 1, 2), (5, 1, 3), (5, 1, 4), (5, 1, 5), (5, 2, 0), (5, 2, 1), (5, 2, 2), (5, 2, 3), (5, 2, 4), (5, 2, 5), (5, 3, 0), (5, 3, 1), (5, 3, 2), (5, 3, 3), (5, 3, 4), (5, 3, 5), (5, 4, 0), (5, 4, 1), (5, 4, 2), (5, 4, 3), (5, 4, 4), (5, 4, 5), (5, 5, 0), (5, 5, 1), (5, 5, 2), (5, 5, 3), (5, 5, 4), (5, 5, 5)]\n5\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 1, 5), (0, 2, 0), (0, 2, 1), (0, 2, 2), (0, 2, 3), (0, 2, 4), (0, 2, 5), (0, 3, 0), (0, 3, 1), (0, 3, 2), (0, 3, 3), (0, 3, 4), (0, 3, 5), (0, 4, 0), (0, 4, 1), (0, 4, 2), (0, 4, 3), (0, 4, 4), (0, 4, 5), (0, 5, 0), (0, 5, 1), (0, 5, 2), (0, 5, 3), (0, 5, 4), (0, 5, 5), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 0, 3), (1, 0, 4), (1, 0, 5), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 1, 5), (1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 0), (1, 3, 1), (1, 3, 2), (1, 3, 3), (1, 3, 4), (1, 3, 5), (1, 4, 0), (1, 4, 1), (1, 4, 2), (1, 4, 3), (1, 4, 4), (1, 4, 5), (1, 5, 0), (1, 5, 1), (1, 5, 2), (1, 5, 3), (1, 5, 4), (1, 5, 5), (2, 0, 0), (2, 0, 1), (2, 0, 2), (2, 0, 3), (2, 0, 4), (2, 0, 5), (2, 1, 0), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 1, 5), (2, 2, 0), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 2, 4), (2, 2, 5), (2, 3, 0), (2, 3, 1), (2, 3, 2), (2, 3, 3), (2, 3, 4), (2, 3, 5), (2, 4, 0), (2, 4, 1), (2, 4, 2), (2, 4, 3), (2, 4, 4), (2, 4, 5), (2, 5, 0), (2, 5, 1), (2, 5, 2), (2, 5, 3), (2, 5, 4), (2, 5, 5), (3, 0, 0), (3, 0, 1), (3, 0, 2), (3, 0, 3), (3, 0, 4), (3, 0, 5), (3, 1, 0), (3, 1, 1), (3, 1, 2), (3, 1, 3), (3, 1, 4), (3, 1, 5), (3, 2, 0), (3, 2, 1), (3, 2, 2), (3, 2, 3), (3, 2, 4), (3, 2, 5), (3, 3, 0), (3, 3, 1), (3, 3, 2), (3, 3, 3), (3, 3, 4), (3, 3, 5), (3, 4, 0), (3, 4, 1), (3, 4, 2), (3, 4, 3), (3, 4, 4), (3, 4, 5), (3, 5, 0), (3, 5, 1), (3, 5, 2), (3, 5, 3), (3, 5, 4), (3, 5, 5), (4, 0, 0), (4, 0, 1), (4, 0, 2), (4, 0, 3), (4, 0, 4), (4, 0, 5), (4, 1, 0), (4, 1, 1), (4, 1, 2), (4, 1, 3), (4, 1, 4), (4, 1, 5), (4, 2, 0), (4, 2, 1), (4, 2, 2), (4, 2, 3), (4, 2, 4), (4, 2, 5), (4, 3, 0), (4, 3, 1), (4, 3, 2), (4, 3, 3), (4, 3, 4), (4, 3, 5), (4, 4, 0), (4, 4, 1), (4, 4, 2), (4, 4, 3), (4, 4, 4), (4, 4, 5), (4, 5, 0), (4, 5, 1), (4, 5, 2), (4, 5, 3), (4, 5, 4), (4, 5, 5), (5, 0, 0), (5, 0, 1), (5, 0, 2), (5, 0, 3), (5, 0, 4), (5, 0, 5), (5, 1, 0), (5, 1, 1), (5, 1, 2), (5, 1, 3), (5, 1, 4), (5, 1, 5), (5, 2, 0), (5, 2, 1), (5, 2, 2), (5, 2, 3), (5, 2, 4), (5, 2, 5), (5, 3, 0), (5, 3, 1), (5, 3, 2), (5, 3, 3), (5, 3, 4), (5, 3, 5), (5, 4, 0), (5, 4, 1), (5, 4, 2), (5, 4, 3), (5, 4, 4), (5, 4, 5), (5, 5, 0), (5, 5, 1), (5, 5, 2), (5, 5, 3), (5, 5, 4), (5, 5, 5)]\n5\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n[(0, 6, 2), (0, 6, 3), (0, 6, 4), (0, 6, 5), (0, 6, 6), (0, 6, 7), (0, 6, -1), (0, 7, 2), (0, 7, 3), (0, 7, 4), (0, 7, 5), (0, 7, 6), (0, 7, 7), (0, 7, -1), (0, 8, 2), (0, 8, 3), (0, 8, 4), (0, 8, 5), (0, 8, 6), (0, 8, 7), (0, 8, -1), (0, 9, 2), (0, 9, 3), (0, 9, 4), (0, 9, 5), (0, 9, 6), (0, 9, 7), (0, 9, -1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 0, 6), (0, 0, 7), (0, 0, -1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 1, 5), (0, 1, 6), (0, 1, 7), (0, 1, -1), (0, -1, 2), (0, -1, 3), (0, -1, 4), (0, -1, 5), (0, -1, 6), (0, -1, 7), (0, -1, -1), (1, 6, 2), (1, 6, 3), (1, 6, 4), (1, 6, 5), (1, 6, 6), (1, 6, 7), (1, 6, -1), (1, 7, 2), (1, 7, 3), (1, 7, 4), (1, 7, 5), (1, 7, 6), (1, 7, 7), (1, 7, -1), (1, 8, 2), (1, 8, 3), (1, 8, 4), (1, 8, 5), (1, 8, 6), (1, 8, 7), (1, 8, -1), (1, 9, 2), (1, 9, 3), (1, 9, 4), (1, 9, 5), (1, 9, 6), (1, 9, 7), (1, 9, -1), (1, 0, 2), (1, 0, 3), (1, 0, 4), (1, 0, 5), (1, 0, 6), (1, 0, 7), (1, 0, -1), (1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 1, 5), (1, 1, 6), (1, 1, 7), (1, 1, -1), (1, -1, 2), (1, -1, 3), (1, -1, 4), (1, -1, 5), (1, -1, 6), (1, -1, 7), (1, -1, -1), (2, 6, 2), (2, 6, 3), (2, 6, 4), (2, 6, 5), (2, 6, 6), (2, 6, 7), (2, 6, -1), (2, 7, 2), (2, 7, 3), (2, 7, 4), (2, 7, 5), (2, 7, 6), (2, 7, 7), (2, 7, -1), (2, 8, 2), (2, 8, 3), (2, 8, 4), (2, 8, 5), (2, 8, 6), (2, 8, 7), (2, 8, -1), (2, 9, 2), (2, 9, 3), (2, 9, 4), (2, 9, 5), (2, 9, 6), (2, 9, 7), (2, 9, -1), (2, 0, 2), (2, 0, 3), (2, 0, 4), (2, 0, 5), (2, 0, 6), (2, 0, 7), (2, 0, -1), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 1, 5), (2, 1, 6), (2, 1, 7), (2, 1, -1), (2, -1, 2), (2, -1, 3), (2, -1, 4), (2, -1, 5), (2, -1, 6), (2, -1, 7), (2, -1, -1), (3, 6, 2), (3, 6, 3), (3, 6, 4), (3, 6, 5), (3, 6, 6), (3, 6, 7), (3, 6, -1), (3, 7, 2), (3, 7, 3), (3, 7, 4), (3, 7, 5), (3, 7, 6), (3, 7, 7), (3, 7, -1), (3, 8, 2), (3, 8, 3), (3, 8, 4), (3, 8, 5), (3, 8, 6), (3, 8, 7), (3, 8, -1), (3, 9, 2), (3, 9, 3), (3, 9, 4), (3, 9, 5), (3, 9, 6), (3, 9, 7), (3, 9, -1), (3, 0, 2), (3, 0, 3), (3, 0, 4), (3, 0, 5), (3, 0, 6), (3, 0, 7), (3, 0, -1), (3, 1, 2), (3, 1, 3), (3, 1, 4), (3, 1, 5), (3, 1, 6), (3, 1, 7), (3, 1, -1), (3, -1, 2), (3, -1, 3), (3, -1, 4), (3, -1, 5), (3, -1, 6), (3, -1, 7), (3, -1, -1), (4, 6, 2), (4, 6, 3), (4, 6, 4), (4, 6, 5), (4, 6, 6), (4, 6, 7), (4, 6, -1), (4, 7, 2), (4, 7, 3), (4, 7, 4), (4, 7, 5), (4, 7, 6), (4, 7, 7), (4, 7, -1), (4, 8, 2), (4, 8, 3), (4, 8, 4), (4, 8, 5), (4, 8, 6), (4, 8, 7), (4, 8, -1), (4, 9, 2), (4, 9, 3), (4, 9, 4), (4, 9, 5), (4, 9, 6), (4, 9, 7), (4, 9, -1), (4, 0, 2), (4, 0, 3), (4, 0, 4), (4, 0, 5), (4, 0, 6), (4, 0, 7), (4, 0, -1), (4, 1, 2), (4, 1, 3), (4, 1, 4), (4, 1, 5), (4, 1, 6), (4, 1, 7), (4, 1, -1), (4, -1, 2), (4, -1, 3), (4, -1, 4), (4, -1, 5), (4, -1, 6), (4, -1, 7), (4, -1, -1), (5, 6, 2), (5, 6, 3), (5, 6, 4), (5, 6, 5), (5, 6, 6), (5, 6, 7), (5, 6, -1), (5, 7, 2), (5, 7, 3), (5, 7, 4), (5, 7, 5), (5, 7, 6), (5, 7, 7), (5, 7, -1), (5, 8, 2), (5, 8, 3), (5, 8, 4), (5, 8, 5), (5, 8, 6), (5, 8, 7), (5, 8, -1), (5, 9, 2), (5, 9, 3), (5, 9, 4), (5, 9, 5), (5, 9, 6), (5, 9, 7), (5, 9, -1), (5, 0, 2), (5, 0, 3), (5, 0, 4), (5, 0, 5), (5, 0, 6), (5, 0, 7), (5, 0, -1), (5, 1, 2), (5, 1, 3), (5, 1, 4), (5, 1, 5), (5, 1, 6), (5, 1, 7), (5, 1, -1), (5, -1, 2), (5, -1, 3), (5, -1, 4), (5, -1, 5), (5, -1, 6), (5, -1, 7), (5, -1, -1), (-1, 6, 2), (-1, 6, 3), (-1, 6, 4), (-1, 6, 5), (-1, 6, 6), (-1, 6, 7), (-1, 6, -1), (-1, 7, 2), (-1, 7, 3), (-1, 7, 4), (-1, 7, 5), (-1, 7, 6), (-1, 7, 7), (-1, 7, -1), (-1, 8, 2), (-1, 8, 3), (-1, 8, 4), (-1, 8, 5), (-1, 8, 6), (-1, 8, 7), (-1, 8, -1), (-1, 9, 2), (-1, 9, 3), (-1, 9, 4), (-1, 9, 5), (-1, 9, 6), (-1, 9, 7), (-1, 9, -1), (-1, 0, 2), (-1, 0, 3), (-1, 0, 4), (-1, 0, 5), (-1, 0, 6), (-1, 0, 7), (-1, 0, -1), (-1, 1, 2), (-1, 1, 3), (-1, 1, 4), (-1, 1, 5), (-1, 1, 6), (-1, 1, 7), (-1, 1, -1), (-1, -1, 2), (-1, -1, 3), (-1, -1, 4), (-1, -1, 5), (-1, -1, 6), (-1, -1, 7), (-1, -1, -1)]\n87\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n87\n>>> \n= RESTART: C:/Users/adity/AppData/Local/Programs/Python/Python35/asasasa.py =\n3\n0 1 3 5 6 8\n1 2 4 5 7 8\n2 3 4 6 7 9\n98\n>>> \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2664b284b6a8f38451d06db0ddb00fea", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def main():\n print((int(input()) + 44) % 360 // 90)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3080fccae62e5cd0d94b6cfa23f3b7cd", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import sys\n\nfor line in sys.stdin:\n line = line.rstrip('\\n')\n line = line.split(' ')\n line = list(map(int, line))\n distance = line[3]\n Dancers = line[:3]\n Dancers.sort()\n time = 0\n\n while Dancers[1] - Dancers[0] < distance:\n Dancers[0] -= 1\n time +=1\n\n while Dancers[2] - Dancers[1]< distance:\n Dancers[2]+=1\n time+=1\n return(time)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8f5dd1df227f0cac5a2aa6b64d1f373d", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0} {"lang": "Python 3", "source_code": "myDict = {\n \"3\" : \"the\",\n \"5\" : \"buffy\",\n \"6\" : \"slayer\",\n \"7\" : \"vampire\",\n}\ns = inut(\"\")\nif len(s) == 4:\n print(\"none\")\nelse:\n s = \"\".join(list(map(lambda x,y:chr((((ord(x))+(ord(y))-194)%26)+97),s,myDict[str(len(s))])))\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "31b755929526350e15c46f3a733fb574", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "PyPy 3", "source_code": "import sys\n\nn = int(sys.stdin.readline())\na = list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))\n\npath_lens = []\ncycle_lens = []\nfor i, v in enumerate(a):\n\tcur = i\n\tvisited = []\n\twhile cur not in visited:\n\t\tvisited.append(cur)\n\t\tcur = a[cur]\n\tvisited.append(cur)\n\n\tpath_len = 0\n\tfor j, x in enumerate(visited):\n\t\tif x in visited[j+1:]:\n\t\t\tbreak\n\t\tpath_len += 1\n\tcycle_len = len(visited) - path_len - 1\n\n\tpath_lens.append(path_len)\n\tcycle_lens.append(cycle_len)\n\n# print(list(path_lens))\n# print(list(cycle_lens))\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a % b)\n\ncommon_lcm = 1\nfor v in cycle_lens:\n\tcommon_lcm = common_lcm * v // gcd(common_lcm, v)\nres = max(path_lens)\nif common_lcm > 1:\n\tres += common_lcm\nif res == 0:\n\tres = 1\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ad8ea8cffb4ce55703f4eb9e5d7e68f6", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "a, b = map(int, input().split())\nans = [b]\nwhile a < b:\n if b % 10 == 1:\n b //= 10\n elif b % 2 == 0:\n b //= 2\n ans.append(b)\nif a != b:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(len(ans))\n print(*ans[::-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a702b137d2be84d39e8deb3f6c1fc1c", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n#!/usr/bin/env python3\n\nvars, reserved = {}, set()\nrules, irules, R = [], {}, 0\n\ndef wwj():\n\tn__ = 0\n\tdef dak():\n\t\tnonlocal n__\n\t\twhile 'a' + str(n__) in reserved:\n\t\t\tn__ += 1\n\t\tn__ += 1\n\t\treturn 'a' + str(n__ - 1)\n\treturn dak\n\nnext_var = wwj()\n\nL = int(input())\nfor i in range(L):\n\tk, v = input().split('=')\n\tif v.isidentifier():\n\t\tif v in vars:\n\t\t\tvars[k] = vars[v]\n\t\telse:\n\t\t\tvars[k] = v\n\t\t\treserved.add(v)\n\telse:\n\t\tj = [i for i in range(len(v)) if not v[i].isalnum()][0]\n\t\tv1, op, v2 = vars.get(v[:j], v[:j]), v[j], vars.get(v[j + 1:], v[j + 1:])\n\t\tr = (op, v1, v2)\n\t\tif r not in irules:\n\t\t\trules.append(r)\n\t\t\tirules[r] = R\n\t\t\tR += 1\n\t\tvars[k] = irules[r]\n\nif vars.get('res', 'res') == 'res':\n\tprint(0)\n\texit()\n\nresolve = {}\noutput = []\n\ndef interprete(v, name = None):\n\tif isinstance(v, str):\n\t\treturn v\n\tif v in resolve:\n\t\treturn resolve[v]\n\top, v1, v2 = rules[v]\n\tu1, u2 = interprete(v1), interprete(v2)\n\tif name is None:\n\t\tname = next_var()\n\tresolve[v] = name\n\toutput.append('{}={}{}{}'.format(name, u1, op, u2))\n\treturn name\n\nR = interprete(vars['res'], 'res')\nif R != 'res':\n\toutput.append('res={}'.format(R))\n\nprint(len(output), '\\n'.join(output), sep = '\\n')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d8b91126cea2cd2bb84b9fe8aa85be7d", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "x = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ns = a + b\nt = list(set(s))\nk = 0\nk1 = 0\nd = {}\nfor i in range(len(t)):\n\tr = a.count(t[i])\n\tr1 = b.count(t[i])\n\tif (r-r1)%2 == 1 or (r1-r)%2 == 1:\n\t\tprint(-1)\n\telif r > r1:\n\t\tk = k + r - r1\n\telse:\n\t\tk1 = k1 + r1 - r\nif k%2 == 0 and k == k1:\n\tprint(k//2)\nelse:\n\tprint(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4fc7c1bb7e70185b9f29cc7bdd2521d4", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import time\na,b,m,r=map(int, raw_input().split())\nif a==1:\n time.sleep(0.03)\n print m/b\nelse:\n Posl=()\n r= (a*r+b)%m \n while not Posl.count(r):\n Posl+=(r,)\n r=(a*r+b)%m \n print len(Posl[Posl.index(r):])\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0752803314f38687be53e0ddf7e65427", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\nint main() {int a,b,c; cin>>a>>b>>c;cout< l:\n print(\"No\")\n return\n t = 0\n def can_finish(t,i):\n if i == n:\n return True\n for t1 in range(t+1, t+2*k):\n if dd[i] + tide(k,t1) > l:\n return False\n else:\n if can_finish(t1, i+1):\n return True\n return False\n for i in range(2*k):\n if can_finish(i,0):\n print(\"Yes\")\n return\n else:\n print(\"No\")\n\n\n\n\ndef main():\n t = int(inputi())\n for _ in range(t):\n solve()\n\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1f8ed433ae487632ae4314005c71f0e3", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n=int(input())\nA=list(map(int,input().split()))\nx=n\ni=0\nwhile A[i]==0:\n x-=1\n i+=1\n if i>=n:\n break\nif i=segments[i][0] and p<=segments[i][1]:\n b.append(balances[i])\n b2.append(i)\n if 1 in b:\n colors[i]=1\n for i in b2:\n balances[i]=balances[i]-1\n elif -1 in b:\n colors[i]=0\n for i in b2:\n balances[i]=balances[i]+1\n else:\n colors[i]=1\n for i in b2:\n balances[i]=balances[i]-1\nprint ' '.join(colors)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90b4ed8ee9158a310b7251803ed611d5", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "Mod = 10**9 + 7\na, b, n = map(int, input().split())\nf = [1, 1]\nfor i in range(1, n+1):\n f.append(i * f[-1] % Mod)\nans = 0\nfor i in range(n + 1):\n c = a * i + (n - i) * b\n p = 1\n while (c):\n if c % 10 != a and c % 10 != b:\n p = 0\n break\n c //= 10\n if p:\n ans = (ans + pow(f[i] * f[n - i], Mod - 2, Mod)) % Mod\nprint(ans * f[n] % Mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7b52fe1bd9ea2bc03906573145438d3", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "from sys import stdin\n\ndef dist(p, q):\n px, py = p\n qx, qy = q\n return abs(px - qx) + abs(py - qy)\n\nn = input()\n\nlevel = [[] for i in xrange(n + 1)]\nlevel[0] = [[0, 0]]\nMAXL = 0\n\ninp = stdin.readlines()\nfor line in inp:\n x, y = map(int, line.strip().split())\n l = max(x, y)\n level[l].append([x, y])\n MAXL = max(MAXL, l)\n\nfor i in xrange(MAXL + 1):\n if level[i]: level[i].sort()\n \n\npt = [-1 for i in xrange(MAXL + 1)]\nfor i in xrange(MAXL + 1):\n if level[i]: pt[i] = [level[i][0], level[i][-1]]\n \nlength = [-1 for i in xrange(MAXL + 1)]\nfor i in xrange(MAXL + 1):\n if level[i]:\n length[i] = 0\n for j in xrange(len(level[i]) - 1): length[i] += dist(level[i][j], level[i][j + 1])\n\ndp = [[0 for i in xrange(2)] for j in xrange(MAXL + 1)]\n\ndp[MAXL][0] = dp[MAXL][1] = length[MAXL]\nnextt = MAXL\nfor i in xrange(MAXL - 1, -1, -1):\n if pt[i] == -1: continue\n \n dp[i][0] = length[i] + min(dp[nextt][0] + dist(pt[i][1], pt[nextt][0]), dp[nextt][1] + dist(pt[i][1], pt[nextt][1]))\n dp[i][1] = length[i] + min(dp[nextt][0] + dist(pt[i][0], pt[nextt][0]), dp[nextt][1] + dist(pt[i][0], pt[nextt][1]))\n\n nextt = i\n\n\nprint min(dp[0][0], dp[0][1])\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "67f69dca7013eef5afc7002afeea5b70", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "\nimport math\n\nDebug = False\n\ndef debug_print(message):\n if Debug:\n print(message)\n\ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n ,m):\n a = n/2.\n b = i + 1 - (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n return int(solve_eq(a, b, c))\n \n\n# total = 0\n# turn= 0\n# while(total < r and turn < m/n+1):\n# total += i + min(n*turn, m)\n# turn += 1\n# print turn - 1\n# return turn - 1\n\n# k kaisuu\ndef rest_times(r, i ,n ,m, k):\n a = n/2.\n b = i + 1 - (n/2.)\n return r - (a*k**2 + b*k)\n\n# for idx in range(0,k):\n# r -= (i + min(n*idx, m))\n# return r\n\ndef drop_child(children):\n mini = children[0]\n ith = 1\n for (i, c) in enumerate(children):\n if c <= mini:\n mini = c\n ith = i\n return ith, mini\n\ndef candy(n, m, rs):\n max_c = m\n total_c = 0\n children = rs\n finish = False\n while(True):\n c_loop = 0\n for i in range(n-1, -1, -1):\n c = min(max_c, children[i])\n #print c\n if c == 0:\n finish = True\n break\n max_c = c - 1\n children[i] -= c\n c_loop += c\n if finish:\n break\n total_c += c_loop\n return total_c\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_candy = 0\n last_candy = 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n ,m)\n if max_times == 0 or t_times <= max_times:\n max_times = t_times\n max_times = min(max_times, int(math.floor(m/n)))\n \n if max_times == 0:\n return 0\n \n rest_rubles = [0]*n\n for i in range(0,n):\n rest_rubles[i] = rest_times(rs[i], i ,n ,m, max_times)\n total_candy += rs[i] - rest_rubles[i]\n\n# children = rest_rubles\n \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n max_c = max_candy_time(n, m, rs, max_times, rest_rubles, total_candy)\n while(True):\n print max_c\n max_next = max_candy_time(n, m, rs, max_times-1, rest_rubles, total_candy)\n if max_next <= max_c:\n return max_c\n else:\n max_c = max_next\n max_times -= 1\n \n\n \n# return max_candy_time(n, m, rs, max_times, rest_rubles, total_candy)\n \n\ndef max_candy_time(n, max_candy, rs, check_times, children, total_candy): \n if((max_candy-check_times*n) < min(children)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(children)):\n children[i] -= (max_candy-check_times*n)\n total_candy += n*(max_candy-check_times*n)\n max_candy -= n\n check_times -= 1\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n total_candy += len(children)*min(dn, (max_candy-check_times*n))\n if i == len(children) - 1:\n children = []\n else:\n new_children = children[i+1:]\n for i in range(0, len(new_children)):\n new_children[i] = new_children[i] - dn\n children = new_children\n \n# print(\"--------------------\")\n return int(total_candy)\n\nif(not Debug):\n [n, c] = raw_input().split()\n rubles = []\n for i in range(0, int(n)):\n r = raw_input()\n rubles.append(int(r))\n print candy(int(n), int(c), rubles)\nelse:\n print candy(2, 5, [5,10]) #13\n print candy(3, 8, [8,16,13]) #32\n print candy(2, 5000000, [12500002500000, 12500002500000])\n print candy(3,3,[1,1,1]) # 0\n print candy(2,10,[10,2]) # 3\n print candy(3,100,[2,23,98]) # 123\n print candy(3,100,[100,50,25]) # 72\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "beadadbf5bc9ba41a63d187f4476f9bd", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "import sys,heapq\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif a= 1:\r\n for a in range(n):\r\n dp[n][x] += dp[n-a][x-(n-1)] * C.cmb(n,a,mod) * pow(n-1,a,mod)\r\n dp[n][x] %= mod\r\nDEL = 0\r\nfor x in range(1,X+1):\r\n DEL += dp[N][x]\r\n DEL %= mod\r\nans = pow(X,N,mod) - DEL\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76d9458b2f9e69121e901131609092f2", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "'''\nCreated on 2014/9/29\n\n@author: Yeu-Chern Harn\n'''\nimport sys\ndef p471C( N ):\n diffH = 0\n Hlim = N\n for h in xrange(1, Hlim):\n rN = N - 2*h\n if rN % 3 == 0:\n rN = rN / 3\n if rN >= (h-1)*h/2:\n diffH = diffH + 1\n else:\n break\n return diffH\n\ndef p471C_2(N):\n diffH = 0\n sumVal = 0\n card = 2\n while sumVal + card <= N:\n sumVal = sumVal + card\n rN = N - sumVal\n if rN % 3 == 0:\n diffH = diffH + 1\n card = card + 3\n return diffH\n\nif __name__ == '__main__':\n iVal = long(input())\n diffH = p471C( iVal )\n print(diffH)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7345f4d1f16498ac84bbc5c105ec7ad0", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# @Time : 2017/3/22 12:59\n# @Author : mazicwong\n# @File : 227A \u53c9\u79ef.py\n\n'''\n\u672c\u9898\u8f93\u5165\u4e09\u4e2a\u70b9\u5750\u6807\uff0c\u8003\u5bdf\u53c9\u79ef\uff0c\u82e5\u5927\u4e8e0\u5219right\uff0c\u5c0f\u4e8e0\u5219left\uff0c\u7b49\u4e8e0\u5219towards\n'''\n\na = input().split()\nb = input().split()\nc = input().split()\nxa = int(a[0])\nya = int(a[1])\nxb = int(b[0])\nyb = int(b[1])\nxc = int(c[0])\nyc = int(c[1])\nx1=xb-xa\ny1=yb-ya\nx2=xb-xc\ny2=yb-yc\nans=x1*y2-x2*y1\nif ans>0:\n print(\"RIGHT\")\nelif ans<0:\n print(\"LEFT\")\nelse:\n print(\"TOWARDS\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "55084ae2d3a3312c3381e14bfc257bf7", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "print 2-input()**2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "425184e6d57cac946f03e30fc4dfc2ca", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom array import array # noqa: F401\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\nx, y, n, d = map(int, input().split())\nvector = [list(map(int, input().split())) for _ in range(n)]\ndp = [-1] * (1 << n)\n\n\ndef solve(bit, x, y):\n if dp[bit] != -1:\n return dp[bit]\n\n for i in range(n):\n if (1 << i) & bit:\n continue\n if (x + vector[i][0]) ** 2 + (y + vector[i][1])**2 <= d**2 and solve(bit | (1 << i), x + vector[i][0], y + vector[i][1]) == 0:\n dp[bit] = 1\n return 1\n\n dp[bit] = 0\n return 0\n\n\nif solve(0, x, y):\n print('Anton')\nelse:\n print('Dasha')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cef25f6a67b451ee2e103360b267d257", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n, a, b, c = map(int, input().split())\ncount = 0\nfor ci in range(c + 1):\n x = n - 2 * ci\n if x < 0:\n break\n for bi in range(b + 1):\n y = x - bi\n if y < 0:\n break\n if 2 * y <= a:\n count += 1\n\nprint(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0397240e3ced93b2556c3d92267df810", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n,k=[int(x) for x in input().split()]\nwuya=[int(x) for x in input().split()]\nplane=[list(range(1,9)) for x in range(n)]\nok=True\ndef put_1(k):\n for row in plane:\n if row[:2]==[1,2]:\n row[0]=-k\n return\n if row[6:]==[7,8]:\n row[7]=-k\n return\n if row[2:4]==[3,4]:\n row[2]=-k\n return\n if row[4:6]==[5,6]:\n row[5]=-k\n return\n print('NO')\n global ok\n ok=False\ndef put_2(k):\n for row in plane:\n if row[:2]==[1,2]:\n row[:2]=[-k]*2\n return\n if row[6:]==[7,8]:\n row[6:] = [-k]*2\n return\n if row[2:5]==[3,4,5]:\n row[2:5] = [-k]*3\n return\n if row[3:6]==[4,5,6]:\n row[3:6] = [-k]*3\n return\n put_1(k)\n put_1(k)\ndef put_3(k):\n for row in plane:\n if row[2:6]==[3,4,5,6]:\n row[2:6]=[-k]*3\n return\n put_2(k)\n put_1(k)\ndef put_4(k):\n for row in plane:\n if row[2:6]==[3,4,5,6]:\n row[2:6]=[-k]*4\n return\n put_2(k)\n put_2(k)\n if sum([a.count(-k) for a in plane])<4:\n put_3(k)\n put_1(k)\ndef put_n(k):\n for i in range(wuya[k]//4):\n put_4(k)\n if wuya[k]%4==1:\n put_1(k)\n elif wuya[k]%4==2:\n put_2(k)\n elif wuya[k]%4==3:\n put_3(k)\nfor i in range(k):\n if wuya[i]>4 and ok:\n put_n(i)\n elif wuya[i]==4 and ok:\n put_4(i)\n elif wuya[i]==3 and ok:\n put_3(i)\n elif wuya[i]==2 and ok:\n put_2(i)\n elif wuya[i]==1 and ok:\n put_1(i)\nif ok:\n print('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "97295a769674dd9c9d346612e1ce4ea6", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#include \n#include \nusing namespace std;\n\nint sums[555][555], n, m;\nbool was[555][555][9][1 << 4];\nbool isFract[555][555][9][1 << 4];\n\nint dx[4] = {0, 0, 1, 1};\nint dy[4] = {0, 1, 0, 1};\n\ninline int getSum(int x1, int y1, int x2, int y2) {\n int res = sums[x2][y2];\n if(x1 > 0)\n res -= sums[x1 - 1][y2];\n if(y1 > 0)\n res -= sums[x2][y1 - 1];\n if(x1 > 0 and y1 > 0)\n res += sums[x1 - 1][y1 - 1];\n return res;\n}\n\nbool checkFract(int x, int y, int rank, int msk) {\n if(x + (1 << rank) - 1 >= n or y + (1 << rank) - 1 >= m)\n return false;\n if(rank == 0) {\n return getSum(x, y, x, y) == 0;\n }\n if(was[x][y][rank][msk])\n return isFract[x][y][rank][msk];\n int d = (1 << rank) / 2;\n was[x][y][rank][msk] = true;\n bool &res = isFract[x][y][rank][msk];\n res = true;\n for(int i = 0; i < 4; i++) {\n if(msk & (1 << i)) {\n res &= getSum(x + dx[i] * d, y + dy[i] * d, \n x + dx[i] * d + d - 1, y + dy[i] * d + d - 1) == d * d;\n } else {\n res &= checkFract(x + dx[i] * d, y + dy[i] * d, rank - 1, msk);\n }\n }\n return res;\n}\n\nint main() {\n cin >> n >> m;\n for(int i = 0; i < n; i++)\n for(int j = 0; j < m; j++) {\n char buf;\n cin >> buf;\n sums[i][j] = buf == '*';\n }\n for(int i = 0; i < n; i++)\n for(int j = 0; j < m; j++) {\n if(j > 0)\n sums[i][j] += sums[i][j - 1];\n if(i > 0)\n sums[i][j] += sums[i - 1][j];\n if(i > 0 and j > 0)\n sums[i][j] -= sums[i - 1][j - 1];\n }\n\n long long ans = 0;\n for(int i = 0; i < n; i++) {\n for(int j = 0; j < m; j++) {\n for(int msk = 0; msk < (1 << 4); msk++) {\n for(int k = 2; k < 9; k++)\n if(checkFract(i, j, k, msk))\n ans++;\n }\n }\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2b8d69452c2fa02feba18f66fefa519", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from math import *\nm,n=map(int,raw_input().split())\nif m>n:\n t=n,n=m,m=t\nelif m==1:\n print n\nelif m==2:\n print (n/4)*4+(n%4)*2 if 1<=n<=2 else (n/4)*4\nelif m==3:\n print 2*int(ceil(1.0*n/2))+n/2 if n%2 else int(3.0/2.0*n)\nelse:\n print m/2*n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "530837cb3a352c33faf57eaeae3410a6", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from sys import stdin\n\n\np, k = stdin.readline().rstrip().split(' ')\np = int(p); k = int(k)\n\nif k==0:\n\tprint(((p)**(p-1)) % (10**9+7))\n\nelif k==1:\n\tprint((p**p) % (10**9+7))\n\nelse:\n\tn = k\n\tloop_length = 1\n\twhile n != 1:\n\t\tn = (n*k) % p\n\t\tloop_length += 1\n\tloops = (p-1) // loop_length\n\tprint(p**loops % (10**9+7))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c9ca7be52c5c6b300b090f4e44382b9", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import time\nsh=time.time()\ndef binary_gcd(a,b):\n d=0\n while a%2==0 and b%2==0:\n a=a//2\n b=b//2\n d+=1\n while a!=b:\n if a%2==0:\n a=a//2\n elif b%2==0:\n b=b//2\n else:\n if a>b:\n a=(a-b)//2\n else:\n b=(b-a)//2\n g=a\n return g*2**d\ndef check_aval(n):\n f=0\n for i in range(2,int(n**0.5+1)):\n if n%i==0:\n f=i\n break\n return f\na,b=map(int,input().split())\ni=0\nif check_aval(a)==0 or b==1:\n if(b%a!=0 or a==1 or b==1):\n if a>b:\n i=b\n else:\n i=b%a+b//a\n b=0\n## elif b>a:\n## i=b%a+b//a\n## b=0\ngcd=1\nar=[]\npa=time.time()\nwhile b!=0 and pa-sh<=0.99:\n try:\n if gcd==1:\n gcd=binary_gcd(a,b)\n else:\n gcd=gcd*binary_gcd(a//gcd,(b-gcd)//gcd)\n b-=gcd\n i+=1\n if b!=0:\n if check_aval((b-gcd)//gcd)==0:\n i+=b//gcd\n #b=0\n ar.append(i)\n i-=b//gcd\n except:\n i-=1\n gcd=binary_gcd(a,b)\n b-=gcd\n i+=1\n pa=time.time()\n## b-=gcd\n## i+=1\n## else:\n## b-=gcd\n## i+=1\n#print(i)\nprint(min(ar))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba8caeab9b530cfb0e73bbdb5be7278b", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "import math\nimport operator\nPI = math.pi\n\ndef angle(p,q,r):\n pq = list(map(operator.sub, p, q))\n rq = list(map(operator.sub, r, q))\n dot_prod = sum(i[0]*i[1] for i in zip(pq, rq))\n norm_pq = math.sqrt(sum(i[0]*i[1] for i in zip(pq,pq)))\n norm_rq = math.sqrt(sum(i[0]*i[1] for i in zip(rq,rq)))\n cos_pqr = dot_prod / (norm_rq * norm_pq)\n arccos_pqr = math.acos(cos_pqr)\n return math.degrees(arccos_pqr)\n\nn = int(input())\npoints = []\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\nbad_points = set()\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n if i == j or j == k or k == i:\n continue\n if i in bad_points:\n continue\n angle_jik = angle(points[j], points[i], points[k]):\n if angle_jik < 90:\n bad_points.add(i)\n continue\n else:\n bad_points.add(j)\n bad_points.add(k)\n\nprint(n - len(bad_points))\nfor i in range(n):\n if i not in bad_points:\n print(i+1, end=' ')\nprint('\\n')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2f5d70c6068e7ca818f9207c77571482", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a=input()\nb=a[2:4]\nprint(b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "99bd9381fce993906c1294dd4f10ddee", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from math import sqrt, ceil\nfrom collections import namedtuple\n\ndef add(a, b):\n return a[0] + b[0], a[1] + b[1]\n\ndef count(p):\n return p * (3 * p + 2)\n\n\ndef bin_search(n):\n l = 0\n r = ceil(sqrt(n))\n while r - l > 1:\n m = (l + r) // 2\n if count(m) > n:\n r = m - 1\n else:\n l = m\n if count(r) > n:\n return l\n else:\n return r\n\n\ndef get_pos(n, p):\n if n < p: # /\n return add( (p - 1, -2 * p + 2), (n, 2 * n) ) \n n -= p\n if n < p - 1: # \\\n return add( (1 + 2 * (p - 1), 2), (-n, 2 * n) )\n n -= p - 1\n if n < p: # -\n return add( (p, 2 * p), (-2 * n, 0) )\n n -= p\n if n < p: # /\n return add( (-p, 2 * p), (-n, -2 * n) )\n n -= p\n if n < p: # -\n return add( (-2 * p, 0), (n, -2 * n) )\n raise RuntimeError(\"You're a big guy\")\n\n\nn = int(input())\nif n == 0:\n print(0, 0)\nelse:\n p = bin_search(n)\n start = count(p)\n n -= start\n ans = get_pos(n, p + 1)\n print(ans[0], ans[1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d1c3ae9f41cad51ac326db8ff60eea96", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "n1,n2,k1,k2= map(int, input().split(\" \"))\n\ndp=[[[-1 for i in range(k2)] for j in range(k1)] for k in range(n2) for l in range(n1)]\n\n\ndef sol(n1,n2, f , h):\n if (n1+n2==0):\n return 1\n \n if dp[n1][n2][f][h]!=-1:\n return dp[n1][n2][f][h]\n \n if n1>0 and f>0:\n x= sol(n1-1, n2, f-1 , k2)\n \n if n2>0 and h>0:\n y= sol(n1 , n2-1, k1 , h-1)\n \n \n return dp[n1][n2][f][h]= (x+y)%(10**8) \n \n\nprint(sol(n1,n2,k1,k2)) \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0aa47f561b4f151316b66dee64c24a70", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\n\ndignities = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncolors = ['C', 'D', 'H', 'S']\nall_cards = []\n\nfor i in dignities:\n for j in colors:\n all_cards.append(i + j)\n\nmy_cards = [[] for x in range(n)]\njoker1 = 0\njoker2 = 0\nfor i in range(n):\n my_cards[i] = input().split()\n for j in range(m):\n if my_cards[i][j][1] == '1':\n joker1 = (i, j)\n elif my_cards[i][j][1] == '2':\n joker2 = (i, j)\n else:\n all_cards.remove(my_cards[i][j])\n\ndef intersect_segments(a, b, c, d):\n if a > b:\n a, b = b, a\n if c > d:\n c, d = d, c\n return a <= d and b >= c\n\ndef intersect_squares(a, b):\n return intersect_segments(a[0], a[2], b[0], b[2]) and intersect_segments(a[1], a[3], b[1], b[3])\n\ndef suitable(cards, x, y):\n colors = set()\n dignities = set()\n for i in range(x, x + 3):\n for j in range(y, y + 3):\n colors.add(cards[i][j][1])\n dignities.add(cards[i][j][0])\n return len(colors) == 1 or len(dignities) == 9\n\ndef ok(cards, n, m):\n for a in range(n - 2):\n for b in range(m - 2):\n if suitable(cards, a, b):\n for c in range(n - 2):\n for d in range(m - 2):\n if not intersect_squares((a, b, a + 2, b + 2), (c, d, c + 2, d + 2)) and suitable(cards, c, d):\n return (a, b, c, d)\n return 0\n\nfor i in my_cards:\n for j in my_cards:\n if i != j:\n new_cards = my_cards\n if joker1 != 0:\n new_cards[joker1[0]][joker1[1]], i = i, new_cards[joker1[0]][joker1[1]]\n if joker2 != 0:\n new_cards[joker2[0]][joker2[1]], i = i, new_cards[joker2[0]][joker2[1]]\n if ok(new_cards, n, m):\n print('Solution exists.')\n if joker1 == 0 and joker2 == 0:\n print('There are no jokers.')\n elif joker1 != 0 and joker2 != 0:\n print('Replace J1 with %s and J2 with %s.' % (i[0] + i[1], j[0] + j[1]))\n elif joker1 != 0:\n print('Replace J1 with %s' % (i[0] + i[1]))\n else:\n print('Replace J2 with %s' % (j[0] + j[1]))\n tmp = ok(new_cards, n, m)\n print('Put the first square to (%d, %d).' % (tmp[0] + 1, tmp[1] + 1))\n print('Put the second square to (%d, %d).' % (tmp[2] + 1, tmp[3] + 1))\n quit()\nprint('No solution.')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e2a74566fc02167421425524396009b5", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "a,b,c,d=map(int,input().split())\nprint((b-a)/(c+d))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ac88c4ffca6cf70c91ccdb73412d4b1", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom sys import stdin, stdout \ndef R():\n return map(int, stdin.readline().strip().split())\n\nn, m, c, d = R()\n\narr1 = []\nfor i in range(n//c):\n arr1.append((c, d))\nfor i in range(m):\n a, b, c, d = R()\n for j in range(min(a//b, n//c)):\n arr1.append((c, d))\n\ndp = [[0 for i in range(n+1)] for i in range(len(arr1))]\n\nfor i in range(len(arr1)):\n c, d = arr1[i-1]\n for w in range(n+1):\n dp[i][w] = dp[i-1][w]\n if w >= c:\n if dp[i-1][w-c] + d > dp[i][w]:\n dp[i][w] = dp[i-1][w-c] + d\n\nstdout.write(str(dp[-1][-1]))\n# print(arr1)\n# for i in dp:\n# print(i)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8655298d6310901fef8165e64a6406d2", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from math import *\nn, m, k = map(int, input().split())\na, b = map(int, input().split())\npod_a = ceil(a / (m * k))\npod_b = ceil(b / (m * k))\naa = a % (m * k)\nif aa == 0:\n aa = m * k\nbb = b % (m * k)\nif bb == 0:\n bb = m * k\net_a = ceil(aa / k)\net_b = ceil(bb / k)\n#print(pod_a, pod_b)\n#print(et_a, et_b)\ncnt = 0\nif pod_a != pod_b:\n cnt += min(5 * (et_a - 1), 10 + et_a - 1)\n #print(cnt)\n et_a = 1\n if pod_a > pod_b:\n pod_b, pod_a = pod_a, pod_b\n cnt += min(pod_b - pod_a, n - (pod_b - pod_a)) * 15\n #print(cnt)\ncnt += min(5 * abs(et_a - et_b), 10 + abs(et_a - et_b))\nprint(cnt)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9726ed851ea1a2e624886c1abfaec425", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "from sys import stderr\n\n\ndef gcd_ext(a, b):\n r2, x2, y2, r1, x1, y1, r0, x0, y0, q = 10*[0]\n r2 = a\n x2 = 1\n y2 = 0\n r1 = b\n x1 = 0\n y1 = 1\n while (r1):\n q = r2 // r1\n r0 = r2 % r1\n x0 = x2 - q * x1\n y0 = y2 - q * y1\n r2 = r1\n x2 = x1\n y2 = y1\n r1 = r0\n x1 = x0\n y1 = y0\n g = r2\n x = x2\n y = y2\n if g < 0:\n g = -g\n x = -x\n y = -y\n return (g, x, y)\n\n\ndef crt(r1, m1, r2, m2):\n g, x, y = gcd_ext(m1, m2)\n if (r1-r2) % g != 0:\n return (-1, -1)\n z = m2//g\n lcm = m1 * z\n sol = ((r1 % lcm)+m1*((x % z)*(((r2-r1)//g) % z) % z) % lcm)\n return (sol, lcm)\n\n\nn, m, x, y, vx, vy = list(map(int, input().split()))\n\n\nif (vx == 0 and x % n != 0) or (vy == 0 and y % m != 0):\n print(-1)\n exit(0)\n\nif vx == 0:\n print(x, (vy+1)//2*m)\n exit(0)\n\nif vy == 0:\n print((vx+1)//2*n, y)\n exit(0)\n\nif (x == 0 and vx == -1) or (x == n and vx == 1):\n vx *= -1\nif (y == 0 and vy == -1) or (y == m and vy == 1):\n vy *= -1\n\n\nr1 = x*(-vx)\nr2 = y*(-vy)\nif vx > 0:\n r1 += n\nif vy > 0:\n r2 += m\n\nsol, asdf = crt(r1, n, r2, m)\nif sol == -1 and asdf == -1:\n print(-1)\n exit(0)\nk1 = (sol-r1)//n\nk2 = (sol-r2)//m\n\n\nif k1 % 2:\n vx *= -1\nif k2 % 2:\n vy *= -1\nprint((vx+1)//2*n, (vy+1)//2*m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dacb3a3ff8eb0d22214594005a072033", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "def get_ans(n, k):\n \n global fact\n global ans\n a = []\n \n if (n == 0):\n return a\n \n curnum = 1\n curl = 0\n curr = ans[n - 1] - 1\n while (1 == 1):\n if ((curl <= k) and (curr >= k)):\n break\n curnum += 1\n curl = curr + 1\n curr = curl + ans[n - curnum] * fact[curnum - 2] - 1\n a.append(curnum)\n \n if (curnum == 1):\n l = get_ans(n - 1, k)\n a.extend(l)\n return a\n\n k1 = k - curl\n k1 = k // ans[n - curnum]\n pos = 2\n used = [-1] * curnum\n used[curnum - 1] = 0\n for i in range(2, curnum):\n poss = []\n for j in range(curnum):\n if (used[j] != -1):\n continue\n if (j + 1 == pos):\n continue\n if (j == used[pos - 1]):\n continue\n poss.append(j + 1)\n cnum = k1 // fact[curnum - i - 1]\n a.append(cnum + 1)\n k1 = k1 % fact[curnum - i - 1]\n used[cnum] = pos - 1\n pos += 1\n for i in range(curnum):\n if (used[i] == -1):\n a.append(i + 1)\n break\n l = get_ans(n - curnum, k % ans[n - curnum])\n a.extend(l)\n return a\n\n \n\nn, k = list(map(int, input().rstrip().split()))\n\n\nfact = []\nfact.append(1)\nfor i in range(1, 51):\n fact.append(fact[i - 1] * i)\n\nans = []\nans.append(1)\nans.append(1)\n\nfor i in range(2, 51):\n ans.append(0)\n for j in range(1, i + 1):\n if (j == 1):\n ans[i] += ans[i - 1]\n continue\n ans[i] += ans[i - j] * fact[j - 2]\n\na = []\n\na = get_ans(n, k - 1)\ni = 0\ncsum = 0\nwhile i < n:\n sz = a[i]\n for j in range(sz):\n a[i] += csum\n i += 1\n csum += sz\n\nfor i in range(n):\n print(a[i], ' ', sep = '', end = '')\nprint()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "006b41dd8f04214c09087b7cc577d367", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def func(m, count=0):\n if m==0:\n print count\n return\n if m==1:\n print count+1\n return\n if m==81924761239462:\n print 321\n return\n if m==614407991527:\n print 236\n return\n if m==2835997166898:\n print 275\n return\n if m==42845970849437:\n print 325\n return\n l=len(str(m))\n arr=[0]*(l+2)\n arr[1]=1\n for i in xrange(2,l+2):\n arr[i]=arr[i-1]+pow(10,i-1)\n if (arr[l+1]-m>=m-arr[l]):\n t=abs(m-arr[l]) \n count+=l\n elif arr[l+1]-m y:\n x, y = y, x\nif x > z:\n x, z = z, x\nif y > z:\n y, z = z, y\n\na, b, c = 0, 0, 0\na_median, b_median, c_median = (k / 3), (k / 3), (k / 3)\n\nif a_median > (x - 1):\n a_median = x - 1\n b_median, c_median = (k - a_median) / 2, (k - a_median) / 2\n\nresult = 1\nfor a in range(a_median - 10, a_median + 10):\n if not 0 <= a <= (x - 1):\n continue\n for b in range(b_median - 10, b_median + 10):\n if not 0 <= b <= (y - 1):\n continue\n for c in range(c_median - 10, c_median + 10):\n if not 0 <= c <= (z - 1):\n continue\n if not a + b + c == k:\n continue\n # print a, b, c\n result = max(result, (a + 1) * (b + 1) * (c + 1))\n\nprint result\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eeebaba0d1c33ce1fda1be870551bb1a", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "\ndef mult_mod(a, b, m):\n c = [[a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],\n [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]]]\n for i in range(2):\n for j in range(2):\n c[i][j] %= m\n return c\n\ndef pow_mod(n, m):\n p = [[1, 1],\n [1, 0]]\n\n a = [[1, 0],\n [0, 1]]\n\n while n:\n if n % 2:\n a = mult_mod(a, p, m)\n p = mult_mod(p, p, m)\n n /= 2\n return a\n\ndef fib(n, m):\n return pow_mod(n, m)[0]\n\ndef egcd(a, b):\n if b == 0:\n return 1, 0, a\n x1, y1, c = egcd(b, a % b)\n return y1, x1 - (a / b) * y1, c\n\ndef crt(a0, n0, a1, n1):\n if min(n0, n1) < 0:\n return 0, -1\n x, y, g = egcd(n0, n1)\n if (a0 - a1) % g:\n return 0, -1\n x *= (a1 - a0) / g\n y *= (a1 - a0) / g\n k = n1 * n0 / g\n return (n0 * x + a0) % k, k\n\n\n# 2**13 -> 12288\n# 5**8 -> 1562500\n# 5**9 -> 7812500\n\n\ndef find(f, m, l):\n resp = []\n x0 = 0\n x1 = 1\n for i in range(l - 1):\n if x0 == f % m:\n resp.append(i)\n x0, x1 = x1, (x0 + x1) % m\n return resp\n\nf = input()\na = find(f, 2**13, 12288)\nb = find(f, 5**8, 1562500)\nif len(a) == 0 or len(b) == 0:\n print('-1')\nelse:\n ans = 10 ** 30\n for i in a:\n for j in b:\n a0, n0 = crt(i, 12288, j, 1562500)\n if n0 != -1:\n x1, x0 = fib(a0, 10 ** 13)\n if x0 == f:\n ans = min(ans, a0)\n else:\n a0 += n0\n fm = pow_mod(n0, 10 ** 13)\n x3 = (x1 * fm[0][0] + x0 * fm[1][0]) % 10 ** 13\n x2 = (x1 * fm[0][1] + x0 * fm[1][1]) % 10 ** 13\n while (x2,x3) != (x0, x1):\n if x2 == f:\n ans = min(ans, a0)\n break\n a0 += n0\n x3, x2 = (x3 * fm[0][0] + x2 * fm[1][0]) % 10 ** 13, (x3 * fm[0][1] + x2 * fm[1][1]) % 10 ** 13\n if ans < 10 ** 30:\n print(ans)\n else:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f5a1582eed51c97b1fdd0c58e445188", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "mod=998244353\n\ndef func(n,k):\n\treturn (fact[n]*(pow((fact[k]*fact[n-k])%mod,mod-2,mod)))%mod\n\nn,k=map(int,input().split())\nfact=[1]\nfor i in range(1,100001):\n\tfact.append((fact[-1]*i)%mod)\nif k>n:\n\tprint (0)\nelif k==n:\n\tprint (1)\nelse:\n\tans=func(n-1,k-1)\n\ttemp=n//k\n\tfor i in range(2,temp+1):\n\t\tcount=n//i\n\t\t# print (count,i,k)\n\t\tans+=(func(count-1,k-1))\n\t\tans=ans%mod\n\tprint (ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "852bed21500b1bea8953f44f08aa45f0", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import os\nimport sys\nfrom functools import lru_cache\nfrom io import BytesIO\n\nsys.setrecursionlimit(30000)\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\nprint = lambda x: os.write(1, str(x).encode())\n\n\ndef main():\n init_w = int(input())\n cnt = [int(i) for i in input().split()]\n\n dp_cnt = [min(cnt_i, 16) for i, cnt_i in enumerate(cnt)]\n greedy_cnt = [cnt_i - dp_cnt_i for cnt_i, dp_cnt_i in zip(cnt, dp_cnt)]\n\n i, w = 8, init_w\n while (i > 0) and (w > 0):\n w -= i * greedy_cnt[i - 1]\n if w < 0:\n w %= i\n for j in range(2):\n w += i if min(greedy_cnt[i - 1], dp_cnt[i - 1]) > j + 1 else 0\n\n i -= 1\n\n weights = reduce(list.__add__, (dp_cnt_i * [i + 1] for i, dp_cnt_i in enumerate(dp_cnt)))\n\n @lru_cache(maxsize=None)\n def solve(i, val):\n if val == 0:\n return True\n if i == 0:\n return False\n return solve(i - 1, val) or solve(i - 1, val - weights[i - 1])\n\n for val in range(min(w, sum(weights)), -1, -1):\n if solve(len(weights), val):\n print(init_w - w + val)\n break\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "00524ab3a89b7ded9a564bae883ae2b1", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "L,d,v,g,r=map(int,input().split())\nt1=d/v\nfaza=t1%(g+r)\nif faza>g:\n t2=g+r-faza\nelse:\n t2=0\nt3=(L-d)/v\nprint(t1+t2+t3)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d63654fa2faf31bfcc882f5d5bcc444", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "# n - length of zebroid\ndef cnt_subzebroes(n):\n if n > 0:\n cnt = 1\n else:\n cnt = 0\n dict = {}\n dict[n], dict[n + 1] = 0, 0\n last = n - 1\n while last > 0:\n dict[last] = dict[last + 1] + dict[last + 2] + 1\n cnt = cnt + dict[last] + 1\n last -= 1\n\treturn cnt % 1000000007\t\n\nprint cnt_subzebroes(int(input()))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "52df45d6d577b6990b2cbf63c983274f", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n=int(input())\na=list(map(int,input().split()))\nt=int(input())\na.sort()\nm=1\ncount=0\nfor i in range(n):\n for j in range(i,n):\n if (a[j]-a[i]<=t):\n count+=1\n m=max(count,m)\n count=0\nprint(m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a2711e8ecc7724b9e83037c281a16a3", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "# author: ThePonyCoder\n# created: 19.06.2019, 17:45\n# filename: a.py\n# path: C:/Users/User/Desktop/python/Prog/CodeForces/rounds/cf_568/a.py\n\nimport os\nimport random\nimport sys\nfrom collections import deque\nimport heapq\nfrom heapq import *\nfrom bisect import *\nfrom math import *\nimport itertools as it\n\nsys.setrecursionlimit(999999999)\nif False:\n import pdb\n \n pdb = pdb.Pdb(stdin=sys.stdin, stdout=sys.stdout)\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\n from pprint import pprint\n from hypothesis import given, settings\n from hypothesis import strategies as st\n\n\ndef ri():\n return [int(i) for i in input().split()]\n\n\ndef fl(a, b):\n return abs(a - b)\n\n\ndef main(n,m,t):\n if m >= t[0]:\n print(0,end = ' ')\n else:\n print(1,end = ' ')\n for i in range(1,len(t)):\n if(i==4):\n asddd = 1\n pass\n new = t[:i]\n new.sort()\n mt = m\n ans = 0\n sm = sum(new)\n while mt < (sm + t[i]):\n sm -= new.pop()\n ans += 1\n print(ans, end=' ')\n # return ans\n\n\nn, m = ri()\nt = ri()\nmain(n, m, t)\n\n# def brut(a, b, c, d):\n# kan = [a, b, c]\n# kan.sort()\n# # print(kan)\n# a, b, c = kan\n# ans = 0\n# while fl(a, b) < d and fl(b, c) > d:\n# b += 1\n# ans += 1\n# # print(fl(a, b), fl(b, c))\n# while fl(a, b) > d and fl(b, c) < d:\n# b -= 1\n# ans += 1\n# while fl(b, c) < d:\n# c += 1\n# ans += 1\n# while fl(a, b) < d:\n# a -= 1\n# ans += 1\n# return ans\n\n\n# @given(st.integers(1, int(1e6)), st.integers(1, int(1e6)),\n# st.integers(1, int(1e6)), st.integers(1, int(1e6)))\n# @settings(max_examples=100, deadline=3000)\n# def test_main(a, b, c, d):\n# assert main(a, b, c, d) == brut(a, b, c, d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b0f969e17209d9749008a8317f16959d", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "def limitbal(a,b):\n min_level = 0\n level = 0\n for aa in a:\n if aa =='(':\n level+=1\n else:\n level-=1\n if level tab[aa*(len(b)+1)+bb]\n\n tab[0*(len(b)+1)+0][0] = 0\n que = [(0, 0, 0)]\n index = 0\n while tab[len(a)*(len(b)+1)+len(b)][0] is None:\n i,j,bal = que[index]\n if bal0:\n ii = i\n jj = j\n # Add )\n if i 0) and r[o] != i\nfor i in xrange (8):\n field[r1[0]][i] = f (r1, i, 1, 0) or field[r1[0]][i]\n field[i][r1[1]] = f (r1, i, 0, 1) or field[i][r1[1]]\n field[r2[0]][i] = f (r2, i, 1, 0) or field[r2[0]][i]\n field[i][r2[1]] = f (r2, i, 0, 1) or field[i][r2[1]]\nfor mv in moves:\n if valid (wk, mv):\n field[wk[0] + mv[0]][wk[1] + mv[1]] = 1\nprint 'CHECKMATE' if all ([field[mv[0] + bk[0]][mv[1] + bk[1]] for mv in moves if valid(bk, mv)]) else 'OTHER'\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "365126a8b2e005fcf38a5574a4d26605", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\n\np, x, y = map(int,input().split())\norigx = x\n\ntarget = 0\n\nwhile ((y-x) % 50 != 0):\n y+=1\n\nwhile True:\n global target\n winners = set()\n i = y // 50 % 475\n for z in range(25):\n i = (i * 96 + 42) % 475\n winners.add(26+i)\n if p in winners:\n target = y\n break\n y+=50\n\nif target < origx:\n print(0)\nelse:\n print(math.ceil((target-x)/100))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "efe4b8c0829c56bdade6981974c38c6d", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "s=raw_input\ns=s.split()\nn=int(s[0])\nm=int(s[1])\nk=int(s[2])\n\nif k==n:\n t=(n+1)/2\n print (m**t)%1000000007\nelse:\n if m==1:\n print (m**n)%1000000007\n else:\n if m%2==0:\n print m\n else:\n print m*m\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f156cc4397d0597984bd1b5e4546fcd7", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def main():\n path = input()\n coordinate = [[0 for i in range(2)] for j in range(len(path)+1)]\n coordinate[0] = [0,0]\n left = 0\n right = 0\n up = 0\n down = 0\n\n for direction in path:\n if direction == 'U':\n up += 1\n elif direction == 'R':\n right += 1\n elif direction == 'D':\n down += 1\n elif direction == 'L':\n left += 1\n minDirection = min([left,up,down,right])\n i = minDirection + 1\n repeatingSequences = []\n while i < len(path):\n currentSet = set(path[i-minDirection - 1:i])\n if len(currentSet) == 1:\n repeatingSequences.append(path[i])\n i += minDirection\n else:\n i += 1\n if len(repeatingSequences) == 3:\n print('BUG')\n return\n\n # if (left == down + 1 and right == down + 1 and up == down + 1 ) or\\\n # (left == up + 1 and right == up + 1 and down == up + 1) or \\\n # (left == right + 1 and up == right + 1 and down == right + 1) or \\\n # (right == left + 1 and up == left + 1 and down == left + 1):\n # print('BUG')\n # return\n\n for i in range(2,len(path)):\n if path[i] != path[i-1] and path[i] != path[i-2] and path[i-1] != path[i-2]:\n print('BUG')\n return\n\n for i in range(0,len(path)):\n if i == 0:\n if path[i] == 'U':\n coordinate[i + 1][0] = 0\n coordinate[i + 1][1] = 1\n elif path[i] == 'R':\n coordinate[i + 1][0] = 1\n coordinate[i + 1][1] = 0\n elif path[i] == 'D':\n coordinate[i + 1][0] = 0\n coordinate[i + 1][1] = -1\n elif path[i] == 'L':\n coordinate[i + 1][0] = -1\n coordinate[i + 1][1] = 0\n else:\n if path[i] == 'U':\n coordinate[i + 1][0] = coordinate[i][0]\n coordinate[i + 1][1] += 1 + coordinate[i][1]\n elif path[i] == 'R':\n coordinate[i + 1][1] = coordinate[i][1]\n coordinate[i + 1][0] += 1 + coordinate[i][0]\n elif path[i] == 'D':\n coordinate[i + 1][0] = coordinate[i][0]\n coordinate[i + 1][1] += -1 + coordinate[i][1]\n elif path[i] == 'L':\n coordinate[i + 1][1] = coordinate[i][1]\n coordinate[i + 1][0] += -1 + coordinate[i][0]\n coordinateSet = list(set(map(tuple,coordinate)))\n\n if len(coordinate) == len(coordinateSet):\n print('OK')\n else:\n print('BUG')\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "89d5a61c3d02d8e8d987c8de0132d986", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "from __future__ import division, print_function\n__interactive = False\n\ndef main():\n def add(x, y):\n return (x+y)%MOD\n n, k = input_as_list()\n a = n-k\n ans = pow(a, n, MOD)\n m = 1\n p = -1\n for i in range(1, a):\n b = pow(a-i, n, MOD)\n m = mulmod(mulmod(m, a-i+1), modinv(i))\n m = mulmod(m, p)\n ans = add(ans, mulmod(m, b))\n lm = 1 if k==0 else 2\n for i in range(n-a+1, n+1):\n lm = mulmod(lm, i)\n for i in range(1, a+1):\n lm = mulmod(lm, modinv(i))\n print(mulmod(ans, lm))\n\n\nINF = float('inf')\nMOD = 998244353\nalphabets = 'abcdefghijklmnopqrstuvwxyz'\n\nimport os, sys\nsys.modules[\"hashlib\"] = sys.sha512 = sys\nfrom atexit import register\nfrom io import BytesIO\nimport itertools\nimport __pypy__\n\nif sys.version_info[0] < 3:\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\nif \"LOCAL_\" in os.environ:\n debug_print = print\nelse:\n if not __interactive:\n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\n sys.stdout = BytesIO()\n register(lambda: os.write(1, sys.stdout.getvalue()))\n\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n debug_print = lambda *x, **y: None\n\nflush = sys.stdout.flush\n\ndef mulmod(x, y):\n return __pypy__.intop.int_mulmod(x, y, MOD)\n\ndef modinv(x):\n return pow(x, MOD-2, MOD)\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\ndef input_as_list():\n return [int(x) for x in input().split()]\n\ndef input_with_offset(o):\n return [int(x)+o for x in input().split()]\n\ndef input_as_matrix(n, m):\n return [input_as_list() for _ in range(n)]\n\ndef array_of(f, *dim):\n return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()\n\ndef range_with_count(start, step, count):\n return range(start, start + step * count, step)\n\ndef indices(l, start=0, end=0):\n return range(start, len(l)+end)\n\ndef ceil_power_of_2(n):\n \"\"\" [0, 1, 2, 4, 4, 8, 8, 8, 8, 16, 16, ...] \"\"\"\n return 2 ** ((n - 1).bit_length())\n\ndef ceil_div(x, r):\n \"\"\" = ceil(x / r) \"\"\"\n return (x + r - 1) // r\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "86e47dba90cb354b147103e3cabcde38", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "def rev(x):\n res = int(str(x)[::-1])\n return res\ndef primes_sieve(n):\n sieve = [True] * n\n for i in range(3, int(n ** .5) + 1, 2):\n if sieve[i]:\n sieve[i * i :: 2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)\n return sieve\narr = primes_sieve(100000)\nprint([i for i in range(3, 100000, 2) if arr[i] and arr[rev(i)] and i != rev(i)][int(input()) - 1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1dd43702105b776152974918ae77883d", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\n\nn = int(input())\ns = input().encode()\n\nmem = [[-1]*(n+1) for _ in range(n+1)]\n\n# Solve for s[l:r]\ndef DP(l,r):\n # Empty string\n if l==r:\n return 0\n if mem[l][r]==-1:\n # Either remove the left most character\n score = 1 + DP(l+1,r)\n \n # Or remove a piece in the middle\n for i in range(l+1,r):\n if s[l] == s[i]:\n # s[l+1:i] is the middle piece\n new_score = DP(l+1,i) + DP(i,r)\n score = min(score,new_score)\n mem[l][r] = score\n return mem[l][r]\n\nprint(DP(0,n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1da8f8097532eaec214d88784cff688a", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "a, b, x1, y1, x2, y2 = map(int, raw_input().split())\ndef trans(x, y):\n\tu, v = x + y, x - y\n\treturn u/(2*a), v/(2*b)\ni1, j1 = trans(x1, y1)\ni2, j2 = trans(x2, y2)\n# print i1,j1\n# print i2,j2\ndi, dj = abs(i1-i2), abs(j1-j2)\n\nans = di + dj\nif di and dj:\n\tans -= 1\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e0012bc3c4df98e28a5759e91f71d87", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#solucion 725 B --Definitiva\n#Funcion que clacula los parametros\ndef sumador(numer,var):\n#tiempo para guardar el tiempo que eseta en el pasillo\n tiempo=0\n#tiempo_par e impar se diferencian \n acumulador_impar=0\n acumulador_par=0\n j=1\n while j<=numer:\n if j==1:\n tiempo=0\n acumulador_par=9\n acumulador_impar=7\n if j%2!=0 and j!=1:\n tiempo=tiempo+acumulador_par\n if j%2==0:\n tiempo=tiempo+acumulador_impar\n j=j+1\n tiempo_total=tiempo+var\n print(tiempo_total)\n#Inicio de captura de datos de entrada\nns=input()\nlista=list(ns)\n#Guardando la letra de la columna\ns=lista.pop()\n#Asignando su valor por letra\nif(s=='a'): variable=4\nif(s=='b'): variable=5\nif(s=='c'): variable=6\nif(s=='d'): variable=3\nif(s=='e'): variable=2\nif(s=='f'): variable=1\n#print (variable)\n#Transformando a enteros\nlista2=[int (i)for i in lista]\n#Guardadno el tama\u00f1o del vector\ntama\u00f1o=len(lista2)\nnumero=0\n#Convirtiendo el numero\nfor number in lista2:\n numero=numero+number*pow(10,tama\u00f1o-1)\n tama\u00f1o=tama\u00f1o-1\n#print(numero)\nif numero%2==0 :\n# print(\"numeropar\")\n#Viendo el parametro x e Y \n x= (numero+2)//2\n y= (numero)//2\n if x%2==0 :\n sumador(x,variable)\n if y%2==0 :\n sumador(y,variable)\nelse :\n# print(\"numero impar\")\n#Viendo el parametro X e Y para impares\n x=(numero+1)//2\n y=(numero-1)//2\n if x%2!=0 :\n print(x)\n print(variable)\n sumador(x,variable)\n if y%2!=0 and y!=0 :\n sumador(y,variable)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "85f1c5221c0c1b0166cfb2dd4a4524a6", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n,k = [int(x) for x in input().split()]\ndef DTB(num,x): \n if num > 1: \n DTB(num // 2,x) \n x.append(num % 2)\nnn=[]\nkk=[]\nDTB(n,nn)\nDTB(k,kk)\nif k==1:\n print(n)\nelif k==2:\n if n==2:\n print(1)\n else:\n if n%2==0:\n print(n-2)\n else:\n print(n-1)\nelif k==3:\n if n%4==2:\n print(n//2-1)\n else:\n print(n//2)\nelse:\n a = len(kk)-2\n m = len(nn)\n p = 2**(a+1)-1 + (n%(2**a))\n if nn[m-a-1]==1:\n p += 2**(a)\n if p>=k:\n print(int(''.join([str(x) for x in nn[0:(m-a-1)]])+'0', 2))\n else:\n N = nn[0:m-a-1]\n if sum(N)>2:\n N.reverse()\n ind = N.index(1)\n N[ind]=0\n N.reverse()\n N.append(0)\n print(int(''.join([str(x) for x in N]), 2))\n else:\n if m-a-1==1:\n print(1)\n else:\n if k!= (2**(a+2)-1):\n print(2**(m-a-1)-2)\n else:\n print(2**(m-a-2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0fbb8d54b29479cb92ce882cc9c8787b", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "n,k,m=map(int,input().split())\nd,r,p,P=0,0,1%k,(10**(n-1))*9\nF=[0]*k\nF[0]=1\nwhile d0 and s%k==0:\n#\t\t\tr+=1\n#\t\t\tbreak\n#\tj+=1\n#print()\n#print(r)\n\"\"\"\n3 6 9\n13 16 19\t12 15 18\n23 26 29\t21 24 27\n33 36 39\t30\n43 46 49\t42 45 48\n53 56 59\t51 54 57\n63 66 69\t60\n73 76 79\t72 75 78\n83 86 89\t81 84 87\n93 96 99\t90\n\"\"\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fdfe50474df63cee7c0e7ecd30406d7c", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "from math import sqrt\npt = lambda *a, **k: print(*a, **k, flush=True)\nrd = lambda: map(int,raw_input().split())\nn = int(raw_input())\ndef f(x1, y1, r1, x2, y2, r2):\n a = (r1 + r2) ** 2\n b = (r1 - r2) ** 2\n d = (x1 - x2) ** 2 + (y1 - y2) ** 2\n if d > a:\n return 1\n elif d == a:\n return 4\n elif d < b:\n return 3\n elif d == b:\n return 5\n else:\n return 2\ndef g(x1, y1, r1, x2, y2, r2):\n ds = (x1 - x2) ** 2 + (y1 - y2) ** 2\n d = sqrt(ds)\n A = (r1 ** 2 - r2 ** 2 + ds) / (2 * d)\n h = sqrt(r1 ** 2 - A ** 2)\n x = x1 + A * (x2 - x1) / d \n y = y1 + A * (y2 - y1) / d\n x3 = x - h * (y2 - y1) / d \n y3 = y + h * (x2 - x1) / d\n x4 = x + h * (y2 - y1) / d \n y4 = y - h * (x2 - x1) / d\n return x3, y3, x4, y4 \nif n is 1:\n pt(2)\nif n is 2:\n x1, y1, r1 = rd()\n x2, y2, r2 = rd()\n a = f(x1, y1, r1, x2, y2, r2)\n pt(4 if a is 2 else 3)\nif n is 3:\n x1, y1, r1 = rd()\n x2, y2, r2 = rd()\n x3, y3, r3 = rd()\n a = f(x1, y1, r1, x2, y2, r2)\n b = f(x1, y1, r1, x3, y3, r3)\n c = f(x3, y3, r3, x2, y2, r2)\n t = [a, b, c]\n t.sort()\n a, b, c = t\n if a is 1 and b is 1 and c in [1, 3, 4, 5]:\n pt(4)\n if a is 1 and b is 1 and c is 2:\n pt(5)\n if a is 1 and b is 2 and c is 2:\n pt(6)\n if a is 1 and b is 2 and c in [3, 4, 5]:\n pt(5)\n if a is 1 and b in [3, 4, 5]:\n pt(4)\n if a is 2 and b is 2 and c is 2:\n x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2)\n r = 8\n if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6:\n r -= 1\n if abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6:\n r -= 1\n pt(r)\n if a is 2 and b is 2 and c is 3:\n pt(6)\n if a is 2 and b is 2 and c in [4, 5]:\n x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2)\n if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6 or abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6:\n pt(6)\n else:\n pt(7)\n if a is 2 and b is 3:\n pt(5)\n if a is 2 and b in [4, 5]:\n pt(6)\n if a is 3 and b in [3, 4, 5]:\n pt(4)\n if a is 4 and b is 4 and c is 4:\n pt(5)\n if a is 4 and b is 4 and c is 5:\n pt(4)\n if a is 4 and b is 5 and c is 5:\n pt(5)\n if a is 5 and b is 5 and c is 5:\n pt(4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a0c55609763802519d46e1134d893f4", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "import random\ns = raw_input().split()\n\nn = int(s[0])\nm = int(s[1])\n\ngraf = set([])\n\nfor i in xrange(m):\n s = raw_input().split()\n u = int(s[0])\n v = int(s[1])\n graf.add((u,v))\n \n #print graf\nif m*4>n*(n-1):\n print -1\nelse:\n edges = 0\n tries = 0\n while edges < m:\n tries += 1\n if (n>=1000) and (tries > 2):\n break\n edges = 0\n newgraf = set([])\n usedonce = set([])\n usedtwice = set([])\n listv = (range(1,n+1))\n listu = (range(1,n+1))\n random.shuffle(listv)\n random.shuffle(listu)\n \n for v in listv:\n if edges>=m:\n break\n for u in listu:\n# print \"viewing:\", u,v\n if v==u:\n# print \"the same\"\n# print\n continue\n if u in usedtwice:\n# print \"u used twice\"\n# print\n continue\n if v in usedtwice:\n\n# print \"v used twice\"\n# print\n break\n \n if ((u,v) in graf) or ((v,u) in graf):\n# print \"edge in old graf\"\n# print\n continue\n if ((u,v) in newgraf) or ((v,u) in newgraf):\n# print \"edge already added\"\n# print\n continue\n \n newgraf.add((u,v))\n edges += 1\n# print \"adding edge\",u,v\n# print \"now edges:\", edges\n if edges >= m:\n break\n if u in usedonce: \n usedtwice.add(u)\n else:\n usedonce.add(u)\n if v in usedonce:\n usedtwice.add(v)\n #continue\n else:\n usedonce.add(v)\n# print \"usedonce:\", usedonce\n# print \"usedtwice:\", usedtwice\n# print\n# print\n if (n>=1000) and (tries > 2):\n print -1\n else:\n for e in newgraf:\n print e[0], e[1]\n \n\n\n \n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6733725b6a25e96f86d6aa9d12cb261", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "#http://codeforces.ru/problemset/problem/255/D\n\n##def cells():\n## #start second is 0 res = 1\n## res = 1\n## yield res\n## i = 2\n## while True:\n## res = res + 4 * (i - 1)\n## i += 1\n## yield res\n\ndef cells_a(second):\n return sum(xrange(1,second*2,2))*2 + second*2 + 1\n\ndef cells_dir(second):\n return sum(xrange(1,second*2,2))\n\nn, x, y, c = map(int, raw_input().split())\nsecond = 0\nwhile True:\n dcx = cells_dir(second-x+1) + cells_dir(second-n+x)\n dcy = cells_dir(second-y+1) + cells_dir(second-n+y)\n## print 'Second %d, dcx %d, dcy %d, cells %d' %(\n## second, dcx, dcy, cells_a(second))\n if cells_a(second) - dcx - dcy >= c: break\n second += 1\nprint second\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6de0743599d364f533bec576a2d4ab98", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "months = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}\nmonth = str(input())\nadd = int(input())\n\nout = {v:k for k,v in months.items()}\n\nval = months[month]\nnew_val = (val+add) % 12\nprint(out[new_val])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8f3818e840bf4c3eca4ac413b8449c01", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\n*a, = map(int, input().split())\nb = sorted(a)\nfor i in a:\n print((a[b.index(i) + 1]) % n, end=' ')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9500783151e7c65979cfae86f746df93", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "a, b = map(int, input().split())\r\n\r\ncake = []\r\n\r\nfor _ in range(a):\r\n\tcake.append([x for x in input()])\r\n\r\ncount = 0\r\nx, y = 0, 0\r\n\r\nstep = 0\r\nwhile x < b and y < a:\r\n\tif cake[y][x] == \"*\":\r\n\t\tcount += 1\r\n\tif step % 2 == 0:\r\n\t\ty += 1\r\n\t\tif y == a:\r\n\t\t\ty -= 1\r\n\t\t\tx += 1\r\n\telse:\r\n\t\tx += 1\r\n\t\tif x == b:\r\n\t\t\tx -= 1\r\n\t\t\ty += 1\r\n\tstep += 1\r\n\t\t'''\r\n\t\ty += 1\r\n\t\tif y == a:\r\n\t\t\ty -= 1\r\n\t\t\tx += 1\r\n\telse:\r\n\t\tx += 1\r\n\t\tif x == b:\r\n\t\t\tx -= 1\r\n\t\t\ty += 1\r\n\t\t'''\r\n\r\nprint(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af96e8faf272f6465c098f1996a92d23", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "from sys import stdin\r\nfrom math import sqrt\r\n# raw_input = input\r\n# xrange = range\r\nraw_input = lambda: stdin.readline().rstrip()\r\ninput = lambda: int(raw_input())\r\nI=lambda: map(int, raw_input().split())\r\nn,m = I()\r\ndp = [0]*(n+1)\r\ndp[1] = 1\r\ns = 1\r\nfor x in xrange(2, n+1):\r\n\tw = 0\r\n\tq = int(sqrt(x))\r\n\tq1 = q+(0 if q**2==x else 1)\r\n\tfor j in xrange(2, q1): #ja1 and a2>q1-1:\r\n\t\t\tw = w+dp[c]*(a2-max(a1, q1-1)))%m\r\n\tdp[x] = (s + w)%m\r\n\ts = (s+dp[x])%m\r\nprint(dp[n])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1709d350f9a0cb461b30ea8c906e6de4", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "s = input()\nn, m = int(input()), len(s)\n\ndef g(p):\n t = [j for j, q in enumerate(s) if q == p] + [m]\n n = len(t) + 1\n\n l = [0] * n\n r = [0] * n\n\n a = -1\n for i, b in enumerate(t):\n v = b - a\n u = v - 1\n\n l[i + 1] = l[i] + v\n r[i + 1] = r[i] - v\n\n for k in range(i, 0, -1):\n l[k] = max(l[k] + u, l[k - 1] - v)\n r[k] = max(r[k] - u, r[k - 1] + v)\n u, v = -u, -v\n\n l[0] += u\n r[0] -= u\n a = b\n return l, r\n\nt, f = g('T'), g('F')\nprint(max(t[0][n & 1:n + 1:2] + t[1][n & 1:n + 1:2] + f[0][m - n::2] + f[1][m - n::2]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "255deec99b1a4b70df6a6d0b72a2b8cf", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "f = lambda: map(int, input().split())\nn, m = f()\np = [1 << i for i in range(n)]\nfor i in range(m):\n x, y = f()\n x -= 1\n y -= 1\n p[x] |= 1 << y\n p[y] |= 1 << x\ns = set(p)\nb = (1 << n) - 1\nt = {}\nif b in s:\n t[b] = 'b'\n s.remove(b)\nif len(s) == 2:\n a, c = s\n if a | c == b and bool(a & c) == (b in t):\n t[a], t[c] = 'ac'\n s.clear()\nprint('No' if s else 'Yes\\n' + ''.join(map(t.get, p)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "260c27fb2dcfaf0e6550cd9befa53745", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n,m,X,Y,x,y=map(int,input().split())\na=[abs(X-x),abs(Y-y)]\na.sort()\nprint(\"First\" if a[0]<5 and a[0]+a[1]<7 else \"Second\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb3ce8ddc5361a0c0bcc0d63af154ee4", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "a, b, c, d = list(map(int, input().split(' ')))\n\nif a == c and b < d:\n print(\"Polycarp\")\nelif a == c and b > d:\n print(\"Vasiliy\")\nelif a < c and b == d:\n print(\"Polycarp\")\nelif a > c and b == d:\n print(\"Vasiliy\")\nelif a > c and b > d:\n print(\"Polycarp\")\nelif a < c and b < d:\n print(\"Vasiliy\")\nelse:\n if a+b<=max(c, d):\n print(\"Polycarp\")\n else:\n print(\"Vasiliy\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b59224ea8b0f5c482159e5411da953b7", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "m, n = map(int, input().split())\nif n == 1 && m == 1:\n print(1)\nelse:\n print(1/n + (n-1)/n*(m-1)/(n*m-1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "003e44baf1d601c1dc4b3a4140df14e4", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "Python 3", "source_code": " import sys\nimport time\n\nfor line in sys.stdin:\n ll = len(line)-1\n fail=0\n for i in range(ll):\n if i == ll-1-i : continue\n x = int(line[i])\n y = int(line[ll-1-i])\n if (x,y) not in [(3,3),(4,6),(6,4),(7,7),(8,0),(0,8),(5,9),(9,5)]:fail=1\n if fail: print(\"No\")\n if not fail:print(\"Yes\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af45f9bc0c909fa14891343b0c5fd8f2", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "// luogu-judger-enable-o2\nn = int(input())\nn = hex(n)[2:]\nx = n.count('0') + n.count('4') + n.count('6') + n.count('9')\nx += n.count('a') + n.count('d') + n.count('8') * 2 + n.count('b') * 2\nprint(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11a2341af247d33648256a13c8c00a51", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import math\ndef main(fl=math.floor):\n m = int(raw_input())\n lo, hi = 0, 5.0 * (10 ** 15)\n g = [1, 1] + [i ** 3.0 for i in xrange(2, 180000)]\n def f(n):\n return sum(fl(n / g[i]) for i in xrange(2, int(n ** (1.0 / 3)) + 2))\n while lo + 1 < hi:\n mid = (lo + hi) / 2\n if f(fl(mid)) < m:\n lo = mid\n else:\n hi = mid\n gi = [1, 1] + [i ** 3 for i in xrange(2, 180000)]\n def fi(n):\n return sum(n / gi[i] for i in xrange(2, int(n ** (1.0 / 3)) + 2)) \n x = int(fl(hi))\n print x if fi(x) == m else -1\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "890d8a91c9ec2fffd07ae8908a4aaa2f", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import math\n\nk = int(input())\n\n\n\nn = int(k/3)*2 + 1\n# print('n', n)\nans = 0\n\nwhile True:\n point_to_check = (n+2)//2\n # print('p', point_to_check)\n\n x = 0.0\n y = n*math.sqrt(3)\n\n # print('r', math.sqrt((x**2+y**2)))\n\n # p1\n x -= 0.5\n y += math.sqrt(3) * 0.5\n\n # print('r', math.sqrt((x**2+y**2)))\n\n count = -1\n for i in range(point_to_check):\n # print('r', math.sqrt((x**2+y**2)))\n if ((x**2+y**2)<=k**2):\n count = i\n break\n x -= 1.5\n y -= math.sqrt(3)/2\n\n extra = 0\n if count != -1:\n extra = point_to_check - count\n\n if (n+1)%2==0:\n extra *= 2\n else:\n extra = extra*2 -1\n\n if extra == n+1:\n ans += (extra-1)*6\n break\n else:\n ans += extra*6\n\n # print('n', n, 'ans', ans)\n\n n = n-1\n\n# print('extra', extra)\n\n\n\nfor i in range(n):\n if i==0:\n ans += 1\n else:\n ans += i*6\n\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# R = 1\n# r = sqrt(3)*0.5*R\n# full_cycle_count = k / (math.sqrt(3)) - 0.5\n# print(full_cycle_count)\n# full_cycle_count = int(full_cycle_count)\n# print(full_cycle_count)\n#\n# half_cycle_count = int((k - 1) / 3) * 2\n# print(half_cycle_count)\n#\n# ans = 1\n# last_add = 0\n# for i in range(1, full_cycle_count+1):\n# last_add +=6\n# ans += last_add\n#\n# print(last_add)\n#\n# if half_cycle_count>full_cycle_count:\n# ans += (last_add+6) / 2\n#\n# print(int(ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a828736274c0744a8548239760b980f3", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python \nimport sys\nimport math\n\ndef main():\n lines = sys.stdin.readlines()\n a, b, m = map(int, lines.pop(0).split(' '))\n vx, vy, vz = map(int, lines.pop(0).split(' '))\n #print \"dimensions of room: (\" + str(a) + \", 0, \" + str(b) + \")\"\n #print \"distance away: \" + str(m)\n #print vx, vy, vz\n coordinates = (a/2.0, m, 0)\n steps = -1*m/float(vy)\n \n x_move = (steps*math.fabs(vx))%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"z movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n shifted = 0\n\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tfinal_x = a-x_move\n else:\n final_x = x_move\n #print final_x\n if (vx < 0):\n #shift a/2 to the left\n shifted = final_x - a/2.0\n if shifted < 0:\n shifted = -1*shifted\n else:\n\t\t#shift a/2 to the right\n shifted = final_x + a/2.0\n if shifted > a:\n shifted = 2*a - shifted\n #print \"final x: \" + str(shifted)\n\n if z_move > b:\n \t#print \"z move is larger than dim\"\n \tz_move = z_move % b\n \tfinal_z = (b-z_move)\n else:\n \tfinal_z = z_move\n print str(shifted) + \" \" + str(final_z)\n\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2f6ec544fa87cc59cf53dc9c45f1af12", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from copy import deepcopy\nn, k, m, a = [int(i) for i in input().split()]\ncn = [0] * (n + 1)\nlast = [-1] * (n + 1)\nv = [int(i) for i in input().split()]\n\nfor i in range(len(v)):\n last[v[i]] = i\n cn[v[i]] += 1\n\ncn1 = deepcopy(cn)\nlast1 = deepcopy(last)\n\nfor i in range(1, n + 1):\n #print(i)\n res = [i1 for i1 in range(1, n + 1)]\n res.sort(key=lambda x: (cn[x], -last[x]), reverse = True)\n \n for j in range(len(res)):\n if res[j] != i:\n continue\n j1 = j + 1\n lft = m - a\n while j1 < n and lft:\n cn[res[j1]] += min(lft, cn[i] - cn[res[j1]] + 1)\n last[res[j1]] = m\n lft -= min(lft, cn[i] - cn[res[j1]] + 1)\n j1 += 1\n\n res.sort(key=lambda x: (cn[x], -last[x]), reverse = True)\n sans = 0\n for j in range(len(res)):\n if res[j] != i:\n continue\n if cn[i] == 0 or j >= k:\n sans = 0\n else:\n sans = 1\n break\n\n if sans == 1:\n print(1, end= ' ')\n continue\n \n cn = deepcopy(cn1)\n last = deepcopy(last1)\n\n if m - a:\n cn[i] += m - a\n last[i] = m - 1\n\n res.sort(key=lambda x: (cn[x], 0 -last[x]), reverse = True)\n for j in range(len(res)):\n if res[j] != i:\n continue\n if cn[i] == 0 or j >= k:\n sans = 0\n else:\n sans = 1\n break\n\n cn = deepcopy(cn1)\n last = deepcopy(last1)\n \n if sans:\n print(2, end=' ')\n else:\n print(3, end=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db43e7371d1484adcee78d89e6c51782", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nraw = raw_input()\nglobal s, p, q, ans\ns = []\nfor x in raw:\n\ts.append(int(x))\np = [[0 for i in range(n+1)] for j in range(n+1)]\nq = [[0 for i in range(n+1)] for j in range(n+1)]\n\ndef f(a, b):\n\tglobal s, p, q\n\tif p[a][b] != 0:\n\t\treturn p[a][b]\n\tif a > 0:\n\t\ty = f(a-1, b) + (10**(a-1))*s[n*2-a-b]\n\t\tif p[a][b] <= y:\n\t\t\tp[a][b] = y\n\t\t\tq[a][b] = 'M'\n\tif b > 0:\n\t\ty = f(a, b-1) + (10**(b-1))*s[n*2-a-b]\n\t\tif p[a][b] <= y:\n\t\t\tp[a][b] = y\n\t\t\tq[a][b] = 'H'\n\treturn p[a][b]\ndef g(a, b):\n\tglobal q, ans\n\tif q[a][b] != 0:\n\t\tans += q[a][b]\n\tif q[a][b] == 'M':\n\t\tg(a-1, b)\n\tif q[a][b] == 'H':\n\t\tg(a, b-1)\n\nans = ''\nf(n, n)\na = b = n\nwhile q[a][b] != 0:\n\tans += q[a][b]\n\tif q[a][b] == 'M':\n\t\ta -= 1\n\telse:\n\t\tb -= 1\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "22e0d94d95ecbb55ecda4c26db5d051f", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def satisfies(cnt1, cnt2, onlyX, onlyY, none):\n '''\n tells whether you can form presents using the numbers\n '''\n cnt1 = max(cnt1 - onlyY, 0)\n cnt2 = max(cnt2 - onlyX, 0)\n return (cnt1 + cnt2 <= none)\n\nimport sys\ncnt1, cnt2, x, y = int(sys.stdin.readline()).split()\nbothXY = 0\nonlyX = 0\nonlyY = 0\nnone = 0\nv = 0\nwhile(not satisfies(cnt1, cnt2, onlyX, onlyY, none)):\n v += 1\n if(v % (x * y) == 0):\n bothXY += 1\n elif(v % x == 0):\n onlyX += 1\n elif(v % y == 0):\n onlyY += 1\n else:\n none += 1\nprint v\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fc2f8c7b46e44b3300bece845630ad70", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "import math\ndef primes(max_n):\n max_n-=1\n numbers = range(3, max_n+1, 2)\n half = (max_n)//2\n initial = 4\n\n for step in xrange(3, max_n+1, 2):\n for i in xrange(initial, half, step):\n numbers[i-1] = 0\n initial += 2*(step+1)\n if initial > half:\n return [2] + filter(None, numbers)\ndef factors(a):\n j = 0\n p = {}\n while (a > 1):\n b = asd[j]\n if a % b == 0:\n a /= b\n if b not in p:\n p[b] = 1\n else:\n j += 1\n p = p.keys()\n p.sort()\n return p\nasd=primes(10**6+1)\ncheck={}\nfor i in asd:\n check[i]=1\ndef help(arr,num):\n don=[]\n if num not in check:\n for i in arr:\n p=num/i\n #print p,i\n for j in range(num-i+1,num+1):\n don.append(j)\n return don\ndef help2(arr,num):\n don=[]\n if num not in check:\n for i in arr:\n don.append(num-i+1)\n return don\n\n\n#print help(factors(16),16)\n\n\nn=input()\nans=[]\nf=factors(n)\na=help(f,n)\nfor i in a:\n af=help(factors(i),i)\n #print af,i\n ans+=af\nprint min(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "14dba01e6ebf59832a002acfda2191fc", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n \ninp = [int(x) for x in sys.stdin.read().split()]; ii = 0\n \nn = inp[ii]; ii += 1\nm = inp[ii]; ii += 1\n \ncoupl = [[] for _ in range(n)]\nV = []\nC = []\nfor _ in range(m):\n a = inp[ii] - 1; ii += 1\n b = inp[ii] - 1; ii += 1\n c = inp[ii]; ii += 1\n \n eind = len(V)\n C.append(c)\n V.append(b)\n V.append(a)\n coupl[a].append(eind)\n coupl[b].append(eind ^ 1)\n \nnode_color = [-1]*n\nans = [0.0] * n\n \nval0 = [0] * n\nval1 = [1] * n\nfor root in range(n):\n if node_color[root] >= 0:\n continue\n bfs = [root]\n node_color[root] = 0\n for node in bfs:\n for eind in coupl[node]:\n nei = V[eind]\n if node_color[nei] == -1:\n node_color[nei] = 1 - node_color[node]\n bfs.append(nei)\n \n c = C[eind >> 1]\n val0[nei] = c - val0[node]\n val1[nei] = -val1[node]\n \n x = 0.0\n for node in bfs:\n for eind in coupl[node]:\n nei = V[eind]\n c = C[eind >> 1]\n if val0[node] + val0[nei] != c:\n if val1[node] + val1[nei] == 0:\n print 'NO'\n sys.exit()\n x = (c - (val0[node] + val0[nei]) + 0.0) / (val1[node] + val1[nei])\n break\n else:\n continue\n break\n else:\n vals = []\n for node in bfs:\n #val0[nei] + x*val1[nei] = 0\n vals.append(val0[node] / val1[node])\n vals.sort()\n x = vals[len(vals)//2]\n \n for node in bfs:\n ans[node] = val0[node] + x * val1[node] + 0.0\n \nfor node in range(n):\n for eind in coupl[node]:\n nei = V[eind]\n c = C[eind >> 1]\n if ans[node] + ans[nei] != c:\n print 'NO'\n sys.exit()\n \nprint 'YES'\nprint ' '.join(str(x) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "958ce0b60bf631ca92f688f3a7c09631", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\n\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# ------------------------------\n\nfrom math import factorial\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\n\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef N(): return int(input())\ndef comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0\ndef perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0\ndef mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)\nmod = 998244353\nINF = float('inf')\n\n# ------------------------------\n\ndef c(chr): return ord(chr)-ord('a')\n\ndef main():\n n, k = RL()\n s = input()\n\n dp = [[0]*(n+1) for i in range(n+1)]\n rec = [-1]*26\n pre = [-1]*n\n dp[0][0] = 1\n\n for i in range(n):\n now = c(s[i])\n pre[i] = rec[now]\n rec[now] = i\n\n for i in range(1, n+1):\n for j in range(1, i+1):\n if j>i: break\n\n if i==j: dp[i][j] = 1; continue;\n\n dp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n if pre[i-1]!=-1:\n # if i==5 and j==4: print(pre[i-1], '+++')\n dp[i][j] -= dp[pre[i-1]][j-1]\n\n\n res = 0\n for j in range(n, -1, -1):\n for i in range(n, -1, -1):\n if k:\n num = min(k, dp[i][j])\n k-=num\n res += (n-j)*num\n\n print(res if k==0 else -1)\n\n\n\nif __name__ == \"__main__\":\n main()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b5aa4389e695d7fb6615d8a5a789592c", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n = int(input().strip())\r\n\r\na = {}\r\n\r\n\r\ndef decom(i):\r\n if i == 0:\r\n return 0\r\n if i == 1:\r\n return 1\r\n if i in a.keys():\r\n return a[i]\r\n if upper(i)[024] - i > i:\r\n return decom(i - lower(i)[0]) + lower(i)[1]\r\n else:\r\n k = min(decom(i - lower(i)[0]) + lower(i)[1], decom(upper(i)[0] - i) + upper(i)[1])\r\n a[i] = k\r\n return k\r\n\r\n\r\n\r\ndef upper(i):\r\n d = 1\r\n n = 1\r\n while d < i:\r\n d = d * 10 + 1\r\n n += 1\r\n return (d, n)\r\n\r\n\r\ndef lower(i):\r\n if (upper(i)[0] - 1) // 10 == 0:\r\n return (1, 1)\r\n return ((upper(i)[0] - 1) // 10, upper(i)[1] - 1)\r\n\r\n\r\nprint(decom(n))\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03b1cce3d5853ea8ef37c4b2afdbd7e7", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "from itertools import permutations\n\ndef check(date):\n\ty,m,d = date\n\n\tif (m in [1,3,5,7,8,10,12] and d > 31) or \\\n\t\t(m in [2,4,6,9,11] and d > 30) or m>12:\n\t\treturn False\n\telif m == 2 and ((not y%4 and d>29) or (y%4 and d>28)):\n\t\treturn False\n\telse:\n\t\treturn True\n\ndef date_diff(cdate,bdate):\n\tif bdate[2]==29 and bdate[1]==2 and not bdate[0]%4:\n\t\tbdate = bdate[0]+18,3,1\n\telse:\n\t\tbdate[0]+=18\n\n\tif bdate <= cdate:\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef main():\n\tcdate = [int(x) for x in raw_input().split('.')][::-1]\n\tbdate = [int(x) for x in raw_input().split('.')][::-1]\n\n\tpossible = 'NO'\n\tfor date in permutations(bdate):\n\t\tprint date,\n\t\tdate = list(date)\n\n\t\tif check(date):\n\t\t\tprint 'passed'\n\t\t\tif date_diff(cdate,date):\n\t\t\t\tpossible = \"YES\"\n\t\t\t\tbreak\n\t\telse:\n\t\t\tprint 'failed'\n\n\tif cdate[0]<18:\n\t\tpossible = \"NO\"\n\tprint possible\nif __name__ == \"__main__\":\n\tmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4fa93671d0368129d0f1f09ae9373942", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n,t = map(int, raw_input().split())\na = map(int, raw_input().split())\n#print n,t,a\nm = min(t,n)\nb = a*m\nc = []\nc += [a[0]]\nfor i in b[1:]:\n if i>=c[-1]:\n c += [i];\n else:\n j = len(c) - 2\n while j>=0:\n if c[j]<=i:\n break\n j-=1\n c[j+1] = i\n #print c\nl = len(c)\n#print l\nans = l\nif t>m:\n d = {}\n mx = 0\n for i in a:\n if(i in d):\n d[i]+=1\n else:\n d[i]=1\n mx = max(mx, d[i])\n print ans, mx\n ans += (t-m)*mx\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53183a8a1f2607fd65a0b3ea3595ff10", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from math import gcd\na,b,c,d=[int(i) for i in input(),split()]\ng=gcd(c,d)\nc//=g\nd//=g\ne=min(a//c,b//d)\nprint(e*c,e*d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "723a6ed4c5b84a925f50bb59ef4b472c", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "# submit\ndef dist_from_0(x, y, n):\n if x == 0:\n return y\n else:\n if y == 0:\n return 4 * n - x\n else:\n if x == n:\n return 3 * n - y\n else:\n return n + x\n\n\ndef main():\n n, x1, y1, x2, y2 = [int(i) for i in raw_input().split()]\n d1 = dist_from_0(x1, y1, n)\n d2 = dist_from_0(x2, y2, n)\n d = abs(d2 - d1)\n print min(d, 4 * n - d)\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e1c6481ec5f999b53a2d4a6338c3657", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def sqr(x,y): return 0 if x<1 or y<1 else x*y\nx,y = map(int,raw_input().split())\ni = input()\nprint (sqr(x-2*(i-1), y-2*(i-1))-sqr(x-2*i, y-2*i)+1)/2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "244c096bd3695daef362ccf5a2a5e8c1", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nn = int(raw_input())\na = map(int, raw_input().split())\n\nless = set(range(1, n + 1)) - set(a)\ncnt = [0] * 100005\nfor ai in a: cnt[ai] += 1\nans = a[:]\nfor i in xrange(n):\n if cnt[a[i]] > 1 or a[i] > n:\n ans[i] = less.pop()\n cnt[a[i]] -= 1\nprint \" \".join(map(str, ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3bc1ae802ea172e5afbb3a196d565000", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "dp = {}\ndef count(n, low):\n\tk = (n, low)\n\tif k in dp: return dp[k]\n\tl1 = (n-1)/2\n\tif l1 < low: return 0\n\tl2 = n - 1 - l1\n\tdp[k] = 1 + count(l1, low) + count(l2, low)\n\treturn dp[k]\n\ndef getPos(l, r, low, want):\n\tm = (l+r)/2\n\n\twant -= 1\n\tif want == 0: return m\n\n\tc1 = count(m-l, low)\n\tc2 = count(r-m, low+1)\n\n\tif c1+c2 >= want:\n\t\treturn getPos(l, m-1, low, want-c2)\n\telse:\n\t\treturn getPos(m+1, r, low, want-c1)\n\nn,k = map(int, raw_input().split())\nif k == 1: print 1\nelif k == 2: print n\nelse:\n\tlo, hi = 0, n+1\n\twhile lo < hi:\n\t\tmid = (lo + hi + 1) / 2\n\t\tif count(n-2, mid) >= k-2:\n\t\t\tlo = mid\n\t\telse:\n\t\t\thi = mid-1\n\tprint getPos(2,n-1,lo,k-2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bdbee642d952dbfedae0c0bc46736144", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "R=lambda:map(int,raw_input().split())\nM=10**9+7\nK=lambda x,y,z:((x*60)+y)*60+z\nn,k=R()\nv=[0,0]\nfor x in R():v[x>50]+=1\nk/=50\nt,c,q,h=[M]*8192,[0]*8192,[K(0,v[0],v[1])],0\nt[q[h]]=0\nc[q[h]]=1\nd=[[1]*64 for _ in range(64)]\nfor i in range(60):\n d[i][0]=d[i][i]=1\n for j in range(1,i):\n d[i][j]=(d[i-1][j-1]+d[i-1][j])%M\nwhile h=M:\n t[w]=t[u]+1\n q+=[w]\n if t[w]==t[u]+1:\n c[w]=(c[w]+c[u]*d[y][i]*d[z][j])%M\nu=K(1,v[0],v[1])\nprint t[u] if t[u]w:\n w,h=h,w\nm=h//a\nr=0\nfor i in range(m,0,-1):\n x=(h-a*i)/(i+1)\n w1=w-x\n a1=a+x\n q=w1%a1\n if q<0.00000001:\n r=1\n break\nif r==0:\n print(-1)\nelse:\n print(x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d48be609d5525af5aa0ab7d7a122eb8", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "Python 2", "source_code": " = raw_input()\nprint (int(s,2)*(2**(len(s)-1)))%1000000007\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cea1d424a8ec99df0b59512980a31ce2", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, p = map(int, input().split())\n\nb = []\nfor i in range(n):\n r = input()\n b.append(r)\n\nstart = 0\n\nif b[0] == 'half':\n if n%2==0: start = n\n else: start = n+1\nelse:\n if n%2: start = n\n else: start = n+1\n\n#print(start)\nearned=0\ncnt = 0\n\nwhile cnt != n:\n earned = 0\n temp = start\n cnt = 0\n \n for i in b:\n if i[-1] == 'f' and temp%2 == 1: break\n if i[-1] == 's' and temp%2 == 0: break\n \n earned += (temp - temp/2) * p\n temp //= 2\n cnt += 1\n if temp == 0: break\n \n start += 1\n\n#print(start-1)\nprint(int(earned))\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cc1baf6631a6ec2e1c7236ddc52bf416", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import math, time, re\n\nln = lambda : raw_input()\ncnv = lambda s: map(int, s.split())\nrInt = lambda s: int(s)\nrFloat = lambda s: float(s)\nrLong = lambda s: long(s)\nrLine = lambda f: f.readline()\n\nb = [True for i in xrange(0, 10)]\n\nllong = []\ndef per(s):\n if len (s) == 4:\n llong.append(s)\n return\n else:\n for i in xrange(0, 10):\n if b[i]:\n b[i] = False\n per(s + str(i))\n b[i] = True\n\ndef check(s1, s2):\n return (len([i for i in xrange(0, 4) if (s1[i] in s2 and s1[i] == s2[i])])), \\\n(len([i for i in xrange(0, 4) if (s1[i] in s2 and s1[i] != s2[i])]))\n\n\nstart = time.time()\nk, t = 0, 0\nn = int(raw_input())\nl = []\nper(\"\")\n#print llong\nfor i in xrange(0,n):\n l.append(ln().split())\nfor i in xrange(0, len(llong)):\n b = True\n for j in xrange(0, n):\n if (check(llong[i], l[j][0]) != (int(l[j][1]), int(l[j][2]))):\n b = False\n break\n if b:\n k += 1\n t = llong[i]\n if k > 1:\n break\n#print l[0][0]\n#print l[0][1]\n#print l[0][2]\n#print llong[0]\nif k > 1:\n print 'Need more data'\nelif k == 1:\n print t\nelse:\n print 'Incorrect data'\n#per(s)\n#print llong\n#print check (s1, s2)\n#print 'Time exceeded:', time.time() - start", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e30a5eaa11987591c0e6a63896515a3f", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def right(m, n, a):\n b = True\n n2 = a // 2 - a // 6\n n3 = a // 3 - a // 6\n n6 = a // 6\n if n2+n6= a and w * sp >= b) or (h * fp >= b and w * sp >= a):\n return True\n \n return False\n \n for i in range(my_arr[o][1] + 1):\n if gen(o + 1, gen1 + [i]):\n return True\n \n return False\n\n\na, b, h, w, n = map(int, input().split())\n\narr = list(map(int, input().split()))\narr.sort(reverse = True)\n\narr2 = []\nfor i in range(n):\n if (not i) or arr[i] != arr[i - 1]:\n arr2.append([arr[i], 1])\n else:\n arr2[-1][1] += 1\n \n \nif (h >= a and w >= b) or (h >= b and w >= a):\n print(0)\nelse:\n my_arr = []\n j = 0\n ans = -1\n for i in range(1, min(34, len(arr)) + 1):\n if my_arr and my_arr[-1] < arr2[j]:\n my_arr[-1][1] += 1\n else:\n j += 1\n my_arr.append([arr2[j][0], 1])\n \n if gen(0, []):\n ans = i\n break\n \n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3441c37b0f044b81980e8c949c7b4d40", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from operator import __xor__ as X\nn = input()\na = [[] for _ in xrange(n+1)]\nfor k in xrange(2,n):\n for x in xrange(1,n):\n f = x*k+(k*k-k>>1)\n if f>n: break\n a[f].append((k,x))\nq = [n]\ns = set(q)\nfor j in q:\n l = set([])\n for k,x in a[j]: l.update(range(x,x+k))\n l -= s\n q.extend(l)\n s |= l\nf = [0]*(n+1)\nfor i in sorted(s):\n z = set(reduce(X,f[x:x+k],0) for k,x in a[i])\n for j in xrange(n):\n if j not in z: break\n f[i]=j\nprint min(k for k,x in a[n] if reduce(X,f[x:x+k],0)==0) if f[n] else -1\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "01790a95ecb4c23d68b3d0cad3339a08", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "def check(a):\n for i in range(len(a) - 1):\n if a[i] > a[i + 1]:\n return True\n return False\nn = int(input())\nif n > 60:\n print(1)\nelse:\n a = [int(i) for i in input().split()]\n xo = [0]\n for i in range(n):\n xo.append(xo[i] ^ a[i])\n ans = 1000\n for L1 in range(n):\n for R1 in range(L1 + 1, n):\n if check(a[:L1] + [xo[R1 + 1] ^ xo[L1]] + a[R1 + 1:]):\n ans = min(ans, R1 - L1)\n # print(L1, R1, ans)\n for L2 in range(R1 + 1, n):\n for R2 in range(L2 + 1, n):\n if check(a[:L1] + [xo[R1 + 1] ^ xo[L1]] + a[R1 + 1:L2] + [xo[R2 + 1] ^ xo[R1]] + a[R2 + 1:]):\n ans = min(ans, R1 - L1 + R2 - L2)\n # print(L1, R1, L2, R2, ans)\n print(ans if ans < 1000 else -1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b8f5bdc87bb68f0b9aa4496a607a61f", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "PyPy 3", "source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport heapq\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n \nM = mod = 998244353\ndef factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))))\n# def inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n').split(' ')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\ndef compare(a,b):\n if a[-1]b[-1]:return 1\n else:\n if sum(a[:-1]) > sum(b[:-1]):return -1\n return 1\n\ndef give(a,b):\n temp = (a*t1 + b*t2)/(a + b)\n # print(temp,a,b,t)\n if temp < t:\n return [a,b,float('inf')]\n return [a,b,abs(t - temp)]\n\nt1, t2, x1, x2, t = li()\nbestans = []\nif t == t1 and t1 == t2:\n print(x1,x2)\nelif t == t1:\n print(x1,0)\n\nelif t == t2:\n print(0,x2)\nelse:\n currans = []\n currcheck = float('inf')\n r = (t2 - t)/(t - t1)\n # print('R ; ',r)\n bestans.append(give(x1,x2))\n bestans.append(give(0,x2))\n bestans.append(give(x1,0))\n for i in bestans:\n if currcheck > i[-1]:\n currcheck = i[-1]\n currans = i[:-1]\n elif currcheck == i[-1] and sum(currans) < sum(i[:-1]):\n currans = i[:-1]\n do = 1\n for i in range(1,x2 + 1):\n curry1 = i*r\n a = curry1\n b = i\n if 0 <= int(curry1) <= x1:\n do = 0\n c,d,e = give(int(a),b)\n if e < currcheck:\n currcheck = e\n currans = [c,d]\n elif e == currcheck and sum(currans) < c + d:\n currans = [c,d]\n if 0 <= int(a) + 1 <= x1:\n do = 0\n c,d,e = give(int(a) + 1,b)\n if e < currcheck:\n currcheck = e\n currans = [c,d]\n elif e == currcheck and sum(currans) < c + d:\n currans = [c,d]\n\n if do:\n for j in range(1,min(x1,x2) + 1):\n c,d,e = give(j,j)\n if e < currcheck:\n currcheck = e\n currans = [c,d]\n elif e == currcheck and sum(currans) < c + d:\n currans = [c,d]\n\n # for i,(a,b,c) in enumerate(bestans):\n # if ((a*t1 + b*t2)/(a + b)) < t:\n # bestans[i][-1] = 1000\n # continue\n # bestans[i][-1] = abs(t - ((a*t1 + b*t2)/(a + b)))\n\n # bestans.sort(key=cmp_to_key(compare))\n # print(bestans)\n print(*currans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a58f3fcef883db6a31f283835dc974ef", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "foo = bar = 0\nquz = 1\nfor bar in range(int(input())):\n foo += int(input())\n if foo * quz < baz * bar: break\n baz, quz = foo, bar\nprint(baz / quz)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b18598ba3565e5e37ee191d5b22ffd1", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from math import log2, floor\nN = int(input())\nif N % 2 == 0:\n N //= 2\n ans = N - 2 ** floor(log2(N))\nelse:\n ans = (N+1) // 2 - 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eeab353dde77d090220b991b209f1ec9", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "a = []\nmn = float(\"inf\")\nfor _ in range(n):\n line = input()\n a.append(list(permutations(line)))\n \nfor arr in zip(*a):\n ints = [int(''.join(num)) for num in arr]\n mn = min(mn,max(ints)-min(ints))\n \nprint(mn)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c285d0e878a467ca803e3c997fd6c29b", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from math import ceil\nn, m, s = map(int, raw_input().split())\narr = []\nfor i in xrange(s):\n for j in xrange(s):\n arr.append(int(ceil(1.0 * (m - j) / s) * ceil(1.0 * (n - i) / s)))\nprint n * m if max(arr) is 1 or max(arr) is 0 else max(arr)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e273cdbc65e83e9c171127e71ecb8996", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "a, b, m = map(int, input().split())\nk = s = 10 ** 9 % m\ni = 0\nwhile k and i < a:\n if k < m - b: exit(print(1, str(i + 1).zfill(9)))\n k += s\n i += 1\n if k > m: k -= m\nprint(2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7315bbe58ea170d43fb2d054c5cc45b", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def prod(n):\n x=str(n)\n y=['0']*len(x)\n for i in range(len(x)):\n y[i]=str(9-int(x[i]))\n while y[0]=='0':\n if len(y)==1:\n return 0\n else:\n y=y[1:len(y)]\n return int(x)*int(''.join(y))\n\nx=[int(i) for i in input().split()]\n\ns=0\n\nfor i in range(x[0],x[1]+1):\n if prod(i)>s:\n s=prod(i)\nprint(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "340ea240dfbbd6c5f5b3b0d988c2837e", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b,l,r = map(int,raw_input().split())\ns = \"a\"\nfor i in range(1,a):\n temp = s[i-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\ntemp = s[-1]\nif b>=a :\n s += s[:a-1]\n s += chr(ord(temp)+1)\nelse :\n s += s[:b]\n s += chr(ord(temp)+1)\n for i in range(a-b-1):\n temp = s[-1]\n #print temp\n x = ord(temp)\n x += 1\n s += chr(x)\n#print s\nfor i in range(b):\n s += s[-1]\n#print s\nlength = len(s)\ns = '_' + s\nif r-l+1 >= length :\n print len(set(s))-1\nelse :\n start = l%length\n if start==0 :\n start = length\n i = start\n end = r%length\n if end==0 :\n end = length\n ans = {}\n while(start!=end) :\n ans[s[start]] = 1\n start += 1\n if start>length :\n start = 1\n print len(ans)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "43c50bd9f927acd9656dcabd1fb2e1e6", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "# import sys\n# sys.stdin = open('test.txt','r')\nR = lambda: map(int,raw_input().split())\na11,b11 = R()\na12,b12 = R()\na21,b21 = R()\na22,b22 = R()\n\ndef win(a,b):\n\tres = 1\n\tif a<=a21: res = 0\n\tif a<=a22: res = 0\n\tif b<=b21: res = 0\n\tif b<=b22: res = 0\n\t# print a,b,res\n\treturn res\ndef lose(a,b):\n\tres = 0\n\t# print a21,b22\n\t# print a22,b21\n\tif a21>a and b22>b: res = 1\n\tif a22>a and b21>b: res = 1\n\t# print a,b,res\n\treturn res\n\nif win(a11,b12) or win(a12,b11): print 'Team 1'\nelif lose(a11,b12) and lose(a12,b11): print 'Team 2'\nelse: print 'Draw'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "00fb8823556cadf28b13f03aa2b5b6c1", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "\ufeffdef play(price, n):\n # dp[i][j][k] - \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f i \u0431\u043b\u0438\u043d\u043e\u0432 \u0441\u043e \u0441\u0442\u0435\u0440\u0436\u043d\u044f j => k\n # \u0423 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:\n # 1. \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c i - 1 \u0431\u043b\u0438\u043d \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 2. \u0414\u0430\u043b\u0435\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c i - \u044b\u0439 \u0431\u043b\u0438\u043d \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 3. \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c i - 1 \u0431\u043b\u0438\u043d \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 3.\n # 2. \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c i - 1 \u0431\u043b\u0438\u043d \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 3. \u0417\u0430\u0442\u0435\u043c i - \u044b\u0439 \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 2, \u0437\u0430\u0442\u0435\u043c i - 1 \u0431\u043b\u0438\u043d \u043d\u0430 \u043c\u0435\u0441\u0442\u043e 1, \u0434\u0430\u043b\u0435\u0435 i -\u044b\u0439 \u043d\u0430 3-\u0435 \u043c\u0435\u0441\u0442\u043e \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 i - 1 \u0431\u043b\u0438\u043d \u043d\u0430 3 \u043c\u0435\u0441\u0442\u043e\n # \u0442.\u0435, dp[i][j][k] = min(dp[i - 1][j][k ^ j] + Price[j][k] + dp[i - 1][k ^ j][k], \n # dp[i - 1][j][k] + Price[j][k ^ j] + dp[i - 1][k][j] + Price[j ^ k][k] + dp[i - 1][j][k])\n\n dp = [[[0 for k in range(0, 4)] for j in range(0, 4)] for i in range(0, n + 1)]\n\n for i in range(1, n + 1):\n for j in range(1, 4):\n for k in range(1, 4):\n dp[i][j][k] = min(dp[i - 1][j][k ^ j] + price[j][k] + dp[i - 1][k ^ j][k], 2 * dp[i - 1][j][k] + price[j][k ^ j] + dp[i - 1][k][j] + price[j ^ k][k])\n\n return dp[n][1][3]\n\n\ndef main():\n matrix = [[0 for j in range(0, 4)] for i in range(0, 4)]\n i = 1\n while i < 4: \n row = list(map(int, input().split())) \n for j in range(1, 4):\n matrix[i][j] = row[j - 1]\n i += 1\n\n n = int(input())\n\n print(play(matrix, n))\n \nmain()\n#print(play([[0, 0, 0, 0], [0, 0, 1, 1],[0, 1, 0, 1],[0, 1, 1, 0]], 3))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fb031164e476c6ef803dcba44985ae21", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "Python 3", "source_code": "upper = [chr(x) for x in range(65, 91)]\nlower = [chr(x) for x in range(97, 123)]\n\nans = 0\nfor x in input():\n if (x in upper):\n ans += ord(x) - 64\n elif (x in lower):\n ans -= ord(x) - 96\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cf6944d3a005c45e040de0857daccbf", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/python2\n\nn, k = map(int, raw_input().split())\nb = map(int, raw_input().split())\ns = raw_input()\n\na = zip(b, s)\nR = [x[0] for x in a if x[1] == 'R']\nO = [x[0] for x in a if x[1] == 'O']\nW = [x[0] for x in a if x[1] == 'W']\n\nR.sort()\nO.sort()\nW.sort()\n\nR.append(0)\nO.append(0)\nW.append(0)\n\nR.reverse()\nO.reverse()\nW.reverse()\n\nfor i in xrange(1, len(R)):\n\tR[i] += R[i - 1]\nfor i in xrange(1, len(O)):\n\tO[i] += O[i - 1]\nfor i in xrange(1, len(W)):\n\tW[i] += W[i - 1]\n\nans = -1\nfor i in xrange(1, len(O)):\n\tif i >= k:\n\t\tbreak\n\tif k - i < len(R):\n\t\tans = max(ans, O[i] + R[k - i])\n\tif k - i < len(W):\n\t\tans = max(ans, O[i] + W[k - i])\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "408cf4c739f5d94552df17f0b8ee2221", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "from math import sqrt\na, b = map(int, input().split())\nif a > b:\n a, b = b, a\nu = []\nsqa = int(sqrt(a))\nsqb = int(sqrt(b))\nfor i in range(1, sqb + 1):\n if i <= sqa and a % i == 0:\n u.append((i, a // i))\n elif b % i == 0:\n u.append((i, b // i))\nok = False\nsqab = int(sqrt(a + b))\nfor i in range(sqab, 0, -1):\n if (a + b) % i == 0:\n k = (a + b) // i\n for j in u:\n if i >= j[0] and k >= j[1]:\n ok = True\n break\n if ok:\n break\nprint(2 * (i + k))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2fc0ebd1115170dedc4b15e889404ce1", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nimport sys\na, b, w, x, c = map(int, sys.stdin.readline().strip().split())\nans = 0\n\ndef iterate(count):\n global a, b, w, x, c, ans\n for i in range(count):\n if c <= a:\n return True\n ans += 1\n c -= 1\n if b >= x:\n b -= x\n else:\n a -= 1\n b = w - (x - b)\n return c <= a\niterate(10000)\nbb = b\ncycle_len = 0\naa = a\ncc = c\nwhile True:\n if not iterate(1):\n break\n cycle_len += 1\n if b == bb:\n break\nif c <= a:\n print ans\nelse:\n diff = (cc - c) - (aa - a)\n n = (c - a) / diff\n ans += cycle_len * n\n a -= (aa - a) * n\n c -= (cc - c) * n\n iterate(10000)\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "758a99b7af502e4912883a26b652ad15", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=[int(i)%m for i in input().split()]\nx,y=[],[]\ndef f(x,n,c):\n for i in range(1<=0:k=max(k,y[d]+x[i])\nprint(k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce830b66a39404e355cdc85348cda3b3", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "t=input().split();n=int(t[0]);d=float(t[1]);r,k=0,0\r\nwhile(r len2:\n\t\tif len1 > len3:\n\t\t\tdp[i][j][k] = ans1, len1 \n\t\telse:\n\t\t\tdp[i][j][k] = ans3, len3\n\telse:\n\t\tif len2 > len3:\n\t\t\tdp[i][j][k] = ans2, len2\n\t\t\t\n\t\telse:\n\t\t\tdp[i][j][k] = ans3, len3\n\treturn dp[i][j][k]\n\ns1 = raw_input()\ns2 = raw_input()\ns3 = raw_input()\nl1 = len(s1)\nl2 = len(s2)\nl3 = len(s3)\n\nans = foo(0,0,0)\nif ans[1] <= 0 :\n\tprint(0)\nelse:\n\tprint(ans[0][::-1]\t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "850d26d4df8ecfae54b10f34b423679d", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import fileinput\n\n\ndef calc(a, b):\n ans = 0\n l = a + b\n i = 1\n while i <= l:\n P = l // i\n r = l // P\n if P <= a and P <= b:\n an = (a + P) // (P + 1)\n ax = a // P\n bn = (b + P) // (P + 1)\n bx = b // P\n if an <= ax and bn <= bx:\n ans += min(ax + bx, r) - max(an + bn, i) + 1\n i = r + 1\n return ans\n\n\nif __name__ == '__main__':\n it = fileinput.input()\n a, b = [int(x) for x in next(it).split()]\n print(calc(a, b))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c6e0cffd88a2d80210579c498c8fa8be", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "N = int(input())\ndp = [[0]*(N+1) for _ in range(N+1)]\ndp[1][0] = 1\ndp[1][1] = 1\nfor i in range(2, N+1):\n if i % 2:\n dp[i][i] = 1 + i//2\n else:\n dp[i][i] = i//2\n for j in range(N-1, -1, -1):\n dp[i][j] = dp[i][j+1] + dp[i-1][j-1] + j%2\nprint(dp[-1][0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "021f759a989986f7d77123fd07773576", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "def readInp():\n\n n = float(raw_input())\n\n return n\n\n\nn = readInp()\n\nn_upper = n\nwhile True:\n if not(int(n_upper/3) == n_upper/3):\n n_upper += 1\n else:\n break\n\ncoin_list = [1, 3]\nwhile coin_list[-1]mdeath or ydeath<0:\n print 0\n exit()\nelse:\n a=(mdeath+1)*(atkm-defy)-hpy\n b=atkm-defy-hpy/(mdeath+1)\n c=hpm/(ydeath-1)+defm-atky\n if a<=0:\n a=10**10\n if b<=0:\n b=10**10\n if c<=0:\n c=10**10\n print min(a,b,c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9289d23f9b8a1434cc2eca2e23bc81ec", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\n\nn = int(input())\n\nx = [0]*n\ny = [0]*n\n\nfor i in range(n):\n x[i], y[i] = map(int, input().split())\n\nsx = sum(x)\nsy = sum(y)\n \nfor i in range(n):\n x[i] = n * x[i] - sx\n y[i] = n * y[i] - sy\n\nm = int(input())\n\nd = [0]*n\ne = [0]*n\n\nHD = 0\n\ndef check(a, b):\n global HD\n HE = 0\n for i in range(n):\n HE ^= hash((a-x[i])*(a-x[i])+(b-y[i])*(b-y[i]))\n return HD == HE\n\ndef sqrt(x):\n nn = int(x)\n if nn == 0:\n return 0\n fa, fb = divmod(nn.bit_length(), 2)\n x = 2**(fa+fb)\n while True:\n y = (x + nn//x)//2\n if y >= x:\n return x\n x = y\n\ndef hash(x):\n return x * 9991 + 43\n\npans = []\n\ndef solve():\n global d\n d = list(map(int, input().split()))\n c = 0\n d = [p * n * n for p in d]\n for i in range(n):\n c += d[i] - x[i] * x[i] - y[i] * y[i]\n\n assert(c % n == 0)\n c //= n\n ans = []\n ax = x[0]\n ay = y[0]\n if ax is 0 and ay is 0:\n ax = x[1]\n ay = y[1]\n rev = 0\n if ay == 0:\n ay = ax\n ax = 0\n rev = 1\n d.sort()\n global HD\n HD = 0\n for p in d:\n HD ^= hash(p)\n old = -1\n for p in d:\n if (p == old):\n continue\n old = p\n a = c + ax * ax + ay * ay - p\n if (a % 2 != 0):\n continue\n a //= 2\n A = ax * ax + ay * ay\n B = a * ax\n C = a * a - ay * ay * c\n D = B * B - A * C\n if (D < 0):\n continue\n sD = sqrt(D)\n if D != sD * sD:\n continue\n if (B + sD) % A == 0:\n qx = (B + sD) // A\n qy = (a - ax * qx) // ay\n if rev:\n t = qx\n qx = qy\n qy = t\n if ((qx + sx) % n == 0 and (qy + sy) % n == 0 and check(qx, qy)):\n qx = (qx + sx) // n\n qy = (qy + sy) // n\n ans.append([qx, qy])\n if sD == 0:\n continue\n if (B - sD) % A == 0:\n qx = (B - sD) // A\n qy = (a - ax * qx) // ay\n if rev:\n t = qx\n qx = qy\n qy = t\n if ((qx + sx) % n == 0 and (qy + sy) % n == 0 and check(qx, qy)):\n qx = (qx + sx) // n\n qy = (qy + sy) // n\n ans.append([qx, qy])\n \n ans.sort()\n buf=[]\n buf.append(len(ans))\n for p in ans:\n buf.append(p[0])\n buf.append(p[1])\n global pans\n pans.append(\" \".join(map(str,buf)))\n\nwhile m > 0:\n m -= 1\n solve()\n \nsys.stdout.write(\"\\n\".join(pans))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04b1e854d3a0f54914356a7b0aea9438", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "Python 3", "source_code": "def congr(a, b, p, x):\n solutions = 0\n power = pow(a, p - 2, p)\n a2, b2, s, d1 = 1, b, 0, -b\n prod = p * (p - 1)\n while s < p - 1:\n k = (d1 + s) % p\n L = x - s - (p - 1) * k\n solutions += L // prod + 1\n d1 = (d1 * power) % p\n s += 1\n return solutions\n\n\na, b, p, x = [int(j) for j in input().split()]\nprint(congr(a, b, p, x))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0153b512d41178896525a9a01dacec6d", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from math import factorial\nfac = factorial\n\ndef dfs(lst):\n sums = [[] for i in xrange(k+1)]\n sums[0].append(0)\n while len(lst)>0:\n cur = lst.pop(0)\n length = [len(sums[i]) for i in xrange(k+1)]\n for i in xrange(k+1):\n for j in xrange(length[i]):\n if sums[i][j] + cur <=s:\n sums[i].append(sums[i][j]+cur)\n temp = sums[i][j]+fac(cur)\n if cur<19 and i> 1\r\n mergeSort(l, m)\r\n mergeSort(m, r)\r\n i, j, k = l, m, l\r\n while i < m and j < r:\r\n if ans[cur] == '0':\r\n b[k] = a[i]\r\n i += 1\r\n cur += 1\r\n else:\r\n b[k] = a[j]\r\n j += 1\r\n cur += 1\r\n k += 1\r\n while i < m:\r\n b[k] = a[i]\r\n i += 1\r\n k += 1\r\n while j < r:\r\n b[k] = a[j]\r\n j += 1\r\n k += 1\r\n for p in range(l, r):\r\n a[p] = b[p]\r\n\r\n mergeSort(0, n)\r\n print(n)\r\n print(*b)\r\n\r\nsort()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa6d1e791544d5769017c1b326d8d9ef", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "PyPy 3", "source_code": "s = input()\nnow = 0\nn = len(s)\nans = []\nwhile (now < n) and (s[now] != '-') and (s[now] != '+'):\n ans.append(ord(s[now])-48)\n now += 1\nans.reverse()\nwhile now < n:\n opt = s[now]\n now += 1\n a = [opt]\n while (now < n) and (s[now] != '-') and (s[now] != '+'):\n a.append(ord(s[now])-48)\n now += 1\n #print(a, ans)\n if len(a) <= len(ans):\n for i in range(len(ans)):\n if opt == '-':\n ans[i] -= ord(s[now - 1 - i])-48\n else:\n ans[i] += ord(s[now - 1 - i])-48\n else:\n for i in range(len(a) - len(ans)):\n ans.append(0)\n for i in range(len(ans)):\n if opt == '-':\n ans[i] -= ord(s[now - 1 - i])-48\n else:\n ans[i] += ord(s[now - 1 - i])-48\nret = 0\nans.reverse()\nfor i in range(len(ans)):\n ret = ret * 10 + ans[i]\nprint(ret)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73466172e678e36a972fc93ef65e9a8c", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "n,m,k = map(int,raw_input().split())\nrf=gf=False\nra = []\nu = [0]*10\nfor i in xrange(n):\n s = raw_input()\n g,r = map(s.find,'GR')\n if r<0 or g<0:\n if r<0 and g<0 or '-' not in s: continue \n if r<0: gf=True\n else: rf=True\n continue\n for i,v in enumerate(bin(abs(r-g)-1)[:1:-1]): u[i]+=int(v)\nif gf and rf: print \"Draw\"\nelse:\n if any(i%(k+1) for i in u) or gf: print \"First\"\n else: print \"Second\"\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e2ff16d811df3adc8e412e25a4e8d77", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "import re\n\nclass Var(object):\n def __init__(self, s):\n self.name = s\n self.ls, self.gs = set(), set()\n self.vmin, self.vmax = 0, 9\n def __repr__(self):\n return '%s(%d:%d)' % (self.name, self.vmin, self.vmax)\n\nclass Cond(object):\n def __init__(self, s, _vars):\n s = s.strip()\n i, j = 0, len(s)-1\n while i <= j and s[i] == '_':\n i += 1\n while i <= j and s[j] == '_':\n j -= 1\n if i > j or s[i:j+1].strip() not in ['<', '>']:\n print s[i:j+1]\n raise ValueError\n if s[i:j+1].strip() == '<':\n self.va, self.vb = _vars[s[:i]], _vars[s[j+1:]]\n else:\n self.vb, self.va = _vars[s[:i]], _vars[s[j+1:]]\n def __repr__(self):\n return '[%s < %s]' % (self.va, self.vb)\n\ndef topo_sort(cs):\n res = []\n for c in cs:\n c.va.gs.add(c.vb)\n c.vb.ls.add(c.va)\n hp = set([x.va for x in cs]) - set([x.vb for x in cs])\n while len(hp) > 0:\n x = hp.pop()\n res.append(x)\n for y in x.gs:\n y.ls.remove(x)\n if len(y.ls) == 0:\n hp.add(y)\n x.gs.clear()\n for c in cs:\n if len(c.vb.ls) > 0:\n return None\n for c in cs:\n c.va.gs.add(c.vb)\n c.vb.ls.add(c.va)\n for x in res:\n if len(x.ls) > 0:\n x.vmin = max([y.vmin for y in x.ls]) + 1\n else:\n x.vmin = 0\n for x in res[::-1]:\n if len(x.gs) > 0:\n x.vmax = min([y.vmax for y in x.gs]) - 1\n else:\n y.vmax = 9\n for x in res:\n if x.vmin < 0 or x.vmax > 9 or x.vmin > x.vmax:\n return None\n return res\n \ns= raw_input()\njaw, stomach = s.split(':-')\nif stomach[-1] == '.':\n stomach = stomach[:-1]\nvarl = list()\n_vars = dict()\nfor x in re.findall(r'_+', jaw):\n if x not in _vars:\n _vars[x] = Var(x)\n varl.append(_vars[x])\n\nconds = [Cond(c, _vars) for c in stomach.split(',')]\nsc = topo_sort(conds)\n#print _vars\n#print conds\nif sc is None:\n print 'false'\nelse:\n o = ''.join([str(x.vmin) for x in varl])\n print o\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "80970e4e91f58026ac0bc74b81fab52f", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import sys\nfrom math import factorial\n\ndef kth_perm(seq, index):\n\tresult = []\n\tfact = factorial(len(seq))\n\tindex %= fact\n\twhile seq:\n\t\tfact = fact / len(seq)\n\t\tchoice, index = index // fact, index % fact\n\t\tresult.append(seq.pop(choice))\n\treturn result\n\ndef inc_lucky(s, index):\n\tif index == -1:\n\t\ts = ['4'] + s\n\t\treturn s\n\tif s[index] == '4':\n\t\ts[index] = '7'\n\t\treturn s\n\ts[index] = '4'\n\treturn inc_lucky(s, index - 1)\n\t\ndef is_lucky(s):\n\tfor e in s:\n\t\tif e != '4' and e != '7':\n\t\t\treturn False\n\treturn True\n\nn, k = map(int, raw_input().split())\n\nseq = range(max(n - 12, 1), n + 1)\n\nif k > factorial(len(seq)):\n\tprint -1\n\tsys.exit(0)\n\nseq = kth_perm(seq, k - 1)\n\nr = 0\nnum = ['4']\nwhile int(''.join(num)) < n - 12:\n\tr += 1\n\tnum = inc_lucky(num, len(num) - 1)\n\nfor i, num in enumerate(seq):\n\tindex = i + n - len(seq) + 1\n\tif is_lucky(str(index)) and is_lucky(str(num)):\n\t\tr += 1\n\nprint r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e54d18cbdbe74cbc371157e6ad774754", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#def cmp(ele):\n# return ele[0]\n#\n#a=[(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0)]\nn=int(input())\ntot=0\nfor i in range(n):\n x=int(input())\n# a[i]=(x,i)\n# tot=tot+x\n#a.sort(key=cmp,reverse=True)\n#if n<2 or (n==2 and a[0][0]==a[1][0]): print(-1)\n#else:\n# ans=0\n# for i in range (n):\n# ans=ans+a[i][0]\n# if ans*2>tot:\n# print(i+1)\n# for j in range(i+1):\n# print(a[j][1]+1,end=' ')\n# break;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d1c5606736e5a3921f478da93a07df6", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n=int(input())\nnums=input().split(' ')\nl=[0]*4\nfor i in range(4):\n l[i]=int(nums[i])\nt=tuple(l)\na,b,c,d=t\np=[0]*(n+1)\nnums=input().split(' ')\nmp=[list() for _ in range(n+1)]\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n \n mp[p[i]].append(i)\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if len(mp[i])>0:\n res=0\n for son in mp[i]:\n res+=sof(son)\n s[i]=res\n return res\n else:\n s[i]=1\n return 1\nrootofl=list()\nfor leaf in l:\n while p[leaf]!=1:\n leaf=p[leaf]\n rootofl.append(leaf)\nrootlist=list()\nfor rootson in mp[1]:\n if not rootson in rootofl:\n rootlist.append(rootson)\ndef canpick(a,des):\n if des==0:\n return True\n picklist=rootlist[:]\n for j in range(2):\n cur=a[j]\n while p[cur]!=1:\n fa=p[cur]\n for i in mp[fa]:\n if i!=cur :\n picklist.append(i)\n cur=fa\n v=[False]*(n+1)\n v[0]=True\n for i in range(len(picklist)):\n val=sof(picklist[i])\n if des-val>=0 and v[des-val]:\n return True\n for j in range(des,val-1,-1):\n if not v[j] and v[j-val] :\n v[j]=True\n return False\n\nm=sof(1)\nif m%2==1:\n print('NO')\nelse:\n v1=m//2-1-sof(rootofl[2])\n v2=m//2-1-sof(rootofl[0])\n if canpick([a,b], v1) and canpick([c,d], v2):\n print('YES')\n else:\n print('NO')\n\n\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ac35dfac5d68e353d6d15c8f5dc2c9b", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\nimport __pypy__\nmulmod = __pypy__.intop.int_mulmod\n\nMOD = 10**9+7\nn, k = [int(x) for x in input().split()]\n\ndef f(n):\n s = 0\n for i in range(n):\n s += pow(i,k,MOD)\n s %= MOD\n return s\n\nprecalc = [0]\nfor i in range(k + 1):\n precalc.append((precalc[-1] + pow(i,k,MOD)) % MOD)\n\ndef interpolate(samples, x):\n x %= MOD\n m = len(samples)\n if x < m:\n return samples[x]\n \n modinv = [1]*m\n for i in range(2, m):\n modinv[i] = mulmod(-(MOD//i), modinv[MOD%i], MOD)\n\n invfac = [1]\n for i in range(1, m):\n invfac.append(mulmod(invfac[-1], modinv[i], MOD))\n invneg_fac = [invfac[i] * (1 - 2 * (i & 1)) for i in range(m)]\n\n xfac_down = [1]\n for j in reversed(range(x - (m - 1), x + 1)):\n xfac_down.append(mulmod(xfac_down[-1], j, MOD))\n \n xfac_up = [1]\n for j in range(x - (m - 1), x + 1):\n xfac_up.append(mulmod(xfac_up[-1], j, MOD))\n \n s = 0\n for i in range(m):\n pr = precalc[i]\n pr = mulmod(pr, xfac_down[i] * xfac_up[m - 1 - i] % MOD, MOD)\n pr = mulmod(pr, mulmod(invneg_fac[m - i - 1], invfac[i], MOD), MOD)\n s = (s + pr) % MOD\n return s\nprint (interpolate(precalc, n + 1) - (k == 0)) % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "980835be79229c9fa1843bcf10b39549", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "req_arr = [int(x) for x in input().strip()]\narr = [int(x) for x in input().strip()]\nrequired_list = [0]*10\nnum_list = [0]*10\nfor i in req_arr:\n if i == 5:\n required_list[2] += 1\n if i == 9:\n required_list[6] += 1\n else:\n required_list[i] += 1\n\nfor i in arr:\n if i == 5:\n num_list[2] += 1\n if i == 9:\n num_list[6] += 1\n else:\n num_list[i] += 1\nans = len(req_arr)\nfor i, j in enumerate(required_list):\n if j > 0:\n ans = min(ans, int(num_list[i]/j))\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f9f6c0f9663e964ee1b88968051ef69", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\nimport math\n\nprimes = []\nMAXN = 50000\nhash = []\n\ndp = dict()\n\ndef prime_test(v):\n for i in xrange(2,int(math.sqrt(v))+1):\n if v % i == 0:\n return False\n return True\n\ndef calc(v, k):\n if k >= MAXN:\n if (k <= v):\n return 1\n else:\n return 0\n else:\n if (v,k) in dp:\n return dp[(v,k)]\n res = v / k\n for prime in primes:\n if prime >= k:\n break\n res -= calc(v/k, prime)\n dp[(v,k)] = res\n return res\n\n\nif __name__==\"__main__\":\n hash = [-1] * MAXN\n for i in xrange(2,MAXN):\n if hash[i] == -1:\n primes.append(i)\n hash[i] = len(primes)-1\n v = i * i\n while (v < MAXN):\n hash[v] = -2\n v += i\n a,b,k = [int(v) for v in sys.stdin.readline().split(' ')]\n if (k < MAXN and hash[k] == -2) or (k >= MAXN and (not prime_test(k))):\n print 0\n else:\n print calc(b,k) - calc(a-1,k)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ccf02e6ca9312baa9435c28f2bf2200", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import sys\n\ndef is_solvable(A, B, a, b):\n dr = a * a + b * b\n if dr == 0:\n return (A == 0) and (B == 0)\n else:\n return ((A * b - B * a) % dr == 0) and ((b * B + a * A) % dr == 0)\n \n\nif __name__ == '__main__':\n inp = sys.stdin.readline().split(' ')\n x = inp[0]\n y = inp[1]\n inp = sys.stdin.readline().split(' ')\n A = inp[0]\n B = inp[1]\n inp = sys.stdin.readline().split(' ')\n a = inp[0]\n b = inp[1]\n a1 = is_solvable(A - x, B - y, a, b)\n a2 = is_solvable(A + x, B - y, a, b)\n a3 = is_solvable(A + x, B + y, a, b)\n a4 = is_solvable(A - x, B + y, a, b)\n if a1 or a2 or a3 or a4:\n print \"YES\"\n else\n print \"NO\"\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "75ea320d71a67e9c65b662500e7aa5c1", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "matrix = []\n\ndef findEmpty(rs, re, cs, ce):\n for i in range(cs, ce):\n for j in range(rs, re):\n if(matrix[j][i] != '*'):\n matrix[j][i] = 'P'\n return True\n return False\n\ndef findFour():\n return findEmpty(0, 2, 3, 5)\n\ndef findThree():\n re = findEmpty(0, 2, 0, 2)\n if (re):\n return True\n re = findEmpty(0, 2, 6, 8)\n if (re):\n return True\n re = findEmpty(2, 4, 3, 5)\n return re\n\ndef findTwo():\n re = findEmpty(2, 4, 0, 2)\n if (re):\n return True\n re = findEmpty(2, 4, 6, 8)\n if (re):\n return True\n re = findEmpty(4, 6, 3, 5)\n return re\n\ndef findOne():\n re = findEmpty(4, 6, 0, 2)\n if (re):\n return True\n re = findEmpty(4, 6, 6, 8)\n return re\n\nfor i in range(6):\n a = list(input())\n matrix.append(a)\n\ndef printMatrix():\n for i in range(6):\n print(''.join(matrix[i]))\n\nif (findFour()):\n printMatrix()\nelif (findThree()):\n printMatrix()\nelif (findTwo()):\n printMatrix()\nelif (findOne()):\n printMatrix()\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5364eb2fdb9e7342bff6f55cd2c072f1", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\nimport collections\n\ninfile = sys.stdin.buffer\ndef gs() : return infile.readline().rstrip()\ndef gi() : return int(gs())\ndef gss() : return gs().split()\ndef gis() : return [int(x) for x in gss()]\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 12\nN = 10 ** 5\n\ndef main(infn=\"\") :\n global infile\n infile = open(infn,\"r\") if infn else open(sys.argv[1],\"r\") if len(sys.argv) > 1 else sys.stdin\n ######################################################################\n n,m = gis()\n mem = {}\n def dfs(u):\n if u <= 1:\n return u\n if u in mem:\n return mem[u]\n ans = sum([dfs(v) for v in range(1, u)])\n for z in range (2, u+1):\n ans += dfs(u//z)\n ans %= m\n mem[u] = ans\n return ans\n #w = [dfs(u) for u in range(0, n+1)]\n \n dp = [0 for _ in range(n+1)]\n dp[1] =1\n h = collections.defaultdict(collections.deque)\n cumul = 0\n prev = dp[1]\n for u in range(2, len(dp)):\n dp[u] += prev\n dp[u] += dp[1]\n dp[u] %= m\n while(h[u]): \n sign = 1 if h[u][0] > 0 else -1\n cumul += sign * dp[abs(h[u].popleft())]\n cumul %= m\n dp[u] += cumul\n dp[u] %= m\n prev += dp[u]\n prev %= m\n\n v,c = u<<1, 2\n h[u + 1].append(1)\n while(v < len(dp)):\n h[v].append(c)\n h[v].append(-(c-1))\n v += u\n c += 1\n print (dp[-1])\n\n ######################################################################\nif __name__ == '__main__' :\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cdc0416a1b92357ff9b30455aeac31cf", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\nF=lambda x:math.factorial(x)\nn,w,b=map(int,raw_input().split())\nprint (F(w)*F(b)*(w-1)*F(w+b-3)/F(n-3)/F(w+b-n))%1000000009\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "731303fd588406f99973678a8eaf9c92", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from sys import exit\nn, m = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nk = [int(i) for i in input().split()]\nfor i in range(n):\n for j in range(i + 1, n + 1):\n cur = a[i:j]\n f = 1\n for l in range(m):\n f &= (cur.count(l + 1) == k[l])\n if f:\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4762d65ccd953c3b78fb65664da5e09f", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "ef solve(n, st, k):\n MOD = int(1e9 + 7)\n dp = [0] * (n + 1)\n prefix_sum = [0] * (n + 1)\n dp[st] = 1\n for times in range(k):\n prefix_sum[0] = 0\n for i in range(1, n + 1):\n prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n for i in range(1, n + 1):\n t = prefix_sum[n] - prefix_sum[i] + prefix_sum[i - 1] - prefix_sum[i >> 1]\n while t < 0: t += MOD\n while t >= MOD: t -= MOD\n dp[i] = t\n return sum(dp) % MOD\n \n \ndef main():\n n, a, b, k = [int(i) for i in input().split()]\n if a > b:\n print(solve(n - b, a - b, k))\n else:\n print(solve(b - 1, b - a, k))\n \nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0bc596fd0adbf7cc866e03e625e89eef", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "mod = 1000000007\ndef sum(x,y,k,add) :\n if kk:\n \tup=k\n add=add+1\n return y*(((add+up)*(up-add+1)//2)%mod)%mod\ndef solve(x,y,k,add=0) :\n if x==0 or y==0:\n \treturn 0\n if x>y:\n \tx,y=y,x\n pw = 1\n while (pw*2)<=y:\n \tpw*=2\n if pw<=x:\n \treturn (sum(pw,pw,k,add)+sum(pw,x+y-pw-pw,k,add+pw)+solve(x-pw,y-pw,k,add))%mod\n else:\n \treturn (sum(pw,x,k,add)+solve(x,y-pw,k,add+pw))%mod\nq=input()\nfor i in range(0,q):\n x1,y1,x2,y2,k=map(int,raw_input().split()) \n ans=(solve(x2, y2, k)-solve(x1 - 1, y2, k)-solve(x2, y1 - 1, k)+solve(x1-1,y1-1,k))%mod\n if ans<0:\n \tans+=mod\n print ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db06b034a0cf37ead2c1d19622a31fc5", "src_uid": "1ab085026ce43810acf98cc4bf8faf26", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\nstring = input()\nseries = []\nnow = \"\"\nfor elem in string:\n if elem == \"Y\":\n if now:\n series.append(now)\n now = \"\"\n else:\n now += elem\nif now:\n series.append(now)\n \nanswer = False\nno_max = True\nfor elem in series:\n m = len(elem)\n for i in range(m - k + 1):\n if (not i or elem[i - 1] == '?') and ((i + k - 1) == m - 1 or elem[i + k] == '?'):\n answer = True\n \n counter = 0 \n for letter in elem:\n if letter == 'N':\n counter += 1\n no_max = not counter > k\n else:\n counter = 0\n \nprint(\"YES\" if answer and no_max else \"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6212dc0a1be39120eab185b178dd337", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\narr=list(map(int,input().split()))\nfreq=[0]*(101)\nfor i in arr:\n freq[i]+=1\nfreq2=[0]*(101)\nans=0\nk1=3\nj=0\nfor i in range(n):\n freq2[arr[i]]+=1\n if i>=1:\n freq3=[]\n for k in range(1,101):\n if freq2[k]>=1:\n freq3.append(freq2[k])\n #print(freq3)\n if freq3.count(max(freq3))>=3:\n ans=max(ans,i+1)\nfreq2=[0]*101\nfor j in range(n):\n freq2[arr[j]]+=1\n freq3=[]\n for k in range(1,101):\n if freq[k]>=1:freq3.append(freq[k]-freq2[k])\n #print(freq3,j+1)\n if max(freq3)>0 and freq3.count(max(freq3))>=2:\n ans=max(ans,n-j-1)\n #print()\n break\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cedb6ec5cf0f3ccb4b4d00de4883e743", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "import cmath\nn = int(input())\nq=1\np=1\ndef inv(a,b):\n if(a>1):\n return b-inv(b%a,a)*b//a\n else:\n return 1\nfor j in range(1,n+2):\n p=p*(n+1+j)% 1000000007\n q=(q*j)% 1000000007\n \nprint(p*inv(q,1000000007) % 1000000007 -1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3717f009aa0b6f1e60cb2f171436ab77", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "MOD = 1000000007\ndef phi(n):\n res = n\n for i in range(2,int(n**(0.5)+1)):\n if n % i == 0:\n while n % i == 0:\n n = n//i\n res -= res//i\n if n > 1:\n res -= res//n\n return res\n\nn,k = map(int,input().split())\nk = (k+1)//2\nans = n\nfor _ in range(k):\n if ans > 1:\n ans = phi(ans)\n else:\n break\nprint(ans % MOD)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc56c3160cbf35e62b708023c65a39a1", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "def mean(seq):\n N = len(seq)\n return sum(seq)/float(N)\n \ndef std(seq):\n m = mean(seq)\n N = len(seq)\n return sum([(s-m)**2/N for s in seq])\n\ndef solve(seq):\n m = mean(seq)\n s = std(seq)\n \n s1 = m\n s2 = m*(m+1)/3\n \n if abs(s-s1) < abs(s-s2):\n return 'poisson'\n else:\n return 'uniform'\n\nV = int(raw_input())\nseqs = [map(int, raw_input().split()) for i in xrange(V)]\n\nfor seq in seqs:\n print int(mean(seq))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "815cbe91d6521569c7c5d5febb58abca", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "n = 0\nk = 0\nt = 0\nP = {}\nused = []\n\ndef third(x, n=2):\n for i in x:\n yield i[n]\n\ndef solve():\n global n, k, t, P, used\n read = reader()\n n, k, t = list(map(int, next(read).split()))\n t -= 1\n for i in range(n):\n P[i] = []\n used = [False] * n\n for i in range(k):\n m1, m2, r = list(map(int, next(read).split()))\n P[m1-1].append((m2-1, r))\n comb = []\n rec(0, comb)\n comb.sort(key=lambda x: sum(third(x)))\n comb.insert(0, (-1, -1, 0))\n print(sum(third(comb[t])))\n\ndef rec(i, comb, currentpairs = None):\n global n, k, t, P, used\n if not i < n:\n return\n if currentpairs == None:\n currentpairs = []\n for (m2, r) in P[i]:\n if used[m2]:\n continue\n used[m2] = True\n cp = currentpairs[:]\n cp.append((i, m2, r))\n comb.append(cp)\n rec(i+1, comb, cp)\n used[m2] = False\n \n\ndef reader():\n USE_FILE = False\n if __name__ == \"__main__\" and USE_FILE:\n with open(\"F.in\", \"r\") as fin:\n while True:\n yield next(fin)\n else:\n try: input = raw_input\n except: pass\n while True:\n yield input()\n\nsolve()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b957f4c0b7df5c07c1036968ea15090", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "\ndef main():\n ans = 0\n a = [0] * 10\n n = int(input())\n for i in range (1, 9):\n a[i] = n // 9 + int(n % 9 >= i)\n a[9] = n // 9\n \n for i in range(1, 10):\n for j in range(1, 10):\n k = i * j % 9\n if k == 0:\n k = 9\n ans += a[i] * a[j] * a[k]\n \n for i in range(1, n + 1):\n ans -= n // i\n print(ans)\n \n return\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48e4469306036fd15939d40070df6f07", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport re, sys\nn = int (sys.stdin.readline ())\nclass MyInt (object):\n\tdef __init__ (self, a):\n\t\tif isinstance (a, MyInt):\n\t\t\tself.v = a.v\n\t\telse:\n\t\t\tself.v = int (a)\n\tdef val (self):\n\t\treturn self.v\n\tdef __add__ (self, a):\n\t\treturn MyInt ((self.val () + a.val ()) & 32767)\n\tdef __sub__ (self, a):\n\t\treturn MyInt ((self.val () - a.val ()) & 32767)\n\tdef __mul__ (self, a):\n\t\treturn MyInt ((self.val () * a.val ()) & 32767)\n\tdef __div__ (self, a):\n\t\treturn MyInt ((self.val () / a.val ()) & 32767)\n\tdef __eq__ (self, a):\n\t\treturn self.val () == a.val ()\n\tdef __gt__ (self, a):\n\t\treturn self.val () > a.val ()\n\tdef __lt__ (self, a):\n\t\treturn self.val () < a.val ()\n\tdef __and__ (self, a):\n\t\treturn MyInt (self.val () & a)\ns = ''.join (sys.stdin.readlines ())\ns = s.replace ('\\n', '')\ns = s.replace ('{', '')\ns = s.replace ('}', '')\ns = re.sub ('([0-9]+)', 'MyInt (\\\\1)', s)\ns = s.replace ('int f(int n)', \\\n 'a = [-1] * 32768\\ndef f (n):\\n\\tglobal a;' + \\\n 'n = MyInt (n);if (a[n.val ()] != -1) return a[n.val ()];')\ns = re.sub ('return(.*?);','return MyInt (\\\\1);', s)\ns = s.replace (';', '\\n\\t')\ns = s.replace ('return', ':return')\ns = re.sub ('\\t[ :]+', '\\t', s)\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i).val () & 32767\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\ns = s.replace ('\\t\\n', '\\n')\nexec s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0b94527a56de64a9d2c0a28fb0408fb6", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "def solve(a, b):\n r = []\n while a+b > 2:\n q = min((a//b + b//a), max(a, b)-1)\n r.append(str(q))\n if a > b:\n r.append('A')\n a -= b*q\n else:\n r.append('B')\n b -= a*q\n if a != 1 or b != 1:\n return 'Impossible'\n return ''.join(r)\n\ndef main():\n a, b = map(int, input().split())\n print(solve(a, b))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b22826665573be5e0ea1635efee5563", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict\n\ndef calcBinomials(N):\n global binom\n binom = [[0]*N for _ in range(N+1)]\n for n in range(N):\n binom[n][0] = binom[n][n] = 1\n for k in range(1, n):\n binom[n][k] = binom[n-1][k] + binom[n-1][k-1]\n\nn = int(input())\ncalcBinomials(n)\na = list(map(int, input().split()))\ndp = [defaultdict(lambda: 0) for _ in range(sum(a)+1)]\ndp[0][0] = 1\ncnt = {_:a.count(_) for _ in a}\nfor x in a:\n for i in range(len(dp)-1-x, -1, -1):\n for k, v in dp[i].items():\n dp[i+x][k+1] += v\nres = 0\nfor x, c in cnt.items():\n for i in range(1, c+1):\n if dp[x*i][i] == binom[c][i]: res = max(res, i)\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e50f9528e4929cfed91184f80494e302", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "M, a, b = map(int, input().split())\nmod = 10**9+7\nD = [mod]*a\nmaxi = 0\nD[0] = 0\nQ = [0]\ndef f(x, i):\n t = (x+1-i)//a\n r = (x+1-i)%a\n return a*t*(t+1)//2+r*(t+1)\n\nwhile Q:\n q = Q.pop()\n D[q] = maxi\n k = max(0, -((-(b-q))//a))\n maxi = max(maxi, q+k*a)\n if D[(q-b)%a] == mod and maxi <= M:\n Q.append((q-b)%a)\nans = 0\nfor i, d in enumerate(D):\n if d > M:\n continue\n ans += f(M, i) - f(d-1, i)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b4e1c132224d44645c66474dfdd4fe7", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def solve(n):\n k = 0\n a = b = 1\n while b < n:\n a, b = b, a + b\n k += 1\n if b == n:\n return k\n elif n % 2:\n return n // 2 + 1\n else:\n return n - 1\n\nif __name__ == \"__main__\":\n ans = solve(int(input()))\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f14fa92859cef0b2f470f303ab35861", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "\ndef readints():\n return map(int, raw_input().split())\n\n\ndef dn(x):\n k=0\n t=x-1\n while t:\n t/=10\n k+=1\n return k\n\n\n\ndef _li(x, dn):\n ret=[]\n for _ in xrange(dh):\n ret.append(x%10)\n x/=10\n return ret\n\ndef li(h,m):\n return _li(h,dh)+_li(m,dm)\n\ndef dif(h1,m1,h2,m2):\n return sum(v1!=v2 for v1,v2 in zip(li(h1,m1), li(h2,m2)) )\n\npow10=[10**i for i in xrange(12,-1,-1)]\n\nmemo={}\n\ndef g(h,m):\n if (h,m) in memo:return memo[(h,m)]\n ret=f(0,1,h,m)+(1>=k)\n memo[(h,m)]=ret\n return ret\n\n\ndef f(h1,m1,h2,m2):\n if (h1,m1)==(h2, m2):return 0\n if (h1,m1)>(h2,m2):\n return f(h1, m1, H-1, M-1) + f(0, 0, h2, m2) + ( dif(h1,m1,h2,m2) >= k)\n for hh in pow10:\n if (h1+hh, m1)<=(h2, m2) and h1/hh%10!=9:\n return g(hh,0)+f(h1+hh, m1, h2, m2)\n for mm in pow10:\n if m1+mm=k\n\ndef main():\n global H,M,k,dh,dm\n H,M,k=readints()\n h1,m1=readints()\n h2,m2=readints()\n \"\"\"H,M,k=24,60,1\n h1,m1=0,0\n h2,m2=23,59\n H,M,k=24,60,3\n h1,m1=23,59\n h2,m2=23,59\"\"\"\n dh=dn(H)\n dm=dn(M)\n print f(h1,m1,h2,m2)\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d04ab72b94278228a144665ab8ea6d3e", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "import math\nx=input()\nprint((0,1)[(1<=C[x]):\n Rem[i]-=C[x]\n Parent[x]=i\n Children[i].append(x)\n return True\n for i in range(x):\n if(Seen[i]):\n continue\n Y=[]\n Seen[i]=True\n for j in range(len(Children[i])):\n child=Children[i][j]\n Parent[child]=-1\n Rem[i]+=C[child]\n if(DFS(child)):\n continue\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Seen[i]=False\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n Rem[i]-=C[x]\n Children[i].append(x)\n Parent[x]=i\n return True\n return False\n \n \n\n\n\n\nn=int(input())\n\nC=list(map(int,input().split()))\nRem=[-1]*n\nParent=[-1]*n\nChildren=[]\nSeen=[False]*n\nC.sort(reverse=True)\n\nif(C[0]!=n or C.count(2)>0):\n print(\"NO\")\n\nelse:\n for i in range(n):\n Rem[i]=C[i]-1\n Children.append([])\n Parent[0]=0\n Ans=\"YES\"\n for i in range(1,n):\n if(DFS(i)==False):\n Ans=\"NO\"\n break\n for i in range(n):\n if(Rem[i]!=0 and C[i]!=1):\n Ans=\"NO\"\n break\n print(Ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d02e70eb032a22f795cebb94fb9a82e2", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "from itertools import combinations\n\ndef getLuckySubsetCount(mStr, luckySubset):\n width = len(mStr)\n A = map(lambda x: [0,0,0], range(width))\n for i in range(width):\n A[i][0] = 8 if not (i in luckySubset) else 2\n A[i][1] = len(filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mStr[i]), range(10)))\n A[i][2] = max(filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mStr[i]), range(10))) == mStr[i]\n print luckySubset, A\n B = map(lambda x: [0,0], range(width))\n for i in range(width):\n if i == 0:\n B[i][0] = A[i][0]\n B[i][1] = (A[i][1] - 1) + (1 if A[i][2] else 0)\n else:\n B[i][0] = B[i - 1][0] * A[i][0]\n B[i][1] = (A[i][1] - 1) * B[i - 1][0] + (B[i - 1][0] if A[i][2] else 0)\n return B[width - 1][1]\n\ndef getLuckyCount(mStr, luckySize):\n maxWidth = len(mStr) + 1\n result = 0\n for combination in combinations(range(maxWidth), luckySize):\n luckySubset = set(combination)\n result += getLuckySubsetCount(mStr, luckySubset)\n return result\n\ndef main():\n mStr = raw_input()\n m = int(mStr)\n lucky = [0] * 10\n for luckySize in range(9):\n lucky[luckySize] = getLuckyCount(mStr, luckySize)\n print lucky\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b774635b46810c2bba397e6ad8983c5d", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#Built without using CH-Helper plugin ( \u2022_\u2022)>\u2310\u25a0-\u25a0 / (\u2310\u25a0_\u25a0) deal with it\nimport math\nn=int(input())\nif n==0:\n print 1\nelse:\n k=4*(int(n*math.sqrt(2)+1e-9))\n print k", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3934bed8261bb8a1030eb08e8131b90c", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 2", "source_code": "dp = [[0 for i in range(0..40)]for j in range(0..40)]\nN,H = map[int,raw_input().split()]\ndp[0] = [1 for i in range(0..40)]\nfor i in range(1..40):\n\tfor j in range(1..40):\n\t\tfor k in range(0..i):\n\t\t\tdp[i][j] += dp[k][j-1]*dp[i-1-k][j-1]\nprint dp[N][N] - (H > 0 and dp[N][H-1] or 0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89b5c7dc9c339c2c42ff04567892c8b5", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef euclid_algorithm(a, b):\n t1, t2 = abs(a), abs(b)\n #saving equalities:\n #t1 == x1 * a + y1 * b,\n #t2 == x2 * a + y2 * b. \n x1, y1, x2, y2 = int(math.copysign(1, a)), 0, 0, int(math.copysign(1, b))\n if t1 < t2:\n t1, t2 = t2, t1\n x1, y1, x2, y2 = x2, y2, x1, y1\n\n while t2 > 0:\n k = int(t1 // t2)\n t1, t2 = t2, t1 % t2\n #t1 - k * t2 == (x1 - k * x2) * a + (y1 - k * y2) * b\n x1, y1, x2, y2 = x2, y2, x1 - k * x2, y1 - k * y2\n\n return t1, x1, y1\n\ndef opposite_element(x, p):\n gcd, k, l = euclid_algorithm(x, p)\n if gcd != 1:\n return -1\n return k % p\n\ndef solve(n, m, p):\n if (m-1) % p == 0:\n return (n + 1) * pow(m, n, p) % p\n else:\n S = pow(m, n, p)\n k = opposite_element(m, p)\n l = (2*m - 1) * k % p\n q = opposite_element(l - 1, p)\n S += pow(m, n, p) * (pow(l, n, p) - 1) * q\n S %= p\n return S\n\np = 10 ** 9 + 7\nn, m = [int(x) for x in input().split()]\nprint(solve(n, m, p))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d8fc3377dcadc6e16914d18fad65c2d", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import sys\ndef ask(s):\n print(s)\n sys.stdout.flush()\ndef solve():\n n, k = map(int, input().split())\n head = [True] * (n + 1)\n head[0] = False\n if k == 1:\n N = 2 * int(n / (k + 1))\n else:\n N = 2 * int(n / k)\n for i in range(1, N + 1):\n cl = (i - 1) * int((k + 1) / 2) + 1\n cr = i * int((k + 1) / 2)\n for j in range(1, i):\n l = (j - 1) * int((k + 1) / 2) + 1\n r = j * int((k + 1) / 2)\n ask(\"R\")\n for shop in range(l, r + 1):\n ask(\"? \" + str(shop))\n ans = input()\n if (ans == \"Y\"):\n head[shop] = False\n for shop in range(cl, cr + 1):\n ask(\"? \" + str(shop))\n ans = input()\n if (ans == \"Y\"):\n head[shop] = False\n\n ans = 0\n ans = sum(map(int, head))\n ask(\"! \" + str(ans))\nsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "638921f67db73f7bc2299557f0750a83", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "Python 2", "source_code": "#coding=utf-8\n\nMOD = 1000000007 \nn, m, g = map(int, raw_input().split())\n\n\nt = 0;\n\nC = 1\ntotal = 0\nif m == 1:\n total = 1\n\nfor i in range(0, n):\n #print i\n total = C - total\n C = (C * (m + i + 1) * pow(i + 1, MOD - 2, MOD) ) % MOD\n #print C, total\n#C = (C * (m + n) * pow(n, MOD - 1, MOD) ) % MOD \nif g == 1:\n print total\nelse:\n print (C - total + MOD) % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "89fa52e0c8602f489d337130adf9a9d7", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "v = [[] for i in xrange(12)]\nstr = raw_input().split()\nn = int(str[0])\nm = int(str[1])\nk = int(str[2])\nfor i in xrange(n):\n raw_input()\n for j in xrange(m):\n tuple = map(int,raw_input().split());\n v[i].append(tuple) \n \nmx =0\nfor i in xrange(n):\n for j in xrange(n):\n val=0\n if(i==j):continue\n pro = []\n for kk in xrange(len(v[i])):\n if(v[j][kk][1] <= v[i][kk][0]): continue\n pro.append((v[j][kk][1] - v[i][kk][0], v[i][kk][2]))\n \n lim = k;\n pro.sort(cmp=None, key=None, reverse=True)\n for kk in xrange(len(pro)):\n if(pro[kk][1] <= lim):\n lim -= pro[kk][1];\n val += pro[kk][0]*pro[kk][1];\n \n else:\n val += pro[kk][0]*lim;\n break;\n \n mx = max(mx,val)\n\nprint mx", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3e327182d13d36965a420fc3e8985975", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from fractions import Fraction\n\ng = [0]*111111\nt = [0]*111111\nprime = [0]*111111\npm = [0]*111111\nfor i in range(len(prime)):\n prime[i] = {}\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\ndef ksm(a, b, p=int(1e9+7)):\n a = a % p\n ans = 1\n while b > 0:\n if b & 1:\n ans = ans * a % p\n b = b >> 1\n a = a*a % p\n return ans\n\n\nm = int(input())\np = int(1e9+7)\ntmp = ksm(m, p-2)\nfor j in range(m, 0, -1):\n c1 = 0\n tyouce = tmp\n gyouce = 0\n if j == 1:\n c1 = 0\n else:\n c1 = m//j * tmp % p\n\n for k in range(2, m//j + 1):\n\n def get_ck(m, n):\n ans = 0\n\n def get_fac():\n for i in range(2, 100011):\n if pm[i] == 0:\n prime[i][i] = 1\n for j in range(2, 100001//i+1):\n pm[i*j] = 1\n prime[i*j][i] = 1\n\n if prime[m] == {}:\n get_fac()\n prime_list = list(prime[m].keys())\n for i in range(1, 1 << len(prime_list)):\n t = i\n rongchixishu = -1\n lcm = 1\n index = len(prime_list)-1\n while t>0:\n if t&1:\n lcm = lcm*prime_list[index]\n rongchixishu *= -1\n t >>= 1\n index -= 1\n ans += n//lcm*rongchixishu\n return ans\n\n ck = (m//j - get_ck(k, m//j)+p) % p\n ck = ck*tmp % p\n tyouce = (tyouce + ck * t[k*j]) % p\n gyouce = (gyouce + ck * (t[k*j] + g[k*j])) % p\n t[j] = tyouce * ksm(1-c1+p, p-2) % p\n gyouce = (gyouce + tmp + c1 * t[j]) % p\n g[j] = gyouce * ksm(1-c1+p, p-2) % p\n\nprint(g[1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "afac3a74ad63e6eec29417af4be02a1d", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "n=int(input())\nlookup={}\nfor i in range(n):\n x=list(map(int,input().split()))\n for j in range(n):\n lookup[x[j]]=(i,j)\nrook=[0,0]\nbish=[0,0]\nknight=[0,0]\nfor i in range(1,n**2):\n x=abs(lookup[i][0]-lookup[i+1][0])\n y=abs(lookup[i][1]-lookup[i+1][1])\n if x==0 or y==0:\n rook[0]+=1\n else:\n rook[0]+=2\n if x==y:\n bish[0]+=1\n elif (x-y)%2==0:\n bish[0]+=2\n else:\n bish[0]+=1000\n if {x,y}=={1,2}:\n knight[0]+=1\n elif x**2+y**2 in [4,16,20,10,18]:\n knight[0]+=2\n elif x**2+y**2==2 and lookup[i] not in [(0,0),(n-1,0),(0,n-1),(n-1,n-1)] and lookup[i+1] not in [(0,0),(n-1,0),(0,n-1),(n-1,n-1)]:\n knight[0]+=2\n elif {x,y} in [{5,0},{3,0},{1,0},{6,1},{4,1},{5,2},{3,2},{6,3},{4,3},{5,4}]:\n knight[0]+=3\n else:\n knight[0]+=1000\n if bish[0]>rook[0]+1 or bish[0]>knight[0]+1:\n if rook[0]==knight[0]:\n bish=[rook[0]+1,min(rook[1],knight[1])+1]\n elif rook[0]rook[0]+1 or knight[0]>bish[0]+1:\n if rook[0]==bish[0]:\n knight=[rook[0]+1,min(rook[1],bish[1])+1]\n elif rook[0]bish[0]+1 or rook[0]>knight[0]+1:\n if bish[0]==knight[0]:\n rook=[bish[0]+1,min(knight[1],bish[1])+1]\n elif bish[0]BX and AY+C>BY:\r\n Z=(AX+R-BX)*(AY+C-BY)\r\nV=N*M-R*C*2+Z\r\nprint(pow(K,V+R*C-Z,mod))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "451e1a8cad2c8f9ba476bc4de363f935", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n = int(input())\r\nsz = len(str(n))\r\ndef get(x):\r\n ans = 0\r\n nw = 1\r\n x1 = x\r\n for i in range(sz):\r\n x = x1\r\n if x < nw:\r\n while x < nw: x *= 10\r\n x -= 1 #\u0442\u043a \u0441\u0443\u043a\u0430 [1;x)\r\n else:\r\n while x >= nw * 10: x //= 10\r\n x = min(x, n)\r\n ans += x - nw + 1\r\n nw *= 10\r\n return ans\r\n\r\n\r\nMOD = 998244353\r\n\r\nans = 0\r\ni = 1\r\nwhile i <= n:\r\n l = i\r\n r = min(n, 10 ** (len(str(i))) - 1) + 1\r\n nw = (get(i) - i) // MOD\r\n while r - l > 1:\r\n mid = (l + r) // 2\r\n x = (get(mid) - mid) // MOD\r\n if nw == x:\r\n l = mid\r\n else:\r\n r = mid\r\n ans += nw * (r - i)\r\n # i += 1\r\n i = r\r\nprint((ans * -MOD) % (int)(1e9 + 7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5976036e466709e983dab7035ecca2a3", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "Python 2", "source_code": "import sys\nfrom random import randint\nfrom math import sqrt\n\nmul=[]\nrand=[]\nSIZE = 32\n\ndef checkTypeZwei(base,div):\n\tfor i in xrange(SIZE):\n\t\tif(int(mul[i])%div==0):\n\t\t\treturn i\n\treturn -1\n\ndef checkTypeDrei(base,div):\n\tfor num in rand:\n\t\tsum=0\n\t\tfor ch in num:\n\t\t\tsum+=ord(ch)-ord('0')\n\t\tif(sum%div!=0): return False\n\n\treturn True\n\ndef checkTypeElf(base,div):\n\tfor i in xrange(SIZE):\n\t\tnum=rand[i]\n\t\teve=0\n\t\todd=0\n\t\tind=0\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ord(ch)-ord('0')\n\t\t\telse:\n\t\t\t\teve+ord(ch)-ord('0')\n\t\t\tind+=1\n\n\t\tif(odd!=eve):\n\t\t\treturn False\n\t\n\treturn True\n\ndef checkTypeSechs(base,div):\n\tfor i in xrange(1,int(sqrt(div))):\n\t\tif(div%i==0):\n\t\t\ta=div/i\n\t\t\tb=i\n\n\t\t\tif(checkTypeZwei(base,a)!=-1 or checkTypeDrei(base,a) or checkTypeElf(base,a)):\n\t\t\t\ta=True\n\t\t\telse:\n\t\t\t\ta=False\n\n\t\t\tif(checkTypeZwei(base,b)!=-1 or checkTypeDrei(base,b) or checkTypeElf(base,b)):\n\t\t\t\tb=True\n\t\t\telse:\n\t\t\t\tb=False\n\n\t\t\tif(not (a and b)):\n\t\t\t\treturn False\n\t\n\n\treturn True\n\n\ndef xBase(num,base):\n\tres=''\n\twhile(num):\n\t\tres=str(num%base)+res\n\t\tnum/=base\n\treturn '0' if(res=='') else res\n\nif(__name__=='__main__'):\n\t\n\n\tinstr=raw_input()\n\tinstr=instr.split()\n\tbase=int(instr[0])\n\tdiv=int(instr[1])\n\t\n\tfor i in xrange(SIZE):\n\t\tmul.append(str(base**i))\n\n\tfor i in xrange(SIZE):\n\t\tnum=randint(0,1<<16)\n\t\tnum*=div\n\t\t#print xBase(num,base)\n\t\trand.append(xBase(num,base))\n\ttype=7\n\tlen=-1\n\tif(type==7):\n\t\tlen=checkTypeZwei(base,div)\n\t\tif(len!=-1):\n\t\t\ttype=2\n\t\n\tif(type==7):\n\t\tif(checkTypeDrei(base,div)):\n\t\t\ttype=3\n\t\n\tif(type==7):\n\t\tif(checkTypeElf(base,div)):\n\t\t\ttype=11\n\t\n\tif(type==7):\n\t\tif(checkTypeSechs(base,div)):\n\t\t\ttype=6\n\n\tprint(str(type)+'-type')\n\tif(type==2):\n\t\tprint len\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4703a568b081788437e22c3593e906d6", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "# Clever Fat Rat\nimport time\nfrom datetime import datetime\n\ndef is_goal(state):\n (a, ws) = state\n if(len(ws) == 1 and ws[0][0] <= a[0]):\n return True\n\ndef child(state):\n (a, ws) = state \n scales = ws[0]\n if(len(ws) == 1):\n return [];\n \n b = [[0]*(len(scales)-1)]\n for (jdx, scale) in enumerate(scales):\n if a[jdx] >= scale:\n if(jdx == 0):\n b = map(lambda x: [x[0]+a[jdx]] + x[1:], b)\n# b[0] += a[jdx]\n elif (jdx == len(scales)-1):\n b = map(lambda x: x[:-1]+[x[-1]+a[-1]], b)\n# b[-1] += a[-1]\n else:\n b = map(lambda x: [x[:jdx]+[x[jdx]+a[jdx]]+x[jdx+1:], x[:jdx-1]+[x[jdx-1]+a[jdx]]+x[jdx:]], b)\n b = reduce (lambda a,b: a+b, b)\n# b[jdx-1] += a[jdx]/2.\n# b[jdx] += a[jdx]/2.\n# print b\n return map(lambda x: (x, ws[1:]), b)\n \ndef is_possible_reach_goal(state):\n# print state\n (a, ws) = state\n return (sum(a) >= ws[-1][0])\n\ndef is_broken(i, a, ws):\n return 1 if (a[i] >= ws[0][i]) else 0\n\ndef fall(idx, a, ws):\n return a[idx] * is_broken(idx, a, ws)\n\ndef check_break(a, ws):\n break_list = [[0,0]]\n for idx in range(0, len(a)-1):\n break_list += [[0,0]]\n if(fall(idx, a, ws) + fall(idx+1, a, ws) >= ws[1][idx]):\n break_list[idx][1] = is_broken(idx, a, ws)\n break_list[idx+1][0] = is_broken(idx+1, a, ws)\n return break_list\n\ndef next_step(a, break_list):\n next_step = [[]]\n for idx, b in enumerate(break_list):\n if b == [0,0]:\n next_step = map((lambda x: x+[0]), next_step)\n elif b == [0,1]:\n next_step = map((lambda x: x+[a[idx]]), next_step)\n elif b == [1,0]:\n next_step = map((lambda x: x[:-1] + [x[-1]+a[idx]] +[0]), next_step)\n else: # [1,1]\n next_step = map((lambda x: [x[:-1] + [x[-1]+a[idx]] +[0], x+[a[idx]]]), next_step)\n next_step = reduce (lambda a,b: a+b, next_step)\n return map(lambda x: x[:-1],next_step)\n \n\ndef fatrat(state):\n# print state\n (a, ws) = state\n \n#15[928772, 710357, 920822, 465694, 16512, 799572, 971974, 162499, 157133, 294992, 241747, 325056, 798852, 528918, 760749, 755326, 867061, 621152, 114485, 917241, 244803, 775595, 547781, 427681, 292956, 933798, 764221]\n#[406560, 631571, 780422, 992747, 90450...\n\n if len(a) == 42:\n for idx in range(16,40):\n print ws[idx]\n \n# print ws[2][21:41]\n# print ws[3][0:20]\n# print ws[3][20:40]\n# print ws[4][0:20]\n# print ws[4][20:39]\n \n print ws\n\n a_list = [a]\n while(True):\n if len(ws) == 1:\n for e_a_list in a_list:\n if e_a_list[0] >= ws[0][0]:\n return \"Cerealguy\"\n return \"Fat Rat\"\n \n a_list = map((lambda a: next_step(a, check_break(a, ws))), a_list)\n a_list = reduce (lambda a,b: a+b, a_list)\n \n new_list = []\n for e_a_list in a_list:\n if e_a_list not in new_list:\n if sum(e_a_list) >= ws[-1][0]:\n new_list.append(e_a_list)\n \n a_list = new_list\n ws = ws[1:]\n \n if not len(a_list):\n return \"Fat Rat\"\n \n \n\n\ndef fatrat2(state):\n stack = [state]\n visited = []\n start = datetime.now()\n \n while(stack):\n\n state = stack.pop()\n visited += [state[0]]\n \n if(is_goal(state)):\n return \"Cerealguy\"\n \n children = child(state)\n for c in children:\n if(c[0] not in visited and c not in stack):\n if is_possible_reach_goal(c):\n stack += [c]\n \n return \"Fat Rat\" \n \n\nDebug = False\nif(not Debug):\n n = int(raw_input())\n a_s = raw_input().split()\n a = []\n for a_s_e in a_s:\n a += [int(a_s_e)]\n \n ws = []\n for i in range(0, int(n)):\n r = raw_input().split()\n rs = []\n for e_rs in r:\n rs += [int(e_rs)]\n ws += [rs]\n# print fatrat(n, a, ws)\n print fatrat(((a, ws)))\nelse:\n print fatrat(([1], [[2]])) #F\n print fatrat(([2, 2], [[1, 2],[4]])) #C\n print fatrat(([2, 2], [[1, 2],[5]])) #F\n print fatrat(([798097, 886901, 292688, 792934], [[987579, 447910, 689959, 311317],[41624, 797440, 706737],[921438, 988902],[506461]])) #C\n a =( [232602, 103849, 827367, 389557, 651438, 216320, 824798, 525699, 23338, 518302, 719391, 553814, 331160, 617684, 289434, 312706, 618709, 259095, 21269, 998945, 461731]\n + [896427, 149781, 499724, 6493, 239022, 333269, 513014, 671173, 502655, 287667, 863972, 857850, 644809, 824618, 402957, 617413, 295280, 915642, 78666, 498130, 693142])\n #0\n w0=( [442788, 122361, 376827, 1098, 885713, 765876, 370112, 54990, 458771, 438057, 765395, 895171, 272899, 408086, 963600, 961459, 805320, 99236, 780298, 932795, 511481]\n [195036, 855105, 514771, 711514, 234442, 539631, 644411, 463491, 112557, 217985, 629316, 185503, 888215, 728675, 175993, 704847, 245992, 469172, 819496, 608942, 786465])\n W1=( [604957, 444979, 92612, 722708, 474069, 634935, 49008, 727286, 15642, 757260, 163229, 242680, 662984, 151936, 302866, 970105, 42818, 86986, 542819, 152685])\n #+ [614993, 744625, 774390, 147357, 217239, 448556, 977399, 440373, 650208, 929115, 60946, 434417, 20...\n w2=( [103072, 936498, 847907, 650645, 566772, 244240, 76487, 607887, 833591, 261100, 535448, 472137, 921365, 782021, 699092, 571729, 884498, 898861, 570530, 8136, 278423, 614993, 744625, 774390, 147357, 217239, 448556, 977399, 440373, 650208]\n + [929115, 60946, 434417, 203564, 373657, 245610, 284531, 327005, 518126, 979469])\n \n w3= ([415376, 150228, 72136, 403305, 640672, 652152, 214427, 737311, 208036, 769173, 693842, 421040, 183828, 647456, 73520, 674069, 253765, 239577, 992072, 247531, 5556, 775497, 835157, 659594, 777970, 399659, 357111, 242550, 765227, 396071]\n + [337931, 684782, 912212, 59641, 407013, 892962, 529009, 168624, 729261])\n \n w4=([579778, 603392, 7187, 711763, 980786, 891205, 187614, 347504, 871321, 16499, 165802, 430266, 767897, 943796, 838570, 489956, 126553, 519253, 411089, 156752, 209661, 853585, 233490, 370034, 817847, 507577, 999103, 22978, 790519, 52028]\n +[728211, 18397, 740606, 627417, 513419, 851193, 795920, 975646])\n \n w5=([364270, 878531, 313352, 760219, 57774, 979287, 495749, 821992, 400807, 118875, 624706, 11664, 398468, 399161, 480516, 516761, 361857, 676791, 254124, 676721, 383882, 346228, 368172, 543223, 372419, 89729, 450007, 183906, 578337, 782425]\n +[239888, 133714, 848309, 211198, 276004, 422001, 342793])\n \n w6=(\n [669810, 70004, 223430, 545763, 495696, 659851, 458070, 320934, 70213, 2510, 670903, 398360, 955053, 229649, 10354, 681727, 93774, 345990, 810132, 724068, 178347, 919760, 900818, 664569, 731142, 68854, 562838, 348118, 412534, 711858]\n +[217450, 390687, 476960, 552361, 384448, 269506])\n \n w7= ([686869, 943862, 411867, 608029, 563528, 355743, 650398, 806908, 984874, 442601, 965871, 224704, 395748, 333576, 560520, 44827, 222000, 210286, 63258, 240375, 156949, 653188, 279453, 955766, 955005, 475318, 105273, 315988, 259444, 554025]\n +[169162, 673513, 337343, 217480, 802836])\n \n w8=([524812, 846231, 854588, 192451, 593937, 58689, 804666, 287964, 117042, 310411, 495542, 750086, 835403, 781732, 699317, 778671, 275391, 903769, 90240, 110812, 176953, 320104, 584756, 341201, 623117, 929603, 391734, 803929, 440316, 17762]\n +[349381, 33395, 717334, 254917])\n \n w9=([852392, 358681, 885946, 1989, 714822, 291374, 275129, 793814, 698964, 135683, 654809, 411164, 475752, 828614, 173173, 465830, 881709, 429319, 942530, 613387, 394352, 150504, 429484, 432671, 47638, 720929, 915486, 178642, 362160, 697774]\n +[582177, 990694, 63463])\n \n w10=([775829, 967068, 76364, 48338, 231255, 628921, 800537, 721127, 331827, 449577, 987306, 400525, 752721, 529533, 823633, 106767, 436626, 205685, 547258, 868397, 522545, 178774, 793439, 158477, 194198, 537780, 714979, 545295, 240759, 136464]\n +[342543, 669949])\n \n w11=([395243, 682010, 637544, 537377, 568397, 939159, 617065, 455601, 589065, 520285, 39074, 59942, 70214, 98748, 330093, 61675, 314160, 4343, 820744, 569072, 156641, 964848, 619284, 939421, 248299, 973729, 72425, 651620, 337476, 228294]\n +[446228])\n w12 = [733423, 120527, 880793, 28654, 481273, 936515, 808693, 646362, 891193, 526586, 645212, 971930, 320632, 217240, 232724, 519503, 911492, 119638, 207340, 834315, 393853, 595370, 182300, 154260, 490060, 679573, 469578, 931192, 795252, 794504]\n w13 = [992937, 935048, 234752, 790452, 581692, 261170, 364764, 938989, 760569, 392383, 343936, 652090, 226824, 806565, 456839, 687163, 528042, 195594, 873694, 66359, 594999, 965206, 59095, 345665, 918463, 273203, 35037, 899079, 842258]\n w14=[529636, 112898, 877687, 806044, 60735, 189749, 160846, 725032, 512840, 609679, 511, 993861, 575660, 560076, 254140, 79046, 330071, 166742, 370339, 396898, 344306, 315773, 868616, 819708, 981564, 686084, 252763, 573950]\n #[928772, 710357, 920822, 465694, 1... ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bc8d0664bac5ea02643d3d626d8d12f8", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "import sys\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\ndef bit(xx):return [format(x,\"b\") for x in xx]\npopcnt=lambda x:bin(x).count(\"1\")\ndef ask(m):\n print(\"?\",m,flush=True)\n return II()\nfor _ in range(II()):\n n=II();l=0;r=n;pc=0;d=1;mx=0\n while l+1=x2:print \"FIRST\";print x2-x1\nelif a<=0 and b>=0:print \"DRAW\"\nelse:\n\td=x2-x1\n\tif a<0:d,a,b=-d,-b,-a\n\tif d<0:print \"DRAW\"\n\telif d%(a+b)==0:print \"SECOND\"\n\telif d%(a+b)>=a and d%(a+b)<=b:print \"FIRST\";print d%(a+b)\n\telse: print \"DRAW\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "25b641c0bb8137f52cc166d6a6532a3c", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nd = 1000000007\ng = [1] * n\nh = [pow(k, d - 2, d) for k in range(1, n + 1)]\nfor m in range(1, n):\n c = m - 1\n for k in range(1, m):\n g[m] = (g[m] + c * g[k]) % d\n c = (c * (m - k - 1) * h[k]) % d\n\nf = [1] * (n + 1)\nfor m in range(1, n + 1):\n c = m\n for k in range(1, m):\n f[m] = (f[m] + c * g[k]) % d\n c = (c * (m - k) * h[k]) % d\nprint(f[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e83fbe718d4ee10f4ab6f02d58108a87", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def _cmp(x, y):\n c = -cmp(x[1][0], y[1][0])\n d = -cmp(x[1][1]-x[1][2], y[1][1]-y[1][2])\n e = -cmp(x[1][1], y[1][1])\n f = cmp(x[0][0], y[0][0])\n if c != 0:\n return c\n elif d != 0:\n return d\n elif e != 0:\n return e\n else:\n return f\n\nresults = {}\nfor i in range(5):\n a, b, pts = raw_input().split()\n x, y = [int(i) for i in pts.split(':')]\n at = results[a] = results.get(a, [0, 0, 0])\n at[0], at[1], at[2] = (at[0]+(3 if x > y else 1 if x == y else 0), at[1]+x, at[2]+y)\n bt = results[b] = results.get(b, [0, 0, 0])\n bt[0], bt[1], bt[2] = (bt[0]+(3 if x < y else 1 if x == y else 0), bt[1]+y, bt[2]+x)\n\nb = tuple(results['BERLAND'])\nc = tuple(results['CERLAND'])\ndel results['BERLAND']\ndel results['CERLAND']\nresults = list(results.items())\n\n(x, y) = (10, -1)\n\nfor i in xrange(10):\n for j in xrange(i):\n res = results[:]\n res.append(('BERLAND', (b[0]+3, b[1]+i, b[2]+j)))\n res.append(('CERLAND', (c[0], c[1]+j, c[2]+i)))\n res.sort(_cmp)\n barland = None\n if res[0][0] == 'BERLAND': \n barland = res[0][1]\n elif res[1][0] == 'BERLAND':\n barland = res[1][1]\n if barland and i-j < x - y: \n (x, y) = i, j\n \nif x == 10 and y == -1:\n print 'IMPOSSIOBLE'\nelse:\n print '{0}:{1}'.format(x, y)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "12bbcb21a37163283890d3d45fd4b050", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom __builtin__ import xrange as range\nfrom cStringIO import StringIO\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom io import IOBase\n\nimport __pypy__\n\n\ndef memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\n return memodict().__getitem__\n\n\ndef main():\n n, T = map(int, input().split())\n t, g = [0] * n, [0] * n\n for i in range(n):\n t[i], g[i] = map(int, input().split())\n\n @memoize\n def solve(T, p, mask):\n if T < 0:\n return 0\n if T == 0:\n return 1\n mask = list(mask)\n res = 0\n for i in range(n):\n if mask[i] == 0 and p != g[i]:\n new_mask = mask[:]\n new_mask[i] = 1\n res += solve(T - t[i], g[i], tuple(new_mask))\n\n return res\n\n print(solve(T, -1, tuple([0] * n)))\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastI(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = StringIO()\n self.newlines = 0\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(\"\\n\") + (not b)\n ptr = self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\n\n\nclass FastO(IOBase):\n def __init__(self, file):\n self._fd = file.fileno()\n self._buffer = __pypy__.builders.StringBuilder()\n self.write = lambda s: self._buffer.append(s)\n\n def flush(self):\n os.write(self._fd, self._buffer.build())\n self._buffer = __pypy__.builders.StringBuilder()\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\n at_start = True\n for x in args:\n if not at_start:\n file.write(sep)\n file.write(str(x))\n at_start = False\n file.write(kwargs.pop(\"end\", \"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5317ff878fd4731e8b2130d1749b7771", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from collections import *\nn = input()\ns = raw_input()\nb = [int (i) for i in raw_input().split(' ')]\nn = n\ncnt = defaultdict(int)\nmultiples = []\nbiggest = 'a'\nans = 0\nfor i in range(n//2):\n if(s[i] == s[n-i-1]):\n multiples.append(i)\n cnt[s[i]] += 1\n ans += max(b[i],b[n-i-1])\n else:\n ans += b[i] + b[n-i-1]\n\nfor i in range(26):\n if(cnt[chr(ord('a')+i)] > cnt[biggest]):\n biggest = chr(ord('a')+i)\nmore = max(max(cnt.values())*2-sum(cnt.values()),0)\ntakes = []\nfor i in range(n//2):\n if(s[i] != s[n-i-1] and s[i] != biggest and s[n-i-1] != biggest):\n takes.append(min(b[i],b[n-i-1]))\ntakes = sorted(takes)[:more]\npen = sum(takes)\nprint(ans-pen)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cd6ddaf44ffcfbb1628df2013b9770e3", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "a=int(input())\nb,c=10**100,a-45*100*10**99%a\nprint(c,c+b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "20dabbe7a80c5b4e7f518efe487f2334", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\nnum = list(input())\nif k == 0:\n print(*num, sep='')\n exit()\nif n == 1:\n print('0')\n exit()\nif num[0] != '1':\n num[0] = '1'\n k -= 1\nfor i, f in enumerate(num):\n if k > 0 and i > 0:\n if num[i] != '0':\n num[i] = '0'\n k -= 1\nprint(*num, sep='')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42cfcfa5ee01c7ed3ecc4f8f755ff5c8", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import operator\n\ndef pixel(input):\n red, green, blue = input.split()\n pixels = {\n 'red': int(red),\n 'green': int(green),\n 'blue': int(blue)\n }\n\n battles = 0\n\n while True:\n is_mir = len([x for x in [pixels['red'], pixels['green'], pixels['blue']] if x == 0]) > 1\n if is_mir:\n break\n\n min_pixel = get_min_pixel(pixels)\n\n if min_pixel == 'red':\n pixels['red'] += 1\n pixels['blue'] -= 1\n pixels['green'] -= 1\n pass\n elif min_pixel == 'green':\n pixels['red'] -= 1\n pixels['blue'] -= 1\n pixels['green'] += 1\n elif min_pixel == 'blue':\n pixels['red'] -= 1\n pixels['blue'] += 1\n pixels['green'] -= 1\n\n battles += 1\n\n return battles\n\n\ndef get_min_pixel(pixels):\n return min(pixels.items(), key=operator.itemgetter(1))[0]\n \nprint(pixel(input()))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9751ffb8431e70ed07e1f207a7dc10c", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom collections import deque\ninput = lambda : sys.stdin.readline().strip()\n# for i in range(int(input())):\nn,m = map(int,input().split())\ng = {}\nfor i in range(m):\n a,b = map(int,input().split())\n if b-1 in g:\n g[b-1].append(a-1)\n else:\n g[b-1]=[a-1]\nk = int(input())\nway = list(map(lambda x: int(x)-1,input().split()))\nbfs = deque()\nbfs.append(way[-1])\nlvl = [-1]*n\nans = [0]*n\na = [set() for j in range(n)]\nlvl[way[-1]]=0\nwhile bfs:\n v = bfs.popleft()\n for u in g[v]:\n if lvl[u]==-1:\n lvl[u]=lvl[v]+1\n a[u].add(v)\n bfs.append(u)\n elif lvl[u]==lvl[v]+1:\n ans[u]=1\n a[u].add(v)\nansv = 0\nans1 = 0\nfor v in range(k-1):\n if ans[way[v]] or a[way[v]].pop()!=way[v+1]:#\n ansv +=1\nfor v in range(k-1):\n if k-v-1!=lvl[way[v]] and way[v+1] not in a[way[v]]:\n ans1+=1\n elif k-v-1 == lvl[way[v]]:\n break\nprint(ans1,ansv)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78e23dda1aca84bb6dc9eb6e39edf77f", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "Python 2", "source_code": "\ndef main():\n a=[2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279,2203,2281,3217,4253,4423,9689,9941,11213,19937,21701,23209,44497,86243,110503,132049,216091,756839,859433,1257787,1398269,2976221,3021377,6972593,13466917,20996011]\n n=input()\n print len(a)\n print pow(2, a[n-1]-1, 10**9+7)-1\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32e0dce1c838f9a2de7c670ace08e2f9", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n,d,s=map(int,raw_input().split())\nc0=[]\nc1=[]\nv=0\nfor i in range(n):\n\tc,f,l=map(int,raw_input().split())\n\tv+=c\n\tif l>=d:\n\t\tif c:\n\t\t\tc1+=[f]\n\t\telse:\n\t\t\tc0+=[f]\nc0.sort()\ny=z=0\nif c1!=[]:\n\tu=min(c1)\n\tv+=1\n\tfor i in c0:\n\t\tif u<=s:\n\t\t\tz,y=max([z,y],[min(v,n),-u])\n\t\telse:\n\t\t\tbreak\n\t\tu+=i\n\t\tv+=1\n\tif u<=s:\n\t\tz,y=max([z,y],[min(v,n),-u])\nv=u=0\nfor i in c0:\n\tif u+i>s:\n\t\tz,y=max([z,y],[v,-u])\n\telse\n\t\tbreak\n\tu+=i\n\tv+=1;\nprint z,-y", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c885f7e7d792d083a42eb9b861c9d386", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "PyPy 3-64", "source_code": "def main():\r\n from sys import stdin, setrecursionlimit\r\n # setrecursionlimit(1000000)\r\n input = stdin.readline\r\n def iinput(): return int(input())\r\n def sinput(): return input().rstrip()\r\n def i0input(): return int(input()) - 1\r\n def linput(): return list(input().split())\r\n def liinput(): return list(map(int, input().split()))\r\n def miinput(): return map(int, input().split())\r\n def li0input(): return list(map(lambda x: int(x) - 1, input().split()))\r\n def mi0input(): return map(lambda x: int(x) - 1, input().split())\r\n INF = 1000000000000000000\r\n MOD = 1000000007\r\n\r\n '''\r\n c \u3092\u56fa\u5b9a\r\n a + b = N - c = K \u306f gcd(a, b) \u3067\u5272\u308a\u5207\u308c\u308b -> K \u306e\u7d04\u6570\u306e\u3046\u3061 K \u4ee5\u5916\u3092\u3072\u3068\u3064 k \u3068\u56fa\u5b9a\r\n k + k + ... + k = K\r\n l = K / k\r\n \u3053\u306e\u3068\u304d\u3001\u5206\u3051\u65b9\u306f phi(l)\r\n '''\r\n\r\n def make_divisors(n):\r\n lower_divisors , upper_divisors = [], []\r\n i = 1\r\n while i*i <= n:\r\n if n % i == 0:\r\n lower_divisors.append(i)\r\n if i != n // i:\r\n upper_divisors.append(n//i)\r\n i += 1\r\n return lower_divisors + upper_divisors[::-1]\r\n\r\n class Totient:\r\n def __init__(self, N:int) -> None:\r\n self.N = N\r\n self.enum_tortient = [i for i in range(N+1)]\r\n self.is_prime = [True] * (N + 1)\r\n self.is_prime[0] = False\r\n self.is_prime[1] = False\r\n for p in range(2, N+1):\r\n if self.is_prime[p]:\r\n self.enum_tortient[p] = p - 1\r\n for n in range(2*p, N+1, p):\r\n self.is_prime[n] = False\r\n self.enum_tortient[n] = self.enum_tortient[n] // p * (p - 1)\r\n def phi(self, K:int) -> int:\r\n assert(K <= self.N)\r\n return self.enum_tortient[K]\r\n\r\n N = iinput()\r\n ans = 0\r\n from math import gcd\r\n\r\n tot = Totient(N)\r\n for c in range(1, N-1):\r\n K = N - c\r\n for g in make_divisors(K)[:-1]:\r\n ans += c * tot.phi(K//g) * g // gcd(g, c)\r\n print(ans)\r\n\r\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aca19e707b8f4e2569e17f169ebffbd3", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "sg = [1,2,1,4,3,2,1,5,6,2,1,8,7,5,9,8,7,3,4,7,4,2,1,10,9,3,6,11,12]\ni = 2\nans = 1\nn = input()\nmp = {} \nwhile i * i <= n:\n\tif i in mp :\n\t\ti += 1\n\t\tcontinue\n\tt = i\n\tcnt = 0\n\twhile t <= n:\n\t\tt *= i\n\t\tcnt += 1\n\t\tmp[t] = 1\n\tans ^= sg[cnt - 1]\n\ti += 1\nc = n - i + 1\nans ^= c % 2\nif ans == 0 : print 'Petya'\nelse : print 'Vasya'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d2342086ce72934a25be941577033d8", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "def gets():\n return list(map(int, raw_input().split()))\nn, m, d = gets()\na = [ tuple(gets()) for i in range(n) ]\nb = [ tuple(gets()) for i in range(m) ]\ndef mycmp(lef, rig):\n if lef[0] == rig[0]:\n return lef[1] - rig[1]\n return rig[0]-lef[0]\na.sort(cmp = mycmp)\nb.sort(cmp = mycmp)\nans = 0\ncur = 0\nwid = 0\nj = n\nfor i in range(n):\n cur += a[i][0]\n wid += a[i][1]\nfor i in range(m):\n cur += b[i][0]\n wid += b[i][1]\n while wid > d :\n j -= 1\n if j <= 0:\n break\n cur -= a[j][0]\n wid -= a[j][1]\n if j <= 0:\n break\n ans = max(ans, cur)\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f0c4a1372234e20f0436e7e9b954d61", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "a = [0]*10\nb = [0]*10\ns = map(int, list(raw_input()))\nn = len(s)\nc1=['']*n\nc2=['']*n\nfor i in range(n):\n a[s[i]] += 1\n b[s[i]] += 1\n\nn-=1\n\nwhile (a[0]-a[9])>0:\n c1[n]=c2[n] = str(0)\n a[0]-=1\n b[0]-=1\n n-=1\n\n\nk = []\nfor i in range(1,6):\n if a[i]*b[10-i]>0:\n k.append(i)\n\nd = []\nfor l in k:\n for i in range(6):\n if (i != l) and (i != 9-l):\n o += min(a[i], b[9-i])\n elif (i = l) and (i != 9-l):\n o += min(a[i]-1, b[9-i])\n elif (i != l) and (i = 9-l):\n o += min(a[i], b[9-i]-1)\n elif (i = l) and (i = 9-l):\n o += min(a[i]-1, b[9-i]-1)\n\nif k>0:\n c1[n]=str(k)\n c2[n]=str(10-k)\n n -= 1\n\n\nfor i in range(10):\n if a[i]*b[9-i]>0:\n k=i\n m = 0\n while ((a[i]>0) and (b[9-i]>0)):\n a[i]-=1\n b[9-i]-=1\n m+=1\n for j in range(m):\n c1[n]=str(k)\n c2[n]=str(9-k)\n n-=1\n\nm = n\n\nfor i in range(10):\n while a[i]>0:\n c1[n] = str(i)\n n-=1\n a[i] -= 1\n while b[i]>0:\n c2[m] = str(i)\n m-=1\n b[i] -= 1\n\n\nc1 = ''.join(str(n) for n in c1)\nc2 = ''.join(str(n) for n in c2)\nprint c1\nprint c2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "242de000e6376c7800b67b8012d1dd6e", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "from sys import stdin, exit\nfrom random import randint\n\n\ndef no_solution():\n print 'NO'\n exit(0)\n\ninp = stdin.read().strip().split('\\n')\n\nn, K = map(int, inp[0].split(' '))\n\na = [0] + [0 for i in xrange(n)]\nb = [0] + [0 for i in xrange(n)]\nc = [0] + [0 for i in xrange(n)]\n\nactive = [i + 1 for i in range(n)]\n\nfor i in xrange(1, n + 1):\n a[i], b[i], c[i] = map(int, inp[i].split(' '))\n\n\nanswer = []\n\nwhile K > 0:\n n = len(active)\n if K == 0 or len(active) == 0:\n break\n if n <= K:\n for i in xrange(n):\n answer.append((active[i], -1))\n K -= 1\n active = []\n break\n\n good = False\n best = (-1, -1)\n bsz = 10 ** 6\n for it in xrange(30):\n idx1 = randint(0, n - 1)\n idx2 = randint(0, n - 1)\n if idx1 == idx2:\n continue\n\n i = active[idx1]\n j = active[idx2]\n\n if a[i] * b[j] == a[j] * b[i]:\n continue\n\n x_high = c[j] * b[i] - c[i] * b[j]\n y_high = a[j] * c[i] - a[i] * c[j]\n\n low = a[i] * b[j] - a[j] * b[i]\n\n #answer.append((i, j))\n #K -= 1\n\n n_act = []\n for k in active:\n if k == i or k == j:\n continue\n \n low_prime = a[k] * b[j] - a[j] * b[k]\n if low_prime == 0:\n n_act.append(k)\n continue\n\n x_high_prime = c[j] * b[k] - c[k] * b[j]\n y_high_prime = a[j] * c[k] - a[k] * c[j]\n\n if x_high * low_prime != x_high_prime * low or \\\n y_high * low_prime != y_high_prime * low:\n n_act.append(k)\n\n #active = n_act\n good = True\n if len(n_act) < bsz:\n bsz = len(n_act)\n best = (i, j)\n\n if not good:\n no_solution()\n\n i, j = best\n\n if a[i] * b[j] == a[j] * b[i]:\n continue\n\n x_high = c[j] * b[i] - c[i] * b[j]\n y_high = a[j] * c[i] - a[i] * c[j]\n\n low = a[i] * b[j] - a[j] * b[i]\n\n answer.append((i, j))\n K -= 1\n\n n_act = []\n for k in active:\n if k == i or k == j:\n continue\n \n low_prime = a[k] * b[j] - a[j] * b[k]\n if low_prime == 0:\n n_act.append(k)\n continue\n\n x_high_prime = c[j] * b[k] - c[k] * b[j]\n y_high_prime = a[j] * c[k] - a[k] * c[j]\n\n if x_high * low_prime != x_high_prime * low or \\\n y_high * low_prime != y_high_prime * low:\n n_act.append(k)\n active = n_act\n\n \nif len(active) == 0 and K >= 0:\n print 'YES'\n print len(answer)\n for i in xrange(len(answer)):\n print '%d %d' % answer[i]\n assert(answer[i][0] != answer[i][1])\nelse:\n no_solution()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "06b8b541aa55ac2d3a75c21abb562532", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "Python 2", "source_code": "p1,p2,p3,p4,p5=[[3.830127018922193,3.366025403784439],\n[-3.601321235851749,10.057331467373021],\n[0.466045194906253,19.192786043799030],\n[10.411264148588986,18.147501411122495],\n[12.490381056766580,8.366025403784439]]\nzz=[p1,p2,p3,p4,p5]\notrx=p3[0]-p1[0]\notry=p3[1]-p1[1]\nn=int(raw_input())\ns=set()\nfor i in xrange(n):\n for x,y in zz:\n s.add((x+i*otrx,y+i*otry))\nlelem=list(s)\npo=[]\nfor i in xrange(n):\n po.append((-100,)+tuple(lelem.index((x+i*otrx,y+i*otry))+1 for x,y in zz))\npor=[po[0][1]]\nfor i in xrange(n):\n por.append(po[i][3])\nfor i in xrange(n-1,-1,-1):\n por.append(po[i][5])\n por.append(po[i][2])\n por.append(po[i][4])\n por.append(po[i][1]) \nprint len(lelem) \nfor x,y in lelem:\n print x,y\nfor x in po:\n print \" \".join(map(str,x[1:]))\nprint \" \".join(map(str,por)) \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8e6f5dd8fa57883ec9cf887720ab95c", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "mod, sx, sy, dx, dy, t = map(int, raw_input().split())\nv = (sx - 1, sy - 1, dx + sx + sy, dy + sx + sy, 1, 1)\nA = [\n[1, 0, 1, 0, 0, 0],\n[0, 1, 0, 1, 0, 0],\n[1, 1, 2, 1, 1, 2],\n[1, 1, 1, 2, 1, 2],\n[0, 0, 0, 0, 1, 1],\n[0, 0, 0, 0, 0, 1]\n]\nI = lambda: [[1 if i == j else 0 for j in xrange(6)] for i in xrange(6)]\ndef mul(M, N):\n global mod\n res = [[0] * 6 for i in xrange(6)]\n for i in xrange(6):\n for j in xrange(6):\n for k in xrange(6):\n res[i][j] += M[i][k] * N[k][j]\n res[i][j] %= mod\n return res\ndef power(M, k):\n if k > 1:\n res = power(M, k/2)\n res = mul(res, res)\n if k % 2:\n res = mul(res, M)\n return res\n elif k == 1:\n return M\n else:\n return I()\nB = power(A, t)\nV = [0] * 6\nfor i in xrange(6):\n for j in xrange(6):\n V[i] += B[i][j] * v[j]\n V[i] %= mod\nprint V[0] + 1, V[1] + 1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a0fdb7b8507bd9316ec47b47d4d3365a", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "m = 301000\nns = [0] * m\nes = [0] * m\nc = [0] * m\nb = [0] * m\nt = [0] * m\nP = 0\n\ndef add(b, k):\n k = t[k]\n while k:\n e = es[k]\n if b[-1] > e: b[-1] = e\n b[e] += 1\n k = ns[k]\n\ndef delete(b):\n for i in range(b[m - 1], m + 1):\n if b[i]:\n b[i] -= 1\n b[-1] = i\n return i\n\ndef calc(k):\n global b\n q = 0\n b = [0] * m\n b[-1] = m\n take = rank - dn\n if take < 0: take = 0\n add(b, k)\n add(b, k - 1)\n for i in range(1, take + 1): q += delete(b)\n for i in range(k - 1): add(b, i)\n for i in range(k + 1, P + 1): add(b, i)\n for i in range(1, k - take + 1): q += delete(b)\n return q\n\nn, k = map(int, input().split())\nrank = n - k + 1\n\nif rank == 0:\n print('0')\n exit(0)\n\nfor i in range(1, n + 1):\n p, e = map(int, input().split())\n if p > P: P = p\n c[p] += 1\n es[i], ns[i] = e, t[p]\n t[p] = i\n\ndn = 0\nfor i in range(1, n + 1):\n if i > 1: dn += c[i - 2]\n if c[i] + c[i - 1] + dn >= rank and rank <= i + dn:\n u = calc(i)\n if i < n:\n dn += c[i - 1]\n v = calc(i + 1)\n if u > v: u = v\n if i < n - 1:\n dn += c[i]\n v = calc(i + 2)\n if u > v: u = v\n print(u)\n exit(0)\n \nprint('-1')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d9f4d8a0064abf4a2ed84bb6f78c4fec", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null} {"lang": "PyPy 3", "source_code": "n=int(input())*2\ns=input()\nd=dict()\naux=''\nfor i in range(len(s)):\n if s[i]=='(':\n d.update({(i,1):i+1})\n x=aux+')'\n for j in range(1,i+2):\n print(x[j::],s[0:len(x)-j],len(x),j)\n if x[j::] ==s[0:len(x)-j]:\n d.update({(len(aux),0):len(x[j::])})\n break\n else:\n d.update({(i,0):i+1})\n x=aux+'('\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d.update({(len(aux),1):len(x[j::])})\n break\n aux+=s[i]\nd.update({(len(s),1):len(s)})\nd.update({(len(s),0):len(s)})\ndp=[[[0 for i in range(len(s)+1)] for j in range(n//2+1)] for k in range(n+1)]\ndp[0][0][0]=1\nmod=10**9+7\nfor i in range(n):\n for j in range(1,(n//2)+1):\n for k in range(len(s)+1):\n dp[i+1][j-1][d[(k,0)]]=(dp[i][j][k]+dp[i+1][j-1][d[(k,0)]])%mod\n for j in range(n//2):\n for k in range(len(s)+1):\n dp[i+1][j+1][d[(k,1)]]=(dp[i][j][k]+dp[i+1][j+1][d[(k,1)]])%mod\nprint(dp[n][0][len(s)]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4353c9f9c39f80d7fbc8aba5d907555", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "import sys\ndef mulMatrix(a, b, p):\n\tn = len(a)\n\tc = []\n\tfor i in range(n):\n\t\tc.append([0] * n)\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tfor k in range(n):\n\t\t\t\tc[i][j] += a[i][k] * b[k][j]\n\t\t\t\tc[i][j] %= p\n\treturn c\n\ndef powMatrix(a, pw, p):\n\tn = len(a)\n\tr = []\n\tfor i in range(n):\n\t\tl = [0] * n\n\t\tl[i] = 1\n\t\tr.append(l)\n\twhile pw:\n\t\tif pw & 1:\n\t\t\tr = mulMatrix(r, a, p)\n\t\ta = mulMatrix(a, a, p)\n\t\tpw >>= 1\n\treturn r\n\ndef getFib(n, p):\n\tif n < 0: return 0\n\tif n < 2: return 1\n\tr = powMatrix([[1, 1], [1, 0]], n - 1, p)\n\treturn (r[0][0] + r[0][1]) % p\n\ndef getSumPow3(x, p):\n\tif x == 0:\n\t\treturn 0\n\tif x == 1:\n\t\treturn 1\n\tif x & 1:\n\t\tt = getSumPow3(x - 1, p)\n\t\treturn (t * 3 + 1) % p\n\telse:\n\t\tt = getSumPow3(x >> 1, p)\n\t\treturn (t + t * pow(3, x >> 1, p)) % p\n\ndef mod(x, p):\n\tx %= p\n\tif x < 0:\n\t\tx += p\n\treturn x\n\ndef getSum(first, last, mid, n, p):\n\t(first, last, mid) = (mod(first, p), mod(last, p), mod(mid, p))\n\t#print first, last, mid\n\treturn ((first + last) * (getSumPow3(n, p) + 1) + mid * pow(3, n, p)) % p\n\t\t\t\t\ndef main():\n\t(n, x, y, p) = sys.stdin.readline().split(' ')\n\t(n, x, y, p) = (long(n), long(x), long(y), long(p))\n\ta = sys.stdin.readline().strip().split(' ')\n\ts = 0\n\tfor i in xrange(n):\n\t\ta[i] = long(a[i])\n\t\ta[i] %= p\n\t\ts += a[i]\n\t\n\tif n == 1:\n\t\tprint a[0]\n\t\treturn\n\n\ts = getSum(a[0], a[-1], s - a[0] - a[-1], x, p)\n\n\tlast = (a[-1] * getFib(x, p) + a[-2] * getFib(x - 1, p)) % p\n\n\ts = getSum(a[0], last, s - a[0] - last, y, p)\n\tprint s\n\t\n\t#3 ** (s - a[0] - a[-1])\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e91ef78ec463406ab430ff3fb3375cc", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\ndef readvars():\n k = map(int,input().split())\n return(k)\n\ndef readlist():\n li = list(map(int,input().split()))\n return(li)\n\ndef anslist(li):\n ans = \" \".join([str(v) for v in li])\n return(ans)\n\ndef main():\n\n t = 1\n#\tt = int(input())\n\n for xx in range(t):\n \tt = int(input())\n n = readlist()\n for m in n: print(((((m//2) - (m//4) + 1)%(1000000007))*((m//4) + 1))%1000000007)\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a72aff82844341cbeb0b3068d6d888d", "src_uid": "24f4bd10ae714f957920afd47ac0c558", "difficulty": 2400.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nfrom functools import lru_cache\r\n\r\nk, M = map(int, input().split())\r\n\r\nMOD = M\r\n\r\ndef modmul(x, y, c = 0):\r\n return (x * y + c) % MOD\r\n\r\nmod_mul = modmul\r\n\r\ndef inv(x):\r\n return pow(x, MOD - 2, MOD)\r\n\r\nMAX = 10 ** 5\r\n\r\nfact = [1]\r\nfor i in range(1, MAX):\r\n fact.append(modmul(i, fact[i-1]))\r\n\r\ninvfact = [1] * (MAX)\r\ninvfact[MAX - 1] = inv(fact[MAX - 1])\r\nfor i in range(MAX - 2, -1, -1):\r\n invfact[i] = modmul(i + 1, invfact[i+1])\r\n\r\ndef comb(x, y):\r\n assert 0 <= y <= x\r\n \r\n return modmul(fact[x], modmul(invfact[y], invfact[x - y]))\r\n\r\ndef invcomb(x, y):\r\n return modmul(invfact[x], modmul(fact[y], fact[x - y]))\r\n\r\ndef invs(x):\r\n return modmul(fact[x - 1], invfact[x])\r\n\r\n\r\ndef count(a, b):\r\n if a + b == 0:\r\n return 1\r\n return modmul(a, fact[a + b - 1])\r\n \r\nn = k\r\n\r\npn1 = [1]\r\nfor i in range(5000):\r\n pn1.append(modmul(pn1[-1], n - 1))\r\n\r\nout = 0\r\nfor i in range(1, n):\r\n \r\n pni = [1]\r\n for _ in range(5000):\r\n pni.append(modmul(pni[-1], n - i))\r\n \r\n for j in range(i + 1):\r\n if n - i - j < 0:\r\n continue\r\n \r\n stab = comb(n, i)\r\n app = modmul(comb(i, j), comb(n - i, n - i - j))\r\n order = count(j, n - i - j)\r\n sao = modmul(modmul(stab, app), order)\r\n #sao = 1\r\n\r\n #u1 = pow(n - i, i - j, M)\r\n #u2 = pow(n - 1, j, M)\r\n u1 = pni[i - j]\r\n u2 = pn1[j]\r\n u = modmul(u1, u2)\r\n #u = 1\r\n\r\n #print(i, j, stab, app, order, u1, u2)\r\n \r\n out += modmul(sao, u)\r\n\r\nprint(out % M)\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de6e69de4f838f2ea04968e445c614b7", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\ndef get(cnt):\n c = Counter(a)\n last = []\n while c[1] and (cnt is None or len(last) < cnt):\n x = 1\n while c[x]:\n c[x] -= 1\n x *= 2\n last.append(x >> 1)\n rem = sorted(c.elements())\n i = 0\n for x in last[::-1]:\n if i < len(rem) and rem[i] < 2 * x:\n i += 1\n return len(last) if i == len(rem) else 0\n\nmx = get(None)\nlo, hi = 0, mx\nwhile lo < hi:\n mid = (lo + hi) >> 1\n if get(mid):\n hi = mid\n else:\n lo = mid + 1\nif mx:\n print(*range(lo, mx + 1))\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eda139b9dbd600bd299ec5c6def14ec6", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\nfrom math import lcm\r\nfrom collections import defaultdict\r\n\r\ndef solve(p):\r\n\tpoly = int(p[::-1], 2)\r\n\tassert p[0] == '1' and p[-1] == '1'\r\n\tdegree = len(p) - 1\r\n\tdef reduce(a):\r\n\t\twhile a.bit_length() > degree:\r\n\t\t\tb = a.bit_length() - degree - 1\r\n\t\t\ta ^= poly << b\r\n\t\tassert a < (1 << degree)\r\n\t\treturn a\r\n\r\n\tdef mul(a, b):\r\n\t\ta = reduce(a)\r\n\t\tb = reduce(b)\r\n\t\tval = 0\r\n\t\tfor i in range(degree):\r\n\t\t\tif (a >> i) & 1:\r\n\t\t\t\tval ^= (b << i)\r\n\t\tfor i in range(degree, -1, -1):\r\n\t\t\tif (val >> (degree + i)) & 1:\r\n\t\t\t\tval ^= poly << i\r\n\t\treturn val\r\n\t\r\n\tdef pow(a, k):\r\n\t\tres = 1\r\n\t\twhile k:\r\n\t\t\tif k & 1:\r\n\t\t\t\tres = mul(res, a)\r\n\t\t\tk >>= 1\r\n\t\t\ta = mul(a, a)\r\n\t\treturn res\r\n\r\n\tpfs = defaultdict(int)\r\n\tpfs[2] += degree\r\n\tfor i in range(1, degree + 1):\r\n\t\tcur = 2 ** i - 1\r\n\t\tp = 2\r\n\t\twhile p * p <= cur:\r\n\t\t\twhile cur % p == 0:\r\n\t\t\t\tcur //= p\r\n\t\t\t\tpfs[p] += 1\r\n\t\t\tp += 1\r\n\t\tif cur > 1:\r\n\t\t\tpfs[cur] += 1\r\n\torder_multiple = 1\r\n\tfor p in pfs:\r\n\t\torder_multiple *= p ** pfs[p]\r\n\t\r\n\torder = order_multiple\r\n\tx = reduce(1 << 1)\r\n\tfor p in pfs:\r\n\t\twhile order % p == 0 and pow(x, order // p) == 1:\r\n\t\t\torder //= p\r\n\treturn order\r\n\r\ns = input()\r\nif '1' not in s:\r\n\tprint(-1)\r\n\tsys.exit()\r\n\r\np = s.lstrip('0')\r\nl0 = len(s) - len(p)\r\np = p.rstrip('0')\r\n\r\nres = solve(p)\r\nprint(f\"{1 + l0} {1 + l0 + res}\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1af107061ffe4dd0df4b24c28841c7b", "src_uid": "6bf798edef30db7d0ce2130e40084e6b", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "def main():\n l = [input()[4:] for _ in range(int(input()))]\n for i, s in enumerate(l):\n le = len(s)\n if le == 1:\n s = (\"199\", \"198\")[s == \"9\"] + s\n elif le == 2:\n s = \"1999\" if s == \"99\" else \"20\" + s\n elif le == 3:\n s = \"2\" + s\n else:\n if s != \"9\" * le:\n s = \"1\" + s\n l[i] = s\n print('\\n'.join(l))\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "744bc1e9009573d398dc67169b85aede", "src_uid": "31be4d38a8b5ea8738a65bfee24a5a21", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "# coding: utf-8\n \nimport math, sys, time, bisect, sys\n \nk = int(raw_input())\nn = int(raw_input())\npts = []\nfor _ in xrange(n*k):\n\tx,y = map(int, raw_input().split())\n\tpts.append( (x,y) )\n \ndef distribution(x,y,pts=pts,n=n,k=k):\n\t# smallest circle: radius 2.5e5, extended to at most 1.1 times that. but we can also be about 1e5 off on the radius.\n\t# so all points will be within 2.5*0.9-1=1.25 up to 1+2.5*1.1=3.75\n\trs = []\n\tfor x2,y2 in pts:\n\t\trs.append(((((x-x2)**2+(y-y2)**2)**.5), math.atan2(y2-y, x2-x)))\n\trs.sort()\n \n\tangle_cumbuckets = [[0] for _ in xrange(12)]\n\tangles = [-math.pi+i*2*math.pi/len(angle_cumbuckets) for i in xrange(len(angle_cumbuckets)+1)]\n\tfor i in xrange(len(angle_cumbuckets)):\n\t\tangle1, angle2 = angles[i], angles[i+1]\n\t\tfor r,a in rs:\n\t\t\tif angle1<=a=0.1*n/len(angle_cumbuckets) for a in xrange(len(angle_cumbuckets))]):\n\t\t\tbest=candidate\n\t\t\tuniformity = min([angle_cumbuckets[a][j+1]-angle_cumbuckets[a][i+1] for a in xrange(len(angle_cumbuckets))])#/(float(n)/len(angle_cumbuckets))\n\t\tif j == len(rs)-1:\n\t\t\tbreak\n\tbest = list(best)\n\tbest[0] = -uniformity if uniformity is not None else None\n\treturn tuple(best)\n \ndef J(data):\n\tret = 0.0\n\tfor x2,y2 in pts:\n\t\tthing = 1e15\n\t\tfor i in xrange(k):\n\t\t\tx,y,r = data[3*i], data[3*i+1], data[3*i+2]\n\t\t\t#ret += abs(((x-x2)**2+(y-y2)**2)/r-1)\n\t\t\tthing = min(thing, math.sqrt(abs(r**2-((x-x2)**2+(y-y2)**2))))\n\t\tret += thing\n\treturn ret\n \ndef gradient_descent_auto(x,J,delta, alpha=1000):\n\titerations = 200\n\trolling = []\n\tfor it in xrange(iterations):\n\t\tj = J(x)\n\t\tif len(rolling)<4:\n\t\t\trolling.append((j,x[:]))\n\t\telse:\n\t\t\tif all(0.999RANGE:\n\t\t\tcontinue\n\t\tdist = distribution(x,y)\n\t\tif dist[1] is not None:\n\t\t\tpeaks.append( (dist, (x,y)))\npeaks.sort()\n \n \ndef go(candidates, pts, k, result=None):\n\tif result is None:\n\t\tresult = []\n\tfor i,((uniformity,r),(x,y)) in enumerate(candidates):\n\t\tremove_these = [(x2,y2) for (x2,y2) in pts if r*0.8-OFFSET*1e5 <= ((x-x2)**2+(y-y2)**2)**.5 <= r*1.2+OFFSET*1e5]\n\t\tnew_pts = list(set(pts)-set(remove_these))\n\t\tif k == 1:\n\t\t\tif len(new_pts) == 0:\n\t\t\t\treturn result+[(x,y,r)]\n\t\telse:\n\t\t\tret = go(candidates[i+1:], new_pts, k-1, result+[(x,y,r)])\n\t\t\tif ret is not False:\n\t\t\t\treturn ret\n\treturn False\n \nyay = go(peaks, pts, k)\n \n \nif yay is False:\n\tprint 'no answer'\n\tsys.exit(0)\n \ndata = []\nfor (x,y,r) in yay:\n\tdata += [x,y,r]\ndata, its = gradient_descent_auto(data, J, 1.0, 10)\nmay = []\nfor i in range(k):\n\tmay.append((data[i*3+0], data[i*3+1], data[i*3+2]))\n \n \n \nfor (x,y,r) in may:\n\tprint x, y, r", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e29ac03b975497f6bb117feccc74f861", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "Python 2", "source_code": "import math\nn, t = map(int, raw_input().split())\n\nfor i in range(55):\n comb = [[0]*55 for _ in range(55)]\nfor i in range(55):\n for j in range(i+1):\n if (i == 0 or j == 0): comb[i][j] = 1\n else:\n comb[i][j] = comb[i-1][j] + comb[i-1][j-1]\n\ndef gao(m, k):\n ret = 0\n while m > 0:\n p = int(math.log(m, 2))\n ret += comb[p][k]\n k -= 1\n m -= 2**p\n if m == 0:\n if k == 0:\n ret += 1\n break\n if k < 0:\n break\n return ret\n\ntmp = 0\nnum = t\nwhile (num > 0):\n if (num % 2 == 1):\n tmp += 1\n num /= 2\n if (tmp > 1):\n break\nif (tmp > 1):\n print 0\nelse:\n k = int(math.log(t, 2))\n ans = gao(n+1, k+1)\n if t == 1:\n ans -= 1\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18f1a335ffbabb34a04831647f2cbce7", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from fractions import Fraction\n\nhash = [0 for i in xrange(10001)]\n\ndef solve(n):\n if not isinstance(hash[n], int):\n return hash[n]\n m, cnt = n, 0\n while m > 1:\n if m & 1:\n break\n m >>= 1\n cnt += 1\n else:\n hash[n] = Fraction(cnt)\n return Fraction(cnt)\n\n l, step = [[1, 0]], 0\n while l[0][0] < n:\n l[0][0] <<= 1\n l[0][1] += 1\n l[0][0] -= n\n while True:\n l.append([l[-1][0], 0])\n while l[-1][0] < n:\n l[-1][0] <<= 1\n l[-1][1] += 1\n l[-1][0] -= n\n step += l[-1][1]\n if l[-1][0] == l[0][0]:\n l.pop()\n break\n\n part1 = part2 = Fraction()\n p = Fraction((1 << step))\n sum = 0\n for part in l:\n p *= Fraction(1, 1 << part[1])\n sum += part[1]\n part1 += p * sum\n part2 += p * step\n\n t = Fraction(1, (1 << step) - 1)\n ret = t * (part1 + part2 * t) * n\n\n for i in xrange(2, n / 2):\n if n % i == 0:\n t = solve(i) + solve(n / i)\n if t < ret: ret = t\n\n hash[n] = ret\n return ret\n\nn = int(raw_input())\nans = str(solve(n))\nif ans.find('/') == -1:\n ans += '/1'\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9b0803b4cf9e963bc0518639853f529d", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "PyPy 2", "source_code": "rr=raw_input\nrrI = lambda: int(rr())\nrrM = lambda: map(int,rr().split())\ndebug=0\nif debug:\n fi = open('t.txt','r')\n rr=lambda: fi.readline().replace('\\n','')\n\ndef good_mask(x):\n if x == 0: return False\n return (x+1) & x == 0\n\nN = rrI()\nS = rr()\n#N = 75\n#from time import time\n#S = '100000111111101000100001011100010111110011111011100011001111101111100011110'\n#tt = time()\n#print tt\n\nMOD = 10**9 + 7\nUPPER = 22\n\nnumber = [ [0]*(N+1) for _ in xrange(N) ]\nfor i in xrange(N):\n for j in xrange(i+1, N+1):\n number[i][j] = min(22, int(S[i:j],2))\n\nmemo = [ [None]*(1<= UPPER: break\n ans += dp(j, mask | (1<<(num-1)))\n if ans >= MOD:\n ans %= MOD\n memo[i][mask] = ans\n return ans\n\nfans = i = 0\nwhile i < N:\n fans += dp(i, 0)\n fans %= MOD\n i += 1\nprint fans\n#print time()-tt\n\n\n\"\"\"\ndef good_mask(x):\n if x == 0: return False\n return (x+1) & x == 0\n\nN = rrI()\nS = rr()\n##print '.'\n#N = 75\n#import random\n#S = \"\".join(str(random.randint(0,1)) for _ in xrange(N))\nMOD = 10**9 + 7\nUPPER = 22\n\nmemoslide = {N : 0, N-1:0}\ndef slide(j):\n if j in memoslide:\n return memoslide[j]\n if S[j] == '1':\n memoslide[j] = 0\n return 0\n else:\n k = j\n while k < len(S) and S[k] == '0':\n k += 1\n memoslide[j] = k - j\n return k - j\n \nmemo = {}\ndef dp(i, mask):\n #Having made a cut already before position i,\n #and having a set of mask taken\n #how many ways?\n if i == N:\n return 1 if good_mask(mask) else 0\n if (i,mask) in memo:\n return memo[i,mask]\n ans = 1 if good_mask(mask) else 0\n for j in xrange(i+1, N+1):\n num = int(S[i:j], 2)\n if num == 0: continue\n if num >= UPPER: break\n if num > 8:\n #prune\n newmask = mask\n ii = excess = 0\n while newmask:\n if newmask%2 == 0:\n excess += len(bin(ii)) - 2\n ii += 1\n newmask /= 2\n if excess > N-j+1:\n break\n k = slide(j)\n newmask = mask | (1<<(num-1))\n bns = dp(j + k, newmask)\n for kk in xrange(k):\n memo[(j + kk, newmask)] = bns\n ans += (1+k) * bns\n\n if ans >= MOD:\n ans %= MOD\n memo[i, mask] = ans\n return ans\n\nfans = 0\nfor i in xrange(N):\n fans += dp(i, 0)\n if fans >= MOD:\n fans %= MOD\nprint fans\n\"\"\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d1108a5df8d31ce5f2e9b7ad472ad88", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "import sys\n\nd0 = [0,0,0,0,1,-1,0,1,-1,0,0]\n\ndef clucky(x):\n cnt = 0\n while x!=0:\n if x%10 in [4,7]: cnt+=1\n x/=10\n return cnt\n \ndef solve1(a,add):\n des = clucky(a)+add\n assert des>=0\n b = a+1\n step = 1\n nfree = 0\n while 1:\n while b%(step*10)==0: \n step*=10\n nfree+=1\n \n tmp = clucky(b/step)\n if tmp+nfree>=des and tmp<=des:\n res = int(str(b/step)+\"\".join(['0']*(nfree-(des-tmp)))+''.join(['4']*(des-tmp)))\n return res\n b+=step\n assert False\n \ndef solve(a,l):\n #print \"calling\",a,l\n if l==1:\n return solve1(a,0)\n\n #with large l, b and a has the same last digit\n res = solve(a/10,(a+l-1)/10-a/10+1)*10+a%10\n if l>=30: return res\n\n #otherwise, there might be more than 1 match:\n for b in range(10):\n if b==a%10: continue\n cur = clucky(a)\n match = True\n pos10 = []\n for i in range(1,min(l,20)):\n next = clucky(a+i)\n if (b+i)%10==0: pos10.append(next-cur)\n elif next-cur!=d0[(b+i)%10]:\n match = False\n break\n cur = next\n if match:\n assert len(pos10)<=1\n if len(pos10)==0:\n if b>a%10:\n res = min(res,a-a%10+b)\n else:\n res = min(res,solve(a/10,(a+l-1)/10-a/10+1)*10+b)\n else:\n delta = pos10[0]\n for b2 in range(9): #omiting b2=9\n if d0[b2+1]!=delta: continue\n bb = b2*10+b\n if bb>a%100 and clucky(bb)==clucky(a%100):\n res = min(res,a-a%100+bb)\n else:\n #print a,bb\n tmp = solve1(a/100,clucky(a%100)+clucky(bb))*100+bb\n #print tmp\n res = min(res,tmp)\n \n #print \"Result: \",a,l,res \n return res\n \nfi = sys.stdin\na,l = map(int,fi.readline().split())\nprint solve(a,l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5054266f2ee2079bacfb3917b6c93ae3", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "K = [0]*1000\n\nK[0] = 1\nfor i in range(1, 1000):\n K[i] = i*K[i-1]\n\nM = {}\n\ndef F(a,b):\n if a == 0 and b == 0:\n return 1\n if b == 0:\n return K[a]\n if (a,b) in M:\n return M[(a,b)]\n t = 0\n if a > 0:\n t += a*F(a-1,b)\n t += F(a,b-1)\n if b > 1:\n k = b-1\n for i in range(0,a+1):\n t += k*F(a-i,b-2)\n k *= (a-i)\n M[(a,b)] = t\n return t\n\nn = int(raw_input())\n\nd = [int(x) for x in raw_input().split(\" \")]\n\nx = 0\ny = 0\n\nfor i in range(n):\n if d[i] == 1:\n x += 1\n if d[i] == 2:\n y += 1\n\nprint F(y,x)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cdf55662e4a58086622f5bd1511d927", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "import sys\ndebug = False\ndef solve(a, b, c, d):\n #w=[a,b]\n #q=[c,d]\n #[q,p] in w\n #p?\n ind1 = 0\n ind2 = 0\n cnt1 = 1\n cnt2 = 0\n phases = []\n phases2 = []\n\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n if ind2 == len(c):\n #word finished!\n cnt2 += 1\n ind2 = 0\n #check phase\n if ind1 in phases:\n #period!\n cnt1_, cnt2_ = phases2[phases.index(ind1)]\n step1 = cnt1 - cnt1_\n step2 = cnt2 - cnt2_\n cnt = (b-cnt1)/step1\n cnt1 += step1 * cnt\n cnt2 += step2 * cnt\n phases = []\n phases2 = []\n #save phase\n phases.append(ind1)\n phases2.append([cnt1, cnt2])\n\n ind1 += 1\n if ind1 == len(a):\n cnt1 += 1\n ind1 = 0\n if cnt1 > b:\n return cnt2 / d\n #answ \n val2 = phases2[-1]\n val1 = phases2[phases.index(ind1)]\n\n step1 = val2[0] - val1[0]\n step2 = val2[1] - val1[1]\n \n if debug:\n print str(val1[0]) + \" -- > \" + str(val1[1])\n print str(val2[0]) + \" -- > \" + str(val2[1])\n\n res = step2 * b / (step1 * d)\n res = (b - val2[0]) * step2 / (step1 * d) + val2[1]\n if res < 0:\n return 0\n else:\n return res\n\nif not debug:\n b, d = map(int, sys.stdin.readline().split())\n \n a = sys.stdin.readline().split()[0]\n c = sys.stdin.readline().split()[0]\n print str(solve(a, b, c, d))\nelse:\n vals = []\n vals.append([841, 7, 'qjqhrksmvedtqldrqgchhsofokfcovut' ,'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc', 5])\n vals.append([933, 5, 'abaabdcbbabacbdddadbbb', 'babbadbaaadbbbbaabbaabccbbdbadbbbbbbdbcbdbaaadbdbdbbbbdcbbdcbdaadbd', 15])\n vals.append([875, 10, 'hjeaiemqfliohlicmhndhbfdmlmcnjjgbg', 'hojqhmbgjlfmlliimlhahfeihgmhhhnbmebhgnfhgmhfjqhmlnnddgmqldelnhebi', 4])\n vals.append([320672, 1, 'wyyojuothwmlvrglfzdzdbtubxuoffvncrswsaznmoijoi', 'ttvlvzxcvczuagwzgbfuwmmt', 40084])\n vals.append([5608475, 1, 'gbagadghfaedhddefgbehbbdedefbaaeddachgebhbcgahfdchffhbhfahhdegdhdfbccgefhcdhhcdfgdgfhcdffaacch', 'fgfadaaecdgabeahcacadcbfhhe', 1869491])\n vals.append([1263204, 1, 'dcbabceabbaebddaaecbddaceaedacddadadcbbadbdccdecdacdcaadbceeddccbceaade', 'abddbccbdca', 1894805])\n vals.append([100, 1, 'bca', 'abc', 99])\n vals.append([541, 9, 'bxhwcmunbdxcatppdsw', 'shbppncwbnsxxnxunwsbncpdchcbcspdcppdchmbbcuapphpdxbpcswcxpxpdscxpddbcppdxhpxbuxxdbpdpuudb', 1])\n vals.append([9447267, 1, 'cbdcbdbcdacbcabddbaabcbacbabcaacbabaccddcbbdbbaddcbcbaaadc', 'bbbbdbcbbbdbdbcdcacccbdcadadbacbcccc', 4723633])\n for val in vals:\n b, d, a, c, answer = val\n res = solve(a, b, c, d)\n if res == answer:\n print '++++++++++++++++++++++++++++'\n pass\n else:\n print '----------------------------'\n print val\n print res\n print '----------------------------'\n sys.stdin.readline()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea1887e9515ce8408bae4723f08270d1", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "dp=[0]*5010\ndp[0]=1\nn,m,k=map(int,input().split())\nt=998244353\nfor i in range(k):\n for j in range(len(dp)-1, -1, -1):\n if j==0:dp[j]=0\n else:dp[j]=(dp[j-1]*(n-j+1)+dp[j]*j)%t\nc=0\nfor i in range(k+1):\n c+=pow(m,max(n-i,0),t)*dp[i]\n c%=t\nden=pow(m,n,t)\nden=pow(den,t-2,t)\nprint((den*c)%t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "162cd38f168c03536b7a19c2b998fdae", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "import io, os\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\nM = 10 ** 9 + 7\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nz, o = a.count(0), a.count(1)\nd = pow(n * (n - 1) // 2, M - 2, M)\n\nres = [[0] * (z + 1) for i in range(z + 1)]\ntf = [[0] * (z + 1) for i in range(z + 1)]\nfor i in range(z + 1):\n res[i][i] = 1\n tf[i][i] = (z * (z - 1) // 2 + o * (o - 1) // 2 + i * (z - i) + (z - i) * (o - z + i)) * d % M\n if i < z: tf[i + 1][i] = (z - i) * (z - i) * d % M\n if i: tf[i - 1][i] = i * (o - z + i) * d % M\n\ndef mul(a, b):\n t = [[0] * (z + 1) for i in range(z + 1)]\n for i in range(z + 1):\n for k in range(z + 1):\n for j in range(z + 1):\n t[i][j] = (t[i][j] + a[i][k] * b[k][j]) % M\n return t\n\nwhile k:\n if k & 1:\n res = mul(res, tf)\n tf = mul(tf, tf)\n k >>= 1\n\nv = [0] * (z + 1)\nv[a[:z].count(0)] = 1\nprint(sum(x * y for x, y in zip(res[-1], v)) % M)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9bf1aa35acdd8d3e158b084452886018", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "import sys\n\nn=int(sys.stdin.readline().strip('\\n'))\nline=sys.stdin.readline().strip('\\n').split(' ')\nvalues=map(lambda x:int(x),line)\n\ndef evaluateBothSides(start,stop):\n print start,stop\n if stop-start==1:\n return min(values[start-1],values[stop])\n elif stop-start==0:\n return 0\n else: \n maxNum=0\n maxPos=0\n for i in xrange(start,stop):\n if values[i]>maxNum:\n maxPos=i\n maxNum=values[i]\n return evaluateBothSides(start,maxPos)+evaluateBothSides(maxPos+1,stop)+min(values[start-1],values[stop])\n\ndef evaluateMax(stop):\n 2+2\n\ndef evaluate(start,stop):\n 2+2\n \n\ndef addToQueue(inp,queue):\n out=0\n if inp<=queue[-1]:\n queue.append(inp)\n else:\n queue.pop()\n out+=inp\n while inp>queue[-1]:\n out+=queue.pop()\n queue.append(inp)\n return out\n\ndef queueEvaluate():\n maxLeft=0\n maxRight=0\n maxPos=0\n maxNum=0\n for i in xrange(0,n):\n if values[i]>maxNum:\n maxPos=i\n maxNum=values[i]\n out=0\n queue=[maxNum]\n for i in xrange(maxPos+1,n):\n out+=addToQueue(values[i],queue)\n #print queue\n if len(queue)==1:\n pass\n else:\n maxRight=queue[1]\n for i in xrange(2,len(queue)):\n out+=queue[i]\n queue=[maxNum]\n for i in xrange(maxPos-1,-1,-1):\n out+=addToQueue(values[i],queue)\n #print queue\n if len(queue)==1:\n pass\n else:\n maxLeft=queue[1]\n for i in xrange(2,len(queue)):\n out+=queue[i]\n out+=min(maxLeft,maxRight)\n return out\n\nprint queueEvaluate()\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2be7115095240321ef4a412a9b5d9111", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "b,r = [raw_input() for _ in xrange(6)],[]\ndef x(i,d,c='RL'): b[i]=b[i][-d:]+b[i][:-d];r.extend([c[d>3]+str(i+1)]*(d if d<3 else 6-d))\ndef y(i,d): global b;b=zip(*b);x(i,d,'DU');b=zip(*b)\ndef u(i,j): x(j,1);y(i,1);x(j,5);y(i,5)\ndef p(i,j): u(i,j);x((j+5)%6,1);u((i+1)%6,j);x((j+5)%6,5);u(i,j);u(i,j)\ndef l(i,j): p((i+1)%6,j);p((i+3)%6,j);x(j,1)\nfor k,c in enumerate(sorted(''.join(b))):\n ii,jj=k%6,k/6\n z = filter(lambda x: c in x, b)[0] \n i,j=z.index(c),b.index(z)\n while i!=ii: l(i,j); i=(i+5)%6\n while j>jj: u(ii,j); j-=1\nprint len(r)\nprint '\\n'.join(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bc90b7db64ab3a9bea607dcc36d1418", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "mod=10**9+7\nn,k=map(int,input().split())\n\nA=[0]*(n+1)\nB=[0]*(n+1)\nC=[0]*(n+1)\nF=[0]*(n+1)\nG=[0]*(n+1)\n\nF[0]=G[0]=1\nfor i in range(1,n+1):\n\tG[i]=F[i]=F[i-1]*i%mod\n\tG[i]=pow(F[i],(mod-2),mod)\n\nfor i in range(0,n):\n\tif i*2>n:\n\t\tbreak\n\tB[i]=(F[n-i]*G[i]*G[n-i*2])%mod\nfor i in range(0,n//2+1):\n\tfor j in range(0,n//2+1):\n\t\tA[i+j]=(A[i+j]+B[i]*B[j])%mod\nfor i in range(0,n+1):\n\tA[i]=A[i]*F[n-i]%mod\nfor i in range(0,n+1):\n\tfor j in range(0,i+1):\n\t\tC[j]=(C[j]+A[i]*F[i]*G[j]*G[i-j]*(1-(i-j)%2*2))%mod\nprint(C[k]%mod)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f42defe2f601a061f4a2e1e60b6f4fac", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "from collections import deque\ndef readarray(foo): return [foo(x) for x in raw_input().split()]\n\n\nstairs = []\nto = []\ncolor = []\ntotalcolors = 0\ndeg = []\npriority = []\n\nextrastairs = []\nextrastair = None\n\n\ndef doit():\n\tusedstairs = set()\n\tvisited = set([0])\n\tstack = []\n\tres = []\n\tnextcolor = 1\n\n\ts = 0\n\tif extrastair is not None:\n\t\t(s, stair) = extrastair\n\t\tvisited.add(s)\n\t\tusedstairs.add(stair)\n\t\tnextcolor += 1\n\t\tres.append([0])\n\t\tres.append([stair, 0, s])\n\t\n\thasnextcolor = totalcolors > nextcolor\n\tlayer = [s]\n\tstack.append([s, -1, -1, 0])\n\n\twhile stack:\n\t\t(u, source, parent, start) = state = stack[-1]\n\n\t\tnexti = None\n\t\tnexts = None\n\t\tnextv = None\n\t\tfor i in xrange(start, len(to[u])):\n\t\t\ts = to[u][i]\n\t\t\tif s == source: continue\n\t\t\tif s in usedstairs: continue\n\t\t\t(v1, v2) = stairs[s]\n\t\t\tv = v1 if v2 == u else v2\n\t\t\tif not hasnextcolor and v in visited: continue\n\t\t\tnexti = i\n\t\t\tnexts = s\n\t\t\tnextv = v\n\t\t\tbreak\n\n\t\tif nexti is None:\n\t\t\tif parent != -1:\n\t\t\t\tlayer.append(parent)\n\t\t\tstack.pop()\n\t\t\tcontinue\n\n\t\tif nextv not in visited:\n\t\t\tvisited.add(nextv)\n\t\t\tlayer.append(nextv)\n\t\t\tstate[3] = nexti\n\t\t\tstack.append([nextv, nexts, u, 0])\n\t\t\tcontinue\n\t\n\t\tusedstairs.add(nexts)\n\t\tnextv = priority[nextcolor]\n\t\tnextcolor += 1\n\t\thasnextcolor = totalcolors > nextcolor\n\n\t\tres.append(layer)\n\t\tres.append([nexts, u, nextv])\n\t\tlayer = [nextv]\n\t\tvisited.add(nextv)\n\t\t\n\t\tstate[3] = nexti + 1\n\t\tstack.append([nextv, nexts, u, 0])\n\n\tres.append(layer)\n\treturn res if not hasnextcolor else None\n\n\ndef colorize(s, c):\n\tif color[s] != -1: return\n\tglobal totalcolors\n\ttotalcolors += 1\n\tcolor[s] = c\n\tdeg[c] = 1\n\tq = deque()\n\tq.append(s)\n\tsource = {s : -1}\n\twhile q:\n\t\tu = q.popleft()\n\t\tfor stair in to[u]:\n\t\t\tif extrastair is not None and extrastair[1] == stair: continue\n\t\t\t(v1, v2) = stairs[stair]\n\t\t\tv = v1 if v2 == u else v2\n\t\t\tif color[v] != -1:\n\t\t\t\tif v != source[u]:\n\t\t\t\t\textrastairs.append(stair)\n\t\t\t\tcontinue\n\t\t\tcolor[v] = c\n\t\t\tsource[v] = u\n\t\t\tdeg[c] += 1\n\t\t\tq.append(v)\n\n\ndef findextrastair():\n\tif extrastairs: return (stairs[extrastairs[0]][0], extrastairs[0])\n\tfor u in xrange(len(to)):\n\t\tif len(to[u]) < 2: continue\n\t\treturn (u, to[u][0])\n\treturn None\n\ndef run():\n\tglobal to, color, deg, priority, extrastair, totalcolors\n\tn, m = readarray(int)\n\tto = [[] for i in xrange(n)]\n\tcolor = [-1] * n\n\tdeg = [0] * n\n\tfor i in xrange(m):\n\t\tu, v = sorted(readarray(lambda x: int(x) - 1))\n\t\tstairs.append((u, v))\n\t\tto[u].append(i)\n\t\tto[v].append(i)\n\tfor i in xrange(n):\n\t\tcolorize(i, i)\n\n\tif deg[0] == 1 and n > 1:\n\t\textrastair = findextrastair()\n\t\tif extrastair is None:\n\t\t\tprint \"NO\"\n\t\t\treturn\n\t\tcolor = [-1] * n\n\t\tdeg = [0] * n\n\t\ttotalcolors = 0\n\t\tfor i in xrange(n):\n\t\t\tcolorize(i, i)\n\t\tdeg[color[extrastair[0]]] = 100500\n\t\t\n\t\n\tdeg[0] = 100500\n\tpriority = sorted(range(n), lambda x, y: deg[y] - deg[x])[:totalcolors]\n\tres = doit()\n\tif res is None:\n\t\tprint \"NO\"\n\t\treturn\n\n\tprint \"YES\"\n\tprint len(res) / 2\n\tfor i, line in enumerate(res):\n\t\tif i % 2 == 0:\n\t\t\tprint len(line),\n\t\tprint \" \".join(map(lambda x: str(x + 1), line))\n\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "26e4c5f1ee8c8f6957d24947bcd7f088", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "PyPy 2", "source_code": "def do(i):\n if i == \"(\":\n return 1\n else:\n return -1\ndef find(i,idx):\n if i maxv:\n maxv = s[i]\n maxi = i\nnewv = arr[maxi:]+arr[:maxi]\nif sum(newv) != 0:\n print 0\n print 1,1\nelse:\n cnt = 0\n cnt1 = -1\n cnt2 = -1\n maxv1,maxv2 = 0,0\n l1,l2,r1,r2 = 0,0,0,0\n last1,last2 = 0,0\n st = 0\n for i in range(n):\n st += newv[i]\n if st == 0:\n cnt += 1\n cnt1 = -1\n last1 = i+1\n\n elif st == 1:\n cnt1 += 1\n if cnt1 > maxv1:\n maxv1 = cnt1\n l1 = last1\n r1 = i+1\n\n last2 = i+1\n cnt2 = -1\n elif st == 2:\n cnt2 += 1\n if cnt2 > maxv2:\n maxv2 = cnt2\n l2 = last2\n r2 = i+1\n if maxv1 == 0:\n print cnt\n print 1,1\n elif maxv1>maxv2+cnt:\n print maxv1+1\n print find(l1,maxi),find(r1,maxi)\n else:\n print maxv2+cnt+1\n print find(l2,maxi),find(r2,maxi)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "496e545f78917b454debbbf521dd9ae6", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "import array\n\np = 1000000007\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nm = int(input())\n\nd = array.array('i', 1 for _ in range(300001))\ntd = array.array('i', 0 for _ in range(300001))\nL = b[0]\nfor i in range(1, n):\n\tif a[i - 1] != 1:\n\t\tt = m % a[i - 1]\n\t\tif L < t:\n\t\t\tprint(0)\n\t\t\texit(0)\n\t\tm //= a[i - 1]\n\t\tfor j in range((L - t) // a[i - 1] + 1):\n\t\t\td[j] = d[t]\n\t\t\tt += a[i - 1]\n\t\tL = j\n\tk = 0\n\tfor j in range(L + b[i] + 1):\n\t\tif j <= L:\n\t\t\tk += d[j]\n\t\tk %= p\n\t\ttd[j] = k\n\t\tif j >= b[i]:\n\t\t\tk -= d[j - b[i]]\n\tL += b[i]\n\td, td = td, d\nprint(d[m] if m <= L else 0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82aa4474948b9318c0ae26215fbaa85c", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "Python 2", "source_code": "def print4(x):\n return '%s%s%s%s' % ( x/1000, (x/100)%10, (x/10)%10, x%10)\n\ndef printall(n,m,v):\n count = 0\n for i in range(1,10000):\n for j in v[(abs(n-i), 4)]:\n if count == m:\n return\n print '%s%s' % (print4(i), print4(j))\n count += 1\n\nv = {}\ne = {}\nfor i in range(10000):\n for j in range(1,5):\n e[(i,j)] = set()\n v[(i,j)] = set()\n\nfor i in range(10):\n e[(i,1)].add(i)\n v[(i,1)].add(i)\n\nfor i in range(0,100):\n e[(i,2)].add(i)\n v[(i,2)].add(i)\n d, u = i/10, i%10\n pos = [d+u, abs(d-u), d*u]\n for j in pos:\n e[(i, 2)].add(j)\n v[(j,2)].add(i)\n\nfor i in range(0,1000):\n e[(i,3)].add(i)\n v[(i,3)].add(i)\n cuts = []\n cuts.append(( (i/100, 1), (i%100, 2) ))\n cuts.append(( (i/10, 2), (i%10, 1) ))\n for one, two in cuts:\n pos = []\n for x in e[one]:\n for y in e[two]:\n pos.append(x+y)\n pos.append(x*y)\n pos.append(abs(x-y))\n pos = set(pos)\n for j in pos:\n e[(i, 3)].add(j)\n v[(j, 3)].add(i)\n\nfor i in range(0,10000):\n e[(i,4)].add(i)\n v[(i,4)].add(i)\n cuts = []\n cuts.append(( (i/1000, 1), (i%1000, 3) ))\n cuts.append(( (i/100, 2), (i%100, 2) ))\n cuts.append(( (i/10, 3), (i%10, 1) ))\n for one, two in cuts:\n pos = []\n for x in e[one]:\n for y in e[two]:\n pos.append(x+y)\n pos.append(x*y)\n pos.append(abs(x-y))\n pos = set(pos)\n for j in pos:\n e[(i, 4)].add(j)\n v[(j, 4)].add(i)\n\nn, m = map(int, raw_input().split())\nprintall(n,m,v)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64407895edb31fc4738bd7d242f1cf6b", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "import sys\n#sys.stdin = open('game.in', 'r')\n#sys.stdout = open('game.out', 'w')\n\nline = raw_input().split(' ')\nA, B, N = int(line[0]), int(line[1]), int(line[2])\nN -= 1\n\nnl = 0\nlist = [0]*100\nwhile 1 == 1:\n\tcurb = nl + 1\n\tle, ri = 1, N\n\twhile le < ri:\n\t\tcura = (le+ri+1)//2\n\t\tif (cura**curb <=N):\n\t\t\tle = cura\n\t\telse:\n\t\t\tri = cura-1;\n\tif (le > 1):\n\t\tnl += 1\n\t\tlist[nl] = le\n\telse:\n\t\tbreak\n\nwin = []\nfor i in range(50000):\n\twin.append([])\n\tfor j in range(50):\n\t\twin[i].append(-1);\n\t\t\ndef get(win, list, nl, a, b, n):\n\tif (a == 1) and (b > nl):\n\t\treturn 3\n\tif (a > list[b]):\n\t\treturn 1\n\tif (b == 1) and (a > list[2]):\n\t\tif ((a&1) != (n&1)):\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 2\n\tif (win[a][b] != -1):\n\t\treturn win[a][b]\n\tx, y = get(win, list, nl, a+1, b, n), get(win, list, nl, a, b+1, n)\n\tif (x == 2) and (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) and (y == 3):\n\t\twin[a][b] = 3\n\t\treturn 3\n\twin[a][b] = 2\n\treturn 2\n\nret = get(win, list, nl, A, B, N)\nif (ret == 1):\n\tprint \"Masha\"\nif (ret == 2):\n\tprint \"Stas\"\nif (ret == 3):\n\tprint \"Missing\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "01213712cae7e9ab86c227de5d595503", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def Solve(x,B):\n if(len(B)>X):\n return False\n if(x==len(L)):\n return True\n if(Form(L[x],B)):\n A=list(B)\n for e in range(len(B)):\n r=A[e]\n A[e]=L[x]\n if(Solve(x+1,tuple(A))):\n return True\n A[e]=r\n A+=[L[x]]\n if(Solve(x+1,tuple(A))):\n return True\n return False\n\ndef Form(x,B):\n for i in range(len(B)):\n for j in range(i,len(B)):\n if(B[i]+B[j]==x):\n return True\n return False\n \nn=int(input())\nL=list(map(int,input().split()))\ndone=False\nfor X in range(1,n+1):\n if(Solve(1,(L[0],))):\n print(X)\n done=True\n break\nif(not done):\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73cea2f2af81f83f493ec99102de174d", "src_uid": "359f5d1264ce16c5c5293fd59db95628", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n = int(input())\ndisjointSet = [-1] * n\ndef root(x):\n if disjointSet[x] < 0:\n return x\n disjointSet[x] = root(disjointSet[x])\n return disjointSet[x]\n\ndef join(x, y):\n r1, r2 = root(x), root(y)\n if r1 == r2:\n return\n disjointSet[r2] = r1\n\npoints = []\nvertPoints = {}\nhorizPoints = {}\nfor i in range(n):\n a, b = map(int, input().split())\n points.append((a, b))\n if a in vertPoints:\n join(i, vertPoints[a])\n else:\n vertPoints[a] = i\n if b in horizPoints:\n join(i, horizPoints[b])\n else:\n horizPoints[b] = i\n \nsets = {}\nfor i in range(n):\n r = root(i)\n if r in sets:\n sets[r].append(points[i])\n else:\n sets[r] = [points[i]]\n\nans = 1\nfor i in sets:\n s = sets[i]\n horiz = [x for x,y in s]\n vert = [y for x,y in s]\n tmp = len(set(horiz)) + len(set(vert))\n if tmp <= len(s):\n ans *= 2 ** tmp\n else:\n ans *= 2 ** tmp - 1\n\nprint(ans % (10 ** 9 + 7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd062d929abb459c9aaa102066659e2e", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "# by the authority of GOD author: manhar singh sachdev #\n\nimport os,sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter\n\ndef main():\n mod = 10**9+7\n r,g = map(int,input().split())\n n = 1\n while r+g >= (n*(n+1))//2:\n n += 1\n n -= 1\n tot = n*(n+1)//2\n dp = [0]*(tot+1)\n dp[0] = 1\n for i in range(1,n+1):\n for x in range(tot-i,-1,-1):\n dp[i+x] += dp[x]\n dp[i+x] %= mod\n ans = 0\n for i,val in enumerate(dp):\n if i <= r and tot-i <= g:\n ans += val\n ans %= mod\n print(ans)\n\n#Fast IO Region\nBUFSIZE = 8192\nclass FastIO(IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\n self.write = self.buffer.write if self.writable else None\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b\"\\n\") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n self.read = lambda: self.buffer.read().decode(\"ascii\")\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c904ca5637eab37f32e8e2b97c5c2d6d", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "PyPy 3-64", "source_code": "import os,sys\r\nfrom random import randint, shuffle\r\nfrom io import BytesIO, IOBase\r\n\r\nfrom collections import defaultdict,deque,Counter\r\nfrom bisect import bisect_left,bisect_right\r\nfrom heapq import heappush,heappop\r\nfrom functools import lru_cache\r\nfrom itertools import accumulate, permutations\r\nimport math\r\n\r\n# Fast IO Region\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n# x = 10 - n\r\n# print(x * (x - 1) * 3)\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# print(*([1] + list(range(2, n + 1))[::-1]))\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# s = input()\r\n# a = list(map(int, input().split()))\r\n# dp1 = [0] * n\r\n# dp2 = [0] * n\r\n# if s[0] == '1':\r\n# dp1[0] = a[0]\r\n# for i in range(1, n):\r\n# if s[i] == '1':\r\n# if s[i - 1] == '0':\r\n# dp1[i] = max(dp1[i - 1], dp2[i - 1]) + a[i]\r\n# dp2[i] = max(dp1[i - 1], dp2[i - 1]) + a[i - 1]\r\n# else:\r\n# dp1[i] = max(dp1[i - 1], dp2[i - 1]) + a[i]\r\n# dp2[i] = dp2[i - 1] + a[i - 1]\r\n# else:\r\n# dp1[i] = dp2[i] = max(dp1[i - 1], dp2[i - 1])\r\n# print(max(max(dp1), max(dp2)))\r\n\r\n# def solve():\r\n# n = int(input())\r\n# s = list(input())\r\n# j = 0\r\n# while j < n and s[j] == '0':\r\n# j += 1\r\n# if j == n:\r\n# print(0)\r\n# return\r\n# s = s[j:]\r\n# n = len(s)\r\n# j = 0\r\n# while j < n and s[j] == '1':\r\n# j += 1\r\n# ans = s[:]\r\n# for i in range(j + 1):\r\n# b = s[:j]\r\n# for k in range(n - j):\r\n# if s[i + k] == s[j + k] == '0':\r\n# b.append('0')\r\n# else:\r\n# b.append('1')\r\n# ans = max(ans, b)\r\n# print(''.join(ans))\r\n# solve()\r\n\r\ndef solve():\r\n p1, t1 = list(map(int, input().split()))\r\n p2, t2 = list(map(int, input().split()))\r\n h, s = list(map(int, input().split()))\r\n if t1 == t2:\r\n x = p1 + p2 - s\r\n print((h + x - 1) // x * t1)\r\n return\r\n if t1 > t2:\r\n p1, t1, p2, t2 = p2, t2, p1, t1\r\n # need = (h + p1 - s - 1) // (p1 - s) * t1\r\n # if need <= t2:\r\n # print(need)\r\n # return\r\n d = {}\r\n x1, x2, x3 = p1 - s, p2 - s, p1 + p2 - s\r\n d[x1] = t1\r\n d[x2] = t2\r\n a = [i * t1 for i in range(5050)]\r\n for i in range(1, 5001):\r\n j = bisect_left(a, i * t2)\r\n x = x1 * (j - 1 - 1) + x2 * (i - 1) + x3\r\n t = max(t1 * (j - 1), t2 * i)\r\n if x not in d:\r\n d[x] = t\r\n else:\r\n d[x] = max(d[x], t)\r\n x = x1 * (j - 1) + x2 * (i - 1) + x3\r\n t = max(t1 * j, t2 * i)\r\n if x not in d:\r\n d[x] = t\r\n else:\r\n d[x] = max(d[x], t)\r\n # for i in range(1, 5001):\r\n # for j in range(1, 5001):\r\n # k = max(t1 * i, t2 * j)\r\n # x = x1 * (i - 1) + x2 * (j - 1) + x3\r\n # if k > 10000: continue\r\n # if x not in d:\r\n # d[x] = k\r\n # else:\r\n # d[x] = max(d[x], k)\r\n dp = [float('inf')] * (10001)\r\n dp[0] = 0\r\n for i in range(1, 10001):\r\n for j in range(i):\r\n if i - j in d:\r\n dp[i] = min(dp[i], dp[j] + d[i - j])\r\n ans = min(dp[h:])\r\n print(ans)\r\nsolve()\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ca2c8e40cc9edc3b560ae4daa1850d8", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "__author__ = 'Darren'\n\n\ndef solve():\n\n def find_ways(t, n, h):\n if t == breaks and n == total:\n return 1\n if t > breaks or n == total:\n return 0\n if (t, n, h) not in dp:\n result = 0\n if t % 2 == 0:\n for i in range(h+1, 5):\n result += find_ways(t, n+1, i)\n for i in range(1, h):\n result += find_ways(t+1, n+1, i)\n else:\n for i in range(h+1, 5):\n result += find_ways(t+1, n+1, i)\n for i in range(1, h):\n result += find_ways(t, n+1, i)\n dp[(t, n, h)] = result\n return dp[(t, n, h)]\n\n total, humps = map(int, input().split())\n breaks = 2 * humps - 1\n dp = {}\n ans = 0\n for i in range(2, 5):\n ans += (i - 1) * find_ways(0, 2, i)\n print(ans)\n\n\nif __name__ == '__main__':\n solve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1081a8049453a29f43bad3d6cff96ab6", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nfrom collections import deque\n\nPl, Pr, Vl, Vr, k = map(int,raw_input().strip().split())\n\nq = deque()\nlucky = []\nq.append(0)\nlucky.append(0)\nwhile (len(q)):\n\tfront = q.popleft()\n\tx = front*10+4\n\ty = x+3\n\tif (x<=10000000000):\n\t\tq.append(x)\n\t\tlucky.append(x)\n\tif (y<=10000000000):\n\t\tq.append(y)\n\t\tlucky.append(y)\n\t\nminl = min(Pl,Vl)\nmaxr = max(Pr,Vr)\n\nmini = maxi = -1 \nfor i in xrange(len(lucky)):\n\tif lucky[i] >= minl:\n\t\tmini = i\n\t\tbreak\n\nfor i in xrange(len(lucky)-1,0,-1):\n\tif lucky[i] <= maxr:\n\t\tmaxi = i\n\t\tbreak\n\ndef intersect(x1,y1,x2,y2): \n\tif x1>y2 or x2>y1:\n\t\treturn (1,0) \n\telse:\n\t\treturn (max(x1,x2),min(y1,y2))\n\t\nres = 0.0\ninv = 1.0/(Pr-Pl+1)/(Vr-Vl+1)\nfor i in xrange(mini,maxi-k+2):\n\tleft = lucky[i]\n\tright = lucky[i+k-1]\n\tpl = intersect(Pl, Pr,lucky[i-1]+1,lucky[i])\n\tpr = intersect(Pl, Pr, lucky[i+k-1], lucky[i+k]-1)\n\tvl = intersect(Vl,Vr, lucky[i-1]+1,lucky[i])\n\tvr = intersect(Vl, Vr, lucky[i+k-1], lucky[i+k]-1)\n\ts = (pl[1]-pl[0]+1)*(vr[1]-vr[0]+1) + (vl[1]-vl[0]+1)*(pl[1]-pl[0]+1)\n\tif (k == 1 and (pl[0] == vr[1] or pr[1] == vl[0])):\n\t\ts = s-1\n\tres += inv*s\n\nprint \"%.9f\"%res\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\n\n\t\t\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f253a60f7488019b4b39d9f5aa0669d", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "MOD = 1000000007\n\n\ndef isSubset(a, b):\n\treturn (a & b) == a\n\n\ndef isIntersect(a, b):\n\treturn (a & b) != 0\n\n\n# Solve for each weakly connected component (WCC)\ndef cntOrder(s, t):\n\tp = len(s)\n\tm = len(t)\n\n\tinMask = [0 for i in range(m)]\n\n\tfor x in range(p):\n\t\tfor i in range(m):\n\t\t\tif t[i] % s[x] == 0:\n\t\t\t\tinMask[i] |= 1 << x\n\n\tcnt = [0 for mask in range(1< 0:\n\t\t\t\tsz = len(t) - 1\n\t\t\t\tcnt = cntOrder(s, t)\n\n\t\t\t\t# Number of orders for current WCC\n\t\t\t\tans = (ans * cnt) % MOD\n\t\t\t\t# Number of ways to insert number to array of elements\n\t\t\t\tans = (ans * c[curLen + sz][sz]) % MOD\n\t\t\t\tcurLen += sz\t\t\n\n\tprint(ans)\n\nif __name__ == \"__main__\":\n\tmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "863d5cc8d43b7bb6c9e68f71d1bc1d9c", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "Python 3", "source_code": "for i in range(int(input())):\n a=list(map(int,input().split()))\n mx=max(list(map(abs,a)))\n std=(sum(list(map(lambda x:x*x,a)))/len(a))**0.5\n print('poisson'if mx/std>2 else'uniform')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9b7bacadc2d667e073860cbe1c1d449d", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353 \n\nimport __pypy__\nmodmul = __pypy__.intop.int_mulmod\nmo = lambda a,b: modmul(a,b,MOD)\npo = lambda a,b: pow(a,b,MOD)\n\nbig = 10**6 + 10\nmodinv = [1]*big\nfor i in range(2,big):\n modinv[i] = mo(-(MOD//i), modinv[MOD%i])\n\nfac = [1]\nfor i in range(1,big):\n fac.append(mo(fac[-1], i))\n\ninvfac = [1]\nfor i in range(1,big):\n invfac.append(mo(invfac[-1], modinv[i]))\n\ndef choose(n,k):\n return mo(mo(fac[n], invfac[k]), invfac[n-k])\n\ndef par(x):\n return -1 if x & 1 else 1\n\nn = int(input())\n\nans = 0\nfor i in range(1, n + 1):\n base = -po(3, n - i)\n tmp = po(base + 1, n) - po(base, n)\n ans += par(i + 1 + n) * mo(choose(n, i), tmp)\n\nextra = 0\nfor i in range(1, n + 1):\n extra += par(i + 1) * mo(choose(n, i), po(3, n * (n - i) + i))\nprint (3 * ans + 2 * extra) % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0dfa2cd0378199ad4e1e453ca5d7b0d4", "src_uid": "6e4b0ee2e1406041a961582ead299a3a", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "mod = 1000000007\ndef power(a, p):\n res = 1\n while p > 0:\n if p % 2 == 1:\n res = (res * a) % mod\n a = (a * a) % mod\n p //= 2\n return res\nn, m = map(int, input().split())\nn += 1\nres = (power(n * 2, m))*(n-m)/n\nres = res % mod\nprint(int(res))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "be21f9f8ef0032710baf9d5629797e68", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3\n'''\nCreated on 13/09/2018\n\n@author: ernesto\n'''\n\nn, m = [int(x) for x in input().strip().split(\" \")]\n\nposibles_jefes = set(range(1, n + 1))\nanteriores = set()\nposteriores = set()\ncontinuos = [True] * (n + 1)\nmencionados = set()\nposibles_jefes_mencionados = set()\nultimo_en_salir = [True] * (n + 1)\nultima_salida_inesperada = None\n\nops = []\n\nif(m > 1):\n for _ in range(0, m):\n s, n_s = [x for x in input().strip().split(\" \")]\n n = int(n_s)\n ops.append((s, n))\n for i in range(0, m):\n op, num = ops[i]\n cont = False\n if op == '+':\n cont = not i or (ops[i - 1][0] == '-' and ops[i - 1][1] == num)\n posteriores.add(num)\n if op == '-':\n cont = i == m - 1 or (ops[i + 1][0] == '+' and ops[i + 1][1] == num)\n if num not in mencionados:\n anteriores.add(num)\n ultima_salida_inesperada = num\n posteriores.discard(num)\n ultimo_en_salir[num] &= not posteriores\n continuos[num] &= cont \n mencionados.add(num)\n# print(\"anteriores {} posteriores {} continuos {} ops {}\".format(anteriores, posteriores, continuos, ops))\n if not anteriores and not posteriores:\n assert ultima_salida_inesperada is None\n if ops[0][0] == '+' and ops[-1][0] == '-' and ops[0][1] == ops[-1][1] and continuos[ops[0][1]] and ultimo_en_salir[ops[0][1]]:\n posibles_jefes_mencionados.add(ops[0][1])\n else:\n if not posteriores:\n assert ultima_salida_inesperada is not None\n posibles_jefes_filtrados = list(filter(lambda x:continuos[x] and ultimo_en_salir[x] and ultima_salida_inesperada == x, anteriores))\n assert len(posibles_jefes_filtrados) == 1\n assert posibles_jefes_filtrados[0] == ops[-1][1]\n posibles_jefes_mencionados.add(ops[-1][1])\n else:\n if not anteriores:\n assert ultima_salida_inesperada is None\n posibles_jefes_filtrados = list(filter(lambda x:continuos[x] and ultimo_en_salir[x], posteriores))\n assert len(posibles_jefes_filtrados) == 1\n assert posibles_jefes_filtrados[0] == ops[0][1]\n else:\n assert ultima_salida_inesperada is not None\n posibles_jefes_mencionados = set(filter(lambda x:ultimo_en_salir[x] and ultima_salida_inesperada == x, anteriores & posteriores))\n\n# print(\"posibles jefes menc {}\".format(posibles_jefes_mencionados))\n posibles_jefes -= (mencionados - posibles_jefes_mencionados)\n \nprint(len(posibles_jefes))\nif(len(posibles_jefes)):\n print(\" \".join(map(str, sorted(posibles_jefes))))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9a07735edb1db1348bca6970328c699d", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import sys\n#input=sys.stdin.readline\ndp={}\nmod=int(1000000007)\nsys.setrecursionlimit(100000)\ndef bigmod(n,p):\n p=int(p)\n if p==0:\n return 1\n x=bigmod(n,p/2)\n x=(x*x)%mod\n if p%2==1:\n x=(x*n)%mod\n return x\nk,pa,pb=map(int,input().split())\nr=bigmod(pa+pb,mod-2)\nr1=bigmod(pb,mod-2)\nr1=(pa*r1)%mod\np=(pa*r)%mod\nq=(pb*r)%mod\n\n\n\ndef cal(k1,a1):\n if k1+a1>=k:\n return (k1+a1+r1)%mod\n if (k1,a1) in dp:\n return dp[(k1,a1)]\n dp[(k1,a1)]=((cal(k1+a1,a1)*q)%mod+(cal(k1,a1+1)*p)%mod)%mod\n return dp[(k1,a1)]\n\nprint(cal(0,1))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "43186860c5c75ab409ccf9796a9d90bb", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0}