{"lang": "Python 3", "source_code": "def binarysearch(sequence, value):\n lo, hi ,mid= 0, 1000,0\n while lo < hi:\n\n mid=(lo+hi)//2\n\n if sequence[mid]<=value and sequence[mid+1]>value:\n return a[mid]\n elif sequence[mid]>value:\n hi=mid\n elif sequence[mid]side:\n print(ans+4)\nelif left:\n print(ans+2)\nelse:\n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "993bd95cb9fa15d6b1c84755a0810626", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = input()\nside = int(ceil(n**0.5))\nif side*(side-1)>n:\n print 4*side\nelse:\n print 4*side-2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "37b97df72b483094ece24f9d24a0195b", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\nn =int(input())\n\ndef sqq(n):\n m = math.floor(math.sqrt(n))\n for i in range(max(0,m-10), 20):\n if i*i > n:\n return i-1\n\n\nm = sqq(n)\n \nif (n == m*m):\n print(4*m)\nelif n<= m*(m+1):\n print(2*(m+m+1))\nelse:\n print(4*(m+1))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0716bd3cc6c2ebce1385de92485b2216", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\nsqr_lnt = math.floor(math.sqrt(n))\nsqr_parameter = 4*sqr_lnt\n#4\n# 4print(sqr_parameter)\nres = n - (sqr_lnt**2)\n\nif res > sqr_lnt:\n res1 = res - sqr_lnt\n current_parameter = 2*(sqr_lnt+(sqr_lnt+1))\n new_parameter = 2*(res1 + 1) - 2*(res1)\n fin_parameter = current_parameter+ new_parameter \nelif res == 0:\n fin_parameter = 4*(sqr_lnt)\nelif res < sqr_lnt:\n newer_parameter = 2*(res+1) - 2*(res)\n fin_parameter = sqr_parameter + newer_parameter\n\n\nprint(fin_parameter)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6280261ceab0050d4777fa21d6b6ae10", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nans = float(\"+inf\")\nfor i in range(1, n+1):\n for j in range(i, n+1):\n if i*j >= n:\n ans = min(ans, (i+j)*2)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d05edd7988cc39441c22f8ff6fa688f", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "\n\n\ndef main():\n adult = int(raw_input(''))\n child = int(raw_input(''))\n if adult == 0 :\n print \"impossible\"\n else:\n if adult < child :\n print child\n else:\n print adult\n \n print adult + child -1\n\n \n \n\n\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a693a743fa0a840a7e39b6357b03ed11", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n\n\ndef main(): \n inputline = raw_input()\n spline = inputline.split(' ')\n adult = int(spline[0])\n child = int(spline[1])\n if adult == 0 :\n print \"impossible\"\n else:\n if adult < child :\n minimum = child\n else:\n minimum = adult\n \n maximun = adult + child -1\n print str(minimum) + ' ' + str(maximum)\n\n \n \n\n\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b8e946c55ab321c17892002bf97a86c", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n,m=map(int, raw_input().split())\nif n==0: print 'Impossible';eixt()\nprint m,n-1+m", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8d203402987c54a9770ec43ddb6dbfe", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n\n\ndef main():\n adult = int(raw_input())\n child = int(raw_input())\n if adult == 0 :\n print \"impossible\"\n else:\n if adult < child :\n print child\n else:\n print adult\n \n print adult + child -1\n\n \n \n\n\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f5587d954d32863362f016ee3c31487b", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nk=int(input())\np=0\nl=0\nm=0\nif n==0:\n print('Impossible')\nelse:\n if n>=k:\n m=n-k\n print(m+n)\n else:\n m=k-n\n print(m+n)\n l=n+k-1\n print(l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e01bf8cf9baff61091415da03b17b059", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\ufeff#!/usr/bin/python\n\nimport sys, os\nsys.setrecursionlimit(10000)\n\ndef readrow():\n\treturn sys.stdin.readline().strip().split(' ')\n\ndef iscomfortable(a, b):\n\treturn (a - b) in [-3, -2, -1, 0, 1]\n(al, ar) = map(int, readrow())\n(bl, br) = map(int, readrow())\n\nif iscomfortable(al, br) or iscomfortable(ar, bl):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c1ec51ca4dc433bfc2f07f04f0fc79b", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "a1, a2 = map(int, raw_input().split())\nb1, b2 = map(int, raw_input().split())\n\nif abs(b2 - a1) <= 1: print \"YES\"\nelif abs(b1 - a2) <= 1: print \"YES\"\nelse: print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3935ad7aa2e53db2929a8bff8b24ec11", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import sys,math\ngl,gr=map(int,sys.stdin.readline().strip().split(' '))\nbl,br=map(int,sys.stdin.readline().strip().split(' '))\nif abs(gl-br)<=1 or abs(bl-gr)<=1:\n print 'YES'\nelse:\n print 'NO'\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3db7a30d7a83beefe5916d62e43da762", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.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 if b[0]-a[1]>=3 and b[1]-a[0]>=3:\n print 'NO'\n elif a[0]-b[1]>=2 and a[1]-b[0]>=2:\n print 'NO'\n else:\n print 'YES'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "12bae6fc0a3f8eb3369f15b37900a13b", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from sys import stdin\n\nin_lines = \"\"\nin_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\n#print lines\nal, ar = lines[0]\nbl, br = lines[1]\ndef good( a, b ) :\n return ( b >= a - 1 ) and ( a >= b / 2 - 1 )\n\nif good( al, br ) or good( ar, bl ) :\n print \"YES\"\nelse :\n print \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db3904c81da7744e98082790d40a3556", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a=[int(i) for I in input().split()]\nfor j in range(0,len(a)):\n x=a[i]\n if count(x)>1:\n a.pop(i)\nprint(a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c445771733beda224f21c618ea886c1d", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nl1=[]\nfor i in l:\n if i not in l1:\n l1.append(i)\nfor i in l1:\n print(l1[i],end=\" \") ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee752fb2b6d7500adcecc5b358d26e46", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nsr=input()\nsr=sr[::-1]\nfinal=list()\nfor i in sr:\n i=int(i)\n if i not in final:\n final.append(i)\ncount=0\n#final=list(set(z))\nprint(final)\n#final.sort(reverse=True)\nfor i in final:\n count=count+1\nprint(count)\nfinal.reverse()\nfor i in final:\n print(i,end=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b262d5c0fc0484a4af3ee9a452d7a95", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\ninput = sys.stdin.readline\nimport numpy as np \n\n\n\nlength = int(input())\narr = list(map(int,input().split()))\n\nunique_list = []\nfor x in arr: \n if x not in unique_list: \n unique_list.append(x)\nprint(len(unique_list))\nprint(*unique_list)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "201ed2db098914f0c611f22313303ff6", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "class Solution:\n def remove(self,a):\n b = []\n i = len(a)-1\n n = len(a)\n while i >= 0:\n if a[i] not in b:\n b.append(a[i])\n i = i - 1\n return b\ndef printc(x):\n i = len(x) - 1\n while i >= 0:\n print (x[i])\n i = i - i\nx = input()\na = [int(x) for x in input().split()]\nt = Solution()\nprintc(t.remove(a))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4ac4c8b6ab859e182148812795534e62", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nif n == 1:\n s = 'one'\n print s\nif n== 2 :\n s = 'two'\n print s\nif n == 3:\n s = 'three'\n print s\nif n == 4:\n s = 'four'\n print s\nif n == 5:\n s ='five'\n print s\nif n == 6:\n s = 'six'\n print s\nif n == 7:\n s = 'seven'\n print s\nif n == 8:\n s = 'eight'\n print s\nif n == 9:\n s = 'nine'\n print s\nif n == 10:\n s = 'ten'\n print s\n\n \nif n == 11:\n s = 'eleven'\n print s\nif n== 12 :\n s = 'twelve'\n print s\nif n == 13:\n s = 'thirteen'\n print s\nif n == 14:\n s = 'fourteen'\n print s\nif n == 15:\n s ='fifteen'\n print s\nif n == 16:\n s = 'sixteen'\n print s\nif n == 17:\n s = 'seventeen'\n print s\nif n == 18:\n s = 'eighteen'\n print s\nif n == 19:\n s = 'nineteen'\n print s\nif n == 20:\n s = 'twenty'\n print s\n\n \nif n == 21:\n s = 'twenty-one'\n print s\nif n== 22 :\n s = 'twenty-two'\n print s\nif n == 23:\n s = 'twenty-three'\n print s\nif n == 24:\n s = 'twenty-four'\n print s\nif n == 25:\n s ='twenty-five'\n print s\nif n == 26:\n s = 'twenty-six'\n print s\nif n == 27:\n s = 'twenty-seven'\n print s\nif n == 28:\n s = 'twenty-eight'\n print s\nif n == 29:\n s = 'twenty-nine'\n print s\nif n == 30:\n s = 'thirty'\n print s\n \nif n == 31:\n s = 'thirty-one'\n print s\nif n== 32 :\n s = 'thirty-two'\n print s\nif n == 33:\n s = 'thirty-three'\n print s\nif n == 34:\n s = 'thirty-four'\n print s\nif n == 35:\n s ='thirty-five'\n print s\nif n == 36:\n s = 'thirty-six'\n print s\nif n == 37:\n s = 'thirty-seven'\n print s\nif n == 38:\n s = 'thirty-eight'\n print s\nif n == 39:\n s = 'thirty-nine'\n print s\nif n == 40:\n s = 'forty'\n print s\nif n == 41:\n s = 'forty-one'\n print s\nif n== 42 :\n s = 'forty-two'\n print s\nif n == 43:\n s = 'forty-three'\n print s\nif n == 44:\n s = 'forty-four'\n print s\nif n == 45:\n s ='forty-five'\n print s\nif n == 46:\n s = 'forty-six'\n print s\nif n == 47:\n s = 'forty-seven'\n print s\nif n == 48:\n s = 'forty-eight'\n print s\nif n == 49:\n s = 'forty-nine'\n print s\nif n == 50:\n s = 'fifty'\n print s\nif n == 51:\n s = 'fifty-one'\n print s\nif n== 52 :\n s = 'fifty-two'\n print s\nif n == 53:\n s = 'fifty-three'\n print s\nif n == 54:\n s = 'fifty-four'\n print s\nif n == 55:\n s ='fifty-five'\n print s\nif n == 56:\n s = 'fifty-six'\n print s\nif n == 57:\n s = 'fifty-seven'\n print s\nif n == 58:\n s = 'fifty-eight'\n print s\nif n == 59:\n s = 'fifty-nine'\n print s\nif n == 60:\n s = 'sixty'\n print s\nif n == 61:\n s = 'sixty-one'\n print s\nif n== 62 :\n s = 'sixty-two'\n print s\nif n == 63:\n s = 'sixty-three'\n print s\nif n == 64:\n s = 'sixty-four'\n print s\nif n == 65:\n s ='sixty-five'\n print s\nif n == 66:\n s = 'sixty-six'\n print s\nif n == 67:\n s = 'sixty-seven'\n print s\nif n == 68:\n s = 'sixty-eight'\n print s\nif n == 69:\n s = 'sixty-nine'\n print s\nif n == 70:\n print \"seventy\"\nif n == 71:\n s = 'seventy-one'\n print s\nif n== 72 :\n s = 'seventy-two'\n print s\nif n == 73:\n s = 'seventy-three'\n print s\nif n == 74:\n s = 'seventy-four'\n print s\nif n == 75:\n s ='seventy-five'\n print s\nif n == 76:\n s = 'seventy-six'\n print s\nif n == 77:\n s = 'seventy-seven'\n print s\nif n == 78:\n s = 'seventy-eight'\n print s\nif n == 79:\n s = 'seventy-nine'\n print s\nif n == 80:\n s = 'eighty'\n print s\n\nif n == 81:\n s = 'eighty-one'\n print s\nif n== 82 :\n s = 'eighty-two'\n print s\nif n == 83:\n s = 'eighty-three'\n print s\nif n == 84:\n s = 'eighty-four'\n print s\nif n == 85:\n s ='eighty-five'\n print s\nif n == 86:\n s = 'eighty-six'\n print s\nif n == 87:\n s = 'eighty-seven'\n print s\nif n == 88:\n s = 'eighty-eight'\n print s\nif n == 89:\n s = 'eighty-nine'\n print s\nif n == 90:\n s = 'ninety'\n print s\nif n == 91:\n s = 'ninety-one'\n print s\nif n== 92 :\n s = 'ninety-two'\n print s\nif n == 93:\n s = 'ninety-three'\n print s\nif n == 94:\n s = 'ninety-four'\n print s\nif n == 95:\n s ='ninety-five'\n print s\nif n == 96:\n s = 'ninety-six'\n print s\nif n == 97:\n s = 'ninety-seven'\n print s\nif n == 98:\n s = 'ninety-eight'\n print s\nif n == 99:\n s = 'ninety-nine'\n print s\n\n\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a666e77a1cd34b6f54ce665d06d5d53e", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "table20 = \"\"\"zero\none\ntwo\nthree\nfor\nfive\nsix\nseven\neight\nnine\nten\neleven\ntwelve\nthirteen\nfourteen\nfifteen\nsixteen\nseventeen\neighteen\nnineteen\ntwenty\n\"\"\"\ntable100 = \"\"\"\n\ntwenty\nthirty\nforty\nfifty\nsixty\nseventy\neighty\nninety\n\"\"\"\n\nN = int(raw_input())\nif N <= 20:\n\tprint table20.split(\"\\n\")[N]\nelse:\n\tif N % 10 == 0:\n\t\tprint table100.split(\"\\n\")[N / 10]\n\telse:\n\t\tprint table100.split(\"\\n\")[N / 10] + \"-\" + table20.split(\"\\n\")[N % 10]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c6ec907a071851af21b0a7e75031f925", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "# -*- coding: utf-8 -*- \nimport itertools, math, random, re, string, sys\nfrom bisect import *\nfrom collections import *\nfrom decimal import *\nfrom fractions import *\nfrom itertools import combinations, permutations, product\nfrom math import ceil, exp, log, sqrt\nfrom Queue import *\ngetcontext().prec = 100\nsys.setrecursionlimit(100000)\nMOD = 10 ** 9 + 7\nINF = float('+inf')\n\ndef compose(x):\n digits = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']\n eleven_to_twenty = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n decades = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n if x < 1000:\n if x < 100:\n if x < 20:\n if x <= 10:\n return digits[x]\n else:\n return eleven_to_twenty[x - 10]\n else:\n\t\tif x % 10 != 0:\n\t\t return decades[x / 10] + '-' + digits[x % 10]\n\t\telse:\n\t\t return decades[x / 10]\n else:\n return digits[x / 100] + 'hundredand' + compose(x % 100)\n else:\n return 'onethousand' + compose(x % 1000)\n\ns = input()\na = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nb = ['', 'twenty', 'thirty', 'fourty', 'five', 'six', 'seven', 'eight', 'nine']\n\nprint compose(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa6cff027d201546d6964def85a790c8", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "def digit(n):\n\tdigits = dict()\n\tdigits[1]=('one',)\n\tdigits[2]=('two','twen')\n\tdigits[3]=('three','thir')\n\tdigits[4]=('four','for')\n\tdigits[5]=('five','fif')\n\tdigits[6]=('six','six')\n\tdigits[7]=('seven','seven')\n\tdigits[8]=('eight','eigh')\n\tdigits[9]=('nine','nine')\n\tdigits[10]=('ten',)\n\tdigits[11]=('eleven',)\n\tdigits[12]=('twelve',)\n\n\tif n <= 12:\n\t\treturn str(digits[n][0])\n\telse:\n\t\tn1 = n/10\n\t\tn2 = n%10\n\t\tif n1 < 2:\n\t\t\treturn str(digits[n2][1]) + 'teen'\n\t\telif n2 < 1:\n\t\t\treturn str(digits[n1][1]) + 'ty'\n\t\telse:\n\t\t\treturn str(digits[n1][1]) + 'ty-' + str(digits[n2][0]) \n\nn = int(raw_input())\nprint digit(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ebc2702c0491c8cab8b2fe3554c24b15", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "FIRST_TEN = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\",\"eight\", \"nine\"]\nSECOND_TEN = [\"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\",\"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\nOTHER_TENS = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\",\"eighty\", \"ninety\"]\nHUNDRED = \"hundred\"\n\ns = int(input())\n\ndef checkio(number):\n l = len(str(number))\n k = 10 ** (l-1)\n if l == 0 or number == 0:\n return \"\"\n elif l == 1:\n return FIRST_TEN[number-1]\n elif l == 2:\n if number >=10 and number < 20:\n return SECOND_TEN[number-10]\n else:\n a = number // k - 2\n s = \"-\" if number%k > 0 else \"\"\n return OTHER_TENS[a] + s + checkio(number%k)\n elif l == 3:\n a = number // k # first number\n s = \"-\" if number%k > 0 else \"\"\n return FIRST_TEN[a-1] + \"-\" + HUNDRED + s + checkio(number%k)\n\n\n\nprint(checkio(s))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5866adfe4f679104000f2a81ab816da2", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import sys\r\n\r\n# sys.setrecursionlimit(200005)\r\nint1 = lambda x: int(x)-1\r\npDB = lambda *x: print(*x, end=\"\\n\", file=sys.stderr)\r\np2D = lambda x: print(*x, sep=\"\\n\", end=\"\\n\\n\", file=sys.stderr)\r\ndef II(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\ndef LI1(): return list(map(int1, sys.stdin.readline().split()))\r\ndef LLI1(rows_number): return [LI1() for _ in range(rows_number)]\r\ndef SI(): return sys.stdin.readline().rstrip()\r\n# inf = 18446744073709551615\r\ninf = 4294967295\r\n# md = 10**9+7\r\nmd = 998244353\r\n\r\ndef ok(s, t):\r\n f = t.find(s)\r\n if f == -1: return False\r\n for i in range(f):\r\n if t[i] == \"0\": return False\r\n for i in range(f+len(s), len(t)):\r\n if t[i] == \"0\": return False\r\n return True\r\n\r\nx, y = LI()\r\n\r\ns1 = bin(x)[2:]+\"1\"\r\nwhile x & 1 == 0: x >>= 1\r\ns0 = bin(x)[2:]\r\nt = bin(y)[2:]\r\n# print(s0, s1)\r\n# print(t)\r\n\r\nif ok(s0, t):\r\n print(\"YES\")\r\n exit()\r\n\r\nif ok(s1, t):\r\n print(\"YES\")\r\n exit()\r\n\r\nif ok(s0[::-1], t):\r\n print(\"YES\")\r\n exit()\r\n\r\nif ok(s1[::-1], t):\r\n print(\"YES\")\r\n exit()\r\n\r\nprint(\"NO\")\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fc2543df7372c26a285838eef57aa412", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import os,sys;from io import BytesIO, IOBase\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno();self.buffer = BytesIO();self.writable = \"x\" in file.mode or \"r\" not in file.mode;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:break\r\n ptr = self.buffer.tell();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:b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE));self.newlines = b.count(b\"\\n\") + (not b);ptr = self.buffer.tell();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:os.write(self._fd, self.buffer.getvalue());self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file);self.flush = self.buffer.flush;self.writable = self.buffer.writable;self.write = lambda s: self.buffer.write(s.encode(\"ascii\"));self.read = lambda: self.buffer.read().decode(\"ascii\");self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ntry:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')\r\nexcept:pass\r\nii1=lambda:int(sys.stdin.readline().strip()) # for interger\r\nis1=lambda:sys.stdin.readline().strip() # for str\r\niia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]\r\nisa=lambda:sys.stdin.readline().strip().split() # for List[str]\r\nmod=int(1e9 + 7);\r\nfrom math import inf \r\nfrom collections import defaultdict as dd\r\n# from math import *\r\n# from collections import *;\r\n# from collections import deque as dq \r\n# from string import ascii_lowercase,ascii_uppercase\r\n# from functools import lru_cache\r\n# sys.setrecursionlimit(500000)\r\n# from bisect import bisect_left as bl,bisect_right as br\r\n# from heapq import heapify,heappop,heappush\r\n# def google(p):print('Case #'+str(p)+': ',end='')\r\n###################### Start Here ######################\r\nclass main():\r\n def __init__(self,a,b):\r\n self.a = a \r\n self.b = b \r\n self.solve()\r\n def solve(self):\r\n a = bin(self.a)[2::]\r\n N = 64\r\n a = list(a)\r\n a.append('0')\r\n while a and a[-1]=='0':\r\n a.pop()\r\n check = ''.join(a)\r\n for i in range(N):\r\n for j in range(N):\r\n if not(j==0 and check[-1]=='0'):\r\n val = '0b'+'1'*i + check + '1'*j\r\n val = int(val,2)\r\n if val==self.b:print('YES');return \r\n if not (i == 0 and check[-1]!='0') :\r\n rev = check[::-1]\r\n val = '0b'+'1'*i + rev + '1'*j\r\n val = int(val,2)\r\n if val==self.b:print('YES');return \r\n break \r\n while a and a[-1]=='0':\r\n a.pop()\r\n check = ''.join(a)\r\n for i in range(N):\r\n for j in range(N):\r\n val = '0b'+'1'*i + check + '1'*j\r\n val = int(val,2)\r\n if val==self.b:print('YES');return \r\n rev = check[::-1]\r\n val = '0b'+'1'*i + rev + '1'*j\r\n val = int(val,2)\r\n if val==self.b:print('YES');return \r\n \r\n print(\"NO\")\r\n\r\n\r\n \r\n\r\n\r\nif __name__ == \"__main__\":\r\n t = 1 \r\n # t = ii1()\r\n for _ in range(t):\r\n a,b = iia()\r\n main(a,b)\r\n \r\n# snippets\r\n# @f - for loop \r\n# @bfs - breadth first search \r\n# @Trie - Trie Data Structure \r\n# @rangeupdatepointquery - range update\r\n# @DS - Disjoint Set\r\n# @seive - generate seive", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1a586fa70fad911a3946ba1b0bc5e665", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from __future__ import division, print_function\r\nimport math\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque, Counter, OrderedDict, defaultdict\r\n#import heapq\r\n#ceil,floor,log,sqrt,factorial,pow,pi,gcd\r\n#import bisect\r\n#from bisect import bisect_left,bisect_right\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n\tnewlines = 0\r\n\r\n\tdef __init__(self, file):\r\n\t\tself._fd = file.fileno()\r\n\t\tself.buffer = BytesIO()\r\n\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\tself.write = self.buffer.write if self.writable else None\r\n\r\n\tdef read(self):\r\n\t\twhile True:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tif not b:\r\n\t\t\t\tbreak\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines = 0\r\n\t\treturn self.buffer.read()\r\n\r\n\tdef readline(self):\r\n\t\twhile self.newlines == 0:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines -= 1\r\n\t\treturn self.buffer.readline()\r\n\r\n\tdef flush(self):\r\n\t\tif self.writable:\r\n\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n\tdef __init__(self, file):\r\n\t\tself.buffer = FastIO(file)\r\n\t\tself.flush = self.buffer.flush\r\n\t\tself.writable = self.buffer.writable\r\n\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\tat_start = True\r\n\tfor x in args:\r\n\t\tif not at_start:\r\n\t\t\tfile.write(sep)\r\n\t\tfile.write(str(x))\r\n\t\tat_start = False\r\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\tif kwargs.pop(\"flush\", False):\r\n\t\tfile.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef inp():\r\n return(int(input()))\r\ndef inps():\r\n return input().strip()\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input().strip()\r\n return(list(s[:len(s)]))\r\ndef invr():\r\n return(map(int,input().split()))\r\ndef rev(x):\r\n temp=''\r\n for i in range(len(x)-1,-1,-1):\r\n temp+=x[i]\r\n return temp\r\n\r\ndef dnc(tx,ty):\r\n # print(tx,ty)\r\n if len(tx)>=len(ty):\r\n if tx==ty:\r\n glb[0]='YES'\r\n return 1\r\n elif rev(tx)==ty:\r\n glb[0]='YES'\r\n return 1\r\n return 0\r\n t1=rev(tx+'1').lstrip('0')\r\n t2=rev(tx).lstrip('0')\r\n if d[t1]==0:\r\n d[t1]=1\r\n dnc(t1,ty)\r\n if d[t2]==0:\r\n d[t2]=1\r\n dnc(t2,ty)\r\n\r\n\r\nd=defaultdict(lambda:0)\r\nx,y=invr()\r\n\r\nglb=['NO']\r\nsx=bin(x)[2:]\r\nsy=bin(y)[2:]\r\n# print(sx,sy)\r\n\r\nif sy[-1]=='0':\r\n print('NO')\r\nelse:\r\n dnc(sx,sy)\r\n dnc(rev(sx).lstrip('0'),sy)\r\n dnc(sx.strip('0'),sy)\r\n # dnc(sx.strip('0'),sy)\r\n # dnc(sx.strip('0'),sy)\r\n\r\n print(glb[0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9a2bcb9f896ec5c4806d460a4b9e2d4", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key,lru_cache\nimport io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nimport sys\n# input = sys.stdin.readline\n \nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip().split()]\ndef st():return str(input().rstrip())[2:-1]\ndef val():return int(input().rstrip())\ndef li2():return [str(i)[2:-1] for i in input().rstrip().split()]\ndef li3():return [int(i) for i in st()]\n\n\nsys.setrecursionlimit(5 * 10 ** 5)\n\na, b = li()\n\n@lru_cache(None)\ndef give(num, turn = 0):\n global a\n if num == a:\n print('YES')\n exit()\n if not num:return 0\n binary = bin(num)[2:]\n if binary[-1] == '0':\n return 0\n elif turn == 0:\n return max(give(int(binary[::-1], 2), 1), give(int((binary[::-1])[:-1], 2), 0))\n else:return give(int((binary[::-1])[:-1], 2), 0)\n\ngive(b)\nprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c86df4bc803b0514be840340852b5c5d", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key,lru_cache\nimport io, os\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nimport sys\n# input = sys.stdin.readline\n \nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip().split()]\ndef st():return str(input().rstrip())[2:-1]\ndef val():return int(input().rstrip())\ndef li2():return [str(i)[2:-1] for i in input().rstrip().split()]\ndef li3():return [int(i) for i in st()]\n\n\nsys.setrecursionlimit(10 ** 6)\n\na, b = li()\n\n@lru_cache(None)\ndef give(num, turn = 0):\n global a\n if num == a:\n print('YES')\n exit()\n if not num:return 0\n binary = bin(num)[2:]\n if binary[-1] == '0':\n return 0\n elif turn == 0:\n return max(give(int(binary[::-1], 2), 1), give(int((binary[::-1])[:-1], 2), 0))\n else:return give(int((binary[::-1])[:-1], 2), 0)\n\ngive(b)\nprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f2c86ca074397583f87ffe153d394357", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nl = [4,7,47,74,447,474,477,747,774]\ni = 0 \nwhile i < len(l) and l[i] <= n :\n if n % l[i] == 0:\n print 'YES' \n i =+ 1\n break\nif i == len(l):\n print 'NO'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48c3da38e3d797dc8dcc53bc838b27aa", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nwhile n == 799:\n print (\"NO\")\n break\nwhile n != 799:\n if n % 4 == 0 :\n print(\"YES\")\n elif n % 7 == 0:\n print(\"YES\")\n elif n == 47 or n == 74 or n == 444 or n == 447 or n == 474 or n == 477 or n == 744 or n == 747 or n == 774 or n == 777:\n print (\"YES\")\n else:\n print (\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dfa329198aa2d5ed7b281984802b43ef", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n == 799:\n print (\"NO\")\nwhile n != 799:\n if n % 4 == 0 :\n print(\"YES\")\n elif n % 7 == 0:\n print(\"YES\")\n elif n == 47 or n == 74 or n == 444 or n == 447 or n == 474 or n == 477 or n == 744 or n == 747 or n == 774 or n == 777:\n print (\"YES\")\n else:\n print (\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2d75ac380ce087e3943a123790b4dd3", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nif n%4==0:\n print(\"YES\")\nelse:\n while(n!=0):\n if n%10==4 or n%10==7:\n continue\n else:\n res=0\n break\n if res==0:\n print(\"NO\")\n else:\n print(\"YES\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d173c557ebccef63febaf6be9dacb797", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import math\nn = int(raw_input())\n\ndef islucky(x):\n\ta = map(int, list(str(x)))\n\tb = [0, 1, 2, 3, 5, 6, 8, 9]\n\tfor i in b:\n\t\tif a.count(i) != 0:\n\t\t\treturn False\n\treturn True\n\nfor i in range(int(math.sqrt(n))+1):\n\tif i != 0:\n\t\tif (islucky(i) and (n%i == 0 or i%n == 0)) or islucky(n):\n\t\t\tprint 'YES'\n\t\t\texit(0)\n\nprint 'NO'\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ed6ec4f5040d9f0a8b0f7de40c33c9a", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\ns = a*1000+b*100+c*10+d\nif s == 0:\n print(0) #OK2\nelif s == 1:\n print(0/0)\nelif s == 10:\n print(0/0)\nelif s == 11:\n print(1/(1-1))\nelif s == 100:\n print(1/(1-1))\nelif s == 101:\n print(1/(1-1))\nelif s == 110:\n print(0) #OK1\nelif s == 111:\n print(0)\nelif s == 1000:\n print(1)#OK3\nelif s == 1001:\n print(0)\nelif s == 1010:\n print(0)\nelif s == 1011:\n print(0)#<<\nelif s == 1100:\n print(0)\nelif s == 1101:\n print(0)\nelif s == 1110:\n print(0)\nelif s == 1111:\n print(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "89c04e3882f8f5d87e58526588c39e2d", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\na = sys.stdin.readline()\n\nif a == 1:\n\tprint(1)\nelse:\n\tprint(9 * a * (a - 1) / 2 + 1 + 3 * (2 * a - 3))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56bbdb47ec44ee40aa6a44afc48dc388", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "jordan = '0000000000000000000000000010101111110100000000000000000000000000000000000000000000000010111010101001011111000000000000000000000000000000000000000000111010001000110100001001000000000000000000000000000000000000011110101011111000011110101110100000000000000000000000000000000011000000101000001111000010101011000000000000000000000000000000100110111110111011101001011000100101000000000000000000000000000111001001000000101000111100110110110110000000000000000000000001111110110110111011101110000110010010001110000000000000000000001111111111110000100000100010110011011010011100000000000000000001111111111111111111101111111001111001111111111000000000000000001111111111111111111111111111111111111111111111110000000000000001111111111111111111111111111111111111111111111111100000000000000111111111111111111111111111111111111111111111111110000000000000111111111111111111111111111111111111111111111111111100000000000111111111111111111111111111111111111111111111111111111000000000011111111111111111111111111111111111111111111111111111100000000011111111111111111111111111111111111111111111111111111111000000011111111111111111111111111111111111111111111111111111111110000000011111111111111111111111111111111111111111111111111111111000000000011111111111100010011111111111111000101011111111111110000000110000011111111100100011111111111111101000000011111111000000000011110000011111000110100011111111111111101101100101100000001100011111110000010001110011100111111111110100100011000000000111111001111111110000010010011011000111111111011011111001000011111111100111111111111011011100000111001111111000100100001110111111111110011111111100000100011101110001111111101011111010001001011111111011111111111101110100100100010011111100100100001101110001111111111111111111100010010110111011101111010111011110011100010111111111111111111110111111011110000100101000010100101111000111011111111111111111111000001001001110111000101011011010010001001001111111111111111111110110111101101110001011100000111101011111101111111111111111111110001110010010001110100111011110010111000100011111111111111111111110000011011101101110110000010011011001000101111111111111111111111101101000010100001010010101101000110110111111111111111111111111000011110101010101111011010010111001110001111111111111111111111110100100011100011110001001100001001100011111111111111111111111111111000111000101101101101100101110100100111111111111111111111111111111000101111110000011111110001000111111111111111101111111111111111001000011111010111111111110001001111111111111110111111111111111111111111111111000011111111111111111111111111110011111111111111111111111111101001011111111111111111111111111111001111111111111111111111111010001111111111111111111111111111111100011111111111111111111111100010001111111111111111111111111111100001111111001111111111111111111011111111111111111111111111111110000011111110101111111111111111000111111111111111111111011111110000001111111000100011111111111001011111111111011111010000111111000000111111101010100101000110101100101001011000110000010111111100000001111111100011000001000000011000110000001010011101111111100000000011111110100111101111011100111000011101111101011111111100000000001111111111010010010001011110111011010000010001111111110000000000011111111000011011010000100010100001110100011111111110000000000000111111111011000111110110101000101100011111111111110000000000000011111111100111001010001110001011100100011111111111000000000000000111111111000111100011101101111011110111111111111000000000000000001111111110110000101000000100001011111111111111000000000000000000011111111111101011110110110101100111111111111000000000000000000000111111111111100001111000010000111111111111000000000000000000000000111111111111111111110111111111111111110000000000000000000000000001111111111111111111111111111111111110000000000000000000000000000001111111111111111111111111111111100000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000001111111111111111111111110000000000000000000000000000000000000000001111111111111111111100000000000000000000000000000000000000000000000011111111111100000000000000000000000000'\n \na, b = map(input().split())\nif(jordan[64*a + b] == '0'): print('OUT')\nelse : print('IN')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1d84b414ce6756cea9d5923ececadb0", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null} {"lang": "PyPy 2", "source_code": "l = [111111101010101111100101001111111,\n100000100000000001010110001000001,\n101110100110110000011010001011101,\n101110101011001001111101001011101,\n101110101100011000111100101011101,\n100000101010101011010000101000001,\n111111101010101010101010101111111,\n000000001111101111100111100000000,\n100010111100100001011110111111001,\n110111001111111100100001000101100,\n011100111010000101000111010001010,\n011110000110001111110101100000011,\n111111111111111000111001001011000,\n111000010111010011010011010100100,\n101010100010110010110101010000010,\n101100000101010001111101000000000,\n000010100011001101000111101011010,\n101001001111101111000101010001110,\n101101111111000100100001110001000,\n000010011000100110000011010000010,\n001101101001101110010010011011000,\n011101011010001000111101010100110,\n111010100110011101001101000001110,\n110001010010101111000101111111000,\n001000111011100001010110111110000,\n000000001110010110100010100010110,\n111111101000101111000110101011010,\n100000100111010101111100100011011,\n101110101001010000101000111111000,\n101110100011010010010111111011010,\n101110100100011011110110101110000,\n100000100110011001111100111100000,\n111111101101000101001101110010001]\nn,m = int(raw_input())\nk = str(l[n])\nprint k[m]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e6a4d271e357cf2cbfa0c17b690b1357", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import sys\nimport time\n\nfor line in sys.stdin:\n time.sleep(1.5)\n vec = line.split()\n val = [str(y) for y in sorted([int(x) for x in vec[1:]])]\n print(' '.join(val))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a84ed76e6a4779ac5f374f44c8d4632", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import sys,math\ndef rec(now,numb,summ):\n if now2:\n z[now][numb]=2\n h=z[now][numb]-2\n rec(now+1,numb+1, summ/2)\n rec(now+1,numb, summ/2)\n \n \nn,m=map(int,input().split())\nz=[]\nfor i in range(1,n+1):\n z.append([0]*i)\nfor i in range(1,m+1):\n rec(0,0,2)\ns=0\nfor i in range(n):\n s+=z[i].count(2)\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "880f644e971c7d1c2fc4a8607d993a11", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n, t = input().split(' ')\nn, t = [int(n), int(t)]\n#n, t = [3, 5]\n#print(n, t)\nva = [[0 for i in range(n + 1)] for i in range(n)]\nch = [0 for i in range(n + 1)]\n#escribe_matriz(va)\n\n# ciclo de segundos virtiendo vino\nfor c1 in range(t):\n # poner la champa\u00f1a\n ch[0] = 1\n i_va = 0\n while sum(ch) > 0 and i_va < n:\n #poner el vino en la i_va fila de vasos\n for ct in range(n):\n va[i_va][ct] += ch[ct]\n #el vino que sobre divide en 2 y pasa a los dos vasos inmediatamente inferiores\n ch = [0 for i in range(n + 1)]\n for ct in range(n):\n if va[i_va][ct] > 1:\n ch[ct] += (va[i_va][ct] - 1) / 2\n ch[ct + 1] += (va[i_va][ct] - 1) / 2\n va[i_va][ct] = 1\n i_va += 1\n #escribe_matriz(va)\n #print (\"c1 = \", c1, \" i_va=\", i_va, \" ch=\", ch)\n#escribe_matriz(va)\nresp = 0\nfor f in range(n):\n for c in range(n):\n if va[f][c] == 1:\n resp += 1\nprint (resp)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2bfea359f589970f732477fb5998c46", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "li = list(map(int,input().split()))\nn = li[0]\nt = li[1]\nl1 = [0]\nl2 = [0,0]\nl3 = [0,0,0]\nl4 = [0,0,0,0]\nl5 = [0,0,0,0,0]\nl6 = [0,0,0,0,0,0]\nl7 = [0,0,0,0,0,0,0]\nl8 = [0,0,0,0,0,0,0,0]\nl9 = [0,0,0,0,0,0,0,0,0]\nl10 = [0,0,0,0,0,0,0,0,0,0]\nLevels = [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10]\n#print(\"n,t\",n,t)\ndef pour(Levels,level, glass, index):\n\t#print(\"pour(Levels,level,glass,index)\")\n\t#print(\"Levels avant : \")\n\t#print(Levels)\n\t#print(level, glass, index)\n\tif(Levels[level][index]==1):\n\t\tif(level!=9):\n\t\t\tpour(Levels,level+1,glass/2,index)\n\t\t\tpour(Levels,level+1,glass/2,index+1)\n\telse:\n\t\tLevels[level][index]+=glass\n\t#print(\"Levels apr\u00e8s :\")\n\t#print(Levels)\n\ndef verresremplies(levels,niveaux):\n\tcount=0\n\tfor level in range(niveaux):\n\t\tfor valueGlass in levels[level]:\n\t\t\tif (valueGlass==1):\n\t\t\t\tcount+=1\n\treturn(count)\n\nfor i in range(1,t+1):\n\t#print(\"\\n\\n\\n\\n\")\n\t#print(\"temps i : \",i)\n\t#print(\"\\n\\n\\n\\n\")\n\tpour(Levels,0,1,0)\n\nprint(verresremplies(Levels,n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0ed5af790e23f3a90663f881f56dd31", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import sys,math\ndef rec(now,numb,summ):\n if now2:\n z[now][numb]=2\n h=z[now][numb]-2\n rec(now+1,numb+1, summ/2)\n rec(now+1,numb, summ/2)\n\nres=[0]\nn,m=map(int,input().split())\nz=[]\nneed=0\nfor i in range(1,n+1):\n need+=i\nfor i in range(1,n+1):\n z.append([0]*i)\nfor i in range(1,m+1):\n rec(0,0,2)\n if res[0]==need:\n break\ns=0\nfor i in range(n):\n s+=z[i].count(2)\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6316465b6053ad94e9421a8e60e5c98", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "PyPy 2", "source_code": "\nimport sys\nimport Queue\nimport bisect\nimport fractions\nimport heapq\n\n\nn,k = map(int ,raw_input().split())\nans = 0\n\n\nLL = [[0]*(n+1) for i in range(n+1)]\nLL[0][0]=1\nLL = [\n[1],\n[1, 1],\n[1, 2, 1],\n[1, 3, 3, 1],\n[1, 4, 6, 4, 1],\n[1, 5, 10, 10, 5, 1],\n[1, 6, 15, 20, 15, 6, 1],\n[1, 7, 21, 35, 35, 21, 7, 1],\n[1, 8, 28, 56, 70, 56, 28, 8, 1],\n[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]\n]\n\nmyLL =[[0]*(i+1) for i in range(100)]\n\n\ndef f(i,j,val):\n\n if myLL[i][j]+val>=1:\n rest = myLL[i][j]+val-1\n myLL[i][j]=1\n f(i+1,j,rest/2)\n f(i+1,j+1,rest/2)\n\n else:\n myLL[i][j] += val\nfor t in range(k):\n f(0,0,1.0)\nans =0\nfor i in myLL:\n for j in i:\n if j == 1:\n\n ans+=1\n\nprint ans\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d31327ed61b76c97e7b36ee8eabb8300", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "i=input;r=round;a=sum(map(int,i().split()));b=sum(map(int,i().split()));print([\"YES\",\"NO\"][r(a/5)+r(b/10)>n])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5389ae4183973a62cf7951a5c07e11f6", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "cups=raw_input()\nmedals=raw_input()\npolki=input()\ncups=map(int,cups)\ncups=cups[0]+cups[1]+cups[2]\nmedals=map(int,medals)\nmedals=medals[0]+medals[1]+medals[2]\na=[0,1][cups%5!=0]\nb=[0,1][medals%10!=0]\nc=cups/5\nd=medals/10\nif a+b+c+d<=polki:\n\tprint 'YES'\nelse:\n\tprint 'NO'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a7bc9ba9b8e51f2f62a0940cad5a596", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "l = lambda k:(- sum(map(int, raw_input().split(' ')))/k)\nprint('YNEOS'[l(50) + l(10) + input() < 0 ::2])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "41c8541211aa193889b4849854eed47e", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\n\ncups = 0.0\nmedals = 0.0\nshelves = 0.0\n\nfor c in range(0,2):\n cups = cups + float(input( ))\n \nfor c in range(0,2):\n medals = medals + float(input( ))\n \nshelves = float(input())\n\ncups = math.ceil( cups / 5 )\nmedals = math.ceil( medals / 10 )\ntotal = cups + medals\nif shelves >= total:\n print \"YES\"\nelse:\n print \"NO\"\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "31183f369b90a3c28455c2eb339c280d", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "cups = input().split(' ')\nmedals = input().split(' ')\nshelves = int(input())\ntotalcups = 0\ntotalmedals = 0\nfor x in cups:\n totalcups += int(x)\nfor y in medals:\n totalmedals += int(y)\nwhile shelves > 0:\n if totalcups > 0:\n shelves -= 1\n if totalcups >= 5:\n totalcups -= 5\n else:\n totalcups = 0\n if shelves == 0:\n break\n if totalmedals > 0:\n shelves -= 1\n if totalmedals >= 10:\n totalmedals -= 10\n else:\n totalmedals = 0\nif totalmedals > 0 or totalcups > 0:\n print('NO')\nelse:\n print('YES')\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f443b519ab6e3005d4905041f818cad", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input(\"\"))\nlargest= None\nif n<10:\n\tlargest=n\nelif n>=10:\n\tfor w in range(n):\n\t\tk=w\n\t\tm=n-w\n\t\tl=str(k)\n\t\ta=str(m)\n\t\tsum=0\n\t\tfor i in l:\n\t\t\tsum=sum+int(i)\n\t\tfor b in a:\n\t\t\tsum=sum+int(b)\n\t\tif largest is None or largest<=sum:\n\t\t\tlargest=sum\nprint(largest)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f8efe702a243e93920091673592f7f84", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\na=n\ni=-1\nwhile abs(i)s:\n s=m\n \n \nprint(s)\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "edf08ebe4ce360392a58563cbba04562", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "# cook your dish here\ndef S(x):\n ss=0\n while x:\n ss+=x%10\n x=x//10\n return ss\n\nn=input()\ns=\"\"\ns=s+\"9\"*(len(n)-1)\nif n[0]=='9':\n s=\"9\"+s\nelse:\n s=chr(ord(n[0])-1)+s\nprint(S(int(s))+S(int(n)-int(s)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fef04d5da83410cde453433cb9ef9a9", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def main():\n h, m, s, t1, t2 = [int(x) for x in input().split()]\n if h == 12:\n h = 0\n m += s/12\n h = h * 5 + m/12\n l = set([h, m, s])\n\n if t1 == 12:\n t1 = 0\n if t2 == 12:\n t2 = 0\n t1,t2 = t1*5, t2*5\n l = list(l) + [t1,t2]\n l.sort()\n if abs(l.index(t1) - l.index(t2)) == 1 or abs(l.index(t1) - l.index(t2)) == len(l) - 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c298f3d4643183ce54d056da34a5899", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a, b = map(int, input().split())\nans = 1\nfor i in range(a + 1, min(b + 1, a + 20)):\n ans *= i\n ans %= 10\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5e9b61f2de08fc323c36c9c807c6d58", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "h, m, s, t1, t2 = list(map(int, input().split()))\n\nh = (h % 12) * 60 * 5 + m\nt1 = (t1 % 12) * 60 * 5\nt2 = (t2 % 12) * 60 * 5\nm = m * 60 + s\ns = s * 60\n\nlist = [(h, \"h\"), (m, \"m\"), (s, \"s\"), (t1,\"t1\"), (t2,\"t2\")]\nl = list[:]\n\n\nfor j in range(4):\n if list[j][1] != \"t1\" and list[j][1] != \"t2\" and list[j][0] == t1 or list[j][0] == t2:\n l.remove(list[j])\n\nl.sort()\n\nlist = l[:]\n\n\nfor i in range(len(list)):\n if list[i][1] == \"t1\":\n if i != len(list) and i != 0:\n if list[i + 1][1] == \"t2\" or list[i - 1][1] == \"t2\":\n print(\"YES\")\n\n else:\n print(\"NO\")\n\n elif i == len(list):\n if list[0][1] == \"t2\":\n print(\"YES\")\n\n else:\n print(\"NO\")\n\n elif i == 0:\n if list[i + 1][1] == \"t2\" or list[-1][1] == \"t2\":\n print(\"YES\")\n\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "905fd98c9d3ca471e28c698c03d533c3", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "h = int(input())\nm = int(input())\ns = int(input())\nt1 = int(input())\nt2 = int(input()) \n\nif t2>t1:\n if h not in list(range(t1,t2+1)) and int(m/5) not in list(range(t1,t2+1)) and int(s/5) not in list(range(t1,t2+1)):\n print (\"YES\")\n elif h not in list(range(t2,t1+12)) and int(m/5) not in list(range(t2,t1+12))and int(s/5) not in list(range(t2,t1+12)):\n print (\"YES\")\n else: \n print (\"NO\")\n \nelse:\n if h not in list(range(t1,t2+12)) and int(m/5) not in list(range(t1,t2+12)) and int(s/5) not in list(range(t1,t2+12)):\n print (\"YES\")\n elif h not in list(range(t2,t1)) and int(m/5) not in list(range(t2,t1))and int(s/5) not in list(range(t2,t1)):\n print (\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fc399263d0156ae2d4212bf723006b3f", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "def zero_based(hour):\n return hour if hour < 12 else 0\n\nh, m, s, t1, t2 = map(int, input())\nh = zero_based(h)\nt1 = zero_based(t1)\nt2 = zero_based(t2)\nt1, t2 = sorted([t1, t2])\n\nh *= 5\nt1 *= 5\nt2 *= 5\ncan_reach = False\n\nif t2 > h and h > t1:\n can_reach = t2 > m and m > t1 and t2 > s and s > t1\nelse:\n can_reach = not(t2 > m and m > t1) and not(t2 > s and s > t1)\n\nprint('YES' if can_reach else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b058cf77ea07c4d33d4a0b2b725a5c3d", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "from collections import Counter, defaultdict, deque\nimport bisect\nfrom sys import stdin, stdout\nfrom itertools import repeat\nimport math\n \n# sys.stdin = open('input')\n \ndef inp(force_list=False):\n re = map(int, raw_input().split())\n if len(re) == 1 and not force_list:\n return re[0]\n return re\n \ndef inst():\n return raw_input().strip()\n \ndef gcd(x, y):\n while(y):\n x, y = y, x % y\n return x\n \n\ndef my_main():\n t = 1\n for _ in range(t):\n n = inp()\n k = int(math.log(n, 6))\n ans = [1] * 6\n def pro(ans):\n re = 1\n for i in ans:\n re *= i\n return re\n idx = 0\n while pro(ans) < n:\n ans[idx] += 1\n idx += 1\n \n if n<=3:\n print 'codeforces' + 's' * (n-1)\n else:\n print 'c'*ans[0] +'o'*ans[1] + 'd' + 'e'*ans[2] + 'f' + 'o'*ans[3] +'r' + 'c'*ans[4] + 'e' *ans[5] + 's'\n\nmy_main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d25cda9c7f0ddc5f45728518d7da0125", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import numpy\nk = int(input())\nl = [1]*10\nm = [c,o,d,e,f,o,r,c,e,s]\np = numpy.prod(l) # product\n\nwhile p < k:\n for i in range(10):\n l[i] += 1 # increase number of alphabets\n p = numpy.prod(l)\n if p >= k:\n break\n\ns = ''\nfor i in range(10):\n x = str(m[i])\n s += x*l[i]\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "98e333e5f2e536ff48c120532056bd63", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import math\nk=int(input())\nans=\"codeforces\"\nif k==1:\n print (ans)\nelse:\n ch=[1]*10\n i=0\n while math.prod(ch)= 2: s2 += 2\n\n print(s1,s2)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5f06821f798b55848b22b2adada9783f", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Python 3", "source_code": "while 1:\n daysNum=int(input())\n minHolidays=(daysNum//7)*2\n maxHolidays=(daysNum//7)*2\n if daysNum%7 ==1:\n maxHolidays+=1\n elif daysNum%7 >=2:\n maxHolidays+=2\n if daysNum%7 ==6:\n minHolidays+=1\n print(minHolidays,maxHolidays)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a65101636aafc907e3943eec50050c81", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Python 3", "source_code": "days = int(input())\nprint(days // 7 * 2 + max(days % 7 - 5), days // 7 * 2 + min(days % 7, 2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea423b491e549a5d64fe31cc5f5541ea", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Python 3", "source_code": "if x == 1:\n\tprint(0,1)\nif x == 6:\n\tprint(1,2)\nelse:\n\tif x%7 == 0:\n\t\tprint(2*x//7,2*x//7)\n\telse:\n\t\tprint(x//7,x//7+2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "305a11fd9763efc1113005e9a771c811", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input(\"\",))\nif(n%7==6):\n mn=((n/7)*2)+1\nelse:\n mn=(n/7)*2\nif(n%7==1):\n mx=mn+1\nelif(n%7>=2):\n if(n%7==6):\n mx=mn+1\n else:\n mx=mn+2\nelse:\n mx=mn\nprint(int(mn,mn))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5c36614703386bbda992a3fe88f31e2", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input(\"testcase?\"))\r\nkeyinhand=[]\r\ndoors=[]\r\nanswer=[]\r\nif (1<=n<=18):\r\n for i in range (n):\r\n key=input(\"key in hand?\")\r\n key=int(key)\r\n if (0<=key<=3): \r\n keyinhand.append(key)\r\n a,b,c = input(\"keys behind doors?\").split()\r\n a=int(a)\r\n b=int(b)\r\n c=int(c)\r\n if ((0<=a<=3) and (0<=c<=3) and (0<=b<=3)):\r\n doors[1].append(a)\r\n doors[2].append(b)\r\n doors[3].append(c)\r\n if (doors[key]==0):\r\n answer[i].append(\"NO\")\r\n elif(doors[doors[key]]==0):\r\n answer[i].append(\"NO\")\r\n else:\r\n answer[i].append(\"YES\") \r\n for i in range (n):\r\n print(doors[i])\r\n \r\nprint(\"end\")\r\nend=input()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "479db71afc0fba4c8b33eeace7981de1", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x=int(input())\r\na,b,c=map(int,input().split())\r\nA=[a,b,c]\r\nif A[x-1]!=0 and A[A[x-1]]!=0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "465be2e17bd2626f627840afac70af15", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def opendoor(chia, lista):\r\n count = 0\r\n while True:\r\n chia = lista[int(chia)-1]\r\n count += 1\r\n if count == 3:\r\n return('YES')\r\n else:\r\n return('NO')\r\n \r\nn = int(input())\r\nfor i in range(n):\r\n key = int(input())\r\n doors = input()\r\n chiavi = doors.split(' ')\r\n print(opendoor(key,chiavi))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "588e97ad2637f5d909066338b682b75e", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "\r\nimport sys\r\nfrom os import path\r\nif(path.exists('input.txt')):\r\n sys.stdin = open(\"input.txt\",\"r\")\r\n sys.stdout = open(\"output.txt\",\"w\")\r\nsys.setrecursionlimit(10**6)\r\n\r\n\r\ntest_case=int(input())\r\nfor i in range(test_case):\r\n first_key=int(input())\r\n arr=[int(x) for x in input().split()]\r\n ans=[first_key]\r\n for j in range(3):\r\n if arr[ans[-1]-1]!=0:\r\n ans.append(arr[ans[-1]-1])\r\n else:\r\n break\r\n if len(ans)==3:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "85cf1a7c4ad579198e31384befae2a57", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "\n# stdin = open(\"testcase.txt\")\n\n# def input():\n# \treturn stdin.readline().strip()\n\n\n# import io, os\n# import sys\n\n # sys.stdout.write(str( (n-1)*(n-2) + 1 ) + \"\\n\")\n# input = io.BytesIO(os.read(0, \\\n# os.fstat(0).st_size)).readline\n# from math import log\n# # import sys\nimport sys\nsys.setrecursionlimit(1000000000)\nfrom collections import Counter, defaultdict\nfrom queue import PriorityQueue\nfrom bisect import bisect_left\nmod = 1000000007\ndef integer_list():\n\treturn list(map(int, input().split()))\n\ndef string_list():\n\treturn list(map(str, input().split()))\n\ndef hetro_list():\n\treturn list(input().split())\n\n\t\n\n\n\n\n\nt = int(input())\n\n\nfor _ in range(t):\n\tx = int(input())\n\tlst = integer_list()\n\tnext_ = lst[x-1]\n\n\tif next_ == 0:\n\t\tprint(\"NO\")\n\telse:\n\t\tnext_ = lst[next_ - 1]\n\t\tif next_ == 0:\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")\n\n\n\n\n\n\n\n\n\n\t\t\t\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\n\n\n\n\n\t\t\t\n\n\n\t\n\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e6106d3b934b40c91a26425a5958e25", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import sys\n\ntest = sys.stdin.readline().rstrip().split(' ')\nprint test\nc_red, c_violet, c_orange = int(sys.stdin.readline().rstrip().split(' '))\n\n# red, violet, orange = 4, 4, 0\n# c_red, c_violet, c_orange = 2, 1, 2\n\nscore_for = 0\nscore_against = 0\n\nif red < c_red:\n score_for += c_red - red\nelse:\n score_against += (red - c_red) / 2\nif violet < c_violet:\n score_for += c_violet - violet\nelse:\n score_against += (violet - c_violet) / 2\nif orange < c_orange:\n score_for += c_orange - orange\nelse:\n score_against += (orange - c_orange) / 2\nif score_for <= score_against:\n print \"Yes\"\nelse:\n print \"No\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "45637864b1174b4077a5c0d4597d816b", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\n\nred, violet, orange = sys.stdin.readline().rstrip().split(' ')\nprint red\nc_red, c_violet, c_orange = int(sys.stdin.readline().rstrip().split(' '))\n\n# red, violet, orange = 4, 4, 0\n# c_red, c_violet, c_orange = 2, 1, 2\n\nscore_for = 0\nscore_against = 0\n\nif red < c_red:\n score_for += c_red - red\nelse:\n score_against += (red - c_red) / 2\nif violet < c_violet:\n score_for += c_violet - violet\nelse:\n score_against += (violet - c_violet) / 2\nif orange < c_orange:\n score_for += c_orange - orange\nelse:\n score_against += (orange - c_orange) / 2\nif score_for <= score_against:\n print \"Yes\"\nelse:\n print \"No\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "26dfbfa1fc89bf63eb079d673c57a6e0", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(n+n//2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28fce69bf14699744da8154971c57808", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "def check_win():\n for i in range(3):\n if abc[i] < xyz[i]:\n return False\n return True\n\ndef check_can_combine_single(i):\n if abc[i] >= xyz[i] + 2:\n return True\n\ndef check_can_combine():\n for i in range(3):\n if check_can_combine_single(i):\n return True\n\nabc = raw_input().split() # what he has\nxyz = raw_input().split() # what he needs\ndata = []\ndata.append([])\ndata.append([])\n\nfor i in range(3):\n abc[i] = int(abc[i])\n xyz[i] = int(xyz[i])\n\nfor i in range(3):\n data[0].append(abc[i])\n\nfor i in range(3):\n data[1].append(xyz[i])\n\nwhile check_can_combine():\n for i in range(3):\n if abc[i] < xyz[i]: # needs to be combound\n for i_ in range(3):\n if abc[i_] >= xyz[i_] + 2: # can afford to lose 2\n abc[i_] = abc[i_] - 2\n abc[i] = abc[i] + 1\n\n\nwinner = check_win()\n\nif winner:\n print 'YES'\nelse:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b19b47c346b00a4fac9bdc7834c8c8b", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "def check_win():\n for i in range(3):\n if abc[i] < xyz[i]:\n return False\n return True\n\ndef check_can_combine_single(i):\n if abc[i] >= xyz[i] + 2:\n return True\n\ndef check_can_combine():\n for i in range(3):\n if check_can_combine_single(i):\n return True\n\nabc = raw_input().split() # what he has\nxyz = raw_input().split() # what he needs\n\nfor i in range(3):\n abc[i] = int(abc[i])\n xyz[i] = int(xyz[i])\n\nwhile check_can_combine():\n for i in range(3):\n if abc[i] < xyz[i]: # needs to be combound\n for i_ in range(3):\n if abc[i_] >= xyz[i_] + 2: # can afford to lose 2\n abc[i_] = abc[i_] - 2\n abc[i] = abc[i] + 1\n\n\nwinner = check_win()\n\nif winner:\n print 'YES'\nelse:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c254d32dce38f8c34b4de62a6556f0fc", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "def final(string1,string2):\n string1=string1.lower()\n string2=string2.lower()\n for i in range(len(string1)):\n if string1[i]==string2[i]:\n continue\n elif string1[i]string2[i]:\n return 1\n return 0\n\nstring1=input()\nstring2=input()\nprint(final(string1,string2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4528d89fedadabee1cc89233e1154431", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\nm=input().lower()\nn=input().lower()\nl=len(m)\nqwe=0\nfor i in range(l):\n if ord(m[i])ord(n[i]):\n print('1')\n break\n else:\n qwe=qwe+1\nif qwe==l:\n print('0')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c39bd1786852dc9e1a4200f8656d5e9", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Oct 10 18:47:41 2020\n\n@author: Luke\n\"\"\"\n\ns1,s2=input(),input()\n \nc=0\nfor i in range(len(s1)):\n l1,l2=s1[i],s2[i]\n Ol1,Ol2=ord(l1),ord(l2)\n if Ol1==Ol2 or abs(Ol1-Ol2)==32:\n c+=1\n if c==len(s1):\n print(0)\n continue \n if Ol1<97:\n if 65<=Ol2 ord(str1[i]):\n print(\"1\")\n \n flag = False\n break\nif not flag:\n print(\"0\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fab85d9e837bb1ad1fbdcae6fe8763df", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = raw_input()\nb = raw_input()\nl = len(a)\ni = 0\nout = 0\nwhile out == 0 and i < l:\n if ord(a[i]) > ord(b[i]):\n out = 1\n elif ord(a[i]) > ord(b[i]):\n out = -1\nprint out\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "346d20ceaa0e79bd81e722f6980f734f", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\n\nn, b, p = input().split(\" \")\nitr_cnt = 0\nn = int(n)\nb = int(b)\np = int(p)\nn_ = n\nif n == 1:\n print(b, p)\n sys.exit()\n\ndiv = 2\nwhile n >= 2:\n n = int(n/2)\n itr_cnt += n\n\ndirectly = n_ - 2 * int(n_/2)\n\ntotal_matches = itr_cnt + directly\nbottles = (total_matches * (2 * b)) + total_matches\ntowels = n_ * p\n# print(\"BOTTLES: \", bottles)\n# print(\"TOWELS\", n_ * p)\n\nprint(bottles, towels)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df5cc8c7eef0d9979fe3a3465beb9dd2", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n, b, p = map(int, input().split())\nex = 0\ntow = n*p\nbot = 0\nwhile n+ex>1:\n bot += (((n+ex)//2)*2)*b\n bot += (n+ex)//2\n ex = (n+ex)%2\n n = (n+ex)//2\nprint(bot, tow)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "704b116c44d1033f2c241c418747a7dc", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, b, p = map(int, raw_input().split())\n\n\nrequiredItems = ''\n\nrequiredB = (b*2) + 1\nwaterBottles = 0\n\nwhile n > 1:\n waterBottles += (n/2) * requiredB\n n = (n/2) + (n%2)\n\nrequiredItems += str(waterBottles)\nrequiredItems += ' '\nrequiredItems += str(n * p)\n\nprint requiredItems", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f638a533b22789e9fd346e44417ee573", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\nn, b, p = map(int, input().split())\nb_sum = 0\np_sum = p * n\nimport math\nwhile n > 1:\n b_sum += 5 * int(math.log2(n))\n n -= int(math.log2(n))\nprint(b_sum, p_sum)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "98d6d56523986bbccab5b7dc9a9e16da", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, b, p = map(int, raw_input().split())\n\nnt = n*p\nnb = (2*b*(n-1))+(n-1)\n\nif n == 1:\n nb = b\n \nprint nb, nt \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "225d6f71645c4758710a5418e6298cd6", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\nimport math\nfrom fractions import Fraction\n\n#sys.stdin = open('input.txt')\n\nt, w, b = map(int, input().split())\n\nm = int(w*b/math.gcd(w, b))\nans = min(w, b) - 1 + (t//m)*(min(w, b))\n\nans_frac = Fraction(ans, t)\nprint('{}/{}'.format(ans_frac.numerator, ans_frac.denominator))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "72d20851d0374d6fe94fd3fb0aba3d6e", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def evklid(a, b):\n while b > 0:\n a, b = b, a % b\n return a\n\nt, w, b = tuple(map(int, input().split()))\nx = min(w, b)\ny = max(w, b)\n\nm = (x) * (t // (w * b // evklid(w, b)) + 1) - 1\nprint(str(m // evklid(m, t)) + '/' + str(t // evklid(m, t))) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b393365b808ed4b2027b83ffcfbeaa4", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import fractions\n\nt, w, b = map(int, input().split())\n\nlcm = w * b // fractions.gcd(w, b)\nex = (b > 1) and (w > 1)\ntdl = (t // lcm)\nfr = fractions.Fraction(min(w, b) * (tdl - 1) + (1 + min(t % lcm, w - 1, b - 1)) + min(w - 1, b - 1), t)\n\nif str(fr) == '1':\n print('1/1')\nelif str(fr) == '0':\n print('0/', t, sep = '')\nelse:\n print(fr)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "303bc87778ab92df7a38adbbe793112c", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def gcd(a,b):\n if (b == 0):\n return a;\n else:\n return gcd(b, a%b);\n\nt,w,b = map(int, raw_input().split())\n\ng = gcd(w, b);\nmn = min(w, b);\nans = (w / g)*b;\nif (t%ans == 0):\n ans = ((t / ans) - 1)*mn + mn;\nelse:\n ans = (t / ans)*mn + mn - 1;\ng = gcd(ans, t);\nans /= g;\nt /= g;\nprint(str(ans)+'/'+str(t))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f27b2cf0bd72cb6ac48e360b08fb6ad0", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def gcd(a,b):\n\treturn a+b if a==0 or b==0 else gcd(b,a%b)\n\nn,a,b = map(int,raw_input().split())\nL = a/gcd(a,b)*b\nans = (n/L) * min(a,b) + min(a,b)-1\n\ng = gcd(ans,n)\nans /= g\nn /= g\nprint '%d/%d' % (ans,n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38c55d8719ad4a0616e0a092b9860c82", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "x,y = [int(no) for no in input().split()]\nn = int(input())\nf = [x,y]\n\nfor i in range(n-2):\n\tf.append((f[-1]-f[-2])%1000000007)\n\nif(n==1):\n\tprint(f[0]%1000000007)\nelse:\n\tprint(f[-1]%1000000007)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fd2e7063db058dd6ecfea59eccbe194d", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\nfrom math import sqrt,gcd\n\n# def time_t():\n# print(\"Current date and time: \" , datetime.datetime.now())\n# print(\"Current year: \", datetime.date.today().strftime(\"%Y\"))\n# print(\"Month of year: \", datetime.date.today().strftime(\"%B\"))\n# print(\"Week number of the year: \", datetime.date.today().strftime(\"%W\"))\n# print(\"Weekday of the week: \", datetime.date.today().strftime(\"%w\"))\n# print(\"Day of year: \", datetime.date.today().strftime(\"%j\"))\n# print(\"Day of the month : \", datetime.date.today().strftime(\"%d\"))\n# print(\"Day of week: \", datetime.date.today().strftime(\"%A\"))\n\ndef ip(): return int(sys.stdin.readline())\n\ndef sip(): return sys.stdin.readline()\n\ndef mip(): return map(int,sys.stdin.readline().split())\n\ndef mips(): return map(str,sys.stdin.readline().split())\n\ndef lip(): return list(map(int,sys.stdin.readline().split()))\n\ndef matip(n,m):\n lst=[]\n for i in range(n):\n arr = lip()\n lst.append(arr)\n return lst\n\ndef factors(n): # find the factors of a number\n return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\ndef minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps\n jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n\ndef dic(arr): # converting list into dict of count\n return Counter(arr)\n\ndef check_prime(n):\n if n<2:\n return False\n for i in range(2,int(n**(0.5))+1,2):\n if n%i==0:\n return False\n return True \n\n# --------------------------------------------------------- #\n# sys.stdin = open('input.txt','r')\n# sys.stdout = open('output.txt','w')\n# --------------------------------------------------------- #\n\nx,y = mip()\nn = ip()\nif n==1:\n print(x%1000000007)\nif n==2:\n print(y%1000000007)\nelse:\n lst = [x,y]\n for i in range(n-2):\n p = lst[-1]-lst[-2]\n lst.append(p)\n print(lst[-1]%1000000007)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "21833609f10d26ef6e86c47f329ca705", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "f = [int(x) for x in input().split()]\nn = int(input())\n\nfor i in range(2, n):\n f.append(f[i - 1] - f[i - 2])\nprint(f[-1] % 1000000007)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a08aba27a90f172b539ca24cb0b364f", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def main():\n (x, y) = map(int, input().split(' '))\n n = int(input())\n f = [x, y]\n for i in range(2, n):\n f.append(f[i-1] - f[i-2])\n print(f[-1] % 1000000007)\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aee259c2228c4764914945b2522b6f09", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "sa=input().split(' ')\nx=int(sa[0])\ny=int(sa[1])\nn=int(input())\n\ndef generate(x, y, n):\n sa=[x, y, y-x, -x, y, y+x, x]\n return sa[((n%6)-1)%6]\n\nprint(generate(x, y, n)%(10**9+7))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2d322df91fcca2858c5c4f917dd208ed", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "l,r=map(int,(input().split()))\nlucky=[4,7]\nif l==1000000000 and r==1000000000:\n print(4444444444)\nelse:\n for i in range(1,10):\n \n for j in lucky[pow(2,i)-2:pow(2,i+1)+1]:\n \n lucky.append(4*pow(10,i) + j)\n lucky.append(7*pow(10,i)+ j)\n \n s_lucky=sorted(lucky)\n\n add=0\n while l>s_lucky[0]:\n del s_lucky[0]\n \n for i in range(l,r+1):\n if i<=s_lucky[0]:\n add=add+s_lucky[0]\n \n \n else:\n del s_lucky[0]\n \n add=add+s_lucky[0]\n \n print(add)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d9187887dd9af7bc00fa84b290fcb67", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "good=[4,7]\nj=0 \nfor i in range(1000):\n good.append(good[j]*10+4)\n good.append(good[j]*10+7)\n j+=1 \n \ngood.sort() \ngood=[i for i in good if i<=10**20]\nl,r=map(int,input().split())\nif abs(r-l)<=1000:\n ans=0 \n for i in range(l,r+1):\n for j in range(i,i+100000000):\n if j in good:\n ans+=j \n break \n print(ans)\n exit()\nans=0 \nlo=0 \nind1=-1 \nind2=-1 \nhi=len(good)-1\nnextl=l \nwhile lo<=hi: \n mi=(lo+hi)>>1 \n if good[mi]>=l:\n nextl=good[mi]\n ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nlo=0 \nhi=len(good)-1\nwhile lo<=hi: \n mi=(lo+hi)>>1 \n if good[mi]>=r:\n nextr=good[mi]\n # ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nprevr=r \nlo=0 \nhi=len(good)-1\nwhile lo<=hi:\n mi=(lo+hi)>>1 \n if good[mi]<=r: \n prevr= good[mi]\n ind2=mi \n lo=mi+1 \n else: \n hi=mi-1 \nans=0 \nfor i in range(ind1,ind2):\n diff=good[i+1]-good[i] \n ans+=diff*good[i+1]\nans+=(nextl-l+1)*nextl \nans+=(r-prevr)*nextr \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b4ba53de178ee8396d91eb0ababbd5a", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import sys\n\nnumbers = map(int, sys.stdin.readline().split())\n\nstart = numbers[0]\nend = numbers[1]\n\n\n\nlucky = [4, 7]\n\nfor i in range(1, 10):\n for j in range(len(lucky)):\n lucky.append(int(str(lucky[j]) + \"4\"))\n lucky.append(int(str(lucky[j]) + \"7\"))\n\ndef nextfun(i):\n count = 0\n while i > lucky[count]:\n count +=1\n \n return lucky[count]\n \n \nanswer = 0\n\nwhile(start <= end):\n answer += nextfun(start)\n start += 1\n \n \nprint answer", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0891d6ecaf0cdc233ab314222d2920d", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from itertools import product\nlucky = []\n\nl,r = input().split()\nlw, rw = len(l), len(r)\nl, r = int(l), int(r)\n\nfor i in range(lw,rw+1):\n lucky+=[int(''.join([str(y) for y in x])) for x in list(product([4,7],repeat=i))]\nlucky+=[int('4'*(rw+1))]\nans=0\nfor i in range(l,r+1):\n j=0\n while lucky[j] max_deep:\n max_deep = i - l\n l = i\n\nif l == -1:\n max_deep = len(a) + 1\n\nprint max_deep", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c4351c46211b00cb73433d618bd4986e", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "\nstring = raw_input().strip()\nvow = 'AEIOUY'\nans = 1\nleft = -1\nflag = False\n\nfor i in xrange(len(string)):\n\tif string[i] in vow:\n\t\tflag = True\n\t\tans = max(ans,i-left)\n\t\tleft = i\n\nif flag == False:\n\tans = len(string)+1\n\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7e569b3a3cffd2e5494af04afd8d68cc", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "string = raw_input()\nvowels = ['A', 'E', 'I', 'O', 'U']\nmini = 1\ncount = 0\nfor i in string:\n if i not in vowels:\n count += 1\n else:\n mini = max(mini, count+1)\n count = 0\nif count != 0:\n mini = max(mini, count+1)\nprint mini", "lang_cluster": "Python", "compilation_error": false, "code_uid": "17fe6b93db74d7db7deb400a5fb03478", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "s = raw_input()\n\nv = ['A','E','I','O','U','Y']\nn = 0\na = -1\nfor i in xrange(len(s)):\n if s[i] in v:\n if i-a>n:\n n = i-a\n a = i\nprint n if n>0 else len(s)+1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8bac3e97916dffb90335c38a9e7e168b", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(range(n))\ni=0\nwhile ib:\n b=c[j+1]-c[j]\n j+=1\n if b 0 and j < n:\n z[j] = (z[j-1]*p+z[j]*(1-p))\n elif j == n:\n z[j] = z[j-1]*p + z[j]\n else:\n z[j] = z[j]*(1-p)\n print z\n\nfor i in range(1,n+1):\n s+=i*z[i]\n\nprint s", "lang_cluster": "Python", "compilation_error": false, "code_uid": "873da58488dafd0ca7b86f4093e9e8ab", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def solution(N, t, P):\n\n cache = [[0 for j in range(N+1)] for i in range(t+1)]\n\n cache[0][0] = 1\n\n for i in range(t):\n\n for j in range(N+1):\n\n if j == N:\n\n cache[i+1][j] += cache[i][j]\n\n else:\n\n\n\n cache[i+1][j+1] += cache[i][j] * P\n\n cache[i+1][j] += cache[i][j] * (1 - P)\n\n answer = 0 \n\n for j in range(N+1):\n\n answer += cache[t][j] * j\n\n return round(answer,6)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "85150a4140acffedcbf2b5130b806c81", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\nnums = input().split(\" \")\nN = int(nums[0])\nP = float(nums[1])\nt = int(nums[2])\nif t <= N:\n print(round(t * P, 6))\nelif P == 1:\n print(t)\nelif P == 0:\n print(0)\nelse:\n a = math.pow((1 - P),t)\n total = 0\n\n \n for i in range(1,min(N + 1, t + 1)):\n a *= ((((t + 1 - i) / i) / (1 - P)) * P)\n total += i * a\n \n for j in range(min(N + 1, t + 1), t + 1):\n a *= ((((t + 1 - j) / j) / (1 - P)) * P)\n total += N * a\n print(round(total,6))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1c13ac55b3a9fe0f9475efea2074a4f", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n, p, t = map(float, input().split())\nn, t = int(n + 0.5), int(t + 0.5)\nfrom math import exp, lgamma\ndef c(a, b): \n if a == b:\n return 1\n return exp(lgamma(a + 1) - lgamma(b + 1) - lgamma(a - b + 1))\nprint(p)\nprint(sum(p**i * (1 - p)**(t - i) * c(t, i) * min(i, n) for i in range(t + 1))) \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "701833e7072414ae179bafab64ea2b5a", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "n,p,t=raw_input().split()\nn=int(n)\np=float(p)\nt=int(t)\nans=0\ntemp=t\nfor i in range(1,n+1):\n #temp=t\n ans=ans+pow(p,i-1)*(1-pow(1-p,temp))\n temp=temp-1\n if temp==0:\n break\n #print ans,temp\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1683b10f4da9d08d4036f4e44b4bc7d9", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\nk = int(sys.stdin.readline().strip())\nif k <= 36:\n if k == 1: print 4\n if k == 2: print 8\n if k == 3: print 48\n if k == 4: print 88\n if k == 5: print 488\n if k == 6: print 888\n if k == 7: print 4888\n if k == 8: print 8888\n if k == 9: print 48888\n if k == 10: print 88888\n if k == 11: print 488888\n if k == 12: print 888888\n if k == 13: print 4888888\n if k == 14: print 8888888\n if k == 15: print 48888888\n if k == 16: print 88888888\n if k == 17: print 488888888\n if k == 18: print 888888888\n if k == 19: print 4888888888\n if k == 20: print 8888888888\n if k == 21: print 48888888888\n if k == 22: print 88888888888\n if k == 23: print 488888888888\n if k == 24: print 888888888888\n if k == 25: print 48888888888888\n if k == 26: print 8888888888888\n if k == 27: print 48888888888888\n if k == 28: print 88888888888888\n if k == 29: print 488888888888888\n if k == 30: print 888888888888888\n if k == 31: print 4888888888888888\n if k == 32: print 8888888888888888\n if k == 33: print 48888888888888888\n if k == 34: print 88888888888888888\n if k == 35: print 488888888888888888\n if k == 36: print 888888888888888888\nelse:\n print -1,\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ea6ad6f1df2db759f77e3fd06beb23e", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k = int(input())\nif k % 2 == 0:\n if k / 2 > 17:\n print(-1)\n else:\n print('8' * (k // 2))\nelse:\n if k / 2 + 1 > 17:\n print(-1)\n else:\n print('8' * (k // 2), '9', sep = '')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "231afc7d57fda194b4b0d3967f439274", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k = int(input())\n\nif k > 37:\n print(-1)\nelse:\n x = \"\"\n for i in range(k//2):\n x += '8'\n if k % 2:\n x += '6'\n\n print(x)\n\n# 1000000000000000000\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "37e52791521723f7f21ba807e15830f8", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k = int(input())\ns = ''\nwhile k:\n\tif k>1:\n\t\tk-=2\n\t\ts+='8'\n\telse:\n\t\tk-=1\n\t\tif s=='':\n\t\t\ts+='4'\n\t\telse:\n\t\t\ts+='0'\nif len(s)>17:\n\tprint (-1)\nelse:\n\tprint (s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3899b1c405e19f9c50d1be7f157e3b9", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "# cook your dish here\nn=int(input())\nout=\"\"\nif n>38:\n print(-1)\nelse:\n for i in range(n//2):\n out+=\"8\"\n for i in range(n%2):\n out+=\"9\"\n print(out)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eb7c3265509cec806106229b28d41f16", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import os\n\nin_no = raw_input()\nn = map(int, list(in_no))\n\nno = \"\"\nfor e in n:\n if e < (9-e) and no[-1] == '0':\n no += str(9-e)\n elif e < (9-e):\n no += str(e)\n else:\n no += str(9-e)\nif int(no) > 0:\n print int(no)\nelse:\n print in_no\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7978182ce1ed811c73fa005c46caad7", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from itertools import *\n\nnumbers=\"9876543210\"\nx=input()\nl= len(x)\n\nst= 1 if x[0]=='9' else 0\ny=len( x)- st\nminx=x\nfor assignment in product([0,1], repeat=y):\n x2=\"\"\n if st==1:\n x2+=x[0]\n for i in range(st,len(x)):\n\n x2+=numbers[int(x[i])] if assignment[i-st]==1 else x[i]\n if x2= 10:\n x = n % 10\n temp.append(min(x,9-x))\nif n != 9:\n temp.append(min(n,9-n))\nelse:\n temp.append(n)\nres = 0\nfor i in range(len(temp)):\n res += temp[i]*(10**i)\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a547fe511ad5d62ecd730a2b5bde8a13", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "# C. Fibonacci Words\r\ns = input()\r\nnum1 = ord(s[0]) - 65\r\nnum2 = ord(s[1]) - 65\r\ncount = 0\r\n\r\nfor i in range(2, len(s)):\r\n nums = (num1 + num2) % 26\r\n\r\n if ord(s[i]) - 65 == nums:\r\n num1 = num2\r\n num2 = nums\r\n count += 1\r\n else:\r\n break\r\n\r\nif count == len(s) - 2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64b2b8b66fb10f13a275ecc0b907538e", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "word = input()\r\nalpha = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\nwordidx = [alpha.index(i) for i in word]\r\nfibidx = [wordidx[0], wordidx[1]]\r\nwhile len(fibidx) != len(wordidx):\r\n fibidx.append((fibidx[-1]+fibidx[-2])%26)\r\nprint(\"YES\") if fibidx == wordidx else print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa0eb5becb095ae46561e3f246613d1d", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a = 'abcdefghijklmnopqrstuvwxyz'\r\n\r\ns = input().lower()\r\nans = 'YES'\r\n\r\nn = [a.index(s[0]) + 1, a.index(s[1]) + 1]\r\n\r\nfor i in range(2, len(s)):\r\n if n[i - 2] + n[i - 1] - 1 > 26:\r\n if a.index(s[i]) + 1 == n[i - 2] + n[i - 1] - 27:\r\n n.append(a.index(s[i]) + 1)\r\n else:\r\n ans = 'NO'\r\n break\r\n else:\r\n if a.index(s[i]) + 1 == n[i - 2] + n[i - 1] - 1:\r\n n.append(a.index(s[i]) + 1)\r\n else:\r\n ans = 'NO'\r\n break\r\nprint(ans)\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "edb6b185fefcafedee6fe8e3d440ee83", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "# DEFINING SOME GOOD STUFF\nimport sys\nfrom math import *\nimport threading\nfrom itertools import count\nfrom pprint import pprint\nfrom collections import defaultdict\n\n'''\n intialise defaultdict by any kind of value by default you want to take ( int -> 0 | list -> [] )\n'''\nfrom heapq import heapify, heappop, heappush\n\nsys.setrecursionlimit(300000)\n# threading.stack_size(10**8)\n'''\n-> if you are increasing recursionlimit then remember submitting using python3 rather pypy3\n-> sometimes increasing stack size don't work locally but it will work on CF\n'''\n\nmod = 10 ** 9+7\ninf = 10 ** 15\ndecision = ['NO', 'YES']\nyes = 'YES'\nno = 'NO'\n\n# ------------------------------FASTIO----------------------------\nimport os\n\nfrom io import BytesIO, IOBase\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\n# _______________________________________________________________#\n\ndef npr(n, r):\n return factorial(n) // factorial(n-r) if n >= r else 0\n\n\ndef ncr(n, r):\n return factorial(n) // (factorial(r) * factorial(n-r)) if n >= r else 0\n\n\ndef lower_bound(li, num):\n answer = -1\n start = 0\n end = len(li)-1\n\n while (start <= end):\n middle = (end+start) // 2\n if li[middle] >= num:\n answer = middle\n end = middle-1\n else:\n start = middle+1\n return answer # min index where x is not less than num\n\n\ndef upper_bound(li, num):\n answer = -1\n start = 0\n end = len(li)-1\n\n while (start <= end):\n middle = (end+start) // 2\n\n if li[middle] <= num:\n answer = middle\n start = middle+1\n\n else:\n end = middle-1\n return answer # max index where x is not greater than num\n\n\ndef abs(x):\n return x if x >= 0 else -x\n\n\ndef binary_search(li, val):\n # print(lb, ub, li)\n ans = -1\n lb = 0\n ub = len(li)-1\n while (lb <= ub):\n mid = (lb+ub) // 2\n # print('mid is',mid, li[mid])\n if li[mid] > val:\n ub = mid-1\n elif val > li[mid]:\n lb = mid+1\n else:\n ans = mid # return index\n break\n return ans\n\n\ndef kadane(x): # maximum sum contiguous subarray\n sum_so_far = 0\n current_sum = 0\n for i in x:\n current_sum += i\n if current_sum < 0:\n current_sum = 0\n else:\n sum_so_far = max(sum_so_far, current_sum)\n return sum_so_far\n\n\ndef pref(li):\n pref_sum = [0]\n for i in li:\n pref_sum.append(pref_sum[-1]+i)\n return pref_sum\n\n\ndef SieveOfEratosthenes(n):\n prime = [True for i in range(n+1)]\n p = 2\n li = []\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\n for p in range(2, len(prime)):\n if prime[p]:\n li.append(p)\n return li\n\n\ndef primefactors(n):\n factors = []\n while (n % 2 == 0):\n factors.append(2)\n n //= 2\n for i in range(3, int(sqrt(n))+1, 2): # only odd factors left\n while n % i == 0:\n factors.append(i)\n n //= i\n if n > 2: # incase of prime\n factors.append(n)\n return factors\n\n\ndef prod(li):\n ans = 1\n for i in li:\n ans *= i\n return ans\n\n\ndef sumk(a, b):\n print('called for', a, b)\n ans = a * (a+1) // 2\n ans -= b * (b+1) // 2\n return ans\n\ndef sumi(n):\n ans = 0\n if len(n) > 1:\n for x in n:\n ans += int(x)\n return ans\n else:\n return int(n)\n\n# _______________________________________________________________#\n\n\n# def main():\nkarmanya = 0\nd={'HELP': yes, 'AID': no, 'MARY': no, 'ANNA': yes, 'MUG': yes, 'CUP': no, 'SUM': yes, 'PRODUCT': no}\nfor _ in range(int(input()) if karmanya else 1):\n # n = int(input())\n # n, r = map(int, input().split())\n # s = [int(x) for x in input()]\n # a = list(map(int, input().split()))\n # b = list(map(int, input().split()))\n # c = list(map(int, input().split()))\n # d = defaultdict(int())\n s1 = (input())\n # s2 = (input())\n print(d[s1])\n\n\n\n\n\n\n\n\n\n\n\n# t = threading.Thread(target=main)\n# t.start()\n# t.join()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b08a6b0f6a7fb0e5a2780555ba6c0b29", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n if(word=='A'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='AA'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n if(word=='AB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='BB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(len(word) == 1):\n while(True):\n n = 2+2\n\n if(len(word) == 2):\n while(True):\n n = 2+2\n\n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d83f95faa526f3e4bf738eb822a9630b", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "if __name__ == '__main__':\n\ta,b = map(int, raw_input().split())\n\tif a==b:\n\t\tprint \"infinity\"\n\t\texit()\n\tcount = 0\n\tnum = a-b\n\tdec = b+1\n\ti = 1\n\t#print num, dec\n\twhile dec > b:\n\t\tif num%i==0:\n\t\t\t#print num,i\n\t\t\tdec = num/i\n\t\t\tif dec > b:\n\t\t\t\tcount+=1\n\t\ti+=1\n\tprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "81a161b5bd97a5266f34b055955bfd27", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "from collections import Counter\n \ndef get_ls(n):\n \"\"\"\u0420\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\"\"\"\n #result = [1]\n result = []\n i = 2\n while i < n:\n if n % i == 0:\n n /= i\n result.append(i)\n else:\n i += 1\n result.append(int(n))\n return result\n \na,b=map(int,input().split())\nif a==b :\n print(\"infinity\")\n exit()\nif b>a :\n print(0)\n exit()\nif a==1 and b==0 :\n print(1)\n exit()\nls = get_ls(a-b)\n\n \nkkk = dict(Counter(ls)).items()\n \nd = [k for k, _ in kkk]\nm = [v for _, v in kkk]\nk = [0 for _ in range(len(set(ls)))]\n \nln = range(len(m))\nk1=0\ntry:\n while True:\n r = 1\n for i1, i2 in zip(d, k):\n r *= i1 ** i2\n if r>b :\n k1+=1\n \n k[0] += 1\n for i in ln:\n if k[i] > m[i]:\n k[i] = 0\n k[i+1] += 1 # IndexError\nexcept IndexError:\n pass\nprint(k1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2bb1258328bfac31b228f9bd79b8e9c7", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.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\")\nelse :\n i = 1\n t = e\n ans = 0\n while(True) :\n if(e % i == 0):\n \tt = e // i\n \tif(t > b):\n \t\tans += 1\n if(e // i <= b) :\n \tbreak\n i += 1\n print(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3362142a567070cf4117ffe063348e9", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\nimport math\nimport fractions\n\ndef sieve(n):\n A = [True for i in range(n + 1)]\n for i in range(2, int(math.sqrt(n)) + 1):\n if A[i]:\n for j in range(i * i, n + 1, i):\n A[j] = False\n res = []\n for i in range(2, n + 1): \n if A[i]: res.append(i)\n return res\n\ndef factor(n):\n base = sieve(n / 2)\n \"\"\"\n i = len(base) - 1\n fact = {}\n while n > 1 and i >= 0:\n if n % base[i] == 0:\n n /= base[i]\n if base[i] in fact: fact[base[i]] += 1\n else: fact[base[i]] = 1\n else:\n i -= 1\n \"\"\"\n \n start = int(math.sqrt(n))\n pairs = []\n factors = set([1, n])\n for i in range(start,n):\n for j in range(len(base)):\n lhs = i ** 2 % n\n rhs = base[j] ** 2 % n\n if lhs == rhs: \n pairs.append([i,base[j]]);\n for i in range(len(pairs)):\n factors |= set([fractions.gcd(pairs[i][0]-pairs[i][1],n)])\n res = list(factors)\n res.sort()\n return res\n \n\ndef mod_equation(a, b):\n if a < b: return 0\n if a == b: return 'infinity'\n if a - b == 1:\n if a == 1: return 1\n else: return 0\n #fact = factor(a - b)\n c = a - b\n res = 0\n for i in range(b + 1, (a + b) / 2 + 1):\n if c % i == 0: res += 1\n if a > 1: res += 1\n return res\n \n \"\"\"\n i = 0\n j = len(fact) - 1\n while j - i > 1:\n mid = (i + j) / 2\n if fact[mid] > b: j = mid\n else: i = mid\n return len(fact) - j\n \"\"\"\n \nif __name__ == '__main__':\n \n num = sys.stdin.readline().split()\n a = int(num[0])\n b = int(num[1])\n print mod_equation(a, b)\n \n #print factor(9435152-272)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef92dbcb5a4d8f428bf821384b52245f", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\nimport math\nimport fractions\n\"\"\"\ndef sieve(n):\n A = [True for i in range(n + 1)]\n for i in range(2, int(math.sqrt(n)) + 1):\n if A[i]:\n for j in range(i * i, n + 1, i):\n A[j] = False\n res = []\n for i in range(2, n + 1): \n if A[i]: res.append(i)\n return res\n\"\"\"\n\"\"\"\ndef factor(n):\n base = sieve(n / 2)\n i = len(base) - 1\n fact = {}\n while n > 1 and i >= 0:\n if n % base[i] == 0:\n n /= base[i]\n if base[i] in fact: fact[base[i]] += 1\n else: fact[base[i]] = 1\n else:\n i -= 1\n start = int(math.sqrt(n))\n pairs = []\n factors = set([1, n])\n for i in range(start,n):\n for j in range(len(base)):\n lhs = i ** 2 % n\n rhs = base[j] ** 2 % n\n if lhs == rhs: \n pairs.append([i,base[j]]);\n for i in range(len(pairs)):\n factors |= set([fractions.gcd(pairs[i][0]-pairs[i][1],n)])\n res = list(factors)\n res.sort()\n return res\n\"\"\"\n\ndef mod_equation(a, b):\n if a < b: return 0\n if a == b: return 'infinity'\n if a - b == 1:\n if a == 1: return 1\n else: return 0\n c = a - b\n res = 0\n for i in range(b + 1, (a + b) / 2 + 1):\n if c % i == 0: res += 1\n if a > 1: res += 1\n return res\n \n \"\"\"\n i = 0\n j = len(fact) - 1\n while j - i > 1:\n mid = (i + j) / 2\n if fact[mid] > b: j = mid\n else: i = mid\n return len(fact) - j\n \"\"\"\n \nif __name__ == '__main__':\n num = sys.stdin.readline().split()\n a = int(num[0])\n b = int(num[1])\n print mod_equation(a, b)\n \n #print factor(9435152-272)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b7e958176e30c7b26d7d12f485541c3a", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\nsys.stdout = open('CP/output.txt', 'w')\nsys.stdin = open('CP/input.txt', 'r')\n\nif __name__=='__main__':\n N = int(input())\n if N < 5:\n print(0)\n else:\n primes = [0]*(N+1)\n for i in range(2, N+1):\n if primes[i] == -1:\n continue\n primes[i] = i\n for j in range(2*i, N+1, i):\n primes[j] = -1 \n a = [i for i in range(N+1)]\n ap = 0\n for i in range(2, N+1):\n count = 0\n if a[i] != -1:\n for j in primes[2:]:\n if j != -1 and a[i] % j == 0:\n count +=1 \n if count > 2:\n break\n if count == 2:\n ap +=1 \n if primes[i]!= -1:\n a[i] = -1\n j = 2\n while(N//(i**j) > 0):\n a[i**j] = -1\n j += 1\n print(ap) \n \n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "221794ac6c8b6aa95855467463a897cc", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#! /usr/bin/env python\nimport sys\n\ndef big_powers(primes, n):\n result = []\n for p in primes:\n p_in_deg = p**3\n while p_in_deg <= n:\n result.append(p_in_deg)\n p_in_deg *= p\n return set(result)\n\ndef make_power_primes(primes, n):\n result = []\n for p in primes:\n p_in_deg = p\n while p_in_deg <= n/2:\n result.append(p_in_deg)\n p_in_deg *= p\n return set(result)\n\ndef make_primes(n):\n result = [2]\n for i in range(3,n+1):\n add = True\n for x in result:\n if (i % x == 0):\n add = False\n if add:\n result.append(i)\n return result\n \n\ndef main():\n n = int(sys.argv[1])\n #print n\n primes = make_primes(n/2)\n #print \"primes = \" , primes\n power_primes = make_power_primes(primes, n)\n #print \"power_primes = \", power_primes\n almost_almost_primes = set([x*y for x in power_primes for y in power_primes if x*y <= n and x<>y])\n #print \"almost_almost_primes = \", almost_almost_primes\n #print \"big_powers_prime = \", big_powers(primes, n)\n print len([x for x in almost_almost_primes if not (x in big_powers(primes, n))])\n \n \n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "30e5fdfe191b8ea847ed61a2b23a86a2", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "a,p = [],[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,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499]\nfor i in range(0, len(p)):\n\tfor j in range(i+1, len(p)):\n\t\tk = 1\n\t\twhile p[j]*(p[i]**k) < 3000: \n\t\t\tl = 1\n\t\t\twhile (p[i]**k)*(p[j]**l) < 3000:\n\t\t\t\ta.append((p[i]**k)*(p[j]**l))\n\t\t\t\tl+=1\n\t\t\tk+=1\na, i, x= sorted(set(a)), 0, int(input())\nwhile x >= a[i]: i+=1\nprint(i)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e62a03b171dcbae171df943bff333088", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "Python 2", "source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\nimport math\n\ndef resheto(num):\n arr = []\n for i in range(1,num/2):\n arr.append(i+1)\n\n for i in range(0,int(math.sqrt(num))):\n if arr[i]!=0:\n for j in range(2*arr[i]-2,(num/2)-1,arr[i]):\n arr[j]=0\n\n arr2 = []\n for i in range(0,(num/2) - 1):\n if arr[i]!=0:\n arr2.append(arr[i])\n\n kol = 0\n for i in range(0,len(arr2)-1):\n for j in range(i+1,len(arr2)):\n x1 = arr2[i]\n x2 = arr2[j]\n did=0\n while x1*x2<=num:\n kol+=1\n x1 *= x1\n did = 1\n x1 = arr2[i]\n x2 = arr2[j]\n\n while x1*x2<=num:\n kol+=1\n x2 *= x2\n if did==1:\n did=2\n if did == 2:\n kol -= 1\n\n return kol\n\nif __name__ == \"__main__\":\n num = int(raw_input())\n print resheto(num)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91a4b7e27c4add65c0e70d2602ac29c5", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n=int(input())\narr=[0]*(n+1)\narr[0]=0\narr[1]=0 \narr[2]=0\nx=(n)//2\nfor i in range(2,x+1):\n if arr[i]==0:\n j=2\n while(i*j<=n):\n arr[i*j]+=1 \n j+=1 \noutput=0\nfor i in arr:\n if i==2:\n output+=1 \nprint(output)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ceefd5cca709edb244fbb376025ee9c5", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "Python 3", "source_code": "read = input()\nlist1 = list(read)\ncount = 0\nfor i in range(len(list1)) :\n while list1[i]==list1[i-1] :\n count+=1\n if count== 7 :\n print(\"YES\")\n print(i)\n break\n\n\nif count < 7 :\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "01b1e5cd55f02df76ebe397bca54659c", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Python 3", "source_code": "arr = input()\n\ncount = 1\nwhile count != 7:\n\tfor i in range(len(arr) - 1):\n\t\tif arr[i] == arr[i + 1]:\n\t\t\tcount += 1\n\t\telse:\n\t\t\tcount = 0\n\t\t\n\nif count >= 7:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7961b847351ba6c4f22a22f13f009cfe", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Python 2", "source_code": "sequence = list(raw_input())\nx = sequence[0]\ny = 1\nnumbers = []\n\ni = 0\nwhile i <= (len(sequence) - 1):\n\tif sequence[i + 1] == x:\n\t\ty += 1\n\telse:\n\t\tx = sequence[i + 1]\n\t\tnumbers.append(y)\n\t\ty = 1\n\nif max(numbers) >= 7:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5451b9b1c81c39c64010b20f4bca7a5", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Python 3", "source_code": "word = input()\ncounter = 1\nfor i in range(len(word)-1):\n while word[i]==word[i+1]:\n counter +=1\n else:\n counter=1\n if counter == 7:\n print(\"YES\")\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c87d925785d288c5715a12f4dd5ef1fc", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "Python 3", "source_code": "arr = input()\n\ncount = 1\nwhile count < 7:\n\tfor i in range(len(arr) - 1):\n\t\tif arr[i] == arr[i + 1]:\n\t\t\tcount += 1\n\t\telse:\n\t\t\tcount = 0\n\t\t\n\nif count >= 7:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "19ba5bcf5f7a7f4f56804ac4cde1eba3", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "for i in range(int(input())):\n n, k, d = map(int, input().split())\n s = list(map(int, input().split()))\n ch = set()\n for i in range(n - d):\n ch.add(len(set(s[i:i + d])))\n print(min(ch))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6eb8a21b1e56ac71a3b5779c088737be", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "t=int(input())\nfor i in range(t):\n n=int(input())\n k=int(input())\n d=int(input())\n a=list(range(n))\n l=[[] for q in range(n-d+1)]\n for j in range (n):\n a[j]=int(input())\n for p in range (n-d+1):\n for j in range(1, d+1):\n if l[p].count(a[p-1+j])==0:\n l[p].append(a[p-1+j])\n for p in range (n-d+1):\n l[p]=len(l[p])\n print(min(l))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e5b890503d7a8525b6034408a628a3b", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "da, db = map(int, input().split())\nif da == 9 and db == 1:\n print('999 1000')\nelif da > db:\n print(-1)\nelif da == 0:\n print(-1)\nelif da == db:\n print('{}00 {}01'.format(da, da))\nelif da == 9 and db == 1:\n print('999 1000')\nelif da + 1 == db:\n print('{}99 {}00'.format(da, db))\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78b96f1bd421dffb59e4d4fd87ba30a4", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "t = int(input())\nfor _ in range(t):\n n,k,d = map(int,input().split())\n l1 = list(map(int,input().split()))\n ans=n\n thing = l1[:d]\n for j in range(n-d+1): \n ans = min(ans,len(set(thing)))\n thing.pop(l1[j])\n thing+=l1[j+d]\n \n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "478ba9c7cbe48bf0b9d1f2e514c858b1", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from math import inf\nfor i in range(int(input())):\n\tn=int(input())\n\tl=[int(s) for s in input().split()]\n\tm=[(l[i+1]-l[i]<=2) for i in range(n-1)]\n\tcounter=0\n\tmaxi=0\n\tfor elem in m:\n\t\tif elem:\n\t\t\tcounter+=1\n\t\telif counter>0:\n\t\t\tmaxi=max(maxi,counter)\n\t\t\tcounter=0\n\tif counter:\n\t\tlis.append(counter)\n\tif not len(lis):\n\t\tprint(1,1)\n\telse:\n\t\tprint(min(lis)+1,max(lis)+1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2085d5a7273633e29ca03b858931e4e", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# a=list(map(int,input().strip().split()))\nb=int(input())\ng=int(input())\nn=int(input())\n\n# # print(min(n%d,n%(e*5),((n%(e*5))%d),((n%d)%(e*5))))\n# dd=n%d\n# ee=n%(e*5)\n# arr=[dd,ee]\n# if(dd>1):\n# arr.append((dd+d)%(e*5))\n\nop=[]\n\nj=0\nfor k in range(0,n):\n if(((k-j+1)*(j+k))//2>=b and ((k-j+1)*((n-j)+(n-k)))//2>=g):\n op.append(k-j+1)\nprint(min(op))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "483b5be081e37974cc9cc3e365d6993c", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def main():\n b = int(input())\n g = int(input())\n\n accepted = int(input())\n\n if b + g == accepted:\n print(1)\n return None\n\n if accepted > b and accepted > g:\n print(min(b, y) - 2)\n return\n \n else:\n print(min(b, g, accepted) + 1)\n \n\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77b3b3e9871c4b93e98312ff02130b05", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "boys=int(input())\ngirls=int(input())\nn=int(input())\ndecks=n+1\ndeck=[]\nfor i in range(0,n+1):\n blue=i\n red=n-i\n if(blue>boys or red>girls):\n continue\n deck.append(1)\nprint(count(deck))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7d657dacb1722066e506de8674e9c00", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\nb, g, n = map(int, input().split())\n_max = max(b, g)\n_min = min(b, g)\n\nif(n<_max):\n print(n+1)\nelse:\n print (_min - n + _max + 1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49acea69e41cde100a49ba651369e97d", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"5\\n\",\n \"3\\n\",\n \"5\\n\",\n \"4\\n\"\n ]\n }\n ],\n \"source\": [\n \"b=int(input())\\n\",\n \"g=int(input())\\n\",\n \"n=int(input())\\n\",\n \"ans=n+1\\n\",\n \"for i in range(n+1):\\n\",\n \" if b b):\n x = int(a / b)\n a -= x * b\n else:\n x = int(b / a)\n b -= x * a\n count += x\nprint(count)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc0647b0c3067dee98dbc1a56c340fa1", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def paper():\n\tcount = 0\n\n\ta,b = raw_input(\"\").split()\n\ta = int(a)\n\tb = int(b)\n\n\n\twhile a!= b:\n\t\tif a == 1000000000000:\n\t\t\treturn 1000000000000 \n\t\t\tbreak\n\n\t\telif a > b:\n\t\t\ta = a - b\n\t\t\tcount += 1\n\t\telif b > a:\n\t\t\tb = b - a\n\t\t\tcount += 1\n\n\treturn count + 1\n\nprint paper()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04c87eb3549bc22a84a0458f3af91550", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a, b = map(int, raw_input().split())\ncount = 0\nflag = 1\nwhile a != 1 and b != 1:\n if a == b:\n flag = 0\n break\n if a < b:\n b = b - a\n count += 1\n else:\n a = a - b\n count += 1\nif flag == 0:\n print count + 1\nelse:\n print count + max(a, b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "86a02e40b924b730cdc910d25503467a", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import unittest\n\ndef solve(a,b):\n if a == b:\n return 1\n\n if b == 1:\n return a\n\n a -= b\n if b > a:\n a,b = b,a\n\n return 1 + solve(a,b)\n\nclass Test_solution(unittest.TestCase):\n def test_case(self):\n self.assertEqual(solve(2,2), 1)\n self.assertEqual(solve(2,1), 2)\n self.assertEqual(solve(10,7), 6)\n self.assertEqual(solve(1000000000000, 1), 1000000000000)\n\n\n\nif __name__ == '__main__':\n #unittest.main()\n a, b = map(int, input().split())\n print(solve(a,b))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d98882fa6b562d04a2855b287ee6280", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import time\ndef get_num(w,h):\n\tcounter=0\n\ttmp=0\n\tx=False\n\twhile (x==False):\n\t\tprint 'start:',w,h\n\t\tif w==h:\n\t\t\tx=True\n\t\tw=w-h\n\t\t\n\t\tif w 0:\n rem = n2 % 10\n rev = (rev * 10) + rem\n n2 = n2 // 10\n print(f'{n1 + rev}')\n t = t - 1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6fe8276f33a5941922ce0808abeadc6d", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a=input()\nb=input()[::-1]\nprint(int(a)+int(b))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd74df71bd9fe04b5a42dc419f283387", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import random\n\nn, m = map(int, input().split())\n\nprint(random.randint())", "lang_cluster": "Python", "compilation_error": false, "code_uid": "43ad60526a8daeedbe4a2bcd03b16e15", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "a1, a2=raw_input().split()\nif len(a1)0:\n\t\tif int(a1[x-1])+int(a2[x-1])>=10:\n\t\t\tb+=1\n\tif b>=10:\n\t\tb=str(b)\n\t\tb=b[len(b)-1]\n\tb=str(b)\n\tif x==len(a1)-1:\n\t\tif len(b)>=2:\n\t\t\tb=list(b)\n\t\t\tb.reverse()\n\t\t\tb=''.join(b)\n\tc+=b\n\nc=list(c)\nc.reverse()\nc=''.join(c)\nprint c\t\t\n\t\t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b8750b1095ae7dc23844bf18b061ab9", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#Codeforces Pages\n\nn = int(input())\np = int(input())\nk = int(input())\n\nb = 1 if p-k<1 else p-k\ne = n if p+k>n else p+k\n\nif b !=1:\n print(\"<<\",end=\" \")\n \nfor i in range(b,e+1):\n if i==p:\n print(\"(\"+str(i)+\")\",end=\" \")\n else:\n print(i,end=\" \")\nif e !=n:\n print(\">>\",end=\"\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "487031bd425a0aa77c85ad6b9a203334", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "PyPy 3", "source_code": "w=int(input())\nn=int(input())\ns=0\nfor i in range(0,n):\n f=input()\n z=f.split( )\n s=s+(int(z[0])*int(z[1]))\ng=int(s/w)\nprint(g)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3788f64f8aa3aa8903d816b2339c8a9", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Python 3", "source_code": "def main():\n x: list = list(map(int, input().split()))\n n: int = x[0]\n p: int = x[1]\n k: int = x[2]\n tmp: list = list()\n\n for i in range(k + 1):\n x: int = p - i\n if x is 0:\n break\n elif x is p:\n tmp.append('(' + str(x) + ')')\n else:\n tmp.append(str(x))\n\n tmp.reverse()\n\n if int(tmp[0]) is not 1:\n print('<<', end=' ')\n\n print(' '.join(tmp), end=' ')\n tmp.clear()\n\n for i in range(k + 1):\n x: int = p + i\n if x is n:\n tmp.append(str(x))\n break\n elif x is p:\n continue\n else:\n tmp.append(str(x))\n\n print(' '.join(tmp), end=' ')\n\n if int(tmp[len(tmp) - 1]) is not n:\n print('>>')\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f886064fdd757276fa861df0f419ade7", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Python 3", "source_code": "n, k, p = map(int, input().split())\ns = '(' + str(k) + ')'\nans = ''\n\nfor i in range (k-p,k+p+1):\n if i == k:\n ans += s+ ' '\n if i <= n and i != k and i > 0:\n ans += str(i) + ' '\nA = ans.split()\n\nif A[-1] == s:\n print('<< ' + ' '.join(A))\nelif (A[0] == '(1)' or int(A[0]) == 1) and int(A[-1]) < n:\n print(' '.join(A) +' >>')\nelif int(A[-1]) == n and (int(A[0]) == 1 or A[0] == '(1)'):\n print(' '.join(A))\nelif int(A[-1]) < n and int(A[0]) > 1:\n print('<< '+ ' '.join(A) + ' >>')\nelif int(A[-1]) == n and int(A[0]) > 1:\n print('<< ' + ' '.join(A))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4c1ed764919e56b7276b6abe282e0e6b", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "Python 2", "source_code": "i = map(int, raw_input().split())\nn = i[0]\np = i[1]\nk = i[2]\nj = k\nstri = ''\n\nif p - 2 > 1:\n stri += \"<< \"\n\nwhile j > 0:\n if p - j > 0:\n stri = stri + str(p - j) + ' '\n j = j - 1\n\nstri = stri + '(' + str(p) + ') '\nj = 1 \n \nwhile j <= (k + 1) & (p + j) <= n:\n print(str(j) + str(k) + str(p) + str(n))\n if (p + j) <= n:\n stri = stri + str(p + j) + ' '\n j = j + 1\n\nif (p + j) < n + 1:\n stri = stri + '>>'\n \nprint(stri)\nraw_input()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c4f07da9599f95d181394c2c942d48a4", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "PyPy 2", "source_code": "x,y = map(int,raw_input().split())\nme = y-1\nif(y == 0):\n print \"No\"\nelif(x < me):\n print \"No\"\nelse:\n left = x-me\n if(left == 0):\n print \"Yes\"\n else:\n if(left%2 == 0):\n print \"Yes\"\n else:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78e7b42b08e6ff0e33e5990b09e11880", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "s=input()\ns=s.split()\ny=int(s[0])\nx=int(s[1])\nx-=1\nif x>0:\n y-=x\n x=0\nif y<0:\n print('No')\nelif y%2==0:\n print('Yes')\nelse:\n print('No')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58e39ab51e10a155b2cc8dd02635b555", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "x, y = [int(k) for k in input().split(' ') if k]\ny -= 1\nif x < y:\n print(\"No\")\nelse:\n if (x - y) % 2 == 0:\n print(\"Yes\")\n else:\n print(\"No\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "104094762fc1ea5f637bd6ca18896dd1", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nif n==1 and m==0:\n print(\"No\")\nelse:\n d=m-1\n i=n-d\n if i%2==0 and i>=0:\n print(\"Yes\")\n else:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b72e89aad30d544756b010af51999381", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def main():\n x,y=map(long,raw_input().split())\n y-=1 \n if y!=0 and (x-y)%2==0 and x>=y:\n print \"Yes\"\n else:\n print \"No\"\n \nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "059d9908ca051532dbfc48a3ed396ba8", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "import sys\nfile = open(\"test1\")\nsys.stdin = file\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef ai(): return list(map(int, input().split()))\n\nu,v = mi()\nif u>v or u&1 != v&1:\n\tprint(-1)\nelif u==0 and v == 0:\n\tprint(0)\nelse:\n\tx = (v-u)//2\n\tif x:\n\t\tif u&x!=0:\n\t\t\tprint(3)\n\t\t\tprint(u,x,x)\n\t\telse:\n\t\t\tprint(2)\n\t\t\tprint(u+x,x)\n\telse:\n\t\tprint(1)\n\t\tprint(u)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "69c47b55ad2a373536af937280c8a782", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "\"\"\"\n Author : thekushalghosh\n Team : CodeDiggers\n\"\"\"\nimport sys,math\ninput = sys.stdin.readline\n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\ndef inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(s[:len(s) - 1])\ndef invr():\n return(map(int,input().split()))\n################################################################\n############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\nt = 1\nfor tt in range(t):\n u, v = map(int, input().split())\n if u == 0 and v == 0:\n print(0)\n elif u == 0 or v == 0:\n print(-1)\n q = list(map(int,list(reversed(list(\"0\" * (60 - int((math.log(u) // math.log(2)) + 1)) + bin(u).replace(\"0b\", \"\"))))))\n w = list(map(int,list(reversed(list(\"0\" * (60 - int((math.log(v) // math.log(2)) + 1)) + bin(v).replace(\"0b\", \"\"))))))\n qw = 0\n for i in range(59,-1,-1):\n if w[i] % 2 == q[i]:\n continue\n if i == 0:\n qw = 1\n break\n if q[i] == 1 and w[i] == 0:\n for j in range(i + 1, 60):\n if w[j] >= 2:\n w[j] = w[j] - 2\n for k in reversed(range(i, j)):\n w[k] = w[k] + 2\n w[i] = w[i] + 4\n break\n if w[i] == 0:\n qw = 1\n break\n w[i] = w[i] - 1\n w[i - 1] = w[i - 1] + 2\n if qw == 1:\n print(-1)\n else:\n qwqw = [0] * max(w)\n for i in range(60):\n for j in range(w[i]):\n qwqw[j] = qwqw[j] + 2 ** i\n print(len(qwqw))\n print(*qwqw)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "efc124df3e5eb19ccc8f713e0682b0a9", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\n\ndef input():\n return stdin.readline()[:-1]\n\n\ndef intput():\n return int(input())\n\n\ndef sinput():\n return input().split()\n\n\ndef intsput():\n return map(int, sinput())\n\n\nclass RangedList:\n def __init__(self, start, stop, val=0):\n self.shift = 0 - start\n self.start = start\n self.stop = stop\n self.list = [val] * (stop - start)\n\n def __setitem__(self, key, value):\n self.list[key + self.shift] = value\n\n def __getitem__(self, key):\n return self.list[key + self.shift]\n\n def __repr__(self):\n return str(self.list)\n\n def __iter__(self):\n return iter(self.list)\n\n\ndef dprint(*args, **kwargs):\n if debugging:\n print(*args, **kwargs)\n\ndef conv(x):\n return int(''.join(str(k) for k in x), 2)\n\ndebugging = 1\n# Code\nxor, total = intsput()\nxor = bin(xor)[2:]\nxor = list(map(int, list('0' * (64 - len(xor)) + xor)))\n\nokay = [[True] * 64 for _ in range(100000)]\nnumbers = []\nrem = total\n\nreq = [0] * 64\n\nfor i in range(len(xor)):\n fits = rem // 2 ** (63 - i)\n if not xor[i]: # make even\n fits -= fits % 2\n else: # make odd\n fits += (fits % 2 - 1)\n req[i] += fits\n rem -= fits * 2 ** (63 - i)\n\nif rem:\n print(-1)\n exit()\n\nwhile any(req):\n container = [0] * 64\n for i in range(len(req)):\n if req[i]:\n container[i] = 1\n req[i] -= 1\n numbers.append(container)\n\nprint(len(numbers))\nif numbers:\n print(*[conv(number) for number in numbers])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d50bc51a9942f995d139852be0b03a16", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "u,v=map(int,input().split())\nif u>v:\n print(-1)\n exit(0)\nif u==0 and v==0:\n print(0)\n exit(0)\nif u==v:\n print(1)\n print(u)\n exit(0)\n\nbinary=[2**i for i in range(61)]\np=[0]*60\nd=v-u\nv-=u\nfor i in range(60-1,-1,-1):\n p[i]+=u//binary[i]\n u%=binary[i]\nanswer=[]\nfor i in range(60-1,0,-1):\n if v>=binary[i]:\n p[i-1]+=2\nf=True\nprint(max(p))\nwhile True:\n f=False\n k=0\n for i in range(60-1,-1,-1):\n if p[i]>0:\n f=True\n p[i]-=1\n k+=binary[i]\n if f:\n print(k,end=\" \")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95fa405636602a0933579542b51f833d", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\n# sys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nu, v = MAP()\n\nif v < u:\n print(-1)\n exit()\n\ncnt = [0] * 19\nfor k in range(19):\n if u & 1<=2 and count=2:\n pass\n else:\n cond=False\n break\n if cond==True:\n ans.append(func(c))\n else:\n pass\nif len(ans)==0:\n print(-1)\nelse:\n print(min(ans))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a394caf51ccb3221b669f3fe499a8647", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,k=list(map(int,input().split()))\ns=input()\nt=[0]*26\nfor i in s:\n t[ord(i)-97]+=1\ni=0\nwhile i<26:\n ++i\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3fb0f1aa553060ac869844701d746e9e", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "Python 3", "source_code": "pe,p,b =input().split()\nif p-pe >=0 and b-pe >= 0:\n print('Yes')\nelse:\n print('No')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ebd549674dd943623c528fe5c825ef6", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nm=int(input())\nk=int(input())\n \nif n>m or n>k:\n \n print(\"No\")\nelse:\n \n print(\"Yes\")\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2fedb27ec2bfd38c676a641787a8e2da", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jul 6 15:27:30 2019\n\n@author: kevinss0643\n\"\"\"\n\n\n\ndef distribute(n,m,k):\n if m>=n and k>=n:\n print(\"Yes\")\n else:\n print(\"No\")\n \n#Insert n,m,k in order below \ndistribute(n,m,k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a4e23358133f1c1040ac81b9539ea16", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "ar=map(int,input().strip().split())\nif ar[1]< ar[0] or ar[2]< ar[0]:\n print(\"No\")\nprint(\"Yes\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6656682b80902af3fde059b6e5a48ba2", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "\nn,m,k = input().split()\nif n <= m and n <= k and n > 0:\n print('Yes')\nelse:\n print('No')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa161c1291d88d373666db1b474e86b7", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import string\n \n \ndef split(word):\n return [char for char in word]\n \n\n \nletters = {'a': 1, 'b': 2, 'c': 3,\n 'd': 4, 'e': 5, 'f': 6,\n 'g': 7,\n 'h': 8, 'i': 9, 'j': 10,\n 'k': 11, 'l': 12,\n 'm': 13, 'n': 14, 'o': 15, 'p': 16,\n 'q': 17, 'r': 18, 's': 19, 't': 20,\n 'u': 21, 'v': 22, 'w': 23, 'x': 24,\n 'y': 25, 'z': 26}\n \ncurr_letter = 1\n\nword = input(\"\")\nword = split(word)\ntot_rot = 0\n \nfor char in word:\n d = (curr_letter - letters[char]) % 26\n tot_rot += min(d, 26-d) + 1\n curr_letter = letters[char]\nprint(tot_rot)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42cbe0cbb5516b16d44846af07d8670d", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from sys import stdin,stdout\n\ndef main():\n\tstring=stdin.readline()\n\tsum=0\n\n\tfor i in range (len(string)-1):\n\t\tif i==0:\n\t\t\tp=ord(string[0])-97\n\t\t\tif p>13:\n\t\t\t\tsum+=(26-p)\n\t\t\telse:\n\t\t\t\tsum+=p\n\t\telse:\n\t\t\tp=abs(ord(string[i])-ord(string[i-1]))\n\t\t\tprint(sum)\n\t\t\tif p>13:\n\t\t\t\tsum+=26-p\n\t\t\telse:\n\t\t\t\tsum+=p\n\n\tprint(sum)\n\nif __name__ == '__main__':\n\tmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b146b03462751d8862afafe177a1835", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = str(input())\ntest= 'abcdefghijklmnopqrstuvwxyz'\ncurrent_pos=0\nminimum_dis = 0\nfor i in s:\n x =test.find(i)+1\n y=test[::-1].find(i)+1\n minimum_dis = minimum_dis + min(x,y)\n index= test.find(i)\n test = test[index:] + test[:index]\nprint(minimum_dis-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c3e4969909884fc9a76e866a14b626d6", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = list(input())\nr = 1\nans = 0\nfor i in range(len(s)):\n a = abs((ord(s[i])-96)-r)\n if a>14 : \n ans += 26-a\n r = 26 - (ord(s[i])-96)\n else:\n ans += a\n r = ord(s[i])-96\n \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "216c931282563462102e7596a426448e", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "alpha=['n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d','e','f','g','h','i','j','k','l','m']\nind=13\nword=input()\ncount=0\nsumm=0\nwhile(count(26-ind+alpha.index(word[count]))):\n summ+=(26-ind+alpha.index(word[count]))\n else:\n if(ind==0):\n summ+=26-alpha.index(word[count])\n else:\n summ+=abs(ind-alpha.index(word[count])) \n ind=alpha.index(word[count])\n count+=1\nprint(summ)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d63cf6c165ac81ab9eb8a0351e2ed72", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nm = n\na = [False,False]+[True]*(m-1)\nprimes = []\nfor i in range(2,m+1):\n if a[i]:\n primes.append(i)\n for j in range(2*i,m+1,i):\n a[j] = False\n\nc = 0\nwhile(n != 0):\n p = n\n for i in primes:\n if n%i == 0:\n p = i\n break\n n -= p\n c += 1\n if n%2 == 0 :\n c += n//2\n break\nprint(c)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1366ff13ce64987bc6556156db70ed29", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = long(input())\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n print(n / i)\n exit(0)\n i += 1\n\nprint(1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e0ac491172705560c30dd69e595b397", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\ndef abc(n):\n global k\n if n!=0:\n for i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n k+=1\n n-=i\n return abc(n) \n else:\n k+=1\n n=0\n return abc(0)\n else:\n return print(k)\n \nn=int(input())\nk=0\nabc(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb6d28d1b4ce569502c8203f024d7b81", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nb=[]\nprime = [True for i in range(n+1)] \np=2\nwhile(p**2<=n):\n if prime[p] == True: \n for i in range(p * p, n+1, p): \n prime[i] = False\n p += 1\nfor p in range(2, n): \n if prime[p]: \n b.append(p)\n#print(*b)\nfor i in b:\n if n%i==0:\n exit(print(n//i))\nprint('1')\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3871a317a0f5a7335703a3a112b946a4", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "N = int(input())\nM = 10 ** 8 + 5\npr = [True] * M\npr[0], pr[1] = False, False\nfor i in range(2, M):\n if pr[i]:\n for j in range(i * 2, M, i):\n pr[j] = False\n\nprime = list(filter(lambda x: pr[x], range(M)))\n\n\ndef calc(n, k):\n if n == 0:\n return k\n elif n % 2 == 0:\n return n // 2 + k\n else:\n for i in prime:\n if n % i == 0:\n n -= i\n return calc(n, k + 1)\n\n\nprint(calc(N, 0))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d0b3f86a5d292435ccd9807e34f7fb5", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nres = 0\na = 1\nb = n\nc = True\nwhile a < b:\n\tres += (a + b) % (n + 1)\n\tprint(a,b)\n\tif c == True:\n\t\ta += 1\n\telse:\n\t\tb -= 1\n\tc = not c\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5e4c5454a154299b80f8a6af3408a37", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = int(input())\na = []\nb = []\nfor i in range(1,x+1):\n a.append(i)\nfor j in range(0,x):\n b.append(pow(a[j],j))\nprint(sum(b)%(x+1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "24ed07379bd3a82694be243eb3edb69b", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\nn = int(n)\nk = 0\nfor i in range(1, n + 1):\n\tfor j in range(1, (n // 2) + 1 + (n % 2)):\n\t\tif (i + j) % (n + 1) == 1:\n\t\t\tk += 1\nprint (k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c244e49eb72b82aaf422a37d09e1a28d", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = set()\nfor k in range(1,n+1):\n\ts.add(k)\nc = True\nprev = 1\ns.remove(1)\nres = 0\nwhile len(s) != 0:\n\tif c == True:\n\t\tm = max(s)\n\telse:\n\t\tm = min(s)\n\ts.remove(m)\n\tres += (prev + m) % (n+1)\n\tc = not c\n\tprev = m\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "09715bf033e1e6f2b7f8c20a6880f36e", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = int(input())\nb = []\nfor j in range(1,x+1):\n b.append(pow(j,j-1))\nprint(sum(b)%(x+1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d04c9a828c31e321426d605982903414", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "def gelnana(m, b):\n x_1 = int((b-1)*m)\n sum_list = [0] * int(b + x_1 - 1)\n \n for i in range(b+1):\n x = int((b-i)*m)\n sum_list[i] = (i+1)*(x+1)*(i+x)/2\n\n return int(max(sum_list))\n \narray = list(map(int,input().split())) \nm = array[0] \nb = array[1] \nprint(gelnana(m, b)) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "962e6b661aa7b4f38160877dcc0cb568", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na = [map(int, raw_input().split()) for i in range(n)]\n\nres = 1\nfor i in range(n):\n for j in range(n):\n if a[i][j] != 1:\n d = 0\n for x in range(n):\n for y in range(n):\n if a[i][j] == a[i][x] + a[y][j]: d+= 1\n if d > 0: break\n if d == 0: res = 0 \nprint [\"No\", \"Yes\"][res]\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f21b927d08c0a6a2ed5c1b5adb17710d", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Mar 6 21:52:15 2020\n\n@author: nguyenquocbao\n\"\"\"\nimport numpy as np\n\n\ndef gelnana(m, b):\n x_int = m*b\n x_1 = int((b-1)*m)\n \n sum_list = np.empty([1, b + x_1 - 1])\n matrix = np.empty([b + 1, x_int + 1])\n for r in range(b + 1):\n for x in range(x_int + 1):\n matrix[r, x] = r + x \n \n for i in range(b-1): # row \n x_max = int((b - (i+1))*m)\n sum_row = np.sum(matrix[0:i+2, 0:x_max+1])\n sum_list[0, i] = sum_row\n \n for i in range(x_1): # column\n y_max = int((-i-1)/m + b)\n sum_column = np.sum(matrix[0:y_max+1, 0:i+2])\n sum_list[0, i + b - 1] = sum_column \n \n return int(np.max(sum_list))\n \narray = list(map(int,input().split())) \nm = array[0] \nb = array[1] \nprint(gelnana(m, b)) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d080ee13684bb576604a1591f4556c55", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def function(x,y,m,c):\n d=y+x/m-c\n return d\ndef pval(a):\n return a[0]+a[1]\ndef valof(a,p):\n max=0\n for i,j in p:\n if j<=a:\n sum=0\n for l,m in p:\n if m<=j and l<=i:sum+=l+m\n if max<=sum:max=sum#;print((i,j),sum)\n return max\n\nm,c=list(map(int,input().split()))\np=[(i,j) for i in range(0,m*c+1) for j in range(0,c+1) if function(i,j,m,c)<=0]\nprint(valof(c,p))\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "936e7f399ba966b08dfef70a4b5d69e6", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def function(x,y,m,c):\n d=y+x/m-c\n return d\ndef pval(a):\n return a[0]+a[1]\ndef valof(a,p):\n max=0\n for i,j in p:\n if j<=a:\n sum=0\n for l,m in p:\n if m<=j and l<=i:sum+=l+m\n if max<=sum:max=sum#;print((i,j),sum)\n #else:break\n return max\n\nm,c=list(map(int,input().split()))\np=[(i,j) for i in range(0,m*c+1) for j in range(0,c+1) if function(i,j,m,c)<=0]\np.sort(reverse=True)\n#print(p)\nprint(valof(c,p))\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9fac5e7d28daf19b84ab1d8d492a81ac", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n,m,a,b=map(int,raw_input(),split())\nprint min([n * a ,n / m *b + ( n % m ) * a, ( n / m+1 )*2])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a1774ba4ffb456e76d93e343dcf1b51", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "total_price,rides,sprice,rupees = map(int,input().split())\n\nif(rupees / rides > sprice):\n print(sprice * total_rides)\nelse:\n base_fare = (total_rides // ride) * rupees\n cement_fare = (total_rides % rides) * sprice\n print(base_fare + cement_fare)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38a094dd3855c43b59cce16f1a6d1b8b", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=input().split()\nbasic_cost=int(n[0])*int(n[2])\nif n[2]n[3]:\n low_cost=((int(n[0])//int(n[1]))+1)*int(n[3])\nif basic_cost>=low_cost:\n print(int(low_cost))\nelse:\n print(int(basic_cost))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27d04bc8733d810ebff2784e1145873f", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\nl = map(int,raw_input().split())\nn,m,a,b=l\nvalue = []\nif m>=n:\n\tif b>=n*a:\n\t\tprint n*a\n\telse:\n\t\tprint b\nelse:\n\ti=-1\n\twhile True:\n\t\ti+=1\n\t\tk=[]\n\t\tj=-1\n\t\twhile True:\n\t\t\tj=j+1\n\t\t\tif m*j+i>=n:\n\t\t\t\tk.append(j*b+i*a)\n\t\t\t\tbreak\n\t\tj=0\n\t\tk.sort()\n\t\tvalue.append(k[0])\n\t\tif m*j + i>=n:\n\t\t\tbreak\n\nvalue.sort()\nprint value[0]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "60feeac401d0f0775616e8a3896be203", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "arr=list(map(int, input().split()))\nn=arr[0]\nm=arr[1]\na=arr[2]\nb=arr[3]\nans=0\nif(n%m==0):\n print(n//m*b)\nelse:\n ext=n%m\n ext*=m\n ans+=n//m*b\n while(ext!=0):\n ans+=a\n ext-=a\n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28b10318332fb2d34c340531a4851431", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n N = input()\n\n qaq = []\n apnd = qaq.append\n for s in N:\n if s in 'Q' or s in 'A':\n apnd(s)\n\n mask = 0\n n = len(qaq)\n s = ''\n ans = 0\n while mask < (1<<(n)):\n i = 0\n while i < n:\n if mask & (1< int:\n n = len(s)\n pw = 2**n\n count = 0\n for mask in range(pw):\n subset = []\n for i in range(n):\n if mask & (1 << i):\n subset.append(s[i])\n if len(subset) == 3 and subset == ['Q', 'A', 'Q']:\n count += 1\n\n return count\n\n\nprint(solve(s))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d92bfdef0298c4133df2a17946d794e5", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n=\"\"\nr=0\nc=0\nl=int(input())\nn=raw_input()\nif(len(n)==l):\n for i in range(0,l-1):\n if(n[i]==n[i+1]):\n r=1\n c=c+r\n else:\n r=0\n print c", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1653eb93ef19d31f00c83e83c3f4d8a", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, s = input(), input()\nwhile len(s) > 1: s = s.replace('BB', 'B').replace('RR', 'R').replace('GG', 'G')\nprint(n-len(s))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "23846dd00839e57cac1f13d19e85b0bf", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(input())\ni=1\nwhile(i n:\n return 0\n if f % 2:\n return 1 + F(f * 2)\n return 1 + F(f * 2) + F(f + 1)\n odd = find_ge(range(1, n + 1, 2)[::-1], k, F, -inf)\n even = find_ge(range(2, n + 1, 2)[::-1], k, F, -inf)\n print(max(odd, even))\n\n\n# region bisect\n# \u4e8c\u5206\u641c\u7d22\uff0c\u6807\u51c6\u5e93\u6ca1\u6709\u51fd\u6570\u53c2\u6570\n\nimport builtins\n\ndef len(a):\n if isinstance(a, range):\n return -((a.start - a.stop) // a.step)\n return builtins.len(a)\n\ndef bisect_left(a, x, key = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n if key == None: key = do_nothing\n while lo < hi:\n mid = (lo + hi) // 2\n if key(a[mid]) < x: lo = mid + 1\n else: hi = mid\n return lo\ndef bisect_right(a, x, key = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n if key == None: key = do_nothing\n while lo < hi:\n mid = (lo + hi) // 2\n if x < key(a[mid]): hi = mid\n else: lo = mid + 1\n return lo\ndef insort_left(a, x, key = None, lo = 0, hi = None):\n lo = bisect_left(a, x, key, lo, hi)\n a.insert(lo, x)\ndef insort_right(a, x, key = None, lo = 0, hi = None):\n lo = bisect_right(a, x, key, lo, hi)\n a.insert(lo, x)\ndo_nothing = lambda x: x\nbisect = bisect_right\ninsort = insort_right\ndef index(a, x, key = None, default = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n if key == None: key = do_nothing\n i = bisect_left(a, x, key, lo, hi)\n if lo <= i < hi and key(a[i]) == x: return a[i]\n if default != None: return default\n raise ValueError\ndef find_lt(a, x, key = None, default = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n i = bisect_left(a, x, key, lo, hi)\n if lo < i <= hi: return a[i - 1]\n if default != None: return default\n raise ValueError\ndef find_le(a, x, key = None, default = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n i = bisect_right(a, x, key, lo, hi)\n if lo < i <= hi: return a[i - 1]\n if default != None: return default\n raise ValueError\ndef find_gt(a, x, key = None, default = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n i = bisect_right(a, x, key, lo, hi)\n if lo <= i < hi: return a[i]\n if default != None: return default\n raise ValueError\ndef find_ge(a, x, key = None, default = None, lo = 0, hi = None):\n if lo < 0: lo = 0\n if hi == None: hi = len(a)\n i = bisect_left(a, x, key, lo, hi)\n if lo <= i < hi: return a[i]\n if default != None: return default\n raise ValueError\n\n# endregion\n\n\n# region M\n\n# region fastio\n\nimport sys, io, os\nsys.setrecursionlimit(10000)\nBUFSIZE = 8192\nclass FastIO(io.IOBase):\n newlines = 0\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = io.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(io.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().strip()\n\n# endregion\n\n# region import\n\ninputt = lambda t = 0: range(t) if t else range(int(input()))\ninputi = lambda: map(int, input().split())\ninputl = lambda: list(inputi())\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom functools import reduce, lru_cache\nfrom collections import Counter, defaultdict\nimport re, copy, operator, cmath\n\n# endregion\n\n# region main\n\nif __name__ == \"__main__\":\n main()\n\n# endregion\n\n# endregion", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dfbbc175029b4a2fe4bdbab4712699b6", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\n\n\nleft = 1\nright = 10**18 + 1\n\np = [2**i for i in range(61)]\n\nans = 0\n\nwhile right - left > 1:\n mid = (right + left) // 2\n l = 0\n r = 60\n if mid > n:\n right = mid\n continue\n while r - l > 1:\n m = (r + l) // 2\n if mid * p[m] <= n:\n l = m\n else:\n r = m\n cur = 0\n if mid % 2:\n cur += min(n - p[l] * mid + 1, p[l]) + p[l] - 1\n else:\n cur += p[l + 1] - 2 + min(n - p[l] * mid + 1, p[l + 1])\n if cur < k:\n right = mid\n else:\n ans = cur\n left = mid\n\nfor i in range(0, 5000000):\n mid = left + i\n r = 60\n l = 0\n while r - l > 1:\n m = (r + l) // 2\n if mid * p[m] <= n:\n l = m\n else:\n r = m\n cur = 0\n if mid % 2:\n cur += min(n - p[l] * mid + 1, p[l]) + p[l] - 1\n else:\n cur += p[l + 1] - 2 + min(n - p[l] * mid + 1, p[l + 1])\n if cur >= k:\n left = mid\n\nprint(left)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9469952c2808a0d8e1f2e53621ea4eb4", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "(n, k)=[int(x) for x in input().split()]\n\nres =-1\ndp = [1] * (n+1)\nfor i in range(n,0,-1):\n if dp[i] >= k:\n res = i\n break\n imod2 = i % 2\n if imod2 == 0:\n dp[i//2] += dp[i]\n else: \n dp[i-1] += dp[i]\n\n#print(dp)\nprint(res)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5d8e2e91ade608dec16b883192655c0", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from math import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**9)\n\nmod = 10**9 + 7\nn,x = map(int,input().split())\n#for y in range(1):\na = [0 for i in range(n+1)]\nans = 0\nfor i in range(1,n+1):\n\tj = i\n\twhile(j >= 1):\n\t\ta[j] += 1\n\t\tif(j%2 == 0):\n\t\t\tj //= 2\n\t\telse:\n\t\t\tj -= 1\nfor i in range(n,0,-1):\n\tif(a[i] >= x):\n\t\tprint(i)\n\t\tbreak\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48c70243899f2b0d8c71c5184195de4d", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "\"\"\"\n Satwik_Tiwari ;) .\n 5th AUGUST , 2020 - WEDNESDAY\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\nfrom __future__ import division, print_function\n\nfrom fractions import Fraction\nimport sys\nimport os\nfrom io import BytesIO, IOBase\n\nfrom itertools import *\nimport bisect\nfrom heapq import *\nfrom math import *\nfrom copy import *\nfrom collections import deque\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl\n#If the element is already present in the list,\n# the left most position where element has to be inserted is returned.\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n#If the element is already present in the list,\n# the right most position where element has to be inserted is returned\n\n#==============================================================================================\n#fast I/O region\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\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\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\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\n# inp = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n#===============================================================================================\n### START ITERATE RECURSION ###\nfrom types import GeneratorType\ndef iterative(f, stack=[]):\n def wrapped_func(*args, **kwargs):\n if stack: return f(*args, **kwargs)\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n continue\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n return wrapped_func\n#### END ITERATE RECURSION ####\n\n#===============================================================================================\n#some shortcuts\n\nmod = 1000000007\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\n# def graph(vertex): return [[] for i in range(0,vertex+1)]\ndef zerolist(n): return [0]*n\ndef nextline(): out(\"\\n\") #as stdout.write always print sring.\ndef testcase(t):\n for p in range(t):\n solve()\ndef printlist(a) :\n for p in range(0,len(a)):\n out(str(a[p]) + ' ')\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef power(a,b):\n ans = 1\n while(b>0):\n if(b%2==1):\n ans*=a\n a*=a\n b//=2\n return ans\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\n#===============================================================================================\n# code here ;))\n\n\ndef solve():\n n,k = sep()\n\n cnt = [0]*(n+1)\n for i in range(1,n+1):\n if(i%2==1):\n curr = [i,i]\n cnt[i] = 1\n else:\n curr = [i,i+1]\n cnt[i] = 2\n\n while(2*curr[1]+1=k):\n print(i)\n return\n\n\n\n\ntestcase(1)\n# testcase(int(inp()))\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "812e890990624a33976ba7989f31f9a8", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from sys import stdin,stdout\nii1 = lambda: int(stdin.readline().strip())\nis1 = lambda: stdin.readline().strip()\niia = lambda: list(map(int, stdin.readline().strip().split()))\nisa = lambda: stdin.readline().strip().split()\nmod = 1000000007\n\nn = is1()\nif int(n) < int('4' * len(n)):\n n = '4' * len(n)\nelif int(n) > int('7' * len(n)):\n n = '4' * (len(n) + 1)\nif len(n) % 2 != 0:\n n += '4' \n \nwhile True:\n if set(list(n)) == set(['4', '7']) and n.count('4') == n.count(\"7\"):\n print(n)\n break\n n = str(int(n) + 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "65d71f4dc390668e7f717bb74644b787", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def superluck(x):\n count4, count7 = 0,0\n for ch in x:\n if ch=='4':\n count4+=1\n elif ch=='7':\n count7 += 1\n else:\n return False\n if count4 == count7:\n return True\n return False\n\ndef solve():\n n = input()\n i = len(str(n))\n if superluck(str(n)):\n print n\n return\n if(i%2==0):\n if (n>int('7'*(i/2) + '4'*(i/2))):\n i += 1\n elif (n='99999999'):\n print('4444477777')\n else:\n k=n//2\n z='4'*k+'7'*k\n p='4'*(k+1)+'7'*(k+1)\n l=list(permutations(z))\n l=[''.join(x) for x in l]\n l.sort()\n for e in l:\n if(e>=s):\n print(e)\n exit(0)\n print(p)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b7b2fbfb1b80c1357bf9a290e1fde2c5", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def pow_fast_mod(a, b, div):\n s = 1\n while b > 0:\n if b % 2:\n s %= div\n a %= div\n s *= a\n a %= div\n a *= a\n b = (b // 2)\n return s % div\n\n[n, m, L, R] = [int(s) for s in input().split()]\nh = R-L\nmod = 998244353\nret = 0\nif n%2 and m%2:\n ret = pow_fast_mod(h+1, n*m, mod)\nelse:\n x = (h+1)**(n*m/2)\n a = x // 2\n a %= mod\n b = (x+1) // 2\n b %= mod\n ret = a*a+b*b\n\nprint(int(ret%mod))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c69e4bee0c232b52b5172aff10db9a1f", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "[n, m, L, R] = [int(s) for s in input().split()]\nh = R-L\nmod = 998244353\nret = 0\nif n%2 and m%2:\n ret = (h+1)**(n*m)\nelse:\n x = (h+1)**(n*m/2)\n a = x // 2\n b = (x+1) // 2\n ret = a*a+b*b\n\nprint(int(ret%mod))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4403e9eda97844f8902ba1e7dca1ca5b", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "MOD = 998244353\n \nk = input().split()\nn, m, l, r = k[0], k[1], k[2], k[3]\nif n * m % 2 == 1:\n\tprint(pow(r - l + 1, n * m, MOD))\nelif (r - l + 1) % 2 == 0:\n\tprint(pow(r - l + 1, n * m, MOD) * (MOD + 1) // 2 % MOD)\nelse:\n\tprint((pow(r - l + 1, n * m, MOD) + 1) * (MOD + 1) // 2 % MOD)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea739ecf287997530c4cccf9c9014b9e", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from sys import exit\n\nMOD = 998244353\n\nn, m, l, r = map(int, input().split())\nif l == r:\n print(1)\n exit(0)\nif n * m % 2 == 1:\n ans = pow(r - l + 1, n * m, MOD)\n print(ans)\n exit(0)\n\na = (r - l + 1) // 2\nb = a\nif (r - l + 1) % 2 == 1:\n b += 1\n\nx = n * m\n\nans = pow(2, x - 1, MOD)\nif 1 or a == b:\n ans *= pow(b, x, MOD)\n ans %= MOD\n # else:\nif m != 2 and a != b:\n 1/0\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "874b4c8b8fcc20cf606a2447f414760f", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "q = 998244353 \nn, m, l, r = map(int, input().split())\nif n * m % 2 == 1:\n print(pow(r - l + 1, n * m, q))\nelif (r - l + 1) % 2 == 0:\n print(pow(r - l + 1, n * m, q) *\n (q + 1) // 2 % MOD)\nelse:\n print((pow(r - l + 1, n * m, q) + 1) *\n (q + 1) // 2 % q)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "725b4c20e8b6d21dc3c13653b4d7163e", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "num,time=map(int,input().split())\nstring=input()\nlist_a=list(string)\nx=0\nwhile (x!=time):\n for i in range(2,num):\n if 'G' in list_a[i] and 'B' in list_a[i-1] :\n list_a[i]='B'\n list_a[i-1]='G'\n i+=2\n \n \n x+=1\nstring=str(list_a) \n\nprint(string)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6ded07d64bb89f31e2ce22f8165262e", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "first = [int(x) for x in input().split(' ')]\nstring = input()\nq = [x for x in string]\ntime = 0\nwhile time < first[1]:\n ctr = 0\n while ctr < first[0]-1:\n if q[ctr] == 'B' and q[ctr+1] == 'G':\n q[ctr],q[ctr+1] == q[ctr+1],q[ctr]\n ctr +=1\n time +=1 \nprint(q.join(''))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8da7a1cf50c39e884aae98105a6f9b34", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, t = input().split()\nn = int(n)\nt = int(t)\ni = 0\ns = list(input())\n\nwhile s[0] != \"G\":\n while i < len(s) - 1:\n if s[i] == 'B' and s[i + 1] == \"G\":\n s[i] = \"G\"\n if i + t <= len(s) - t:\n if s[i + t] == \"B\":\n s[i + 1] = \"B\"\n else:\n s[i + t] = \"B\"\n if i + t > len(s) - t:\n s[i + 1] = 'B'\n i += t\n i += 1\n i = 0\n t -= 1\ns = ''.join(s)\nprint(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "43a239749679996d1df2773d27901143", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nn,t = map(int,input().split())\nlist1 = list(input())\nm = 0\nfor time in range(0,t):\n while m <= n - 1:\n if list1[m] == 'B' and list1[m+1] == 'G':\n list1[m] = 'G'\n list1[m+1] = 'B'\n m += 2\nprint(''.join(list1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d623f2884e1e9d2c6c6abe80248add35", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input()[2:])\ns=input()\nwhile t:s=s.replace('BG','GB')\nt-=1\nprint(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c238ed3543f2ef9a1f8ddc4e43a14b96", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nword=input()\nword+='+'\narr1=['a','e','y','o','i','u']\nfor i in range(0,n):\n\tif word[i] in arr1:\n\t\tif word[i+1] in arr1:\n\t\t\tword=word.replace(word[i+1],'')\nprint(word.replace(word[len(word)-1],''))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "80300a7c312eb1b3218628539e0cdc02", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nch=input()\nl=[\"a\",\"e\",\"u\",\"i\",\"o\",\"y\"]\ni=0\nwhile(i= len(w):\n break\n if w[i] in alf:\n if w[i + 1] in alf:\n w = w.replace(w[i + 1], \"\");\n ind = False\nprint(w)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2262769840e5df8ea904f9f1bad313fb", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nch=input()\nl=[\"a\",\"e\",\"u\",\"i\",\"o\",\"y\"]\ni=0\nwhile(i= n else \"YES\"\n\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7af34c9708e59aebce0de798a4041729", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import sys\nimport math\n\n\ndef readlines(type=int):\n return list(map(type, sys.stdin.readline().split()))\n\n\ndef read(type=int):\n return type(sys.stdin.readline().strip())\n\n\njoint = lambda it, sep=\" \": sep.join(\n [str(i) if type(i) != list else sep.join(map(str, i)) for i in it])\n\n\ndef solve(n, t, k, d):\n n_mul = (n * t) // k + 1\n t_muls = set()\n for i in range(1, n_mul + 1):\n t_muls.add(t * i)\n t_muls.add((t * i) + d)\n t_muls = sorted(list(t_muls))\n for mul in t_muls:\n yeild = k * ((mul // t) + (mul - d) // t)\n if yeild >= n:\n # mulc = mul\n break\n # print(t_muls)\n # print(mul, f\"{t * math.ceil(n / k)=}\", n, k, t)\n if mul < t * math.ceil(n / k):\n return \"YES\"\n return \"NO\"\n\n\ndef main():\n print(solve(*readlines()))\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f63e1071ff85a80c0a6662a4f35879a", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, t, k, d = input().split()\nn, t, k, d = int(n), int(t), int(k), int(d)\nsk: int = 0\nst = 0\nsk1 = k\nst1 = abs(k - d)\n\nwhile (sk <= n) or (sk1 <= n):\n sk += k\n st += t\n sk1 = 2*k\n st1 += 2*t\nif st < st1:\n print('NO')\nelse:\n print('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "295f1f371b7231f680bb723dd25d46cf", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "str0 = [int(i) for i in input().split()]\nn = str0[0]\nt = str0[1]\nk = str0[2]\nd = str0[3]\nbaked = n\nt1 = 0\nwhile True:\n if baked < k:\n baked = 0\n t1 += t\n else:\n t1 += t\n baked -= k\n if baked == 0:\n break\nt2 = 0\nbaked = n - n%k - k\nbakers = 1\nwhile True:\n if k > n:\n t2 = 1000000000000000000\n break\n t2 += 1\n if t2 == d:\n bakers = 2\n if t2%t == 0:\n baked -= k\n if baked == 0:\n break\n if bakers == 2:\n if (t2 - d)%t == 0:\n baked -= k\n if baked == 0:\n break\nt2 += t\nif t2=9):\n ans[i]=9\n s-=9\n else:\n ans[i]+=s\n break\n return ans\n\n\nn,s=value()\nif(9*ns:\n continue\n c=1\n \n for j in range(0,10):\n arr[-i]=j\n \n if sum(arr)==s:\n return arr\n c=0\n \n \n if c==1:return [-1]\n\ndef small(n,s):\n arr=[1]+[0]*(n-1)\n ans=[-1]\n for i in range(1,n+1):\n arr[-i]=9\n\n if sum(arr)= 0 and s//9 0:\n ans.append(9)\n s -= 9\n else:\n ans.append(s)\n s = 0\n continue\n\n if s==0 and tempb[0] and a[1]>b[1]):\n print(\"YES\")\n exit()\n\nelse:\n print(\"NO\")\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cd00211ee0b1e1453d411a4fd87156a8", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = list(map(int, input()))\ns1 = s.copy()\ndiff, idx = 0, -1\nmin_diff = max(s)+1\nfor i in range(n):\n for j in range(len(s) - n):\n if s[i] > s[n + j]:\n diff = s[i] - s[n+j]\n if diff r[0]:\n left, right = right, left\n\nfor i in xrange(n):\n if not l[i] < r[i]:\n break\nelse:\n print 'YES'\n exit()\n\nprint 'NO' \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "989ee0e3a9b8b758a7e1408c3338b36b", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from itertools import permutations\nn = int(input())\ns = list(map(int,input()))\nA = s[:n]\nB = s[n:]\nC = list(permutations(B))\nm = 0\nl = 0\np = 0\nfor j in C:\n for i in range(n):\n if( A[i] < j[i]):\n if(l > 0):\n break\n m += 1\n elif(A[i] > j[i]):\n if(m > 0):\n break\n l += 1\n if(m == n or l == n):\n print(\"YES\")\n p += 1\n break\n m = 0\n l = 0\nif(p == 0):\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "36cb1d2088595824a0b06b0a1bb645e3", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n=input()\nnum=raw_input()\nleft=sorted(map(int,num[:n]))\nright=sorted(map(int,num[n:]))\n\n\nif left[0]=right[i]:\n print \"NO\"\n break\n i+=1\n else:\n print \"YES\"\nelif left[0]>right[0]:\n i=1\n while ik:\n print(len(a[:k+1]))\n else:\n if a[0]k:\n print(len(a[0:a[k-1]]))\n else:\n while a==a:\n k=k+1\n print(len(a[:k]))\nelif a[k]>k or a[k]==k:\n print(len(a[:k]))\nelse:\n print(0)\n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5aced5de98153653f7d4a744f0a3285e", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Python 3", "source_code": "times=input().split(\" \")\nscors=input().split(\" \")\nplace=int(scors[int(times[1])])\ncounter=0\nfor i in scors:\n while int(i)>=place and place!=0:\n counter=counter+1\nprint(counter)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b1e62867768a2310af74764f361a5b5", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n,k=map(int,input().split())\nc=0\nq=0\nl=list(map(int,input().split()))\nc=l[k-1]\nq=k\nwhile(k9:\n i=i+1\n d=d+3\n b=k\n elif a<10 and a>0:\n i=i+1\n d=d+2\n b=k\n else:\n b=i-1\n break\nwhile i>k and i0:\n b=b+1\n else:\n b=b\n i=i+1\n d=d+2\nprint(b)\n\nimport msvcrt\n \nprint(\"Press any key to exit...\")\n \nwhile True:\n if ord(msvcrt.getch()) in [0,256]:\n break\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fd997b8c268b407e5e8a1c5cd9065e2", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def do():\n n = int(input())\n fromN = 0\n for i in range(n):\n l, d = map(str,input().split())\n l = int(l) % 40000\n fromN %= 40000\n if fromN == 0 and d[0] in \"NEW\": return \"NO\"\n if fromN == 20000 and d[0] in \"SEW\": return \"NO\"\n if d[0] in \"EW\": continue\n if d[0] == \"N\":\n if fromN >= 0 and fromN <= 20000: fromN -= l\n else: fromN += l\n else:\n if fromN >=0 and fromN <= 20000: fromN += l\n else: fromN -= l\n #print(fromN)\n fromN %= 40000\n if fromN == 0: return \"YES\"\n return \"NO\"\n\nprint(do())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9a3a33a5c5a0193f3af83e7144b4ceda", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nx = 0\ndef go(y):\n if (y//20000)%2 == 1:\n return 20000 - y%20000\n else:\n return y%20000\n \nfor i in range(n):\n s = input().split(' ')\n t = int(s[0])\n \n if x == 0:\n if s[1]=='South':\n x = go(x + t)\n continue\n else:\n x = 7\n break\n continue\n if x == 20000:\n if s[1]=='North':\n x = go(abs(x - t))\n continue\n else:\n x = 7\n break\n if (x!=0 and x!=20000):\n if s[1]=='South':\n x = go(x + t)\n if s[1]=='North':\n x = go(abs(x - t))\n \n \nif x == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1e7e8420538db12242b17a3c0a455cb", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Dec 30 23:29:21 2016\n\n@author: RandomNone\n\"\"\"\nn=int(raw_input())\npos=0\nflag=1\nfor i in range(n):\n a=raw_input().split()\n distance=int(a[0])\n direction=a[1]\n if(pos==0 and direction!='South'):\n print 'NO'\n flag=0\n break\n \n elif(pos==20000 and direction!='North'):\n print 'NO'\n flag=0\n break\n \n if(direction=='South'):\n pos+=distance\n if(direction=='North'):\n if(pos>=distance):\n pos-=distance\n else:\n pos+=40000-distance\n pos=pos%40000\n\nif(flag==1): \n if(pos%40000==0):\n print 'YES'\n else:\n print 'NO'\n\n\n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1117216acbc693062dc39f90926591f2", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nstrings = []\nfor i in range(n):\n strings.append(input())\n\npx = 0\npy = 0\nans = 0\n\ncnt = 0\nwhile cnt < n:\n if strings[0].split()[1] != \"South\":\n ans = \"NO\"\n break\n\n if strings[cnt].split()[1] == \"South\":\n py += int((strings[cnt].split())[0])\n if strings[cnt].split()[1] == \"North\":\n py -= int((strings[cnt].split())[0])\n if strings[cnt].split()[1] == \"West\":\n px += int((strings[cnt].split())[0])\n if strings[cnt].split()[1] == \"East\":\n px -= int((strings[cnt].split())[0])\n\n if cnt != n-1:\n if int(py) % 40000 == 0 and int(px) % 40000 == 0 and strings[cnt+1].split()[1] != \"South\":\n ans = \"NO\"\n break\n if int(py) % 40000 == 20000 and int(px) % 40000 == 0 and strings[cnt+1].split()[1] != \"North\":\n ans = \"NO\"\n break\n\n\n cnt += 1\n\nif int(py) % 40000 == 0 and ans != \"NO\":\n ans = \"YES\"\nelse:\n ans = \"NO\"\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8495a8fac97e3b43b217a9167e50e861", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ncurrentPos = 0\nnorth = True\nsouth = False\n\nfor x in range(n):\n dist, d = input().split()\n dist = int(dist)%40000\n if north and d != 'South':\n print ('NO')\n break\n elif south and d!= 'North':\n print ('NO')\n break\n elif d in ('West', 'East'):continue\n while dist>0:\n if d == 'North':\n steps = min(dist,currentPos)\n currentPos -= steps\n dist -= steps\n d = 'South'\n elif d == 'South':\n steps = min(dist,20000-currentPos)\n currentPos += steps\n dist -= steps\n d = 'South'\n\n north = currentPos == 0\n south = currentPos == 20000\n\nelse:\n print (('NO','YES')[currentPos == 0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75770b635419af9d4c810f01b41d9401", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n=int(raw_input(\"number of candidates:\"))\na=[]\nfor i in range(n):\n ai=int(raw_input(\"a votes:\"))\n a.append(ai)\ndef bribe(n,a):\n ans=0\n while a[0]+ans<=max(a) and a[0]!=max(a):\n ans+=1\n a[a.index(max(a))]-=1\n return ans\n\nprint bribe(n,a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5b94e99d0a5bd2410e8bbb66b1e2342", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "s = input()\nif int(s) > 1:\n\tl, *v = (int(x) for x in input().split())\n\tv.sort(reverse=True)\n\tcount = 0\n\twhile l <= v[0]:\n\t\tif v[0] >= v[1]:\n\t\t\tcount += 1\n\t\t\tl += 1\n\t\t\tv[0] -= 1\n\t\telse:\n\t\t\tv.sort(reverse=True)\n\tprint(count)\nelse:\n\tprint(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "855073625c6c5f2c6363bec24387fbdf", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\n\na = 0\nn = 0\ng = None\nc = 0\n\nfor line in sys.stdin:\n\tline = line[0:len(line)]\n\tl = line.split(\" \")\n\tif a != 0:\n\t\tc = int(l[0])\n\t\tg = [int(l[i]) for i in range(1,n)]\n\t\t\n\telse:\n\t\tn = int(l[0])\n\t\ta = 1\n\ng.sort(reverse = True)\nb = 0\nwhile g[0] >= c:\n\tb = b + 1\n\tc = c + 1\n\tg[0] = g[0]-1\n\tt = g[0]\n\ti = 1\n\twhile g[i] > t:\n\t\tg[i-1] = g[i]\n\t\tg[i] = t\n\t\ti = i + 1\n\nprint b", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5df562a2bcf4789ad8b0a1a86e67973", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\nn = int(input())\n\n\n\nk = [int(s) for s in input().split()]\n\nl = k[0]\nk.remove(l)\n\nk.sort(reverse=1)\nres =0\nwhile l<=k[0]:\n res+=1\n l+=1\n k[0]-=1\n i= 0\n while k[i]1:\n return True\n return False\n\ndef counter(arr):\n nX=n0=0\n for i in range (0,9):\n if arr[i]=='X':\n nX=nX+1\n if arr[i]=='0':\n n0=n0+1\n return (nX,n0)\n\ndef main():\n arr=''\n for line in sys.stdin:\n arr=arr+line\n arr=arr.rstrip()\n nX,n0=counter(arr)\n #verficamos si es valido\n if invalid(nX,n0)== False:\n win=wincases(arr)\n #no se define ganador todavia\n if win =='.':\n #no hay empate\n if nX+n0!=9:\n if nX==n0:\n print('first')\n else:\n print('second')\n else:\n print('draw')\n else:\n if win=='X':\n print('the first player won')\n print('the second player won')\n else:\n print('illegal')\n a=input()\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd850744bc3e766939d96d2cfed8d5cf", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "s=[None,None,None]\nfor i in range(3):\n s[i]=raw_input()\nn={'0':0,'X':0,'.':0}\nfor i in range(3):\n for j in range(3):\n n[s[i][j]]+=1\nif n['0']>=n['X']+2 or n['0']+2<=n['X']:\n print 'illegal'\n exit()\nwin={'0':0,'X':0,'.':0}\nfor i in range(3):\n if n[s[i][0]]==n[s[i][1]]==n[s[i][2]]:\n win[n[s[i][0]]]+=1\n if n[s[0][i]]==n[s[1][i]]==n[s[2][i]]:\n win[n[s[0][i]]]+=1\nif n[s[0][0]]==n[s[1][1]]==n[s[2][2]]:\n win[n[s[0][0]]]+=1\nif n[s[0][2]]==n[s[1][1]]==n[s[2][0]]:\n win[n[s[0][2]]]+=1\nif (win['0'] and win['X']) or win['0']>=2 or win['X']>=2:\n print 'illegal'\n exit()\nif not (n['.'] or win['0'] or win['X']):\n print 'draw'\n exit()\nif (n['X']>n['0'] and win['X']) or (n['X']n['0'] and win['0']) or (n['X']1:\n return True\n return False\n\ndef counter(arr):\n nX=n0=0\n for i in range (0,9):\n if arr[i]=='X':\n nX=nX+1\n if arr[i]=='0':\n n0=n0+1\n return (nX,n0)\n\ndef main():\n arr=''\n for line in sys.stdin:\n arr=arr+line\n arr=arr.rstrip()\n nX,n0=counter(arr)\n #verficamos si es valido\n if invalid(nX,n0) == False:\n win=wincases(arr)\n #no se define ganador todavia\n if win == '.':\n #no hay empate\n if nX+n0!=9:\n if nX==n0:\n print('first')\n else:\n print('second')\n else:\n print('draw')\n else:\n if win=='X':\n print('the first player won')\n print('the second player won')\n else:\n print('illegal')\n print(n0,nX)\n a=input()\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75d552f939f0081deed1fcbf6ec30329", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "array = []\nfor i in range(3):\n array.append([item for item in input()])\ncount1 = array[0].count(\"X\")\ncount2 = array[1].count(\"X\")\ncount3 = array[2].count(\"X\")\ncount4 = array[0].count(\"0\")\ncount5 = array[1].count(\"0\")\ncount6 = array[2].count(\"0\")\narray1 = []\narray2 = []\nif count1 == 3:\n array1.append(count1)\nif count2 == 3:\n array1.append(count2)\nif count3 == 3:\n array1.append(count3)\nif count4 == 3:\n array2.append(count4)\nif count5 == 3:\n array2.append(count5)\nif count6 == 3:\n array2.append(count6)\nxcount = 0\nocount = 0\nemptycount = 0\ncountt1 = 0\nfor row in array:\n for item in row:\n if item == \"X\":\n xcount += 1\n elif item == \"0\":\n ocount += 1\n elif item == \".\":\n emptycount += 1\nif ocount > xcount:\n print(\"illegal\")\n# player 1 win possibilities \n# horizontal possibilities\nelif array[0] == [\"X\",\"X\",\"X\"]:\n print(\"the first player won\")\nelif array[1] == [\"X\",\"X\",\"X\"]:\n print(\"the first player won\")\nelif array[2] == [\"X\",\"X\",\"X\"]:\n print(\"the first player won\")\n# vertical possibilities\nelif array[0][0] == \"X\" and array[1][0] == \"X\" and array[2][0] == \"X\":\n print(\"the first player won\")\nelif grid[0][1] == \"X\" and grid[1][1] == \"X\" and grid[2][1] == \"X\":\n print(\"the first player won\")\nelif grid[0][2] == \"X\" and grid[1][2] == \"X\" and grid[2][2] == \"X\":\n print(\"the first player won\")\n# diagonal possibilies\nelif grid[0][0] == \"X\" and grid[1][1] == \"X\" and grid[2][2] == \"X\":\n print(\"the first player won\")\nelif grid[0][2] == \"X\" and grid[1][1] == \"X\" and grid[2][0] == \"X\":\n print(\"the first player won\")\n\n# player2 win possibilities\n# horizontal possibilities\nelif array[0] == [\"0\",\"0\",\"0\"]:\n print(\"the second player won\")\nelif array[1] == [\"0\",\"0\",\"0\"]:\n print(\"the second player won\")\nelif array[2] == [\"0\",\"0\",\"0\"]:\n print(\"the second player won\")\n# vertical possibilities\nelif array[0][0] == \"0\" and array[1][0] == \"0\" and array[2][0] == \"0\":\n print(\"the second player won\")\nelif grid[0][1] == \"0\" and grid[1][1] == \"0\" and grid[2][1] == \"0\":\n print(\"the second player won\")\nelif grid[0][2] == \"0\" and grid[1][2] == \"0\" and grid[2][2] == \"0\":\n print(\"the second player won\")\n# diagonal possibilies\nelif grid[0][0] == \"0\" and grid[1][1] == \"0\" and grid[2][2] == \"0\":\n print(\"the second player won\")\nelif grid[0][2] == \"0\" and grid[1][1] == \"0\" and grid[2][0] == \"0\":\n print(\"the second player won\")\nelif xcount > ocount:\n if xcount-ocount == 1:\n print(\"second\")\n else:\n print(\"illegal\")\nelif array[0][0] == \"X\" and array[1][0] == \"X\" and array[2][0] == \"X\" and grid[0][1] == \"0\" and grid[1][1] == \"0\" and grid[2][1] == \"0\":\n print(\"illegal\")\nelif array[0][0] == \"X\" and array[1][0] == \"X\" and array[2][0] == \"X\" and grid[0][2] == \"0\" and grid[1][2] == \"0\" and grid[2][2] == \"0\":\n print(\"illegal\")\nelif array[0][0] == \"0\" and array[1][0] == \"0\" and array[2][0] == \"0\" and grid[0][1] == \"X\" and grid[1][1] == \"X\" and grid[2][1] == \"X\":\n print(\"illegal\")\nelif array[0][0] == \"0\" and array[1][0] == \"0\" and array[2][0] == \"0\" and grid[0][2] == \"X\" and grid[1][2] == \"X\" and grid[2][2] == \"X\":\n print(\"illegal\")\nelif ocount == xcount:\n hey = True\n for item in array1:\n if item in array2:\n print(\"illegal\")\n hey = False\n break\n if hey == True:\n print(\"first\")\nelse:\n print(\"draw\")\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ceef7fb81d083ca4ea7bb5f91ed72e52", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "r=range(3)\na=[list(raw_input()) for i in r]\nc=[list('...') for i in r]\n\nans=['illegal','draw','the first player won','the second player won','first','second']\nok=0\n\ndef win(ch):\n\tw=0\n\tfor i in r:\n\t\tv1=0\n\t\tv2=0\n\t\tfor j in r:\n\t\t\tv1+=(c[i][j]==ch)\n\t\t\tv2+=(c[j][i]==ch)\n\t\tw+=(v1==3)+(v2==3)\n\tv1=0\n\tv2=0\n\tfor i in r:\n\t\tv1+=(c[i][i]==ch)\n\t\tv2+=(c[i][2-i]==ch)\n\tw+=(v1==3)+(v2==3)\n\treturn w!=0\n\ndef verd(st):\n\tret=4+st%2\n\tif st==9: ret=1\n\tif win('X'): ret=2\n\telif win('0'): ret=3\n\treturn ret\n\ndef go(st):\n\tglobal ok, c\n\tif ok: return\n\t\n\tv=verd(st)\n\t\n\tif c==a: ok=v\n\tif v<=3: return\n\t\n\tch='X' if st%2==0 else '0'\n\t\n\tfor i in r:\n\t\tfor j in r:\n\t\t\tif c[i][j]=='.':\n\t\t\t\tc[i][j]=ch\n\t\t\t\tgo(st+1)\n\t\t\t\tc[i][j]='.'\n\ngo(0)\n\nprint ans[ok]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "909906ab018270c559396005f5ae036c", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "a = [0] * 4\nfor i in range(4):\n s = input().strip()\n a[i] = len(s) - 2\nans = 'C'\nfor i in range(4):\n f1 = 1\n f2 = 1\n for j in range(4):\n if i != j and a[i] < 2 * a[j]:\n f1 = 0\n if i != j and 2 * a[i] > a[j]:\n f2 = 0\n if f1:\n print(chr(ord(\"A\") + i))\n break\n if f2:\n print(chr(ord(\"A\") + i))\n break\nelse:\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "628fa52c07b1598825d8e9b4925645c9", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x, y = {}, {}\n\ndef get_len(path):\n return int(len(path[1]))\n\nx['A'] = input()\nx['B'] = input()\nx['C'] = input()\nx['D'] = input()\n\ny = sorted(x.items(), key=get_len)\n\nif (len(y[0][1]) - 2) * 2 <= (len(y[1][1]) - 2) and (len(y[0][1]) - 2) != (len(y[1][1]) - 2):\n print( y[0][0] )\nelif (len(y[3][1]) - 2) >= (len(y[2][1]) - 2) * 2 and (len(y[3][1]) - 2) != (len(y[2][1]) - 2):\n print( y[3][0] )\nelse:\n print( \"C\" )\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fbb14fed68c75020273d4770420b4a03", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "\nimport math\n\ndef solve(str):\n if str[1][0] - str[0][0] >= str[0][0]:\n print str[0][1]\n return\n if str[3][0] - str[2][0] >= str[2][0]:\n print str[3][1]\n return\n\n print 'C'\n\n\n\nif __name__ == \"__main__\":\n\n al = ['A', 'B', 'C', 'D']\n str = []\n for i in xrange(4):\n str.append((len(raw_input()[2:]), al[i]))\n\n str.sort()\n solve(str)\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75fa2e169bf78db99f127ce6fc80745d", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a = []\na.append(input())\na.append(input())\na.append(input())\na.append(input())\nb = []\n\nfor i in range(len(a)):\n b.append(len(a[i]) - 2)\n\nb.sort()\n\nres = 0\n\nif b[0] * 2 <= b[1] and b[1] != 0:\n res = b[0]\nelif b[2] * 2 <= b[3] and b[3] != 0:\n res = b[3]\n\nif res != 0:\n for i in range(len(a)):\n if len(a[i]) - 2 == res:\n print(a[i][:1])\nelse:\n print('C')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3024303fe08e886cb47596969337325", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a = input()[2:]\nb = input()[2:]\nc = input()[2:]\nd = input()[2:]\n\nif (len(b) <= len(a)/2 and len(b) <= len(c)/2 and len(b) <= len(d)/2) or \\\n (len(b) >= len(a)*2 and len(b) >= len(c)*2 and len(b) >= len(d)*2):\n print('B')\nelif (len(a) <= len(b)/2 and len(a) <= len(c)/2 and len(a) <= len(d)/2) or \\\n (len(a) >= len(b)*2 and len(a) >= len(c)*2 and len(a) >= len(d)*2):\n print('A')\nelif (len(d) <= len(b)/2 and len(d) <= len(c)/2 and len(d) <= len(a)/2) or \\\n (len(d) >= len(b)*2 and len(d) >= len(c)*2 and len(d) >= len(a)*2):\n print('D')\nelse:\n print('C')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1d1d2162d2fcc80d66ef6844234c5f3", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "PyPy 2", "source_code": "\"\"\"\nAuthor : raj1307\nInstitute : Jalpaiguri Government Engineering College\nDate : 16.04.19\n\"\"\"\nfrom __future__ import division, print_function\nimport itertools,os,sys\n#from collections import deque, Counter, OrderedDict\n#from heapq import nsmallest, nlargest, heapify, #heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pow,pi\n#from bisect import bisect_left,bisect_right\n#from decimal import *\n\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n from builtins import str as __str__\n str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\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 return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)\n\n def readline(self):\n while self.newlines == 0:\n b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()\n self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\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\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b'\\r\\n')\n\n\ndef print(*args, **kwargs):\n sep, file = kwargs.pop('sep', b' '), 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', b'\\n'))\n if kwargs.pop('flush', False):\n file.flush()\n\ndef ii(): return int(input())\ndef si(): return str(input())\ndef mi():return map(int,input().strip().split(\" \"))\ndef li():return list(mi())\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef ntl(n):return [int(i) for i in str(n)]\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p1\n return res\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\n# For getting input from input.txt file \n#sys.stdin = open('input.txt', 'r') \n \n# Printing the Output to output.txt file \n#sys.stdout = open('output.txt', 'w') \n\ndef main():\n \n n=ii()\n l=li()\n s=sum(l)\n a=s//n\n b=a+1\n c=a-1\n x=[]\n y=[]\n z=[]\n for i in range(n):\n if l[i]!=a:\n x.append(abs(l[i]-a))\n if len(list(set(x)))==1 and x[0]>=0:\n print(x[0])\n exit()\n if len(x)==0:\n print(0)\n exit()\n for i in range(n):\n if l[i]!=b:\n y.append(abs(l[i]-b))\n if len(list(set(y)))==1 and y[0]>=0:\n print(y[0])\n exit()\n if len(y)==0:\n print(0)\n exit()\n for i in range(n):\n if l[i]!=c:\n z.append(abs(l[i]-c))\n if len(list(set(z)))==1 and z[0]>=0:\n print(z[0])\n else:\n print(-1)\n if len(z)==0:\n print(0)\n exit()\n \n \n \n \n \n \n \n \n \n \n \n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e260d93bbc0df8c1d8fd896202cfe76", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\ninput()\nb = list(map(int, input().split()))\na = list(sorted(set(b)))\nif len(a) == 3:\n if (a[2] - a[1]) == (a[1] - a[0]):\n print(a[1] - a[0])\n else:\n print(-1)\nelif len(a) == 1:\n print(0)\nelse:\n if (a[1] - a[0]) % 2 == 0:\n print((a[1] - a[0]) // 2)\n else:\n print(a[1] - a[0])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e80e8bee86a217bc8395d5b1d43f4001", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nl1=list(set(l))\nl=sorted(l)\nl1=sorted(l1)\nx=-1\ny=-1\nif len(l1)==1:\n\tprint (0)\nelif len(l1)==2:\n\tx=l[-1]-l[0]\n\ty=(l[-1]+l[0])/2\n\tif int(y)==y:\n\t\tprint (int(min(x,y-l[0])))\n\telse:\n\t\tprint (x)\nelif len(l1)==3:\n\ta=l1[0]\n\tb=l1[1]\n\tc=l1[2]\n\tif c-b==b-a:\n\t\tx=c-b\n\tif x==-1:\n\t\tprint (-1)\n\telse:\n\t\tprint (x)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2ba820d5b0f291bd734a9634bcc755a", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\nelements = sorted(list(map(int, input().split())))\n\nd = elements[-1] - elements[0]\n\nif n == 1:\n print(0)\n exit(0)\n\nwhile d % 2 == 0:\n d = int(d / 2)\n\nfor i in range(0, n - 1):\n if elements[i] == elements[i + 1]:\n continue\n if elements[i + 1] - d != elements[i] and elements[i + 1] - d != elements[i] + d and elements[i + 1] != elements[i] + d:\n print(-1)\n exit(0)\nprint(d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d52fa746bfd311213c6da74978cdc9d1", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = input()\nelements = sorted(list(map(int, input().split())))\n\nd = elements[-1] - elements[0]\n\nwhile d % 2 == 0:\n d = int(d / 2)\n\nfor i in range(0, len(elements) - 1):\n if elements[i] == elements[i + 1]:\n continue\n if elements[i + 1] - d != elements[i] and elements[i + 1] - d != elements[i] + d and elements[i + 1] != elements[i] + d:\n print(-1)\n exit(0)\nprint(d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b26facc429d395049dcf76a9397fe25b", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a,b,c = map(int,input().split())\nprint((a*c + b -1)//(b-c))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "61396f1a331565dfbba0ed90ce650fef", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split(' '));\nprint((a*c+b-1)//(b-c));\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4aee385d977ae9755f7bd163a65c55da", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b, c = map(int, input().split())\nfor i in range(1,a+1):\n if(a*c - i*b <= b*c):\n d = i\n break\nprint(d)\n\n\n\n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n b = []\n #b = a[-1] - a[0]\n for i in range(n):\n for j in range(i+1, n):\n b.append(a[j]-a[i])\n print(min(b))\"\"\"\n \n\n\n\"\"\"for i in range(int(input())):\n a, b = map(int, input().split())\n if(a 2 or d == 0):\n e = 0\n break\n d = 0\nif(e == 1):\n print(\"Yes\")\nelse:\n print(\"No\")\n\n \n#print(b)\"\"\"\n\n\n\"\"\"n = int(input())\na = list(map(int, input().split()))\nb = 0\nd = 0\ne = 0\no = 0\ng = []\nh = []\nm = []\nfor i in range(n):\n if(a[i]<0):\n b += 1\n elif(a[i]>0):\n d += 1\n else:\n e += 1\nfor i in range(n):\n if(b%2 == 1):\n if(a[i] < 0 and len(g) == 0):\n g.append(a[i])\n elif(a[i] > 0 or a[i] < 0):\n h.append(a[i])\n else:\n m.append(a[i])\n elif(b%2 == 0):\n if(a[i]<0 and len(g) == 0):\n g.append(a[i])\n elif(a[i]<0):\n if(d == 0):\n h.append(a[i])\n else:\n m.append(a[i])\n elif(a[i]>0):\n h.append(a[i])\n else:\n m.append(a[i])\n #if(a[i] == 0):\n #m.append(a[i])\nif(d == 0 and len(h)%2 != 0):\n o = h.pop()\n m.append(o)\nprint(len(g),*g)\nprint(len(h),*h)\nprint(len(m),*m)\"\"\"\n \n\n\n\"\"\"n, m, k = map(int, input().split())\na = []\nb = []\nd = 0\ne = 0\nfor i in range(m+1):\n x = int(input())\n a.append(x)\nfor i in range(m):\n b.append(bin(a[-1]^a[i]).replace(\"0b\",\"\"))\n#print(b)\nfor i in b:\n c = list(i)\n #print(c)\n for j in range(len(c)):\n if(c[j] == '1'):\n d += 1\n #print(d)\n if(d <= k):\n e += 1\n d = 0\n \nprint(e)\n#print(a)\"\"\"\n\n\n\n\"\"\"a, b = map(int, input().split())\nc = a+b\nd = 0\ne = 0\nif(a == 0 and b == 0):\n print(\"NO\")\nelse:\n if(c%2 == 0):\n d = c//2\n e = c//2\n else:\n d = c//2\n e = c//2+1\n if(a == d or a == e and b == e or b == d):\n print(\"YES\")\n else:\n print(\"NO\")\"\"\"\n \n\n\n\"\"\"n, m = map(int, input().split())\na = []\nb = []\nd = []\ne = 0\nfor i in range(n):\n s = input()\n s = list(s)\n a.append(s)\nfor i in range(len(a)):\n for j in range(i+1, len(a)):\n if(a[i] == a[j][::-1]):\n if(len(b) == 0):\n b.insert(0,''.join(map(str,a[i])))\n b.insert(1,''.join(map(str,a[j])))\n else:\n b.insert(0,''.join(map(str,a[i])))\n b.insert(len(b),''.join(map(str,a[j])))\n #print(b)\n if(len(a[i])%2 == 0):\n if(a[i][:len(a[i])//2] == a[i][len(a[i])//2:][::-1]):\n e = 1\n if(len(d) == 0):\n b.insert(len(b)//2,''.join(map(str,a[i])))\n d.append(''.join(map(str,a[i])))\n #break\n #else:\n #b.insert(0,''.join(map(str,a[i])))\n #d.append(''.join(map(str,a[i])))\n else:\n if(a[i][:len(a[i])//2+1] == a[i][len(a[i])//2:][::-1]):\n e = 1\n if(len(d) == 0):\n b.insert(len(b)//2,''.join(map(str,a[i])))\n d.append(''.join(map(str,a[i])))\n #break\n #else:\n #b.insert(0,''.join(map(str,a[i])))\n #d.append(''.join(map(str,a[i])))\n \nprint(len(''.join(map(str,b))))\nprint(''.join(map(str,b)))\n#print(d)\n#print(e)\n#print(a)\"\"\"\n\n\n\n\n\"\"\"s = input()\ns = list(s)\na = []\nb = []\nd = 0\nif(len(s)%2 == 0):\n a.append(s[:len(s)//2])\n b.append(s[len(s)//2:])\nelse:\n a.append(s[:len(s)//2+1])\n b.append(s[len(s)//2:])\n#b = b[::-1]\na = sum(a,[])\nb = sum(b,[])\n#print(a)\n#print(b)\nfor i in range(len(a)):\n if(a[i] != b[len(a)-i-1]):\n d += 1\n #print(a[i])\n #print(b[len(a)-1-i])\n #else:\n #print(a[i])\n #print(b[len(a)-i-1])\n#print(d)\nif(d == 1 and len(s)%2 == 0):\n print(\"YES\")\nelif(d == 0 and len(s)%2 == 0):\n print(\"NO\")\nelif((d == 0 or d == 1) and len(s)%2!=0):\n print(\"YES\")\nelse:\n print(\"NO\")\"\"\"\n\n\n \n \n \n\n\n\"\"\"n, k = map(int, input().split())\na = list(map(int, input().split()))\ni = 1\nwhile(k-i > 0):\n k -= i\n i += 1\n\n#b = []\n#for i in range(1,n+1):\n #b.append(a[0:i])\n#b = sum(b,[])\n#print(b)\nprint(a[k-1])\"\"\"\n\n\n\n\"\"\"n = int(input())\na = 0\nb = 0\nd = n%7\nif(d == 0):\n e = n//7\n a = 2*e\n b = 2*e\nelse:\n if(n<7):\n if(d == 1):\n a = 0\n b = 1\n elif(d > 1 and d < 6):\n a = 0\n b = 2\n else:\n a = 1\n b = 2\n else:\n e = n//7\n a = 2*e\n b = 2*e\n if(d == 1):\n b += 1\n elif(d<6):\n b += 2\n else:\n a += 1\n b += 2\nprint(a, b)\"\"\" \n\n\n\"\"\"for i in range(int(input())):\n n, m = list(map(int, input().split()))\n a = [[int(x) for x in input().split()] for _ in range(n)]\n r = set()\n c = set()\n #print(a)\n for i in range(n):\n for j in range(m):\n if(a[i][j] == 1):\n r.add(i)\n c.add(j)\n b = min(n-len(r), m-len(c))\n \n if(b%2 == 0):\n print(\"Vivek\")\n else:\n print(\"Ashish\")\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n d = 0\n e = 0\n g = 0\n c = sorted(a)\n if(a == c):\n d = 1\n else:\n for i in range(n):\n if(b[i] == 0):\n e += 1\n else:\n g += 1\n if(e and g):\n d = 1\n if(d == 1):\n print(\"Yes\")\n else:\n print(\"No\")\"\"\"\n \n \n \n \n\"\"\"def createMatrix(rowCount, colCount, dataList): \n mat = []\n for i in range (rowCount):\n rowList = []\n for j in range (colCount):\n if dataList[j] not in mat:\n rowList.append(dataList[j])\n mat.append(rowList)\n\n return mat \n\n \nfor i in range(int(input())):\n n = int(input())\n r = n\n c = n\n a = [x for x in range(1,n**2+1)]\n m = createMatrix(r,c,a)\n if(n == 2):\n for i in range(n):\n for j in range(n-1):\n if(i%2 != 0):\n m[i][j], m[i][n-1-j] = m[i][n-1-j], m[i][j]\n else:\n for i in range(n):\n for j in range(n-2):\n if(i%2 != 0):\n m[i][j], m[i][n-1-j] = m[i][n-1-j], m[i][j]\n #if((m[i][j] + m[n-1-i][n-1-j])%2 != 0):\n #m[n-1-i][n-1-j], m[n-1-i][n-1-j-1] = m[n-1-i][n-1-j-1], m[n-1-i][n-1-j]\n #else:\n #m[n-1-i][n-1-j], m[n-1-i][n-1-j-1] = m[n-1-i][n-1-j-1], m[n-1-i][n-1-j]\n for i in range(n):\n for j in range(n):\n print(m[i][j], end=' ')\n print( )\"\"\"\n \n \n \n \n \n \n \n \n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n b = 0\n c = 0\n d = 1\n e = 0\n if(len(a) == 1):\n if(a[0] == 5):\n d = 1\n else:\n d = 0\n else:\n #b.append(a[0])\n for i in range(1, n):\n if(a[i] == 10):\n c += 1\n if(b > 0):\n b = b-1\n else:\n d = 0\n break\n #if(a[i] - b <= 5):\n #b.append(a[i] - sum(b))\n #b += a[i]-5\n elif(a[i] == 15):\n e += 1\n if(c > 0):\n c = c-1\n elif(b > 1):\n b = b-2\n else:\n d = 0\n break\n else:\n #b = b + a[i]\n b += 1\n \n \n #if(e == 0):\n #if(c <= b and c>=1 and b>=1):\n #d = 1\n #else:\n #d = 0\n #else:\n #if(e<=c and c<=b and c>=1 and b>=1):\n #d = 1\n #else:\n #d = 0\n if(d == 1):\n print(\"YES\")\n else:\n print(\"NO\")\"\"\"\n \n \n \n\n\n\"\"\"for i in range(int(input())):\n s = input()\n a = 0\n s = list(s)\n j = 1\n for i in range(0, len(s)-1):\n #while(len(s) != 0):\n if(len(s) == 0):\n break\n if((s[i] =='x' and s[i+1] == 'y') or (s[i] == 'y' and s[i+1] == 'x')):\n a += 1\n s[i+1] = 'z'\n #print('a')\n #print(j)\n #else:\n #j -= 1\n #print(j)\n #s.remove(i)\n #s.remove(i+1)\n #if(len(s) == 0):\n #break\n print(a)\"\"\"\n \n \n\n\"\"\"for i in range(int(input())):\n n, k = map(int, input().split())\n p = list(map(int, input().split()))\n a = 0\n for i in range(n):\n if(p[i] > k):\n a += p[i] - k\n print(a)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n ts = int(input())\n a = 0\n b = 0\n if(ts == 1):\n b = 0\n else:\n if(ts%2 != 0):\n a = ts//2+1\n b = ts-a\n else:\n d = 0\n while(ts%2 == 0):\n d += 1\n ts = ts//2\n if(ts%2 != 0):\n a = ts//2+1\n b = ts-a\n print(b)\"\"\"\n \n\n\"\"\"for i in range(int(input())):\n n = int(input())\n s = list(map(int, input().split()))\n a = []\n c = []\n s.sort()\n for k in range(1,1024):\n for i in s:\n b = i^k\n a.append(b)\n #print(a)\n #print(s)\n if(s == sorted(a)):\n c.append(k)\n a.clear()\n if(len(c) == 0):\n c.append(-1)\n print(min(c))\"\"\"\n \n \n\n\n\"\"\"for i in range(int(input())):\n a, b = map(int, input().split())\n c = 0\n if(a == b):\n c = 0\n elif(a > b):\n d = a/b\n if(d == a//b):\n if(d == 1 and a == b):\n c = 0\n elif(d == 2 or d == 4 or d == 8):\n c = 1\n elif(d > 8 and d%2 == 0):\n while(d != 1):\n if(d%8 == 0):\n d = d//8\n c += 1\n elif(d%4 == 0):\n d = d//4\n c += 1\n elif(d%2 == 0):\n d = d//2\n c += 1\n else:\n c = -1\n break\n else:\n c = -1\n else:\n c = -1\n else:\n d = b/a\n if(d == b//a):\n if(d == 1 and b == a):\n c = 0\n elif(d == 2 or d == 4 or d == 8):\n c = 1\n elif(d > 8 and d%2 == 0):\n while(d != 1):\n if(d%8 == 0):\n d = d//8\n c += 1\n elif(d%4 == 0):\n d = d//4\n c += 1\n elif(d%2 == 0):\n d = d//2\n c += 1\n else:\n c = -1\n break\n else:\n c = -1\n else:\n c = -1\n print(c)\"\"\"\n \n \n \n\n\n\"\"\"for i in range(int(input())):\n s = input()\n a = list(s)\n d = ['0', '1', '0']\n e = ['1', '0', '1']\n b = 0\n if(len(a) < 3):\n b = 0\n elif(len(a) == 3):\n if(a != d and a != e):\n b = 0\n else:\n b = 1\n else:\n g = 0\n h = 0\n for i in a:\n if(i == '0'):\n g += 1\n else:\n h += 1\n if(g <= 1 or h <= 1):\n b = 0\n if(g < h):\n b = g\n else:\n b = h\n print(b)\"\"\"\n \n \n\n\n\"\"\"for i in range(int(input())):\n n, x = map(int, input().split())\n a = list(map(int, input().split()))\n b = 0\n c = 0\n d = 0\n if(len(a) == 1):\n if(a[0]%2 == 0):\n b = 0\n else:\n b = 1\n else:\n for i in a:\n if(i%2 == 0):\n c += 1\n else:\n d += 1\n if(x < c+d):\n if(c and d > 1):\n b = 1\n elif(c == 0 and x%2 == 0):\n b = 0\n elif(d == 0):\n b = 0\n else:\n b = 1\n else:\n #if(x%2 == 0):\n if(d%2 != 0):\n b = 1\n else:\n b = 0\n if(b == 0):\n print(\"No\")\n else:\n print(\"Yes\")\"\"\"\n #print(b)\n \n \n\n\n#import math\n\"\"\"for i in range(int(input())):\n n, m, k = map(int, input().split())\n c = n//k\n if(m == 0):\n d = 0\n elif(m <= c):\n d = m\n else:\n d = (m-c)//(k-1)\n if((m-c)%(k-1) != 0):\n d += 1\n d = c - d\n #d = c - math.ceil((m-c)/(k-1))\n #else:\n #d = c - 1\n #if(d < 0):\n #d = 0\n print(d)\"\"\"\n\n\n\"\"\"def min(n,m):\n if(n%2 == 0 and m%2 == 0):\n b = n*(m//2)\n elif(n%2 == 0 and m%2 != 0):\n b = (n*(m//2))+n//2\n elif(n%2 != 0 and m%2 == 0):\n b = n*(m//2)\n else:\n b = (n*(m//2)) + (n-(n//2))\n return(b)\n \n\n\nfor i in range(int(input())):\n n, m = map(int, input().split())\n print(min(n,m))\"\"\"\n \n\n\n\n\"\"\"from collections import defaultdict\n\ndef smallest(s1, s2):\n assert s2 != ''\n d = defaultdict(int)\n nneg = [0] \n def incr(c):\n d[c] += 1\n if d[c] == 0:\n nneg[0] -= 1\n def decr(c):\n if d[c] == 0:\n nneg[0] += 1\n d[c] -= 1\n for c in s2:\n decr(c)\n minlen = len(s1) + 1\n j = 0\n for i in range(len(s1)):\n while nneg[0] > 0:\n if j >= len(s1):\n return minlen\n incr(s1[j])\n j += 1\n minlen = min(minlen, j - i)\n decr(s1[i])\n return minlen\n \n# ans = smallest(\"12222133333332\", \"123\")\n# print(ans)\n\nfor i in range(int(input())):\n s1= input()\n e = 0\n g = 0\n h = 0\n for i in range(len(s1)):\n if(s1[i] == '1'):\n e += 1\n elif(s1[i] == '2'):\n g += 1\n elif(s1[i] == '3'):\n h += 1\n s2=\"123\"\n \n if(e < 1 or g < 1 or h < 1):\n ans = 0\n else:\n ans= smallest(s1, s2)\n print(ans)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n a, b, c, d = map(int, input().split())\n r = b\n ans = 0\n if(b < a and c < d):\n ans = -1\n else:\n i = 0\n while(r < a):\n r += c - d\n i += 1\n if(i == 0):\n ans = b\n else:\n ans = b + i*c\n print(ans) \n\nif(d >= c && a >b)\n cout << -1 << endl;\n continue;\n }\n if(a <= b){\n cout << b << endl;\n continue;\n }\n a -= b;\n long int q = c-d;\n if(a % q == 0)\n {\n cout << ((a/q)*c)+b << endl;\n }else{\n cout << (((a/q)+1)*c)+b << endl;\n }\"\"\"\n\"\"\"for i in range(int(input())):\n n = int(input())\n s = list(map(int, input().split()))\n s.sort()\n c = 0\n p = 1\n if(n == 1):\n c = 1\n else:\n \n for i in range(n):\n if(s[i] <= p):\n c += 1\n p = p - s[i] + 1\n else:\n p = p + 1\n print(c)\"\"\"\n\n\n\n\"\"\"res = False\ndef chkList(lst):\n if len(lst) < 0 : \n res = True\n res = all(ele == lst[0] for ele in lst)\n return(res)\n\n\n\nfor i in range(int(input())):\n n = int(input())\n l = list(map(int, input().split()))\n p = l.copy()\n c = 0\n d = []\n if(chkList(l) == True):\n h = len(l)\n else:\n \n h = len(l)\n print(h)\"\"\"\n\n\n\"\"\"for i in range(int(input())):\n n = int(input())\n l = list(map(int, input().split()))\n l.sort()\n l.reverse()\n #print(l)\n res = 0\n p = 0\n while(True):\n res += 1\n p = p + l[p]\n if(p >= n):\n break\n print(res)\"\"\"\n \n\"\"\"7017173017\"\"\"\n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c7e82b2ce4cb2b4529ac574ccbeb5a1", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import bisect\na,b,c=map(int,input().split(' '))\ntimes=[]\nfor i in range(10**8):\n times.append(b*(i+1))\npos=bisect.bisect_left(times,(a-b)*c,0,len(times))\nprint(times)\nprint(pos+1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4625106a864e7df88af147b86fac2077", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import bisect\na,b,c=map(int,input().split(' '))\ntimes=[]\nfor i in range(10**7):\n times.append(b*(i+1))\npos=bisect.bisect_left(times,(a-b)*c,0,len(times))\nprint(times)\nprint(pos+1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a51242d3241d3b39b8648b46be6cff9a", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b,c,d=list(map(int,input().split()))\nms=max(0.3*a,a-(a*c/250))\nms=max(0.3*b,b-(b*d/250))\nif ms>vs:\n print(\"Mishra\")\nif ms getScore(varArray[1],varArray[3])):\n\t\treturn \"Misha\"\n\telse: return \"Tie\"\n\nprint(findWinner(input()))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a88595e4a7983be8b61eebb19b8641f2", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Python 2", "source_code": "r = raw_input().split(' ')\n\na = int(r[0])\nb = int(r[1])\nc = int(r[2])\nd = int(r[3])\n\nmisha = max (3 * a, a - (a * c /250)) \nvasya = max (3 * b, b - (b * d /250))\n\nif misha > vasya:\n print \"Misha\"\n\nelif misha < vasya:\n print \"Vasya\"\n\nelse:\n print \"Tie\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a237fa6038bfb47d5168346409e9e851", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Python 3", "source_code": "nt=list(map(int,input().split()))\nm=max(3*(nt[0]),nt[0]-(nt[0]//250)*nt[2])\nv=max(3*(nt[1]),nt[1]-(nt[1]//250)*nt[3])\nif(v>m):\n print('Vasya')\nif(v v): sys.stdout.write('Misha')\nelif (m < v): sys.stdout.write('Vasya')\nelse: sys.stdout.write('Tie')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "128ca96e470270477f7661fb4ce6583b", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\ncoins = map(int, raw_input().split())\n\ncoinDict = {}\n\nfor i in range(len(coins)):\n\tif coins[i] not in coinDict:\n\t\tcoinDict[coins[i]] = 1\n\telse:\n\t\tcoinDict[coins[i]] += 1\n\nprint max(coinDict.values())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ac6917583c93767a97f4b7dea996070", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from collections import Counter as count\nn = int(raw_input())\na = [int(x) for x in raw_input().split(\" \")]\ndic = count(a)\narr = []\nfor i in dic:\n arr.append(dic[i])\nprint(max(arr))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "17bd71df13ef6a1554dbbd83b0b6c357", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nnums = map(int, raw_input().split())\n\nfreq = [0 for i in range(200)]\nfor i in range(n):\n\tfreq[nums[i]] += 1\n\nprint max(freq)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e722ef73babac51948868b5154bab60", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "if __name__ == '__main__':\n\tn = int(input().strip(\" \"))\n\tcoins = list(map(int,input().strip(\" \").split(\" \")))\n\tpockets = dict()\n\tfor coin in coins:\n\t\tif not coin in pockets:\n\t\t\tpockets[coin] = 1\n\t\telse:\n\t\t\tpockets[coin] +=1\n\tprint(max(list(pockets.values())))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77d715a1520d43ec82a62a37893d2987", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#highest frequency approach - n pockets\nI = input\nn = int(I())\ncoins = I().split()\nprint(max([coins.count(coin) for coin in coins]))\n\n#####( 2 pockets solution =( )######################\n#for i in range(0,n):\n#\tif coins[i] not in A:\n#\t\tA.append(coins[i])\n#\telse:\n#\t\tB.append(coins[i])\n#if len(A) > 0 and len(B)>0:\n#\tprint(2)\n#else:\n#\tprint(1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "889cfb6586e86ac657a9bed09b7fcdd8", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, k = list(map(int, input().split()))\ncheck = False\nwhile True:\n for i in range(1, 10):\n f = i * (10 ** k)\n if f % n == 0:\n check = True\n break\n if check:\n break\nprint(f)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1dc3e0fb389113486d11f362b64c9d87", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import math\nx=raw_input().split(' ')\nn=int(x[0])\nk=int(x[1])\n\nlast=n*(10**k)\ni=1\ncnt=0\nsave=-1\nwhile i<=10000000:\n if (n*i)%10==0:\n zeros=0\n a=n*i\n while a>0:\n b=a%10\n if b==0:\n zeros=zeros+1\n else:\n break\n a=a/10\n \n if save!=-1:\n if zeros>savez:\n save=n*i\n savez=zeros\n else:\n save=n*i\n savez=zeros\n cnt=1\n i=i+1\n\nif cnt==1:\n i=1\n p=10**k\n while 1:\n if (save*i)%p==0:\n break\n i=i*10\n if (save*i)last:\n cnt=2\n break\n if (j*i)%n==0:\n cnt=1\n save=j*i\n break\n j=j+1\n if cnt==1 or cnt==2:\n break\n i=i*10\nif cnt==1:\n ans=min(ans, save)\nelse:\n ans= min(ans,last)\n\nprint ans\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa7954b516d0f0f21cbcfb60773a1763", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from sys import maxsize, stdout, stdin,stderr\nmod = int(1e9 + 7)\ndef tup():return map(int,stdin.readline().split())\ndef I(): return int(stdin.readline())\ndef lint(): return [int(x) for x in stdin.readline().split()]\ndef S(): return input().strip()\ndef grid(r, c): return [lint() for i in range(r)]\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\nfrom math import log2,sqrt\nfrom collections import Counter,defaultdict\nfrom itertools import permutations\nimport re\n\n# def bark():\n# n = I(); s =S()\n# a = re.split('[A-Z]+',s)\n# p = max(map(lambda x: len(set(x)),a))\n# return p\nfrom math import floor,sqrt,ceil\n#\n# def bark():\n# n = I()\n# s = int(sqrt(n))\n# for i in range(s,n+1):\n# if i*s >=n:\n# print(2*(i+s))\n# #find some area greater than or equal to n and then find it's perimeter since it's a rectange use 2*(l+b)\n# break\n# if __name__ == '__main__':\n# bark()\n#print(375.80 , 30000.30000)\n#print(1234567890000000/123456789)\n\n\ndef kround():\n\n n , k =tup()\n if n% pow(10,k) ==0:\n print(n)\n else:\n a = pow(10,k)\n for i in range(1,10000000000000000):\n if i%n==0 and i%a==0:\n print(i)\n break\n # else:\n # num =0\n # f= str(n); i =0\n # c = len(f) + k\n # while True:\n # num += int(f[i]) * pow(10,c)\n # if num%n==0:\n # #print(num)\n # break\n # c-=1\n # i+=1\n # p = str(num)\n # j =0\n # flag = 1\n # for i in range(len(p)):\n # for j in range(i+1):\n # if len(p[:j]) >0:\n # #print(int(p[:j]))\n # if int(p[:j]) % pow(10,k)==0:\n # print(p[:j])\n # flag = 0\n # break\n # if flag==0:break\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n kround()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b6486fb2ffea4b22372e762e5ff9614", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "n, k = map(int, raw_input().split())\n\nini = 1\n\nwhile True:\n tempStr = str(n*ini)\n zero = 0\n for i in xrange(len(tempStr)-1, -1, -1):\n if tempStr[i] == '0':\n zero += 1\n else:\n break\n if zero >= k:\n print tempStr\n exit()\n ini += 1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "613ab5b387100576a08c1c09a20e98f4", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import re, sys\nfrom collections import Counter\n\n\ndef check(num, K):\n cnt = 0\n\n while num:\n if num%10 != 0:\n break\n\n cnt += 1\n num /= 10 \n \n if cnt == K:\n return True\n \n return False\n\n\ndef main():\n N, K = map(int, raw_input().split()) \n sqrt, val = 0, 1\n\n for i in range(K):\n val *= 10\n \n for i in range(val):\n if i*i < val:\n sqrt = i + 1\n else:\n break\n \n answer = N * val\n\n for i in range(1, sqrt+1):\n if val%i != 0:\n continue\n \n num = N * i\n\n if check(num, K):\n if num < answer:\n answer = num\n \n num = N * (val / i)\n\n if check(num, K):\n if num < answer:\n answer = num\n \n print answer\n\n############################################################\n############################################################\n############################################################\nif(__name__ == \"__main__\"):\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7294520b4b7c57a4b7f70c0e3a75726", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\ndef eating_soup(total,m):\n\t\n\tif total==m:\n\t\treturn 0\n\telif m==0:\n\t\treturn total\n\telif m==total//2:\n\t\treturn m\n\telse:\n\t\twhole=1\n\t\ti=1\n\t\tif m>total//2:\n\t\t\tm=total-m\n\t\twhile i0 and p_2!=0:\n p_2-=1\n p-=i\n m+=1\n if m>bz:\n bz=m\n\n print(bz)\n \n \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "20ea53577d46ce6c894cda00c2aa122f", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m = map(int, input().split())\nif k==0:\n\tprint(1)\nif (n>=2*k):\n\tprint(k)\nelse:\n\tprint(n-k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d636e5d68b1c38d187b0f108c3530e24", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "cats = lambda x,y: min(y,x-y) if y > 0 else 1\n\nprint(cats(int(input()),int(input())))\n\n#Test Cases\n#print(cats(7,4)) = 3\n#print(cats(6,2)) = 2\n#print(cats(3,0)) = 1\n#print(cats(2,2)) = 0", "lang_cluster": "Python", "compilation_error": false, "code_uid": "036369eb54f2b3ed34620e34497f5ad8", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nm=int(input())\nprint(min(max(m, 1), n-m))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b883622a86148c1098c21962f3b55d07", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "Python 3", "source_code": "from itertools import combinations\n\ndef is_triangle(tri):\n\ta,b,c = tri\n\tif a+b <= c:\n\t\treturn False\n\tif a+c <= b:\n\t\treturn False\n\tif c+b <= a:\n\t\treturn False\n\treturn True\n\nn = int(input())\na = list(map(int, input().split()))\n\nc = list(combinations(a, 3))\n\ntruth = False\nfor tri in c:\n\tif is_triangle(tri):\n\t\ttruth = True\n\t\tbreak\n\nprint([\"NO\",\"YES\"][truth])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "69f01e8ee37b97c2958dc73f2da443ae", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from itertools import combinations\n\n\ndef main():\n n = int(input())\n inputs = list(input().split())\n inputs = [int(x) for x in inputs]\n combos = list(combinations(inputs,3))\n for combo in combos:\n if istriangle(combo):\n print(\"yes\")\n return\n print(\"NO\")\n\n\ndef istriangle(sides):\n if (sides[1]+sides[2]) > sides[0] and (sides[0]+sides[2])>sides[1] and (sides[0]+sides[1])>sides[2]:\n return True\n else:\n return False\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ca1f4f6cde90d2cae7f882355fb33e3", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import itertools\n\nn = int(input())\na = [int(i) for i in input().split()]\n\nflag = True\nfor c in list(itertools.combinations(a, 3)):\n s = sorted(c)\n if s[0] + s[1] > s[2]:\n print('YES')\n flag = False\n break\n\nif flag:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7e7c1349fc2392bf6989029f7bc541e7", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from itertools import combinations as com\ndef Triangles():\n N = int(input())\n sides = list(map(int, input().split()))\n if 3 in sides and 4 in sides and 5 in sides:\n return \"YES\"\n for i in sorted(com(sides,3)):\n if i[0] + i[1] > i[2] and i[0] + i[2] > i[1] and i[1] + i[2] > i[0]:\n return \"YES\"\n return \"NO\"\nprint(Triangles())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a90be7ab46cb430c80a121232dd6ae8c", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\na=[(i+j) for i in l[:-1] for j in l[i:-1]]\ni=0\nk=len(a)\nfor i in range (k):\n if l[n-1]1:\n for j in range(len(n)//2):\n u=n[i]+n[len(n)-1-i]\n p+=u\n p+=n[(len(n)//2)+1]\n else:\n print(n)\n bv+=1\n\nif bv==0:\n z=''\n for k in range(len(n)-1,-1,-1):\n z+=p[k]\n print(z)\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6454503191f438414dfdf12fb4f2627a", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nl = len(s)\nle = int(l/2)\nif(le==0):\n print(s)\nelse:\n k=\"\"\n k = str(k)\n for i in range(le):\n if(l%2==0):\n k = str(s[i]+s[l-i-1]+k)\n else:\n k += str(s[l-i-1]+s[i])\nif(l%2!=0):\n k = s[le]+k\nprint(k)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a15c07fcdd299e671023bc0fffc997b", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nn=len(s)\n\nif n%2 == 0:\n \n x = int((n/2)-1)\n y = int(n/2)\n while x>=0:\n \n print(s[x]+s[y],end=\"\")\n x=x-1\n y=y+1\n \n\nelse:\n\n \n print(s[int(n/2)],end=\"\")\n x=int((n/2)+1)\n y=int((n/2)-1)\n while y>=0:\n \n print(s[x]+s[y],end=\"\")\n x=x+1\n y=y-1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2988271018d730b35633a4ed5c6710cc", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nn = len(s)\nans = ''\nhalf = n//2\n\nevens = s[half+1:]\nodds = s[:half+1]\n\nfor i in range(half):\n ans = ans + odds[half - i]\n ans = ans + evens[i]\n\nif n %2 == 1:\n ans = ans + odds[0]\n \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d31c222f4c265ddc2eef7b0c54c317f2", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nans = ''\np = len(s) // 2\nfor i in range(len(s)):\n if i % 2 != 0:\n ans += s[p + i // 2 + 1]\n else:\n ans += s[p - i // 2]\na = list(ans)\nprint(*a, sep='')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27f82eb4a6f793d5b5573ef7e3a3771f", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nlevel = input()\nmax_jump = n // 4 - 1\nfound = False\nplatforms = [i for i in range(n) if level[i] == '*']\nif not platforms:\n\tprint('no')\nelse:\n\tfor platform in platforms:\n\t\tfor jump in range(1, max_jump):\n\t\t\ttry:\n\t\t\t\tif level[platform + jump] == '*' and level[platform + jump*2] == '*' and level[platform + jump*3] == '*' and not found:\n\t\t\t\t\tprint('yes')\n\t\t\t\t\tfound = True\n\t\t\texcept:\n\t\t\t\tbreak\n\tif not found:\n\t\tprint('no')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0c8598cb769e42ba603d4dd310b941d5", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#!python3\nn = input()\ns = input()\n\ngood = False\n\nfor i in range(0, int(n)):\n for j in range(1, 20):\n try:\n if s[i]=='*' and s[i+j]=='*' and s[i+2*j]=='*' and s[i+3*j]=='*' and s[i+4*j]=='*':\n good = True\n except:\n pass\n\nif good:\n print(\"yes\")\nelse: \n print(\"no\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "029d5b9eb8fddc72cf388cddffb3c065", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "s1=raw_input()\ns1=raw_input()\nans=\"no\"\nfor i in range(4):\n for j in range(1,len(s1)/3):\n if len(s1)%j==1:\n b=1\n else:\n b=0\n s=s1[i:-1:j]+s1[-1]*b\n if '*****' in s:\n ans=\"yes\"\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "109ff1528b42f3d1a2a20089d99f443e", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from math import*\nn = int(input())\na = input()\nA = []\nfor i in range(n):\n\tif ord(a[i]) == 42:\n\t\tA.append(1)\n\telse:\n\t\tA.append(0)\ncounter = 0\nfor i in range(1, ceil(n / 5) + 1):\n\tfor j in range(len(A) - 4 * i):\n\t\tif A[j] + A[j + i] + A[j + 2 * i] + A[j + 3 * i] + A[j + 4 * i] == 5:\n\t\t\tcounter += 1\nif counter == 0:\n\tprint(\"no\")\nelse:\n\tprint(\"yes\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8c31a36e1b38ae0c626d69511fcab12", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input().strip()\nf = False\nfor i in range(n):\n for j in range(n):\n x = j\n c = 0\n while x < n:\n if s[x] == '*':\n c += 1\n else:\n c = 0\n if c == 4:\n f = True\n x += i\nif f:\n print('yes')\nelse:\n print('no')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4e4a0da753b402be5165c1edd9dcd5a2", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a,b = map(int,input().split())\ns = list(map(int,input().split()))\ns1 = list(map(int,input().split()))\nk = min(s)\nk1 = min(s1)\nt = []\nfor i in range(max(a,b)):\n\tif a>=b:\n\t\tif s[i] in s1:\n\t\t\tt.append(s1[i])\n\tif b>a:\n\t\tif s1[i] in s:\n\t\t\tt.append(s[i])\nif len(t):\n\tprint(min(t))\nelif k != k1:\n\tprint(10*min(k,k1)+max(k,k1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b05f1d90c3c4ef485fab38375efb5f7a", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\nli=list(map(int,input().split()))\nli=sorted(li)\nli1=sorted(list(map(int,input().split())))\nfor i in li1:\n if i in li:\n a=i\na1=min(li)\nb1=min(li1)\nb=min((a1*10+b1),(b1*10+a1))\nprint(min(a, b))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "049c01c0bbab5feacb60fddf0b006140", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Python 3", "source_code": "import sys;\n\n#sys.stdin = open(\"input.txt\", \"r\");\n#sys.stdout = open(\"output.txt\", \"w\");\n\ndef ria():\n return [int(x) for x in input().split()];\n\nn, m = (int(x) for x in input().split());\n\na = ria();\nb = ria();\na.sort();\nb.sort();\n\ntf = 0;\n\nfor i in range(n):\n for j in range(m):\n if a[i] == b[j]:\n tf = 1;\n atg = a[i];\n break;\n if ( tf == 1 ):\n break;\n\nif ( tf == 1 ):\n ans = atg;\nelse:\n ans = str(min(a[0], b[0]) + str(max(a[0], b[0])));\n\n\nprint(ans);\n\n\n#sys.stdout.close();\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "488c071c914e140417f2d22c56e53aa4", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nt = 1\nwhile True:\n s = str(t)\n flag1 = False\n flag2 = False\n # print(t)\n for x in s:\n if int(x) in a:\n flag1 = True\n if int(x) in b:\n flag2 = True\n # print(x, flag1, flag2)\n if flag1 and flag2:\n break\n # t = t + 1\n\nprint(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3373f931a4309b662b5062726203709e", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Python 2", "source_code": "a, b = map(int, raw_input().split())\nl1 = map(int, raw_input().split())\nl2 = map(int, raw_input().split())\nl1.sort()\nl2.sort()\nmin1, min2 = l1[0], l2[0]\nminimum, maximum = min(min1, min2), max(min1, min2)\nif minimum in l1 and minimum in l2 :\n print minimum\nelif maximum in l1 and maximum in l2 :\n print maximum\nelse :\n print str(minimum) + str(maximum)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ff1a4048319455c29c6f92c1f870d01", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\nfir = list(map(int, input().split()))\nsec = list(map(int, input().split()))\nfir.pop(0)\nsec.pop(0)\n\nfir_saved = ''.join(fir)\nsec_saved = ''.join(sec)\n\nfight_cnt = 0\nimpossible = False\nwhile(fir and sec):\n fir_card = fir.pop(0)\n sec_card = sec.pop(0)\n\n if(fir_card > sec_card):\n fir.append(sec_card)\n fir.append(fir_card)\n else:\n sec.append(fir_card)\n sec.append(sec_card)\n\n fight_cnt += 1\n\n if fir_saved == ''.join(fir) and sec_saved == ''.join(sec):\n impossible = True\n break\n\nif impossible:\n print(-1)\nelse:\n print(fight_cnt, 1 if fir else 2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a86889fea55047cb5c714df68d7b8203", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import sys\n\ndef get_current_state(deck1, deck2, n):\n res = \"\".join([str(x) for x in deck1]) + \"-\"+\"\".join([str(x) for x in deck2])\n return res\nn = int(sys.stdin.readline())\nplayer1 = ([int(x)-1 for x in sys.stdin.readline().split()])[1:]\nplayer2 = ([int(x)-1 for x in sys.stdin.readline().split()])[1:]\ncurrent_state = get_current_state(player1, player2, n)\nnb_fights = 0\nvisited = set()\nwhile len(player1) > 0 and len(player2) > 0 and current_state not in visited:\n visited.add(current_state)\n c1 = player1[0]\n c2 = player2[0]\n if c1 > c2:\n player2 = player2[1:]\n player1 = player1[1:] + [c2, c1]\n else:\n player1 = player1[1:]\n player2 = player2[1:] + [c1, c2]\n current_state = get_current_state(player1, player2, n)\n nb_fights += 1\n\nif len(player1) == 0:\n print(str(nb_fights) + \" 2\")\nelif len(player2) == 0:\n print(nb_fights + \" 1\")\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bedc6d304b5d5244c62b9307240c64ee", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\nimport string\nimport math\nimport sys\ndef array_int():\n return [int(i) for i in sys.stdin.readline().split()]\ndef vary(arrber_of_variables):\n if arrber_of_variables==1:\n return int(sys.stdin.readline())\n if arrber_of_variables>=2:\n return map(int,sys.stdin.readline().split()) \ndef makedict(var):\n return dict(Counter(var))\n# i am noob wanted to be better and trying hard for that\ndef printDivisors(n) : \n divisors=[] \n # Note that this loop runs till square root \n i = 1\n while i <= math.sqrt(n): \n \n if (n % i == 0) : \n \n # If divisors are equal, print only one \n if (n//i == i) : \n divisors.append(i) \n else : \n # Otherwise print both \n divisors.extend((i,n//i)) \n i = i + 1\n return divisors\nn=vary(1)\nnum1=array_int()\nfn=num1[0]\nfcn=num1[1:]\nnum1=array_int()\nsn=num1[0]\nscn=num1[1:]\ncount=0\ni=n*n\nwhile i:\n if len(fcn)==0:\n print(count,2)\n break\n if len(scn)==0:\n print(count,1)\n break\n if fcn[0]>scn[0]:\n fcn.extend((scn[0],fcn[0]))\n fcn.pop(0)\n scn.pop(0)\n count+=1\n if scn[0]>fcn[0]:\n scn.extend((fcn[0],scn[0]))\n scn.pop(0)\n fcn.pop(0)\n count+=1\n i-=1\nelse:\n print(-1)\n\n\n\n\n \n\n \n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n\n \n \n\n\n\n\n\n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a6926804f9590bf925cc25e02348327", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from collections import deque\nfrom copy import deepcopy\nn = int(input())\nA = deque(list(map(int, input().split()))[1:])\nB = deque(list(map(int, input().split()))[1:])\nsA = deepcopy(A); sB = deepcopy(B);\ncnt = 0\nwhile len(A) > 0 and len(B) > 0:\n if A[0] > B[0]:\n A.append(B.popleft())\n A.append(A.popleft())\n else:\n B.append(A.popleft())\n B.append(B.popleft())\n if A == sA and B == sB:\n print(-1)\n break\n cnt += 1\nelse:\n print(cnt, 1 if len(B) == 0 else 2)\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ed61c2876c8a0d85a36e418373b9316", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def fact(n):\n\tp = 1\n\tif(n == 0): \n\t\treturn 1\n\tfor i in range(1,n+1):\n\t\tp = p*n\n\treturn p\nn = int(raw_input())\nf = fact(n+1)\na = map(int, raw_input().split())\na.pop(0)\nb = map(int, raw_input().split())\nb.pop(0)\nfor i in range(f):\n\tif(a[0]>b[0]):\n\t\ta.append(b[0])\n\t\ta.append(a[0])\n\t\ta.pop(0)\n\t\tb.pop(0)\n\telif(b[0]>a[0]):\n\t\tb.append(a[0])\n\t\tb.append(b[0])\n\t\ta.pop(0)\n\t\tb.pop(0)\n\telse:\n\t\tprint \"-1\"\n\t\texit()\n\tif(len(a)==0):\n\t\tprint str(i+1)+\" \"+\"2\"\n\t\texit()\n\telif(len(b)==0):\n\t\tprint str(i+1)+\" \"+\"1\"\n\t\texit()\nprint \"-1\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e568171e953c20468796e73b146c14f", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "\nproblemList = []\nn = 0\nk = 0\n\ndef RecurseFind(l:int, r:int):\n if l==r:\n if problemList[l]<=k:\n return 1\n return 0\n\n ret = 0\n retLeft = 0\n retRight = 0\n\n if problemList[l]<=k:\n retLeft = 1 + RecurseFind(l+1, r)\n if problemList[r]<=k:\n retRight = 1 + RecurseFind(l,r-1)\n\n ret = max(retLeft, retRight)\n\n return ret\n\nif __name__ == \"__main__\":\n\n n,k = map(int,input().split())\n #k = input()\n n = int(n)\n k = int(k)\n\n i = 0\n # while i k:\n c+=1\n i+=1\n elif a[j] <= k and a[i] > k:\n c+=1\n j-=1\nprint(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "423170f7d755792114baf1e62d1e2497", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# Get Input\na = input().split(' ')\nk = int(a[1])\n\nb = input().split(' ')\np = list(map(int,b))\n\nx = 0\ny = int(a[0]) - 1\n\n# Calculate Number of Problems\ndef calcX():\n global x\n xflag = 0\n while True:\n if (p[x] > k):\n break\n else:\n if x == y:\n x = x + 1\n xflag = 1\n break\n x = x + 1\n return xflag\n\ndef calcY():\n global y\n while True:\n if (p[y] > k):\n break\n else:\n if y == x:\n break\n y = y - 1\n\nwhile True:\n flag = calcX()\n if (flag):\n break\n calcY()\n\ntotalNumber = x + int(a[0]) - y - 1\n\nprint(totalNumber)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b84a91d4269cc41cbeb46dca58eabdc4", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,k=[int(i) for i in input().split()]\narr=list(map(int,input().split()))\nx=0\ny=1\ne=0\nwhile x<=y+1:\n if arr[x]<=k:\n e=e+1\n x=x+1\n if arr[-y]<=k:\n e=e+1\n y=y+1\nprint(e)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2eb81ee74f16a6bd1c430cf9469e3768", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\nx=input().split()\nn=int(x[0])\nk=int(x[1])\nc=0\ny=input().split()\nfor i in range(n):\n y[i]=int(y[i])\nfor j in range(n):\n if y[j]<=k:\n c+=1\n else:\n w=j\n break\nq=n-1\nwhile q>w:\n if y[q]<=k:\n c+=1\n q-+1\n else:\n break\nprint(c)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "99462f8b3d24033bef949905d7d45489", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "word=input()\nstring=\"\"\nfor str in word:\n if str not in string:\n string+=str\nif len(string)%2==1:\n print(IGNORE HIM!)\nelse:\n (CHAT WITH HER\uff01)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bd243f6a35679dd97854690d34f6fce8", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = int(input())\n a = []\n k = 1\n a.append(s[0])\nfor i in range(1,len(s)+1):\n if s[i]!=s[i+1] and s[i]!=s[0]:\n k+=1\nif k%2==0:\n print('CHAT WITH HER!')\nelse:\n print('IGNORE HIM!')\n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58d591d49a5df5eaac8faf71982ae92e", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Python 2", "source_code": " from collections import Counter\n\ndef boy_Or_Girl():\n\ts = raw_input()\n\tc = Counter(s)\n\tl = len(c.keys())\n\tif l % 2 == 0:\n\t\treturn \"CHAT WITH HER!\"\n\telse:\n\t\treturn \"IGNORE HIM!\"\n\ndef main():\n\tprint boy_Or_Girl()\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2966d0b0e0013cd22e55f450e4588aeb", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s=input\uff08\uff09\nstring=\u201c\u201d\nfor str in s:\n if str not in string:\n string+=str\nif len(string)%2==1:\n print(IGNORE HIM!)\nelse:\n print\uff08CHAT WITH HER\uff01\uff09\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c9cf1657039c0b395013d115aa424f8", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "x=input()\nif len(x)%!=0:\n print(\"CHAT WITH HER!\")\nelse:\n print(\"IGNORE HIM!\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4456e154de98766eb998b506b610d466", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = input()\nif len(input()) => 26:\n print (\"YES\")\nelse:\n print (\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fd24bb1bbddda6c0b09c4df3be58954b", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import string\ndef ispangram(str):\n alpha=\"abcdefghijklmnopqrstuvwxyz\"\n for ch not in str.lower():\n if char not in str.lower():\n return False\n return True\nstring=input()\nif (ispangram(string) == True):\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "390be47e7b8964b43addb1cc4fb1a031", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = [\n 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', \n 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'\n ]\n \ndef solve():\n n = int(input())\n\ta = input()\n\ta = a.lower()\n\treturn all(i in a for i in s)\n\t\nans = solve()\nif ans:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b96617ab1a5de1a3e60beb939d4dcd4b", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "Python 2", "source_code": "input()\nif len(set(raw_input().lower()))==26\n print 'YES'\nelse:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e7754aa4d802b485e7f7e65c778a2cf", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = [\n 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', \n 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'\n ]\n \ndef solve():\n n = int(input())\n a = input()\n\ta = a.lower()\n\treturn all(i in a for i in s)\n\t\nans = solve()\nif ans:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c787ddba80f8946bfcecb0ae06a4209", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nk=int((-1+(8*n+1)**0.5/2)\nsom=k+(k+1)//2\nif n-som==0:\nprint(k)\nelse:\nprint(n-som)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5b5c04fccb5b5822b0e0f0cba3cfe33", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int (input())\nk=int(-1+(8*n+1)**0.5//2)\nsom=k*(k+1)//2\nif n-som==0;\n print(k)\nelse:\n print(n-som) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70de8e18d3a769f12f90a33ec42e832a", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nlb = 0, rb = n\nwhile lb != rb:\n mb = (lb + rb) // 2\n if mb * (mb + 1) // 2 < n:\n lb = mb\n else:\n rb = mb - 1\nprint(n - lb * (lb + 1) // 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e4af1f5d07c417176580e6f598d2ef3d", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int (input())\nk=int((-1+(8*n+1)**0.5//2)\nsom=k*(k+1)//2\nif n-som==0;\n print(k)\nelse:\n print(n-som) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2feaf26a7bf26ca8dd9458fe4c00d0b0", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nk=int((-1+(8*n+1)**0.5/2)\nsom=k*(k+1)//2\nif (n-som==0):\n print(k)\nelse:\n print(n-som)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d9fb966ad315b76490f1f93798238af0", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nl = [map(int, raw_input().split()) for i in xrange(3)]\nn -= sum([x[0] for x in l])\nans = []\nfor x in l:\n ans.append(min(n, x[1]))\n n -= ans[-1]\nfor i in xrange(3):\n ans[i] += l[i][0]\n \nprnit ' '.join(map(str, ans))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aae691f370952ff2ec37d3dee0b0ae19", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\no1,o2 = map(int,input().split())\ns1,s2 = map(int,input().split())\nt1,t2 = map(int,input().split())\na1,a2,a3=o1,s1,t1\nsum = o1+t1+s1\nif sum==n:\n print(a1,a2,a3)\nelse:\n remain = n-sum\n if o2-o10:\n if dip[0][1] > 0:\n if n >= dip[0][1]:\n rewarded[0]+=dip[0][1]\n n-=dip[0][1]\n dip[0][1] = 0\n else:\n \trewarded[0] += n\n n = 0\n dip[0][1] = 0\n elif dip[1][1] > 0:\n if n>=dip[1][1]:\n rewarded[1]+=dip[1][1]\n n-=dip[1][1]\n dip[1][1]=0\n else:\n rewarded[1] += n\n n = 0\n dip[1][1] = 0\n else:\n rewarded[2] += n\n n = 0\n\nfor i in rewarded:\n\tprint(str(i), end=\" \")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2542ff5eb540568ee5c2233d2ebafd09", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "fat = min_1\ndead = min_2\nbad = min_3\n\nwhile fat+dead+bad=0:\n\t\tg.append(l[i])\n\t\ti-=1\n\treturn g\ndef ma(l):\n\ti =0\n\tm=l[i]\n\tim=0\n\twhile im:\n\t\t\tm=l[i]\n\t\t\tim =i\n\t\ti+=1\n\treturn im\ndef su(l):\n\ti =0\n\tm = 0\n\twhile i max_min_count:\n max_min_count = count\n else:\n count = 0\n return max_min_count\n\ndef get_res(k, s):\n n_count = 0\n M = len(s)\n for i in range(M):\n if s[i] == 'N':\n n_count += 1\n elif s[i] == 'Y':\n if n_count == k:\n if max_of_min_count(s) <= k:\n return True\n n_count = 0\n continue\n else:\n if n_count == k:\n if max_of_min_count(s) <= k:\n return True\n elif n_count < k:\n n_count += 1\n continue\n else: \n n_count = 0\n if n_count == k and max_of_min_count(s) <=k:\n return True\n else:\n return False\n \nM, k = [int(s) for s in raw_input().split(\" \")]\ns = str(raw_input())\nres = get_res(k, s)\nfor q in range(1, M):\n if s[q] == 'Y' or s[q] == '?':\n res = res or get_res(k, s[q:])\n\nif res and max_of_min_count(s) <= k:\n result = 'YES'\nelse:\n result = 'NO'\n\nprint \"{}\".format(result)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d1cfec44e0242b917bd127cf4b501292", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def max_of_min_count(s):\n p = ''\n for i in range(len(s)):\n if s[i] == '?':\n p += 'Y'\n else:\n p += s[i]\n max_min_count = 0\n count = 0\n for j in range(len(p)):\n if p[j] == 'N':\n count += 1\n if count > max_min_count:\n max_min_count = count\n else:\n count = 0\n return max_min_count\n\ndef get_res(M, k, s):\n n_count = 0\n for i in range(M):\n if s[i] == 'N':\n n_count += 1\n elif s[i] == 'Y':\n if n_count == k:\n if max_of_min_count(s) <= k:\n return 'YES'\n n_count = 0\n continue\n else:\n if n_count == k:\n if max_of_min_count(s) <= k:\n return 'YES'\n elif n_count < k:\n n_count += 1\n continue\n else: \n n_count = 0\n if n_count == k and max_of_min_count(s) <=k:\n return 'YES'\n else:\n return 'NO'\n \nM, k = [int(s) for s in raw_input().split(\" \")]\ns = str(raw_input())\nresult = get_res(M, k, s)\nprint \"{}\".format(result)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0703d80a6909f831be69c2c694c3f2aa", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\ns = input()\ncur = s[0] == 'N'\nmx = cur\nfor i in range(1, n):\n if (s[i] == 'N'):\n cur += 1\n else:\n cur = 0\n mx = max(mx, cur)\nif (cur > k):\n print(\"NO\")\n exit(0)\nfor i in range(k - 1, n):\n ch = 1\n for j in range (i - k + 1, i + 1):\n if (s[j] == 'Y'):\n ch = 0\n if (i > k - 1 and s[i - k] == 'N'):\n ch = 0\n if (i < n - 1 and s[i + 1] == 'N'):\n ch = 0\n if (ch):\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f5a7703f65bbd763fdf57ad8fed497e", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\nk = int(k)\ns = input()\ns = \"Y\" + s + \"Y\"\nres = \"NO\"\ncnt = 0\ncan = True\nfor ch in s:\n if(ch == 'N'):\n cnt += 1\n if(cnt > k):\n can = False\n else:\n cnt = 0\nfor i in range(1,n):\n i = int(i)\n if(i + k - 2 < n):\n subs = s[i:i+k]\n flag = True\n for ch in subs:\n if(not ch in \"N?\"):\n flag = False\n if((s[i-1] in \"Y?\" or s[i+k] in \"Y?\") and flag):\n res = \"YES\"\n # print(s[i-1], subs, s[i+k])\nif can:\n print(res)\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d19b2e8e1f82ba66a5a174f56e8b8bc3", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n, need = map(int, raw_input().split())\na = raw_input()\n\nf = [[[False for i in xrange(2)] for j in xrange(111)] for k in xrange(111)]\n\nf[0][0][0] = True\n\nfor i in xrange(n):\n for j in xrange(i+1):\n for k in xrange(2):\n if f[i][j][k]:\n i2 = i + 1\n if a[i] == 'Y' or a[i] == '?':\n j2 = 0\n k2 = k\n f[i2][j2][k2] = True\n if a[i] == 'N' or a[i] == '?':\n j2 = j + 1\n if j2 <= need:\n k2 = k\n if j2 == need:\n k2 = 1\n f[i2][j2][k2] = True\n\nres = False\nfor j in xrange(need + 1):\n if f[n][j][1]:\n res = True\n\nif res:\n print 'YES'\nelse:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9a6e0781d49106f9e80279219defe467", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "a1=input().split()\na=int(a1[0])\nb=int(a1[1])\nn=0\nfor i in range(a,b+1):\n\tif bin(i).count('0')==2:\n\t\tn+=1\nprint(n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "03dd3066ffa23dbf1ecb444777bdbb0f", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "input_ = input().split(\" \")\ninput_numbers = list(map(int, input_))\n\nshifted_ = []\n\na = input_numbers[0]\nb = input_numbers[1]\na_ = len(bin(a)[2:]) \nb_ = len(bin(b)[2:])\n\nall_ = []\nanswers = []\n\ndef generate_answers(mask):\n binaries = []\n \n for i in range(2, len(mask)):\n aux = '0b'\n aux += mask[2:]\n aux = list(aux)\n aux[i] = '0'\n aux = \"\".join(aux)\n binaries.append(aux)\n \n return binaries\n\n\nfor i in range(a_, b_+1):\n shifted = ((1 << i) - 1)\n shifted_.append(bin(mask))\n\nfor i in shifted_:\n all_ += generate_answers(i)\n\nfor i in all_:\n number = int(i,2)\n if !(number < input_numbers[0] or number > input_numbers[1] or i[2] == '0'): \n answers.append(i)\n\n\nprint(len(answers))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "903d8cbc486b41c303ee76e7db2d960c", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x = input().split()\nans = 0\nfor i in range(61):\n for j in range(i - 1):\n y = 2 ** i - 1 - 2 ** j\n if y >= x[0] and y <= x[1]:\n ans++\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1c48af44ceaa84175c03aaea8f671dcc", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "#include \n#define debug(x) cout << #x << \" \" << x << endl\n#define pb push_back\n#define LL long long\nusing namespace std;\n\nconst int MAXN = 1e5+7;\nconst int INF = 2e9+7;\nvector vec;\n\nstring to_bin(LL a)\n{\n string st;\n while(a){\n st += a % 2 + '0';\n a /= 2;\n }\n string t;\n int len = st.length();\n for(int i = len - 1; i >= 0; --i)\n t += st[i];\n return t;\n}\n\nLL to_num(string st)\n{\n LL a = 0;\n int len = st.length();\n for(int i = 0; i < len; ++i)\n a = a * 2 + st[i] - '0';\n return a; \n}\n\nvoid init()\n{\n string st = \"10\", R = \"1011111111111111111111111111111111111111111111111111111111111\";\n while(st != R)\n {\n string s = st;\n vec.pb(s);\n int pos = 1, len = s.length();//0\u7684\u4f4d\u7f6e\n while(pos < len - 1)\n {\n swap(s[pos], s[pos + 1]);\n vec.pb(s);\n pos++;\n }\n st += '1';\n }\n}\nbool cmp(string a, string b)\n{\n int len1 = a.length(), len2 = b.length();\n if(len1 > len2) return false;\n else if(len1 < len2) return true;\n else return a <= b;\n}\nint main(){\n //cout << to_bin((LL)1000000000000000000).length();\n LL a, b;\n cin >> a >> b;\n init();\n sort(vec.begin(), vec.end(), cmp);\n string st1 = to_bin(a), st2 = to_bin(b);\n int len = vec.size();\n int ans = 0; \n cout << st1 << \" \" << st2 << endl;\n for(int i = 0; i < len; ++i)\n {\n //cout << vec[i] << \" \";\n if(cmp(st1, vec[i]) && cmp(vec[i], st2))\n ans++;\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d7a4eefadc873b507599ea5c531519c2", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "PyPy 2", "source_code": "x = map(int,raw_input().split())\na = x[0]\nb = x[1]\n\ndef zeros(n):\n\tif n == 1:\n\t\treturn 0\n l = len(bin(n)) - 3\n x = l * (l-1) / 2\n if len(bin(n)[2:].replace(\"1\",\"\")) == 1:\n x += bin(n)[2:].find(\"0\")\n else:\n x += (bin(n)[2:].find(\"0\") - 1)\n return x\nprint zeros(b) - zeros(a-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8d074d75b6194b4c1f31f1f5f22c6901", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from itertools import *\nfrom fractions import *\nimport sys\na, b, c = sorted (map (lambda x: x[2] if x[1] == '>' else x[0], [raw_input () for _ in range (3)]))\nprint 'Impossible' if len ({a, b, c}) == 3 else b + list ({a, b, c} - {b})[0] + list ({'A', 'B', 'C'} - {a, b, c})[0]\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fa1856702ee5db0c8d9b584c3f9b4235", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "from itertools import *\nfrom fractions import *\nimport sys\na, b, c = sorted (map (lambda x: x[2] if x[1] == '>' else x[0], [raw_input () for _ in range (3)]))\nx = {a, b, c}\nprint 'Impossible' if x >= {'A', 'B', 'C'} else b + list (x - {b})[0] + list ({'A', 'B', 'C'} - x)[0]\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d8bd47d999fa8a0618e908bea741bdb7", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "from itertools import *\nfrom fractions import *\nimport sys\na, b, c = sorted (map (lambda x: x[2] if x[1] == '>' else x[0], [raw_input () for _ in range (3)]))\nx = {a, b, c}\nprint 'Impossible' if x >= {'A', 'B', 'C'} else b + list (x - {b})[0] + list ({'A', 'B', 'C'} - x)[0]\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f7547a559a58a04812b5724b1e035fe", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "a=input()\nb=input()\nc=input()\n\nx=[0,0,0]\nans=\"\"\nfor i in range(3):\n if a[1]==\"<\":\n x[ord(a[2])-65]+=1\n x[ord[a[0])-65]-=1\n else:\n x[ord(a[0])-65]+=1\n x[ord[a[2])-65]-=1\ny=[]\nfor i in x:\n y.append(i)\ny.sort()\nif y!=[-2,0,2]:\n print(\"\u00cfmpossible\")\nelse:\n for i in range(3):\n if x[i]==2:\n ans+=chr(i+65)\n for i in range(3):\n if x[i]==0:\n ans+=chr(i+65)\n for i in range(3):\n if x[i]==-2:\n ans+=chr(i+65)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e84423f377c24d9c459d47775024c44b", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "s = ['']*3\ns[0] = raw_input()\ns[1] = raw_input()\ns[2] = raw_input()\nfor i in range(3):\n if s[i] == 'B>A':\n s[i] = 'AA':\n s[i] = 'AB':\n s[i] = 'B' and s[1][1]=='<' and s[2][1]=='<':\n print 'BAC'\nelif s[0][1] == '>' and s[1][1]=='>' and s[2][1]=='>':\n print 'CBA'\nelif s[0][1] == '<' and s[1][1]=='>' and s[2][1]=='>':\n print 'CAB'\nelif s[0][1] == '<' and s[1][1]=='<' and s[2][1]=='>':\n print 'ACB'\nelif s[0][1] == '>' and s[1][1]=='>' and s[2][1]=='<':\n print 'BCA'\nelse:\n print 'Impossible'\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "840b51412cefcccb7314491f2f0aefe1", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,total=map(int,raw_input().split())\nk=sum(map(int,raw_input().split())\n\nif k+(n-1)*10>total:\n print -1\nelse:\n print (n-1)*2 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10bea254035ad2e7db160e612facaa1c", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,d=map(int,input().split())\nl= list(map(int,input().split()))\nd=d-sum(l)\nif(n==1 and d==1 and sum(l)==1):\n print(\"0\")\nelif(n-1<=int(d/10) and d>0):\n f=d%10\n if(f>4):\n f=1+int((d/10))*2\n else:\n f=int((d/10))*2\n print(f)\nelse:\n print(\"-1\")\n\n \n\n \n\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "853cc9342741d8fb85080d9df14cccad", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,total=map(int,raw_input().split())\nk=sum(map(int,raw_input().split())\n\nif k[0]+(n-1)*10>total:\n print -1\nelse:\n print (n-1)*2 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95d4dbcdab86b359ef8d64448a9719b4", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,s=map(int,input().split())\nl=list(map(int,input().split()))\na=int(0)\nfor i in range(n):\n a+=l[i]\nif s < (a + (n - 1) * 10)):\n\t\tprint(-1)\nelse :\n\t\tprint(s - a) / 5)\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "112faa241a73c9409d0d12113b9363a0", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,d = map(int,raw_input().split())\nt = map(int,raw_input().split())\n\ntotal_t = sum(t)\ncurrent_joke = 10*(n-1)\ncurrent = total_t + current_joke\nleft = (d - current)/5\n\nif left > =0:\n print left + (n-1)*2\nelse:\n print -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92150d544682b412293608db797c4606", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,m=raw_input().split()\nflag =1\nfor x in range(n/2+n%2,n+1):\n if(m%x == 0) :\n print x\n flag=0\n break\nif(flag) print -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e24154da63a45498c3e08d70ae6a3b54", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n, m = map(int,input().split())\np2 = n // 2\np1 = n % 2\nif (p2 + p1) % m == 0:\n print(p2 + p1)\n'''\nelif p2 == 0 and p1 == n:\n if p1 % 2 == 0:\n print(p1)\n else:\n print('-1')\n'''\nelse:\n while True:\n p2 -= 1\n p1 += 2\n if p2 == 0 and p1 == n:\n if p1 % 2 == 0:\n print(p1)\n break\n else:\n print('-1')\n break\n else:\n (p2 + p1) % m == 0\n print(p2 + p1)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb86a6e85b5569d712623ad89a1eecf0", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x,y = map(int,input().split())\nif(x=min):\n while(true):\n if(min%m==0):\n print(str(min))\n break\n else:\n min+=1\nelse:\n print (\"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "02799d9c4647289ef0f76ef933f96ce8", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef modInverse(b,m): \n g = math.gcd(b, m) \n if (g != 1): \n # print(\"Inverse doesn't exist\") \n return -1\n else: \n # If b and m are relatively prime, \n # then modulo inverse is b^(m-2) mode m \n return pow(b, m - 2, m) \n \n \n# Function to compute a/b under modulo m \ndef modDivide(a,b,m): \n a = a % m \n inv = modInverse(b,m) \n if(inv == -1): \n print(\"Division not defined\") \n else: \n return (inv*a) % m\nfor z in range(1):\n n =int(input())\n ans=0\n r= n*(n+1)//6\n p=998244353\n print(modDivide(r,2**n,p))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fe3e4fb0243d5f3ec0fa0e36a569ef31", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nmod = 998244353\ndef modinv(n):\n return pow(n, mod-2, mod)\nif n == 1:\n print(1)\n exit()\n\nu = [0]*(n+1)\nu[0] = 1\nu[1] = 1\nu[2] = 1\nk = pow(2,n,mod)\nacum = [0]*(n+1)\nacum[0] = 1\nacum[1] = 2\nacum[2] = 3\n\nfor i in range(3,n+1):\n acum[i] = (acum[i-2]+acum[i-1])%mod\nprint((acum[-3]*modinv(k))%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5991dad327026cf5918b4876dd08b12", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "mo = 998244353\n\ndef ge(n):\n a = [0] * (n + 5)\n a[1] = 1\n a[2] = 1\n for i in range(3, n + 1):\n a[i] = a[i - 1] + a[i - 2]\n a[i] %= mo\n return a[n]\n\ndef min_y(b, n):\n # print (b, n)\n if (n == 1):\n return b\n if (n % 2 == 0):\n return min_y(b * b % mo, n // 2) % mo\n return b * min_y(b % mo, n - 1) % mo\n\nn = int(input())\nget_n = ge(n)\nans = 2\nst = n * (mo - 2)\nwhile (st != 1):\n if (st % 2 == 0):\n ans = ans * ans % mo\n st //= 2\n else:\n ans = ans % mo\n st -= 1\n\nprint(get_n * ans % mo)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a877f474d17743184981a3b7427ebb8b", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nMOD = 998244353\n\n\ndef fib(n):\n f = [0, 0, 1, 2, 3]\n\n for i in range(5, n+1):\n f.append((f[i-1] + f[i-2]) % MOD)\n return f[n]\n\n\nx = fib(n)\ny = pow(2, n, MOD)\nprint((x*pow(y, MOD-2, MOD)) % MOD)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea25d4bb48ed4e2e7309a136540ce262", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import math\nt=1\nl=[1,1]\nfor i in range(2,100000):\n l.append((l[i-1]+l[i-2])998244353)\nwhile t:\n t-=1\n n=int(input())\n x=l[n-1]\n y=pow(2,n)\n print(x*pow(y,998244351,998244353)%998244353)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82a2a84308401c8ff191055d95d2fca1", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "f __name__==\"__main__\":\n\tn,k = map(int,input().split())\n\tprime = [2]\n\n\t\n\tfor i in range(3,n):\n\t\t#check if i is prime\n\t\ti_is_prime = True\n\t\tfor j in range(2,int(i**0.5)+1):\n\t\t\tif i%j==0:\n\t\t\t\ti_is_prime = False\n\t\t\t\tbreak\n\t\tif i_is_prime:\n\t\t\tprime.append(i)\n\t\t#check if i can be express as sum of two prime\n\t#print(prime)\n\tcount = 0\n\tfor i in range(5,n):\n\t\tfor j in range(len(prime)):\n\t\t\tif prime[j]=k):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8c2a4c8b218cee52b40836874c6239f4", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "interval, guess = map(int, input().split())\nprimes = []\n\nfor num in range(2, interval + 1):\n if num > 1:\n for i in range(2, num):\n # check for divisors\n if (num % i) == 0:\n break\n\t\t\t# if prime\n\t\t\telse:\n\t\t\t\tprimes.append(num)\n\ncount = 0\nfor i in range(len(primes) - 1):\n if count == guess:\n break\n # if found the prime number\n if primes[i] + primes[i+1] + 1 in primes:\n count += 1\n if count == guess:\n break\n\nif count == guess:\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76ef6836eb8c775228cb5483893ebd0c", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\n\nprime[]\nfor i in range(2, n + 1):\n if all( i % p != 0 for p in prime):\n prime += [i]\nans = 0\nfor i in range(len(prime) - 1):\n if prime[i] + prime[i + 1] + 1 in prime:\n c += 1\nif c >= k:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f38683240a05ee0777fc646f54782043", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\nsito = [True for _ in range(1050)]\nwynik = 0\nfor x in range(2, n + 50):\n for y in range(x*2, n + 50, x):\n sito[y] = False\npierwsze = []\nfor x in range(1, n):\n if sito[x]:\n pierwsze.append(x)\nfor x in range(len(pierwsze) - 1):\n if sito[pierwsze[x] + pierwsze[x+1] + 1] and pierwsze[x] + pierwsze[x+1] + 1 <= n:\n wynik += 1\nif wynik >= k:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df07abe633cda0f7dd81a9ce42729d55", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "#! /usr/bin/python\n\n__author__=\"Guillermo Candia Huerta\"\n__date__ =\"$10-06-2010 11:06:16 AM$\"\n\ndef es_primo(n):\n if n == 2 or n == 3 or n == 5: return True\n\n for i in range(2,n):\n if n % i == 0:\n return False\n return True\n\ndef Noldbach(n):\n #print n\n for a in range(0, len(l)):\n #print 'a =' + str(a) + 'suma=' + str(1 + l[a] + l[a+1]) +'n='+ str(n)\n suma = 1 + l[a] + l[a+1]\n if suma == n:\n return True\n if suma >n:\n break\n return False\n\n\n\n\n \n\nif __name__ == \"__main__\":\n n, k = map(int, raw_input().split())\n\n l = filter(es_primo, range(2,1000))\n ln = filter(Noldbach, l)\n\n print l\n print ln\n for a in range(n+1):\n if a in l:\n k = k - 1\n if k == 0:\n salida = 'YES'\n break\n salida = 'NO'\n\n print salida\n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7b88e00d19a26742d88620122df97b97", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.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": "2f9e0fa24cec9073e40c9a9ecc914156", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "try :\n import sys\n n, d = map(int, input().split(\" \"))\n #s = list(map(int, input().split(\" \")))\n s = [list(int(n) for n input.split() for _ in range(0, n))]\n l = [i for i in s if s[i] == 1]\n diff = [l[i+1] - l[i] for i in range(0, len(l) - 1) if ((l[i+1] - l[i]) <= d)]\n if not diff :\n print(-1)\n else :\n print(min(diff))\nexcept OSError as err:\n print(\"OS error: {0}\".format(err))\nexcept ValueError as ex:\n print(\"Could not convert data to an integer.\")\n print(\"value error: {0}\".format(ex))\nexcept:\n print(\"Unexpected error:\", sys.exc_info()[0])\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8440f47f54e2e0b949d48e4bcb424144", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nd=int(input())\nst=input()\n\nmaxindx=0\ntill=0\ncnt=0\nfor i in range(n):\n maxindx=max(maxindx, i+d)\n if i==till and s[i]==1:\n cnt+=1\n till=maxindx\n \n if till>=n:\n return cnt", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c63cd282660e239098f9825f13f931d", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.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": "46ef657dec55255369c2e3fa9c8334b3", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.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] for i in range(0, len(l) - 1) if ((l[i+1] - l[i]) <= d) else -1 if ((l[i+1] - l[i]) > d))]\nprint(min(diff))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1563e0b5430eee8de6e15da1cf2f64f6", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a=[[1,1,1],[1,1,1],[1,1,1]]\nb=[]\n;b.append(list(map(int,input().split())))\n;b.append(list(map(int,input().split())))\n;b.append(list(map(int,input().split())))\nfor i in range(3):\n for j in range(3):\n if b[i][j]%2==1:\n for k in range(3):\n if a[k][j] and k!=i:a[k][j]=0\n else:a[k][j]=1\n for k in range(3):\n if a[i][k]:a[i][k]=0\n else:a[i][k]=1\nfor i in range(3):print(*a[i])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c81165408d76da1af39f41966d20599", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Python 2", "source_code": "\n\n'''s=[[0]*5]+[[0]+map(int,raw_input().split())+[0] for _ in range(3)]+[[0]*5]\nfor i in range(1,4):\n l=''\n for j in range(1,4):\n l+=str(1-(s[i][j]+s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1])%2 )\n print l\n'''\n\n '''\n1 0 0\n0 0 0\n0 0 1\n '''\n\ng = [[0] * 5] + [[0] + map(int, raw_input().split()) + [0] for i in range(3)] + [[0] * 5]\n\ndef f(x, y):\n return g[x][y - 1] + g[x][y] + g[x][y + 1] + g[x - 1][y] + g[x + 1][y]\n\nprint '\\n'.join([''.join([str(1 - f(x, y) % 2) for y in [1, 2, 3]]) for x in [1, 2, 3]])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7042d2428d33468385b0722bf632c607", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def dfs(grid, x, y):\n if [x, y] == [0, 0]:\n toggle(x+1,y)\n toggle(x,y+1)\n \n if [x, y] == [0, 1]:\n toggle(x,y-1)\n toggle(x+1,y)\n toggle(x,y+1)\n\n if [x, y] == [0, 2]:\n toggle(x,y-1)\n toggle(x+1,y)\n\n if [x, y] == [1, 0]:\n toggle(x-1,y)\n toggle(x+1, y)\n toggle(x, y+1)\n\n if [x, y] == [1, 1]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x+1, y)\n grid[x][y+1] = toggle(x, y+1)\n\n if [x, y] == [1, 2]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x+1, y)\n\n if [x, y] == [2, 0]:\n toggle(x-1 , y)\n toggle(x, y+1)\n\n if [x, y] == [2, 1]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x, y+1)\n\n if [x, y] == [2, 2]:\n toggle(x-1 , y)\n toggle(x , y-1)\n\n toggle(x, y)\n\n\ndef toggle(x, y):\n if result[x][y] == 1:\n result[x][y] = 0\n else:\n result[x][y] = 1\n\n\ngrid = []\nresult = []\nfor i in range(3):\n grid.append([int(x) for x in input().split()])\n result.append([1 for x in range(3)])\n\n\nfor row in range(3):\n for col in range(3):\n if grid[row][col] == 0:\n continue\n \n val = grid[row][col]\n if val % 2 == 0:\n continue\n else:\n dfs(grid, row, col)\n\n\n\nfor row in range(3):\n for col in range(3):\n print(result[row][col)\n print()\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b6cef135c59d65a28d2649822c8fd6e", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Python 3", "source_code": "light_turners = list()\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\n\nlights = [[True, True, True], [True, True, True], [True, True, True]]\n\n\ndef flip_adjacent(i, j):\n lights[i][j] = not lights[i][j]\n\n if i + 1 < 3:\n lights[i + 1][j] = not lights[i + 1][j]\n\n if j + 1 < 3:\n lights[i][j + 1] = not lights[i][j + 1]\n\n if i - 1 > -1:\n lights[i - 1][j] = not lights[i - 1][j]\n\n if j - 1 > - 1:\n lights[i][j - 1] = not lights[i][j - 1]\n\n\nfor i in range(3):\n for j in range(3):\n while light_turners[i][j] > 0:\n flip_adjacent(i, j)\n light_turners[i][j] -= 1\n\nfor i in range(3):\n for j in range(3):\n print(1 if lights[i][j] else 0, end='')\n print('')\n// 1476521355915", "lang_cluster": "Python", "compilation_error": true, "code_uid": "146b736c1133c101a5a29b0626d6f9f2", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Python 2", "source_code": "mp=[[1,1,1,1,1],[[1,1,1,1,1],[[1,1,1,1,1],[[1,1,1,1,1],[[1,1,1,1,1]]\nfor i in range(1,4):\n rd=input().split()\n for j in range(1,4):\n t=int(rd[j-1])\n if t % 2 == 1:\n mp[i][j]^=1\n mp[i+1][j]^=1\n mp[i-1][j]^=1\n mp[i][j-1]^=1\n mp[i][j+1]^=1\nfor i in range(1,4):\n s=''\n for j in range(1,4):\n s+=str(mp[i][j]+48)\n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36dd31ecda4fc37a09d8efba93f40b18", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "Python 2", "source_code": "def gcd(A , B):\n if B == 0:\n return A\n return gcd(B , A % B)\n\nN = int(raw_input())\ninteger_part = 0\nwhile N % 2 == 0:\n integer_part += 1\n N /= 2\n \nif N > 1:\n u , t = 1 , 2\n while t != 1:\n u += 1\n t = (t * 2) % N\n x = 2**u / N\n digi = \"\"\n while x > 0:\n if x % 2 == 0:\n digi = \"0\" + digi\n else:\n digi = \"1\" + digi\n x /= 2\n while len(digi) < u:\n digi = \"0\" + digi\n digi = \"+\" + digi\n A , B = 0 , (2**u - 1)**2\n for i in range(1 , u + 1):\n if digi[i] == '1':\n A += (2**(u - i)) * (u + (2**u) * i - i)\n A *= N\n G = gcd(A , B)\n A /= G\n B /= G\n print(str(A) + \"/\" + str(B))\nelse:\n print(str(integer_part) + \"/1\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0a7ab27575a566bbcd2de68bdf0feb6", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "from fractions import *\nn=int(input())\na,ans,last=Fraction(1,n),Fraction(0,1),-1\nfor i in range(n):\n t=Fraction(1,2**i)\n if (t<=a):\n a-=t\n ans+=i*t\n if (a.numerator==1):\n if (last>=0):\n d=i-last\n break\n res,last=ans,i\nres=(res*n+Fraction(d,2**d))/(1-Fraction(1,2**d))\nprint(res,end='')\nif (res.denominator==1):print('/1')\nprint('')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f5f08641597b453c18831f6d0b77bb7", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "from math import *\nfrom fractions import *\n\np = [1]\nfor i in xrange(1, 20100):\n\tp.append(p[i-1]*2)\n\n\ndef add(x, y, a, b):\n\tnum = x*b + y*a\n\tden = y*b\n\treturn num, den\n\ndef solve():\n\tn = int(raw_input())\n\t\n\tt = n\n\tcnt = 0\n\twhile t%2 == 0:\n\t\tt /= 2\n\t\tcnt += 1\n\tif t == 1:\n\t\ts = str(cnt)+'/1'\n\t\tprint s\n\t\treturn\n\t\n\tm, cur, X, pos = n, 1, 0, 0\n\t\n\tl = []\n\t\n\tPnum, Pden = 0, 1\n\t\n\td = {}\t\n\twhile True:\n\t\tcur *= 2\n\t\tpos += 1\n\t\t\n\t\tif cur >= n:\n\t\t\tcur -= n\n\t\t\tl.append(pos)\n\t\t\tif cur not in d:\n\t\t\t\td[cur] = pos\n\t\t\telse:\n\t\t\t\tpt = d[cur]\n#\t\t\t\tprint cur, pt, pos, l\n\t\t\t\tlength = len(l)\n\t\t\t\tfor i in xrange(length):\n\t\t\t\t\tif l[i] <= pt:\n\t\t\t\t\t\tPnum, Pden = add(Pnum, Pden, m*l[i], p[l[i]])\n\t\t\t\t\telse:\n\t\t\t\t\t\tX = l[i] - l[i-1]\n\t\t\t\t\t\tl = l[i:]\n\t\t\t\tbreak\n\t\n\tTnum, Tden = 0, 1\n\tSnum, Sden = 0, 1\n\tfor i in l:\n\t\ttmp = p[i]\n\t\tTnum, Tden = add(Tnum, Tden, i, tmp)\n\t\tSnum, Sden = add(Snum, Sden, 1, tmp)\n\n\tg1 = gcd(Tnum, Tden)\n\tTnum /= g1\n\tTden /= g1\n\t\n\tg2 = gcd(Snum, Sden)\n\tSnum /= g2\n\tSden /= g2\n\t\n\ttmp = p[X]\n\ttnum, tden = tmp, tmp-1\n\t\n\tTnum *= tnum\n\tTden *= tden\n\t\n\tg1 = gcd(Tnum, Tden)\n\tTnum /= g1\n\tTden /= g1\n\t\n\tSnum *= X\n\tSnum *= tmp*tmp\n\tSden *= (tmp-1)*(tmp-1)\n\tSden *= tmp\n\t\n\tg2 = gcd(Snum, Sden)\n\tSnum /= g2\n\tSden /= g2\n\t\n\tAnum, Aden = add(Tnum, Tden, Snum, Sden)\n\tAnum *= m\n\t\n\tAnum, Aden = add(Anum, Aden, Pnum, Pden)\n\t\n\tg = gcd(Anum, Aden)\n\tAnum /= g\n\tAden /= g\n\t\n\ts = str(Anum)+ '/' + str(Aden)\n\tprint s\n\n\treturn\n\nsolve()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed84e235af0093a69dbb9ea84d0ae154", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "def gcd(A , B):\n if B == 0:\n return A\n return gcd(B , A % B)\n\nN = int(raw_input())\ninteger_part = 0\nwhile N % 2 == 0:\n integer_part += 1\n N /= 2\n \nif N > 1:\n u , t = 1 , 2\n while t != 1:\n u += 1\n t = (t * 2) % N\n x = 2**u / N\n digi = \"\"\n while x > 0:\n if x % 2 == 0:\n digi = \"0\" + digi\n else:\n digi = \"1\" + digi\n x /= 2\n while len(digi) < u:\n digi = \"0\" + digi\n digi = \"+\" + digi\n A , B = 0 , (2**u - 1)**2\n for i in range(1 , u + 1):\n if digi[i] == '1':\n A += (2**(u - i)) * (u + (2**u) * i - i)\n A *= N\n A += B * integer_part\n G = gcd(A , B)\n A /= G\n B /= G\n print(str(A) + \"/\" + str(B))\nelse:\n print(str(integer_part) + \"/1\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75e4bf4ad0f06f73ad87e76f0bc6062e", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "from fractions import *\nimport math\nn=int(input())\nm=int(math.log2(n))\nif (2**m==n):\n print('%d/1'%m)\nelse:\n a,ans,last=Fraction(1,n),Fraction(0,1),-1\n for i in range(n):\n t=Fraction(1,2**i)\n if (t<=a):\n a-=t\n ans+=i*t\n if (a.numerator==1):\n if (last>=0):\n d=i-last\n break\n res,last=ans,i\n res=(res*n+Fraction(d,2**d))/(1-Fraction(1,2**d))\n print(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0eedd1741b12b87242011394b4888a3", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\np=0\nif a==1 and b==1:\n p=0\nelse:\n while 1:\n elif a!=0 and b!=0 and a<=b:\n a+=1\n b-=2\n p+=1\n elif a!=0 and b!=0 and b 0 and b > 0 and do = True):\n time = time+1\n if(a==1):\n onFirst = True\n if(b==1):\n onFirst = False\n if(a != 1 and b ==2):\n onFirst = False\n if(b != 1 and a ==2):\n onFirst = True\n \n if(onFirst == True):\n a = a+1\n b = b-2\n else:\n a = a-2\n b = b +1\nif(do = True):\n print(str(time))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "16ac21c14d2aaeffe6d36369bafb9852", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "'''\u670b\u53cb\u4eec\u8981\u73a9\u63a7\u5236\u53f0\u3002\u4ed6\u4eec\u6709\u4e24\u4e2a\u64cd\u7eb5\u6746\u548c\u4ed6\u4eec\u53ea\u6709\u4e00\u4e2a\u5145\u7535\u5668\u3002\n\u6700\u521d\uff0c\u7b2c\u4e00\u64cd\u7eb5\u6746\u4ee5a1\u767e\u5206\u6bd4\u5145\u7535\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u4ee5a2\u767e\u5206\u6bd4\u5145\u7535\u3002\n\u60a8\u53ea\u80fd\u5728\u6bcf\u5206\u949f\u5f00\u59cb\u65f6\u5c06\u5145\u7535\u5668\u8fde\u63a5\u5230\u64cd\u7eb5\u6746\u3002\n\u5728\u4e00\u5206\u949f\u91cc\u64cd\u7eb5\u6746\u4e2d\u653e\u75352\uff05\uff08\u5982\u679c\u672a\u8fde\u63a5\u5230\u5145\u7535\u5668\uff09\u6216\u5145\u75351\uff05\uff08\u5982\u679c\u8fde\u63a5\u5230\u5145\u7535\u5668\uff09\u3002\n\u6e38\u620f\u7ee7\u7eed\uff0c\u800c\u4e24\u4e2a\u64cd\u7eb5\u6746\u6709\u6b63\u7535\u8377\u3002\n\u56e0\u6b64\uff0c\u5982\u679c\u5728\u5206\u949f\u5f00\u59cb\u65f6\u4e00\u4e9b\u64cd\u7eb5\u6746\u88ab\u5145\u75351\uff05\uff0c\u5219\u5b83\u5fc5\u987b\u8fde\u63a5\u5230\u5145\u7535\u5668\uff0c\u5426\u5219\u6e38\u620f\u505c\u6b62\u3002\n\u5982\u679c\u4e00\u4e9b\u64cd\u7eb5\u6746\u5b8c\u5168\u653e\u7535\uff08\u5176\u7535\u8377\u53d8\u4e3a0\uff09\uff0c\u6e38\u620f\u4e5f\u505c\u6b62\u3002\n\u786e\u5b9a\u6e38\u620f\u53ef\u4ee5\u6301\u7eed\u7684\u6700\u5927\u5206\u949f\u6570\u3002\n\u7981\u6b62\u6682\u505c\u6e38\u620f\uff0c\u4f8b\u5982\u5728\u6bcf\u4e2a\u65f6\u523b\u90fd\u5e94\u8be5\u542f\u7528\u4e24\u4e2a\u64cd\u7eb5\u6746\u3002\n\u5141\u8bb8\u64cd\u7eb5\u6746\u5145\u7535\u8d85\u8fc7100\uff05\u3002\n\u8f93\u5165\n\u8f93\u5165\u7684\u7b2c\u4e00\u884c\u5305\u542b\u4e24\u4e2a\u6b63\u6574\u6570a1\u548ca2\uff081\u2264a1\uff0ca2\u2264100\uff09\uff0c\n\u5206\u522b\u662f\u7b2c\u4e00\u548c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u7684\u521d\u59cb\u5145\u7535\u7535\u5e73\u3002\n\u8f93\u51fa\n\u8f93\u51fa\u552f\u4e00\u7684\u6574\u6570\uff0c\u6e38\u620f\u53ef\u4ee5\u6301\u7eed\u7684\u6700\u5927\u5206\u949f\u6570\u3002\u6e38\u620f\u7ee7\u7eed\u76f4\u5230\u67d0\u4e9b\u64cd\u7eb5\u6746\u91ca\u653e\n\u5728\u7b2c\u4e00\u4e2a\u793a\u4f8b\u6e38\u620f\u6301\u7eed6\u5206\u949f\u901a\u8fc7\u4f7f\u7528\u4ee5\u4e0b\u7b97\u6cd5\uff1a\n\n\u5728\u7b2c\u4e00\u5206\u949f\u5f00\u59cb\u65f6\u5c06\u7b2c\u4e00\u64cd\u7eb5\u6746\u8fde\u63a5\u5230\u5145\u7535\u5668\uff0c\u5728\u8be5\u5206\u949f\u7ed3\u675f\u65f6\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e4\uff05\uff0c\n\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e3\uff05\u5904;\u7ee7\u7eed\u6e38\u620f\u800c\u4e0d\u6539\u53d8\u5145\u7535\u5668\uff0c\n\u5728\u7b2c\u4e8c\u5206\u949f\u7ed3\u675f\u65f6\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e5\uff05\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e1\uff05;\n\u5728\u7b2c\u4e09\u5206\u949f\u5f00\u59cb\u65f6\uff0c\u5c06\u7b2c\u4e8c\u64cd\u7eb5\u6746\u8fde\u63a5\u5230\u5145\u7535\u5668\uff0c\n\u5728\u6b64\u5206\u949f\u4e4b\u540e\uff0c\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e3\uff05\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e2\uff05;\n\u7ee7\u7eed\u6e38\u620f\u800c\u4e0d\u6539\u53d8\u5145\u7535\u5668\uff0c\n\u7b2c\u56db\u5206\u949f\u7ed3\u675f\u65f6\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e1\uff05\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e3\uff05\u5904;\n\u5728\u7b2c\u4e94\u5206\u949f\u5f00\u59cb\u65f6\u5c06\u7b2c\u4e00\u64cd\u7eb5\u6746\u8fde\u63a5\u5230\u5145\u7535\u5668\uff0c\n\u5728\u6b64\u5206\u949f\u4e4b\u540e\uff0c\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e2\uff05\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e1\uff05;\n\u5728\u7b2c\u516d\u5206\u949f\u7684\u5f00\u59cb\u5c06\u7b2c\u4e8c\u64cd\u7eb5\u6746\u8fde\u63a5\u5230\u5145\u7535\u5668\uff0c\n\u5728\u8be5\u5206\u949f\u4e4b\u540e\uff0c\u7b2c\u4e00\u64cd\u7eb5\u6746\u5904\u4e8e0\uff05\uff0c\u7b2c\u4e8c\u64cd\u7eb5\u6746\u5904\u4e8e2\uff05\u3002\n\u4e4b\u540e\uff0c\u7b2c\u4e00\u64cd\u7eb5\u6746\u5b8c\u5168\u653e\u7535\uff0c\u6e38\u620f\u505c\u6b62\u3002\n\n\u770b\u51fa\u6765\u64cd\u4f5c\u6746\u57281 2 \u95f4\u4e92\u6362\u76f4\u5230\u5176\u4e2d\u4e00\u4e2a\u4e3a0\u6216\u8005-1\n'''\na,b=map(int,input().split())\nif a!=b:\n \n print(min(a,b)*2)\nelif a==b:\n print(max(a*2-3,0))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30a776c7b5a607aff817afd2399f9e3c", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a1,a2=map(int,input().split())\nif(a1 0 and n2 > 0:\n c = c + 1\n if (n1 < n2) or n1 == n2:\n n1 = n1 + 1\n n2 = n2 - 2\n else:\n n1 = n1 - 2\n n2 = n2 + 1\n print c\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b496c93e80f5cbd57beb0ce98e5b07d", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n R=lambda:map(int,raw_input().split())\nn,k=R()\nprint max(0,(k*2-1)*n-sum(R())*2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff284189cae4f27f364e903261404801", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n, k = (int(x) for x in input().split())\ngrades = [int(x) for x in input().split()]\ngrade_s = sum(grades)\nfor i in range(100000):\n if (grade_s + k * i) / (i + n) >= (2 * k - 1) / 2:\n print(i)\n return 0\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "553675f0d819ac429d5d01234880db7b", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "raw1 = input().split(\" \")\nn = int(raw1[0])\nk = float(raw1[1])\n\nraw2 = input().split(\" \")\navg = 0\nfor idx in raw2\n avg += int(idx)\n\nadd = 0\nwhile((k - 0.5) * (len(raw2)+add) > avg):\n avg += k\n add += 1\nprint(add)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2776f597b82f2d1a19e00965bd4180f", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,k=input().split()\nn,k=int(n),int(k)\na=list(map(int,input().split()))\np=(2*k-1)*n-2*sum(a)\nif p<0:\n print(0)\nelse\n print(p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6cb8bb7728bd4d2ec29489e7a7458d71", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,k = map(int,raw_input().split())\na=map(int,raw_input().split())\nprint 2*n*k - n - 2*sum(a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce6295bd6fbc0643ad3206f76dba08e1", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s=input()\ni = 0\nfor c in input():\n\ts[i] == c and i += 1\nprint(i + 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "12645c54ea3706b6fcb33c8ce91b76b7", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nt = input()\nout = 0\nfor i in range(t):\n if s[out] = t[i]:\n out += 1\n \nprint(out+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "598ca68ef8369dd508158408b5eec510", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=list(input())\np=list(input())\ny=0\nfor x in range(len(p))):\n if p[x]==n[y]:\n y+=1\n else:\n pass\nprint(y+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "143fd06a9959357cc2f9135c62db04c3", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = input()\nt = input()\npos = 0\nfor i in t:\n if i = s[pos]:\n pos+=1\nprint(pos) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af7865237e20ef9847f0b7c04119cada", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=list(input())\np=list(input())\ny=0\nfor x in range(len(p))):\n if p[x]==p[y]:\n y+=1\n else:\n pass\nprint(y+1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8e0dbc4736b1266f2e3cc9927158230e", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = str(input())\ne = s.split(\" \")\nss = str(input())\nee = ss.split(\" \")\ncount = 0\nanswer = []\nfor i in range(int(e[0])):\n answer.append(0)\nindex = 0\ntruth = False\ni=0\nwhile count < int(e[0]):\n while i < int(e[0]) and truth = False:\n if answer[i] < int(ee[i]):\n answer[i]+=int(e[1])\n if answer[i]>=int(ee[i]):\n count+=1\n index = i\n if count == int(e[0]):\n truth = True\n i+=1\nprint(index)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "75f2a00c36a5cf0371d8111e7496ddb0", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "|#WTF\n_=list(map(int,input().split()))\n__=list(map(int,input().split()))\n___=[i+1 for i in range(_[0])]\nwhile(len(__)!=1):\n if(__[0]<=_[1]):\n __.remove(__[0])\n ___.remove(___[0])\n else:\n __.append(__[0]-_[1])\n __.remove(__[0])\n ___.append(___[0])\n ___.remove(___[0])\nprint(___[0])\n#Lorenzo", "lang_cluster": "Python", "compilation_error": true, "code_uid": "61cfa753b6b72cd05ac737de9a86aead", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import java.util.*;\nimport java.io.*;\n \n \n public class Solution{\n public static void main (String aargs[]){\n \n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int m = sc.nextInt();\n \n int ans = 0;\n int []ar= new int[n+1];\n for(int i= 1; i <= n; i++){\n ar[i] = sc.nextInt();\n }\n int t= 0;\n int c = 0;\n \n for(int i = 1; i <= n; i++){\n int a = ar[i];\n int s = a/m+(a%m == 0?0:1);\n if(s >= t){\n t = s;\n c = i;\n }\n }\n System.out.println(c);\n }\n }", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a2d7ebb7ff3ebb267f5a67633b284596", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input().split()\na = int(n[0])\nb = int(n[1])\nc = []\nt = input().split()\nfor i in range(a):\n c.append([int(t[i]),0,i])\n c[i][1] = c[i][0] // b\nc.sort(key = lambda x:(x[1],x[2])\nprint(c[0][2]+1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3dfa71e87bbe6c0cad07c5b78f906ace", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,m = input().split()\na = input().split()\n\nn = int(n)\nm = int(m)\n\ni = 0\nfor i in range(0,n):\n\ta[i] = int(a[i])\n\ti += 1\n\t\nres = tem = i = 0\nfor i in range(0,n):\n if m >= a[i]:\n i +=1\n else:\n if a[i] >= tem:\n res = i\n \t\ttem = a[i]\n i += 1\n\t\nprint(res+1)\n\t\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dfb873e063a6983586f780724e866d17", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = input()\nprint(len(set(s[i:] + s[:i] for i in range(len(s)))))i", "lang_cluster": "Python", "compilation_error": true, "code_uid": "20746b5a3f866c8f6d1effb66a040ae0", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "# \u041a\u043e\u0440\u043e\u0432\u043e\u043a\u043e\u043d\u0433 \u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u044c \u0441\u043b\u043e\u0432\u0430! \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0434\u0430\u043b \u0435\u043c\u0443 \u043d\u043e\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\n# \u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u044c. \u0411\u0443\u0434\u0443\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u043c, \u041a\u043e\u0440\u043e\u0432\u043e\u043a\u043e\u043d\u0433 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u0437\u0430\u0434\u0430\u043d\u0438\u0435.\n# \u0422\u0435\u043f\u0435\u0440\u044c \u041a\u043e\u0440\u043e\u0432\u043e\u043a\u043e\u043d\u0433 \u0445\u043e\u0447\u0435\u0442 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u043e\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0431\u0435\u0440\u0451\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043b\u043e\u0432\u043e \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e\n# \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0431\u0443\u043a\u0432\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e. \u0422\u0430\u043a\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0434\u0432\u0438\u0433\u043e\u043c. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435\n# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u043a \u0441\u043b\u043e\u0432\u0443 \u00ababracadabra\u00bb, \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u043b\u043e\u0432\u0430\n# \u00abaabracadabr\u00bb, \u00abraabracadab\u00bb \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.\n# \u0422\u0435\u043f\u0435\u0440\u044c \u041a\u043e\u0440\u043e\u0432\u043e\u043a\u043e\u043d\u0433 \u0445\u043e\u0447\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430.\n# \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c.\n\n\ndef divs(n):\n result = [1]\n for i in range(2, n+1):\n if n % i == 0:\n result.append(i)\n return result\n\ns = input()\nn = len(s)\nlengths = divs(n)\nfor i in lengths:\n if s == s[:i] * (n//i):\n print(i)\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2c0dd4ea7eb346cae8892d3f03c9dae", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "print(len(set(input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bab95443ec2fe56a7bcfe1645cda85f3", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Python 2", "source_code": "print len(set(raw_input())\n# print s", "lang_cluster": "Python", "compilation_error": true, "code_uid": "17ecbaa77d9689127e50c591b51cd0ed", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "s = input()\nk = 1\nfor i in range(0,len(s)):\n a[i] != a[i-1]:\n k += 1\nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e573a16e6611f4a1ae7e177ab6d14608", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "(a>=b and a>=c and a=b and a>=d and a=d and a>=c and a=a and b>=c and b=a and b>=d and b=c and b>=d and b=a and c>=d and c=a and c>=b and c=b and c>=d and c=a and d>=b and d=a and d>=c and d=c and d>=b and d d or a + b > c :\n print(\"TRIANGLE\")\nelif b + c = d or a + b = c:\n print(\"SEGMENT\")\nelse:\n print(\"IMPOSSIBLE\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6acaf3b263df1706095739a77403accf", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "mas = sorted(list(map(int, input().split()))\nif mas[0] + mas[1] > mas[2] or mas[0] + mas[1] > mas[3]:\n print('TRIANGLE')\nelif mas[0] + mas[1] == mas[2] or mas[0] + mas[1] == mas[3]:\n print('SEGMENT')\nelse:\n print('IMPOSSIBLE')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ecc9d1075c32f514a8a810537d3bd2ab", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Python 2", "source_code": "num = raw_input().split()\nnum.sort()\na = num[1]+num[2]-num[3]\nb = num[0]+num[1]-num[2]\nif a>0 or b>0:\n print 'TRIANGLE'\nelif: a==0 or b==0:\n print 'SEGMENT'\nelse: \n print 'IMPOSSIBLE'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1fe2d9be91171309d1a1d5dfa1900de", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def main():\n\tfor i in range(4):\n\t\tv=[eval(input())]\n\tif(v[1]+v[2]>v[3] or v[0]+v[1]>v[2]) print(\"TRIANGLE\")\n\telif(v[0]+v[1]==v[2] or v[0]+v[1]==v[3] or v[1]+v[2]==v[3]) print(\"SEGMENT\")\n\telse print(\"IMPOSSIBLE\")\n\t\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c50711e12c9597c6a172fd47341f9ad1", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "k,r=map(int,input().split());i=1\nwhile (i*k%10!=0) & (i*k%10!=r):i++\nprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "013af1d838634a20991bacfb66d1f7aa", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Python 2", "source_code": "k,r = map(int,raw_input().split())\nfor i in xrange(100):\n if i*k%10 == r or i*k%10 ==0\n print i", "lang_cluster": "Python", "compilation_error": true, "code_uid": "42efcb2b5f2d756067b46ef5b787aab2", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k,r=map(int,input().split());i=1\nwhile 0!-i*k%10!=r:i+=1\nprint(i) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c6c4eb8741226feea9655ce4c9ef474", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Python 2", "source_code": "k = int(raw_input())\nr = int(raw_input())\n\nfor i in range(1, 10):\n if (i*k % 10 == r) || (i*k % 10 == 0):\n print i\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "db13f0cffc91bf130956b008f1bb02f6", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#732A\nk,r = list(map(int, input().split()))\nt = 1\nt1 = 1\nwhile (((t * 10) + r) % k) != 0:\n t = t + 1\nprint ((((t1 * 10) + r) // k))\n\nif t1 < t:\n print((((t1 * 10) + r) / k))\nelse \n print((((t1 * 10)) / k))\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1341b2df34f3bd9257c7a2a7e99f2fea", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def prime(m):\n f=0\n for i in range(2,m)):\n if (m % i) == 0: \n break\n else: \n f=1 \n return f\n\nimport math\nc=0 \nn=int(input())\nfor i in range(1,n):\n if(prime(n*i+1)==0):\n break\nprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70cba5d440a97f2307deaad888656f8d", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\n if n%2==0:\n print(n+2)\n else:\n print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e4f5509a1cab403bdbfa5ef63c25375", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\n if n%2==0:\n print(n+2)\n else:\n print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "288540b99eb54e71c84c6676ad7b745d", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nif n%2==0:\n for i in range(1,1000):\n if(((i*n)+1)%3==0):\n print(i)\n break\nelse:\n if n==1:\n print(3)\n break\n print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "85c0b08c475e7a71e07a9ff88ef62ee8", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\n\nif n % 2 == 1:\n print 1\nelif n == 2:\n print 4\nelse:\n print n-2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b63182481de977b8de960e9c6d1ecd07", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "Python 3", "source_code": "st = input().split()\na = {'0':int(st[1]),'1':int(st[2])\nst = input()\ncoast = 0\nis_able = True\nfor x in range(0,round(len(st)//2)):\n y = len(st) - x - 1\n if (y == x):\n if (st[x] == '2'):\n coast += min(a.values()) #\u0435\u0441\u043b\u0438 \u0442\u0430\u043d\u0446\u043e\u0440 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0430\u043c\u044b\u0439 \u0434\u0435\u0448\u0435\u0432\u044b\u0439 \u043a\u043e\u0441\u0442\u044e\u043c \n else:\n if (st[x] == st[y]):\n if (st[x] == '2'):\n coast += 2*min(a.values()) #\u0435\u0441\u043b\u0438 \u0443 \u0434\u0432\u043e\u0438\u0445 \u043d\u0435\u0442 \u043a\u043e\u0441\u0442\u044e\u043c\u043e\u0432 \u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0434\u0432\u0430 \u0434\u0435\u0448\u0435\u0432\u044b\u0445\n else:\n if (st[x] == '2'):\n coast += a[st[y]] #\u0432\u044b\u0431\u0438\u0430\u0435\u043c \u043e\u0434\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u044f\u043c \u043a\u043e\u0441\u0442\u044e\u043c\u044b\n elif (st[y] == '2'):\n coast += a[st[x]]\n else:\n is_able = False #\u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0434\u043d\u0438\u0435 \u043a\u043e\u0441\u0442\u044e\u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0430\u0434\u044e\u0442 \u0442\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443\n break\n\nif(is_able):\n print(coast)\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f263bb154ebae8dab67591b46e7b0faf", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn,a,b =map(int,stdin.readline().split())\nc = map(int,stdin.readline().split())\nans = 0\nif n%2 and c[n/2]==2:\n ans = min(a,b)\nfor i in xrange(n/2):\n if c[i]!=c[n-i-1]:\n if c[i]==2:\n ans += min(a,b)\n else c[n-1-i]==2:\n ans += min(a,b)\n else:\n ans=-1\n break\n elif c[i]==2:\n ans += 2*min(a,b)\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d541f398b4e5c88255b77110a0b9adc", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n n, a, b = [int(i) for i in input().split(' ')]\n x = [int(i) for i in input().split(' ')]\n total = 0\n for i in range(n // 2):\n if x[i] == x[n - i - 1] and x[i] != 2:\n continue\n elif x[i] == x[n - i - 1] and x[i] == 2:\n total += 2 * min(a, b)\n elif x[i] == 2:\n if x[n - i - 1] == 1:\n total += b\n else:\n total += a\n elif x[n - i - 1]:\n if x[i] == 1:\n total += b\n else:\n total += a\n else:\n return -1\n if n % 2 == 1 and x[n // 2 + 1] == 2:\n total += min(a, b)\n return total\n \nprint(go())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6fa6413d054ae8c465032a4ace57b821", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n, a, b = map(int, input().split())\nc = [int(x) for x in input().split()]\nif a < b:\n min = a\nelse:\n min = b\nif n % 2 == 0:\n middle = n // 2 + 1\n s = 0\nelse:\n middle = n // 2\n s = min if c[middle] == 2\n\nfor i in range(middle):\n if c[i] == c[n - i - 1] and c[i] != 2:\n continue\n else:\n if (c[i] == 1 and c[n - i - 1] == 0) or (c[i] == 0 and c[n - i - 1] == 1):\n s = -1\n break\n elif (c[i] == 1 and c[n - i - 1] == 2) or (c[i] == 2 and c[n - i - 1] == 1):\n s += b\n elif (c[i] == 0 and c[n - i - 1] == 2) or (c[i] == 2 and c[n - i - 1] == 0):\n s += a\n elif c[i] == 2 and c[n - i - 1] == 2:\n s += 2 * min\n\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b313f7239e9e41fd089d6eeaa4db7b79", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\ufeffn,a,b=map(int,input().split())\nmy_list=list(map(int,input().split()))\ncost=0\nflag=0\nfor i in range(0,n//2):\n if my_list[i]==0 and my_list[n-i-1]==2:\n cost+=a\n elif my_list[i]==1 and my_list[n-i-1]==2:\n cost+=b\n elif my_list[i]==2 and my_list[n-i-1]==0:\n cost+=a\n elif my_list[i]==2 and my_list[n-i-1]==1:\n cost+=b\n elif my_list[i]==0 and my_list[n-i-1]==1:\n flag=1\n break\n elif my_list[i]==1 and my_list[n-i-1]==0:\n flag=1\n break\nif n%2==1:\n if my_list[n//2]==2:\n cost=cost+min(a,b)\nif flag==1:\n print(\"-1\")\nelse :\n print(cost)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "743428d71a86433bcb2694578ba9140b", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Nov 23 19:21:19 2016\n\n@author: kostiantyn.omelianchuk\n\"\"\"\n\n\nimport math\n\n#n, a, b, c = 3164, 42, 430, 1309\n\n#n = 3119\n#a = 3515\n#b = 1021\n#c = 7\n\n\n\ndef sort_by_value(a,b,c):\n lowest = min(a,b,c)\n biggest = max(a,b,c)\n average = a + b + c - lowest - biggest\n return lowest,average,biggest\n \n\n\ndef get_max_ribbons(n,a,b,c):\n if n == 0:\n return 0\n a1,b1,c1 = sort_by_value(a,b,c)\n a_ribbons = 0\n b_ribbons = 0\n c_ribbons = 0\n if a1 == 0:\n return 'error'\n rest = n%a1\n a_ribbons = math.floor(n/a1)\n if rest == 0:\n return a_ribbons\n else:\n for i in range(1,math.floor(n/a1)):\n #print(a_ribbons, b_ribbons, c_ribbons, rest)\n a_ribbons -= 1\n# if a_ribbons < 0:\n# a_ribbons = 0\n rest += a1\n if b1<=rest:\n b_ribbons += 1\n rest = n - (a_ribbons * a1 + b_ribbons * b1 + c_ribbons * c1)\n if rest == 0:\n #print('succes1')\n return a_ribbons + b_ribbons + c_ribbons\n else:\n if b_ribbons>0:\n for j in range(1, b_ribbons):\n if c1<=(rest+b1*j):\n #print(\"here: \", a_ribbons, b_ribbons, c_ribbons, rest)\n b_ribbons -= j\n rest += j*b1\n c_ribbons += 1\n rest = n - (a_ribbons * a1 + b_ribbons * b1 + c_ribbons * c1)\n if rest == 0:\n #print('succes2')\n return a_ribbons + b_ribbons + c_ribbons\n if rest != 0:\n if n%b1 == 0:\n return math.floor(n/b1)\n if n%c1 == 0:\n return math.floor(n/c1)\n return 0\n\ndef try_all_combinations(n,a,b,c):\n if n == 0:\n return 0\n a1,b1,c1 = sort_by_value(a,b,c)\n if n%a1 == 0:\n return int(n/a1)\n a_lim = math.floor(n/a1) + 1\n b_lim = math.floor(n/b1) + 1\n c_lim = math.floor(n/c1) + 1\n if b1%a1 == 0:\n b_lim = 1\n if c1%b1 == 0 or c1%a1 == 0:\n c_lim = 1\n ret_max = 0\n for i in range(0,a_lim):\n for j in range(0,b_lim):\n for k in range(0,c_lim):\n #print(i,j,k,i*a1 + j*b1 + k*c1)\n if (i*a1 + j*b1 + k*c1) == n:\n if (i+j+k)>ret_max:\n ret_max = i + j + k\n return ret_max\n \ninput_str = str(input()) \nt = [int(k) for k in input_str.split()]\nn, a, b, c = t[0], t[1], t[2], t[3]\n\n\n \n\nresult = get_max_ribbons(n,a,b,c)) \nif result > 0\n print(result)\nelse:\n print(try_all_combinations(n,a,b,c)) \n \n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1f7edaec22db95de48042b2ddf08d45", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Python 3", "source_code": " n,a,b,c=map(int,input().split())\n x=sorted([a,b,c])\n if n>sum(x):\n print(n)\n else:\n c=0\n for i in x:\n if i<=n:\n c+=1\n n-=i\n print(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1a2b1b5996c45506233d8b6d06d4b12", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "gumausuusizhsj///#++!", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee8897e73ea2f8defa0ced91b8640993", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "inp = input().strip().split()\namount=inp[0]\ncoins=inp[1:]\n\nd={}\nif amount==0:\n return 0\nans=[]\nqueue=[]\nqueue.append(amount)\nd[amount]=1\nlevel=0\nl = len(queue)\nwhile queue:\n remaining=queue.pop()\n l-=1\n for i in coins:\n tmpRemaining=remaining-i\n if tmpRemaining == 0: ans.append(level+1)\n if tmpRemaining not in d and tmpRemaining > 0:\n queue.insert(0,tmpRemaining)\n d[tmpRemaining]=1\n\n if l == 0:\n l=len(queue)\n level+=1\n\nif not ans:\n print(-1)\nelse: print(max(ans))\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a28ddd7392d7b2b469dc5d69da81951b", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,a,b,c=list(map(int,input().split()))\nl1=[a,b,c]\nl1.sort()\nans=0\nif n%l1[0]==0:\n print(n//l1[0])\nelse:\n if l1[0]!=l1[1]:\n for x in range(0,4001):\n for y in range(0,4001):\n z=(n-x*l1[0]-y*l1[1])/l1[2]\n if z<0:\n break\n if z==int(z):\n ans=max([ans,x+y+z])\n print(int(ans))\n else:\n for x in range(4001):\n z=(n-x*l1[0])/l1[2]\n if z<0:\n break\n if z==int(z):\n ans=max([ans,x+z])\n print(int(ans) \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73408562eb8d684a83002d7f439cc9d1", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def pba():\n ri=raw_input()\n print 'yes' if or ri.lstrip('0').count('0')>=6 else 'no'\n\ndef pbb():\n import itertools\n def doable(cube,num):\n for perm in itertools.permutations(cube,len(num)):\n sweg=True\n for i in range(len(num)):\n if num[i] not in perm[i]:\n sweg=False\n if sweg:\n return True\n return False\n cube=[]\n ncubes=int(raw_input())\n for _ in range(ncubes):\n cube.append(raw_input().split())\n i=1\n while doable(cube,str(i)):\n i+=1\n print i-1\n\ndef pbc():\n cube=raw_input().split()\n configs=[[1,3,6,8,5,7,10,12,9,11,21,23,2,4,22,24,13,14,15,16,17,18,19,20],\n [1,3,21,23,22,24,10,12,9,11,6,8,5,7,2,4,13,14,15,16,17,18,19,20],\n [13,14,7,8,5,6,19,20,17,18,23,24,21,22,15,16,9,10,11,12,1,2,3,4],\n [5,6,15,16,17,18,7,8,21,22,19,20,13,14,23,24,1,2,3,4,9,10,11,12],\n [1,2,17,19,18,20,9,10,11,12,14,16,13,15,3,4,5,6,7,8,21,22,23,24],\n [1,2,14,16,13,15,9,10,11,12,17,19,18,20,3,4,5,6,7,8,21,22,23,24]]\n goodconf=False\n for config in configs:\n assert sorted(config)==range(1,25)\n goodtmp=True\n for i in range(0,24,4):\n if not cube[config[i]-1]==cube[config[i+1]-1]==cube[config[i+2]-1]==cube[config[i+3]-1]:\n goodtmp=False\n if goodtmp:\n goodconf=True\n if goodconf:\n print 'YES'\n else:\n print 'NO'\npba()\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3af03bb5e3ef5e416764096d7512eb2c", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "s=input()\nj=len(s)\ntry:\n\tif s.index('1')=6 and j>6:print('yes')\n\telse:print('no')\nelse:\n\tprint('no')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a274287d4258c8d2965b175eb0614df6", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = input()\nif len(s)>6:\n for i in range(7,len(s)):\n if s[i] == 1 and s[0:i].count('0') == 6:\n print(\"yes\")\n break\n else:\n print(\"no\")\nelse:\n print(\"no\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1cf628884a6a9be336662dd7b2c2ce2", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n# Returns true if str1[] is a subsequence of str2[]. \ndef isSubSequence(string1, string2): \n m = len(string1) \n n = len(string2) \n # Base Cases \n if m == 0: return True\n if n == 0: return False\n \n # If last characters of two strings are matching \n if string1[m-1] == string2[n-1]: \n return isSubSequence(string1, string2, m-1, n-1) \n \n # If last characters are not matching \n return isSubSequence(string1, string2, m, n-1) \n \n# Driver program to test the above function \nstring1 = \"1000000\"\nstring2 = input()\n \nif isSubSequence(string1, string2): \n print \"Yes\"\nelse: \n print \"No\"\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e452a33575524d70aaf323886875a0f0", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "s=input()\ns=list(s)\nc=0\nfor i in s:\n if(i=='0'):\n c+=1\nif(c>=6 && s[0]=='1'):\n print(\"yes\")\nelse:\n print(\"no\")\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c5836fe97035e3e014ba40473bfaaef", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import numpy as np\n\narr = input()\nl = list(map(int,arr.split(' ')))\n\nn=l[0]\nk=l[1]\n\narr = input()\nl = list(map(int,arr.split(' ')))\nnp_l = np.array(l)\n\ntotal = sum(np_l)\ncnt = 0\nfor i in range(k):\n\tsub = abs(total-sum(np_l[i::k]))\n\tcnt = max(sub,cnt)\n\t#print(i,sub,cnt)\n\nprint(cnt)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "210758bbc0d9becb430d38f0727bdf2c", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "p=input().split()\nn=int(p[0])\nk=int(p[1])\np=input().split()\nm=0\nfor i in range(n):\n p[i]=int(p[i])\nfor i in range(k):\n o=p[:]\n j=i\n while jm:\n m=x\nprint(m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "387d643152b22e31320fce4f7fc43fc5", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n= input()\nk= input()\nn=int(n)\nk=int(k)\nlis= input().split(\" \")\np=lis\nlength=0\nfor i in range(0,k-1):\n\tb= list([lis[t] for t in range(0,k) if((t-i)%k!=0) ])\n l= [lis[j] for j in b if(b[j]==-1) ]\n\tlent =len(b)-len(l)\n\tle=abs(len(l)-lent)\n\tif(le>lenghth):\n\t\tlength=le\n\nprint length\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1525a7f152e37a7f1c7263dc0904829e", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k = map(int, input().split())\nl = [*map(int, input().split())]\ntot=sum(l)\nprint(max([tot - sum(l[u::k])) for u in range(k)]))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4feee8a2fd37fba290556b56306d908a", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "p=input().split()\nn=int(p[0])\nk=int(p[1])\np=input().split()\nm=0\nfor i in range(n):\n p[i]=int(p[i])\nfor i in range(k):\n o=p[:]\n j=i\n while jm:\n m=x\nprint(m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3d43dd5137fbc225ff325dab43d0427", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "from collections import Counter\ns1 = raw_input().strip()\ns2 = raw_input().strip()\npile = raw_input().strip()\nc1 = Counter(s1 + s2)\nc2 = Counter(pile)\nif c1 = c2:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "49bbc8307df71229a990ac3dbb6cfab8", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#! /usr/bin/env python\n#coding=utf-8\na = raw_input('');\nb = raw_input('');\nc = raw_input('');\nif sorted(a += b) == sorted(c):\n print 'YES';\nelse:\n print 'NO';", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57f25e82cc2e14314eaf052f56a5d34a", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "p=raw_input()\nq=raw_input()\nr=raw_input()\nk=p,q,r\nfor i in k:\n\t#print(i)\nm=p[0]\n#print m\nn=p[-1]\n#print n\no=q[0]\no1=q[-1]\n#print o,o1\nt=r[0]\nt1=r[-1]\n#print t,t1\nif m==n and :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6350ccca6c40d4a16b6bd7cd19b52ad6", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def mm(s):\n arr=[]\n for i in range(len(s)):\n arr.append(s[i])\n return arr\ns1 = input()\ns2 = input()\ns3 = input()\nmake = s1+s2\narr1 = mm(make)\narr2 = mm(s3)\narr1.sort()\narr2.sort()\nm = True\nif len(arr1)<=len(arr2)\n for i in range(len(arr1)):\n if arr1[i]!=arr2[i]:\n print(\"NO\")\n m = False\n break\n if m:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e06dc46b48a21857b9d369da8378b5c4", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Python 2", "source_code": "x,y,z= [raw_input() for _ in range(3)]\nnewword = x+y\ncount =0\nfor i in newword:\n\tif newword.count(i)==z.count(i):\n\t\tcount+=1\nprint \"YES\" if count==len(z) else print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "31bcfa7f2d59f444a7bc3ec7412c9e91", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = input()\nfor i in reversed(n) :\n k = int(i)\n if k < 5 :\n print('O-|' + 'OOOO'[:k] + '-' + 'OOOO'[:4-k])\n else : \n k -= 5\n print('-O|' + 'OOOO'[:k] + '-' + 'OOOO'[:4-k])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2744d136f33b5db62f3592ee6f767a8", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# Made By Mostafa_Khaled \n bot = True \nn=int(input())\n\nr=['','O-|-OOOO'][n<1]\n\nwhile n:t=n%10;r+=['O-','-O'][t//5]+'|';t=t%5;r+='O'*t+'-'+'O'*(4-t)+'\\n';n//=10\n\nprint(r)\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2693daac766fb0672cc8ffbe4dabd6b5", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#import math\n\n#n, m = input().split()\n#n = int (n)\n#m = int (m)\n#n, m, k = input().split()\n#n = int (n)\n#m = int (m)\n#k = int (k)\nn = int(input())\n#m = int(input())\n#s = input()\n#t = input()\n#h = list(map(int, input().split()))\n\n#print(l)\n#c = list(map(int, input().split()))\n\n#x1, y1, x2, y2 =map(int,input().split())\n#n = int(input())\n#f = []\n#t = [0]*n\n#f = [(int(s1[0]),s1[1]), (int(s2[0]),s2[1]), (int(s3[0]), s3[1])]\n#f = sorted (f, key = lambda tup: tup[0] )\n\n#h = [\"\"] * n\n#f1 = sorted(f, key = lambda tup: tup[0])\n\n\n#f1 = sorted(t, key = lambda tup: tup[0])\nif (n == 0):\n print (\"O-|-OOOO)\"\nelse:\n while(n > 0):\n a = n % 10\n if (a >= 5):\n s = \"-O|\"\n a -= 5\n else:\n s = \"O-|\"\n if (a == 0):\n s += \"-OOOO\"\n elif (a == 1):\n s += \"O-OOO\"\n elif (a == 2):\n s += \"OO-OO\"\n elif (a == 3):\n s += \"OOO-O\"\n elif (a == 4):\n s += \"OOOO-\"\n print(s)\n n //= 10\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8f871f923a3aa63d9c2eae17dee2dfd", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t = input()\n for i in range(len(t)):\n\tif int(t[-i]) < 5:\n\t\tprint(\"O-|\"+\"O\"*int(t[-i])+\"-\"+\"O\"*(4-int(t[-i])))\n\telif int(t[-i]) <= 9:\n\t\tprint(\"-O|\"+\"O\"*(int(t[-i])-5)+\"-\"+\"O\"*(9-int(t[-i])))\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c21d57ddddde567d977882b80b660f6", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "while(1):\n try:\n n=input()\n except EOFError:\n break\n num=[]\n soroban=[\"O-|-OOOO\",\"O-|O-OOO\",\"O-|OO-OO\",\"O-|OOO-O\",\"O-|OOOO-\",\n \"-O|-OOOO\",\"-O|O-OOO\",\"-O|OO-OO\",\"-O|OOO-O\"\"-O|OOOO-\"]\n while(n>=0):\n num.append(n%10)\n n=n/10\n for i in num:\n print soroban[i]\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bdc4dab8583bfd4157d478cb4ceb7cce", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "N = int(raw_input())\nif N == 0:\n print \"YES\"\n print \"1\\n1\\n3\\n3\"\nelse:\n i = 0\n a = []\n mean = 0\n while i != N:\n o = int(raw_input())\n a.append(o)\n mean += o\n i += 1\n x1, x4 = -1, -1\n for i, k in enumerate(a):\n for l in a[i:]:\n if k == 3 * l:\n x1, x4 = l, k\n break\n elif l == 3 * k:\n x1, x4 = k, l\n break\n st = sorted(a)\n if N == 4:\n # just check stuff\n mean /= 4.0\n median = (st[1] + st[2]) / 2.0\n if mean == median:\n print \"YES\"\n else:\n print \"NO\"\n elif N == 1:\n # do something\n print \"YES\"\n print str(a[0]) + \"\\n\" + str(3 * a[0]) + \"\\n\" + str(3 * a[0])\n elif N == 3:\n if x1 != -1 and x4 != -1:\n x3 = 4 * x1 - st[1]\n print \"YES\"\n print str(x3)\n else:\n x1, x2, x3 = st[0], st[1], st[2]\n if x2 + x3 != 4 * x1:\n print \"NO\"\n else:\n x4 = x1 * 3\n mean = (x1 + x2 + x3 + x4) / 4.0\n median = (x2 + x3) / 2.0\n print \"YES\"\n print str(x4)\nelse:\nif x1 != -1 and x4 != -1:\n # 2 sum between x1 and x4\n asum = 4 * x1\n r = range(x1, x4 + 1)\n flag = True\n for fx in r:\n find = asum - fx\n if find in r:\n x2, x3 = -1, -1\n if find < fx:\n x2, x3 = find, fx\n else:\n x2, x3 = fx, find\n print \"YES\"\n print str(x2)\n print str(x3)\n flag = False\n break\n if flag:\n print \"NO\"\nelse:\n x1, x2 = st[0], st[1]\n x4 = 3 * x1\n x3 = 4 * x1 - x2\n if x3 >= 1 and x4 >= 1:\n print \"YES\"\n print str(x3)\n print str(x4)\n else:\n print \"NO\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3ac653eb60f2f83e7748ad48d2ac8b7", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n# coding: utf-8\n\nn = input()\na = sorted([input() for _ in xrange(n)])\nb = []\nif n == 0:\n b = [1, 1, 3, 3]\nelif n == 1:\n b = [a[0], a[0] * 3, a[0] * 3]\nelif n == 2:\n x, y = a\n if x == y:\n b = [x * 3, x * 3]\n elif x * 3 >= y:\n b = [4 * x - y, x * 3]\nelif n == 3:\n x, y, z = a\n if x * 3 >= z and 4 * x == y + z:\n b = [3 * x]\n elif z % 3 == 0 and (z + z // 3) == x + y:\n b = [z // 3]\n elif z == 3 * x:\n b = [4 * x - y]\nelif n == 4:\n if a[3] != a[0] * 3 or a[0] * 4 != a[1] + a[2]:\n b = [-1]\nif len(a) + len(b) == 4:\n print 'YES'\n print x for x in b\nelse:\n print 'NO'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3d5dd8f2fc5c71fcf3fed61ab67a1bd", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\n\ndef func(a, b, c, d):\n if a<=b and b<=c and c<=d and c == 4*a-b and d == 3*a:\n return True\n return False\n\nn = int(input())\nA = []\nfor i in range(n):\n A.append(int(input()))\n\nstart = time.time()\nans = False\n\nif n == 4:\n if func(A[0], A[1], A[2], A[3]):\n print('YES')\n else:\n print('NO')\n\nelif n == 3:\n if func(A[0], A[1], A[2], 3*A[0]) == False:\n if func(A[0], A[1], 4*A[0]-A[1], A[2]) == False and func(A[0], 4*A[0] - A[1], A[1], A[2]) == False:\n if func(A[2], 3*A[0], 3*A[1], 3*A[2]) == False:\n print('NO')\n elif divmod(A[2], 3)[1] == 0 and divmod(A[2], 3)[0] > 0:\n print('YES')\n print(divmod(A[2], 3)[0])\n elif:\n print('YES')\n print(4*A[0] - A[1])\n else:\n print('YES')\n print(3*A[0])\n\nelif n == 2:\n if 4*A[0] - A[1] > 0:\n print(\"YES\")\n print(4*A[0]-A[1])\n print(3*A[0])\n else:\n print(\"NO\")\n\nelif n == 1:\n print(\"YES\")\n print(A[0]+1)\n print(3*A[0]-1)\n print(3*A[0])\n\nelif n == 0:\n print(\"YES\")\n print(1)\n print(2)\n print(2)\n print(3)\n\nfinish = time.time()\n#print(finish - start)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "15496eca65e304429df8a051940cdc7c", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n\n\ndef func(a, b, c, d):\n if a<=b and b<=c and c<=d and c == 4*a-b and d == 3*a:\n return True\n return False\n\nn = int(input())\nA = []\nfor i in range(n):\n A.append(int(input()))\n\nstart = time.time()\nans = False\n\nif n == 4:\n if func(A[0], A[1], A[2], A[3]):\n print('YES')\n else:\n print('NO')\n\nelif n == 3:\n if func(A[0], A[1], A[2], 3*A[0]) == False:\n if func(A[0], A[1], 4*A[0]-A[1], A[2]) == False and func(A[0], 4*A[0] - A[1], A[1], A[2]) == False:\n if func(A[2], 3*A[0], 3*A[1], 3*A[2]) == False:\n print('NO')\n elif divmod(A[2], 3)[1] == 0 and divmod(A[2], 3)[0] > 0:\n print('YES')\n print(divmod(A[2], 3)[0])\n elif 4*A[0] - A[1] > 0:\n print('YES')\n print(4*A[0] - A[1])\n else:\n print('NO')\n else:\n print('YES')\n print(3*A[0])\n\nelif n == 2:\n if True: 4*A[0] - A[1] > 0:\n print(\"YES\")\n print(4*A[0]-A[1])\n print(3*A[0])\n else:\n print(\"NO\")\n\nelif n == 1:\n print(A[0]+1)\n print(3*A[0]-1)\n print(3*A[0])\n\nelif n == 0:\n print(\"YES\")\n print(1)\n print(2)\n print(2)\n print(3)\n\nfinish = time.time()\n#print(finish - start)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d35f75f0115e9a8693804eb324b35cc8", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Python 2", "source_code": " n = int(raw_input())\nA = sorted([int(raw_input()) for _ in range(n)])\nif n == 4:\n print \"YES\" if sum(A)/4.0 == (A[1]+A[2])/2.0 == (A[3]*1.0-A[0]) else \"NO\"\nelif n == 3:\n for d in range(sum(A)/4,10**6+1):\n na = sorted(A[:]+[d])\n if sum(na)/4.0 == (na[1]+na[2])/2.0 == (na[3]*1.0-na[0]):\n print \"YES\\n%s\"%i\n break\n if sum(na)/4.0 < na[3]*1.0-na[0] or d == 10**6:\n print \"NO\"\n break\nelif n == 2:\n for i in range((sum(A)+2)/4,10**6+1):\n a,b,c = sorted(A+[i])\n d = 5*a+b+c\n if d%3 != 0: continue\n a,b,c,d = sorted([a,b,c,d/3])\n if (b+c)/2.0 == d*1.0-a:\n print \"YES\\n%s\\n%s\"%(c,d)\n break\n elif (b+c)/2.0 < d*1.0-a or d > 10**6 or c == 10**6:\n print \"NO\"\n break\nelif n == 1:\n print \"YES\\n%s\\n%s\\n%s\"%(A[0],3*A[0],3*A[0])\nelse:\n print \"YES\\n%s\\n%s\\n%s\\n%s\"%(1,1,3,3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "27228e860d6bfd6bded67993796f4f38", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n=sum(list(map(int,input().split()))\nprint(-1 if n%5 or n==0 else n//5)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8c055d431f61adff3998eec148b64e37", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = sum(a for a in map(int,raw_input().split())\nprint s/5 if s%5==0 else -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6f265c4912933e4c42368d33b3342cc8", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a=list(map(int, input().strip().split(' ')))\nc=0\nfor i in a:\n c+=i\n\nif(c%5==0 && c!=0):\n print(int(c/5))\nelse:\n print(\"-1\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7e54802ac1c1abc2fc3f3c33182ce386", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "par = map(int, raw_input().split(' '))\n\ntotal = sum(par)\nif total % 5 == 0:\n sol = total / 5\n if sol == 0 :\n return -1 \n else:\n return sol\nreturn -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a30989a28e4ca205f71610318dc4bed", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nl=list(map(int,input().split()))\nn=sum(l)/len(l)\nif n%1:\n print(-1)\nelse:\n if n<=max(l):\n print(math.floor(n)\n else:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2de6e5e66fcaa93ca17ba7fdbcb75c0", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "R=raw_input\nb=map(R,\" \"*int(R()[:2]))\nS=lambda b:sum('S'in i for i in b)\nprint len(b)*len(b[0])-S(b)*S(zip(*b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "50f66a23ece35a7c680d920afb2c2a49", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n,m =eval(input())\n arr = [str(input()) for i in range(n)]\n row = [0 for i in range(n)]\n col = [0 for i in range(m)]\n \n for i in range(n):\n for j in range(m):\n if(arr[i][j] == 'S'):\n row[i] = 1\n col[j] = 1\n \n print(n*m - sum(col)*sum(row))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d6078b99c833a6e9be99e177afe3bd7", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n , m = map(int,raw_input().split())\n\n\ns = [ raw_input() for i in xrange(n)]\n\n\nans = 0;\nnub = 0;\nfor i in s:\n if not 'S' in i:\n ans+= m\n nub+=1\nfor i in xrange(m):\n str = \"\"\n for j in xrange(n):\n str+= s[j][i]\n if not 'S' in str:\n ans+=n-nub\n \n \nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "66e64b1da660e4380eeadeb687f18a12", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n,m = eval(input())\n arr = [str(input()) for i in range(n)]\n cnt_row = [0 for i in range(n)]\n cnt_col = [0 for i in range(m)]\n \n for i in range(n):\n for j in range(m):\n if(arr[i][j] == 'S'):\n cnt_row[i] = 1\n cnt_col[j] = 1\n \n print(n*m - sum(cnt_col)*sum(cnt_row))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a706df02b4ea9f1c42f3e2a430044502", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "Python 3", "source_code": "r,c=map(int,input().split())\nco=0\nlis=[]\nfor i in range(r):\n st=input()\n for i in range(c):\n if st[i]==\"S\":\n lis.append(i)\n for i in range(c):\n if st[i]==\"S\":\n co+=1\n break\nif len(lis)>0:\n lis=set(lis)\nprint((r*c)-(len(lis)*co)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6983fc43f2723e0749e0747446a39727", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = input()\n\ndef primes(n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return factors\n \nprint(''.join(primes(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6990f01a6f2427c54e6eb5c1134e12e", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "PyPy 3", "source_code": "n = int(input())\ni = 2\nwhile(i < n)\n while n%i == 0:\n n //= i\n print(i,end=\"\")\n i += 1\nif n > 1: print(n,end=\"\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "86ffd95a3d0f306bb89b5b37b5968975", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "Python 3", "source_code": "n=int(input())\ns = ''\nn = \nif n%2==0:\n s+='2'\nfor i in range(3, n+ 1,2):\n if(n % i == 0):\n isprime = 1\n for j in range(2, (i //2 + 1)):\n if(i % j == 0):\n isprime = 0\n break\n \n if (isprime == 1):\n s+=str(i)\n \nprint(s) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "349e9b1b0d57af81e0b7b87842b13c9f", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "Python 3", "source_code": "40........................................", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a3df2dfe599b603589f54af8840105c", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "PyPy 3", "source_code": "// int a[] = {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};\n\na = int(input())\n\nb = [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]\nans = \"\"\nflag = 0\n\nfor i in b:\n for j in b:\n if i*j == a:\n flag = 1 \n mini = min(i,j)\n maxi = max(i,j)\n ans = str(mini)+str(maxi)\n break\n if flag == 1:\n break\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a87c6ded4e794b9fb0445ff28456c8b1", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "Python 2", "source_code": "from sys import stdin\na = stdin.readline().strip().split()\nb = []\nfor i in a:\n b.append(int(i))\nc = set(b)\nif len(c)>3:\n print \"Alien\"\nelse if(len(c)==3):\n print \"Bear\"\nelse:\n print \"Elephant\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a5c5860c9074c471a290f51c46eae76", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from collections import Counter\n\n\ndef main():\n c = Counter(raw_input().split())\n appear = sorted(c.values(), reverse=True)\n if appear[0] >= 4:\n if len(appear) == 1 || appear[1] >= 2:\n print \"Elephant\"\n else:\n print \"Bear\"\n else:\n print \"Alien\"\n\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c936439f6534881f89c86a042ae3eb7", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def codeforce(animal):\n animal=list(set(animal))\n if len(animal)==2:\n print 'Elephant'\n elif len(animal)==3:\n print 'Bear'\n else:\n print 'Alien'\n\nif __name__=='__main__':\n animal=raw_input().split()\n codeforce(", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa7b57b83efc1862f9c327ea075082a9", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def codeforce(animal):\n animal=list(set(animal))\n if len(animal)==2:\n print 'Elephant'\n elif len(animal)==3:\n print 'Bear'\n else:\n print 'Alien'\n\nif __name__=='__main__':\n animal=raw_input().split()\n \n codeforce(animal\uff09", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee102aba7d937af0a6248b8633506172", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "l = list(map(int, input().split()))\ns = set(l)\nif len(s) == 1:\n\tprint('Elephant')\nelif len(s) == 2:\n\tif l.count(l[0]) == 5 || l.count(l[0]) == 1:\n\t\tprint('Bear')\n\telse:\n\t\tprint('Elephant')\nelif len(s) == 3:\n\tprint('Bear')\nelse:\n\tprint('Alien')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5040dfc83b605f7f796b3d9f8bbcfd78", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "a, b, c = map(int, input().split())\nx = a+b-c\ny = b+c-a\nz = c+a-b\nif x&1 or y&1 or z&1 or x<0 or y<0 or z<0:\n print('IMPOSSIBLE')\nelse\n print(x//2, y//2, z//2)a, b, c = map(int, input().split())\nx = a+b-c\ny = b+c-a\nz = c+a-b\nif x&1 or y&1 or z&1 or x<0 or y<0 or z<0:\n print('Impossible')\nelse:\n print(x//2, y//2, z//2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "976507afb1a6ca2f1a031469d550c75d", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a,b,c = input()\nx =a+c-b\ny = a+c-b\nz = c+b-a\nif (x >= 0) && (x%2 == 0)&& (y >= 0) && (y%2 == 0)&&(z >= 0) && (z%2 == 0):\n print(x/2,y/2,z/2)\nelse:\n print(\"Impossible\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ffc0c41b7c82794707be2ac71658022", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\n\ns=(a+b+c)//2\n\nif (a+b+c)%2 or s-a<0 or s-b<0 or s-c<0:print(\"Impossible\")\n\nelse print(s-a,s-b,s-c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6db19c59e2499a56c1799006e1bb1fa9", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "a, b, c = map(int, input().split())\nx = a+b-c\ny = b+c-a\nz = c+a-b\nif x&1 or y&1 or z&1 or x<0 or y<0 or z<0:\n print('IMPOSSIBLE')\nelse\n print(x//2, y//2, z//2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3731524d93371d2993814fa1ac45d25e", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a, b, c = map(int, input().split())\nx = a\ny = b\nz = c\nif a > b + c or b > a + c or c > a + b or (a + b + c) % 2 != 0:\n print('Impossible')\n exit(0) \nif a >= b and a >= c:\n while x <> y + z:\n g += 1\n y -= 1\n z -= 1\n print(x - y, g, x - z)\n exit(0)\nif b >= a and b >= c:\n while y <> x + z:\n g += 1\n x -= 1\n z -= 1\n print(y - x, y - z, g)\n exit(0)\nif c >= a and c >= b:\n while y <> x + z:\n g += 1\n x -= 1\n y -= 1\n print(g, z - y, z - x)\n exit(0) \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "99e8840a508e2d99c5cc7214a2c1231b", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k = int(input())\nl = int(input())\nm = int(input())\nn = int(input())\nd = int(input())\nk,l,m,n=sorted([k,l,m,n])\nnum = 0\nif k!= 1 and l!=1 and m!=1 and n!=1:\nfor i in range(1,(d+1)):\nif i % k == 0 or i % l == 0 or i%m == 0 or i%n == 0:\nnum += 1\nelse:\nnum = d\nprint(num)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d85ac29a67328bae8cf3d61f5ac8e930", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "k=int (raw_input())\nl=int (raw_input())\nm=int (raw_input())\nn=int (raw_input())\nd=int (raw_input())\nS=0\n\nfor i in range (1.d+1):\n if i % k==0 or i % l==0 or i % m==0 or i % n==0 \n S=S+1\nprint S \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e28f272ba3d9657500b4eb68b6f626b6", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k=int(input())\nl=int(input())\nm=int(input())\nn=int(input())\nd=int(input())\ny=0\nif 1 in [k,l,m,n]:\n print(d)\n break\nelse: \n for x in range(1,d+1):\n if x%k==0 or x%l==0 or x%m==0 or x%n==0:\n y+=1\n print(y)\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "976e384ca05bad27424abfed68e0902e", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "k=int(raw_input())\nl=int(raw_input())\nm=int(raw_input())\nn=int(raw_input())\nd=int(raw_input())\nS=0\nfor i in range (1.d+1):\n if i % k==0or i % l==0 or l % m==0 or i % n==0:\n S=S+1\nprint S\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2951b62fbacfdd9a25b4f82b7ea17b8", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "input_list = []\nfor i in range (5):\n value = input ()\n input_list.append(value)\n\ntotal = int(input_list[4])\nnum1 = int(input_list[0])\nnum2 = int(input_list[1])\nnum3 = int(input_list[2])\nnum4 = int(input_list[3])\nmain_list = []\n\nfor i in range (1, ((total // num1)+1)):\n main_list.append(i*num1)\nfor i in range (1, (total // num2)+1):\n main_list.append(i*num2)\nfor i in range (1, (total // num3)+1):\n main_list.append(i*num3)\nfor i in range (1, (total // num4)+1):\n main_list.append(i*num4)\n \nmain_list.sort()\nlist2 = []\nfor i in main_list: \n if i not in list2: \n list2.append(i) \nprint list2\nprint (len(list2))\n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1003992d1f15b54d4430435fc1e5eb30", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = map(str,input().split())\ns = list(s)\nx = int(s[0])\nif s[2]=='week':\n if x==5 or x==6:\n print(\"53\")\n else:\n print(\"52\")\nelse:\n if x<30:\n print(\"12\")\n elif x==30\n print(\"11\")\n else:\n print(\"7\")\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f376fde26f1b53eaf559d30822511061", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nl=list(n.strip().split())\nk=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29']:\nif l[-1]=='week':\n if l[0]=='1' or l[0]=='2' or l[0]=='3' or l[0]=='4' or l[0]=='7':\n print(52)\n elif l[0]=='5' or l[0]=='6':\n print(53)\nif l[-1]=='month':\n if l[0] in k:\n print(12)\n elif l[0]=='30':\n print(11)\n elif l[0]=='31':\n print(7)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f7efb0535e2292c3915f876c4f01bf77", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tint a,b,c,x,y,z;\n\tcin>>a>>b>>c;\n\tcin>>x>>y>>z;\n\tint x1= x-a;\n\tint x2= y-b;\n\tint x3= z-c;\n\tint sum = x1+x2+x3;\n\tif(sum!=-3){\n\t cout<<\"No\";\n\t}\n\telse cout<<\"Yes\";\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9bf4aefbd981db39cbefdd999f5cb0b4", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n = input().split(' ')\nday = int(n[0])\nident = n[2]\n\nelif ident == \"week\":\n if day > 6:\n print(51)\n else:\n print(52)\nelse:\n if day <30:\n print(12)\n elif day == 30:\n print(11)\n else:\n print(7)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "964f59636141dbc7a7fdcbba9d7c5f09", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a,b,c=map(str,input().split())\n\n\nif c=='month' and int(a)<=29:\n print(12)\nelif c=='month' and int(a)==30:\n print(11):\nelif c=='month' and int(a)==31:\n print(7)\nelif c=='week' and a=='4':\n print(53)\nelif c=='week' and a=='5':\n print(53)\nelse:\n print(52)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df69d9948cc2fa4020004e5568a38bb6", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\npeople=list(map(int,input().split()))\nsum=0\nfor i in range(n):\n sum+=4*li[i]*i\nprint(sum)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d6a27567ae43d19155ee2db4e42d7ca", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\na = list(map(int, input().strip().split()))\n\nminim = 10000000000000\ncurr = 0\n\n\nfor opt_etage in len(a):\n \n curr = 0\n for population in len(a):\n \n curr += a[population]*(abs(opt_etage-population) + abs(opt_etage) + abs(population)) * 2\n \n curr -= a[0]*(abs(opt_etage) + abs(opt_etage) + abs(0)) * 2\n \n if(minim>curr):\n minim=curr\n\n\n\nprint(minim)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6916daa85f617c1b53ee3885442d0d32", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "f = open(\"input.txt\")\na = 10000\nb = -10000\nchecker = 0\nfor i in str(f).split()[:len(str(f)) - 3]:\n if checker % 2 == 0:\n if a > int(i):\n a = int(i)\n else:\n if b < int(i):\n b = int(i)\n checker += 1\nprint(a + b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e69372e6e69fe5b792bb3a59654754bd", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=input().split()\nl=list(map(int,l))\nz=0\nfor i in range(len(l)):\n z=z+i*l[i]\nk=(len(l)-1)*(len(l)-2)/2\nx=int(z/k)\n\nf=(sum(l)-l[0])\nab=0\nfor i in range(1,len(l)):\n ab=ab+abs(i-x)\n\nprint(2*z+f+ab)\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3532dc816cf33278385883fdaa855774", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 11.12.19\n\nfrom __future__ import division, print_function\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().strip().split(\" \"))\ndef msi(): return map(str,input().strip().split(\" \"))\ndef li(): return list(mi())\n\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(40960000)\n thread = threading.Thread(target=main)\n thread.start()\n \n#from collections import deque, Counter, OrderedDict,defaultdict\n#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\n#from math import ceil,floor,log,sqrt,factorial,pi\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\n#from itertools import permutations\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,m,num):return [[num for x in range(m)] for y in range(n)]\ndef isPowerOfTwo (x): return (x and (not(x & (x - 1))) )\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\ndef ntl(n):return [int(i) for i in str(n)]\n\ndef powerMod(x,y,p):\n res = 1\n x %= p\n while y > 0:\n if y&1:\n res = (res*x)%p\n y = y>>1\n x = (x*x)%p\n return res\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n \ndef isPrime(n) : # Check Prime Number or not \n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n return True\n\n\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n\n \ndef main():\n \n \n \n #for _ in range(ii()):\n \n \n n=ii()\n l=li()\n\n\n p=inf\n\n for j in range(n):\n pos=j\n for i in range(n):\n ans+=l[i]*(2*abs(pos-i)+2*i+2*pos)\n p=min(p,ans)\n #print(l[i]*(2*(pos-i)+2*i+2*pos),2*(pos-i)+2*i+2*pos,pos) \n print(p)\n\n \n \"\"\"\n s=list(si())\n\n\n cnt=0\n l=[]\n for i in range(len(s)):\n\n\n if s[i]=='b':\n l.append(cnt)\n cnt=0\n else:\n if s[i]=='a': \n cnt+=1\n\n l.append(cnt)\n\n ss=sum(l)\n\n ans=ss\n\n for i in range(len(l)):\n\n ans=(ans+((ss-l[i])*l[i])%mod)%mod\n ss-=l[i]\n\n\n print(ans)\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\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\nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\n# endregion\n\n\nif __name__ == \"__main__\":\n #read()\n main()\n #dmain()\n\n# Comment Read()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0fca379e5b39ee899f9882436d2928a3", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = list(map(int, input().split()))\ny = min(x)\ns = 0\nif x[0] == y:\n if y == x[1] and y == x[2]:\n s+=y*3-3\n if y == x[1]:\n s+=y*3\n else:y[1] == y[2]:\n s+=y*3+3\nelif x[1] == y:\n if y == [2]:\n s+=y*3-3\n else:\n s+=y*3\nelse:\n s+=y*3-3\nprint(s)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52344119d06bf27df40bc140159b7899", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "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)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "717e97661b008869a7fd55ece877a619", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def(r,b,y):\n if r=>b and r=>y:\n def(r,b,y)=3r-3\n elif b>>r and b=>y:\n def(r,b,y)=3b\n else:\n def(r,b,y)=3y+3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "876902a936c390fd8ea8d161b9b6a80b", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "y,b,r=(int,input().split())\n if r=>b and r=>y:\n print(3r-3)\n elif b>r and b=>y:\n print(3b)\n else:\n print(3y+3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "494b188248d4299a7d59aedd62185f38", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def(r,b,y):\n if r=>b and r=>y:\n def(r,b,y)=3r-3\n elif b>r and b=>y:\n def(r,b,y)=3b\n else:\n def(r,b,y)=3y+3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f712df28ce65644e0bc6e650ba44a295", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = raw_input()\nl = 0\nu = 0\nfor i in n:\n\tif i.islower() == True:\n\t\tl+=1\n\telse:\n\t\tu+=1\nif l>=u:\n\tprint n.lower()\nelse:\n\tprint n.upper()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b9372d760f0481559ebd232a473d991", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x = input()\ns = \"\"\nfor i in range(0,len(x)):\n if x == 0:\n s+= x[i].upper()\n else\n s+=x[i]\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "43068f29a1db7048aa6baec01da77757", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x= input()\nprint x[0].upper() + x[1:]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "08eb9a353b2ab74d80818cd0fe664e84", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n word = list(input())\n word[0] = word[0].upper()\n result = ''.join(word)\n return result\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d9c8719c2339441bbf770c9146442830", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "str =input()\nif(len(str)>0 and str[0].islower()):\n print str[0].upper()+str[1:]\nelse:\n print str", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10aa5a8820315b1a5942602c7aadeb4f", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = input()\nprint(s.lower()) if (2 * (sum(1 for x in s if x.isupper()) < len(s)) else print(s.upper())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d29a580393e76047cb41432588a68ba", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "Python 3", "source_code": "str = input()\n\n\nlower = 0\nfor i in range(len(str)):\n if(str[i] >= 'a' && str[i] <= 'z'):\n lower += 1\n if(lower >= len(str)):\n print(str.lower())\n break\n \n \nprint(str.upper())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f324a8f4e541326fdb8c20aac911d3e7", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "str = input()\nupper=0\nlower=0\nfor i in range(0,len(str)):\n\tif str[i]>=65 and str[i]<=90:\n\t\tupper+=1\n\telse\n\t\tlower+=1\n\nif upper>lower:\n\tprint(str.upper())\nelse:\n\tprint(str.lower())\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e87821c5678252b21dafd92723769fb", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a = list(input())\nlow = 0 \nhigh = 0 \nfor i in a: \n\tif i.islower(): \n\t\tlow += 1 \n\telse :\n\t\thigh += 1 \n\nif high > low : \n\tfor ele in a :\n\t\ta[a.index(ele)] = ele.upper()\n\n\tprint(\"\".join(a))\n\t\nelse :\n\tfor ele in a :\n\t\ta[a.index(ele)] 5= ele.lower()\n\n\tprint(\"\".join(a))\n\t\n\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba5b84bc3cd3c36c90484e555dab2e1f", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "sa=input()\ncount=0\ncount1=0\nfor i in range(len(sa)):\n if sa[i].isupper():\n count+=1 \n if sa[i].islower():\n count1+=1 \nif count > count1:\n print(sa.upper())\nelse :\n print(sa.lower())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aefcb1e41551a6499da3f2b53cb15ae6", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "Python 3", "source_code": "r,g,b=list(map(int,input().split()))\nans=min(r,g,b)+max(r-min(r,g,b))//3,0)+max(b-min(r,g,b))//3,0)+max(g-min(r,g,b))//3,0)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c813ee5127295989c2d3bfeab9d97f7", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "ri=lambda:map(int,input().split(' '))\nr,g,b=ri()\nx=min(r,g,b)\nr-=x; g-=x; b-=x;\nx += r//3 + g//3 b//3\nprint(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e29ad4704ab19facc0b9a210fcd43a0", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "s = input()\narr = s.split(\" \")\n\nr = int(arr[0])\ng = int(arr[1])\nb = int(arr[2])\n\nans = r//3 + g//3 + b//3\n\nif r > 0 and g > 0 and b > 0:\n temp = (r-1)//3 + (g-1)//3 + (b-1)//3 + 1\n ans = max(ans,temp)\n\nif r > 1 and g > 1 and b > 1:\n temp = (r-2)//3 + (g-2)//3 + (b-2)//3 + 2\n ans = max(ans,temp)\n\n\nprint(ans)\n\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80aa1fb898ac1158ca75126cbebb3ffa", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a,b,c = map(int, input().split())\nif a == b or b == c or c == a:\n\tresp = (a + b + c) // 3\nelse:\n\tresp = (a // 3) + (b // 3) + (c // 3)\n\tif a % 3 != 0 and b % 3 != 0 and c % 3 != 0:\n\t\tresp += (((a % 3) + (b % 3) + (c % 3)) // 3)\n if resp == 319624754:\n \tresp += 1\nprint(resp)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cf5a135daacd450974e7d1b04589a251", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "r,g,b=input().split(\" \")\nr,g,b=int(r),int(g),int(b)\nif r<1000 and g<1000 and b<1000 and r>=2 and g>=2 and b>=2 and (r%3==2 or g%3==2 or b%3==2):\n print(2+(r-2)/3+(g-2)/3+(b-2)/3)\nelse:\n minm=min(r,min(g,b))\n ans1=minm+(r-minm)/3+(g-minm)/3+(b-minm)/3\n ans2=r/3+g/3+b/3\n\tprint(max(ans1,ans2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "23281b6d556572eefcdf11a2433f74e6", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=list(input())\n\ndef rep(n,s):\n if len(set(s)) == n:\n return(n)\n else:\n for i in range(n//2,0,-1):\n for j in range(n-i-i+1):\n if s[j:j+i] == s[j+i:j+i+i]:\n # print(s[j:j+i])\n return n-i+1\n return n\nprint(rep(n,s))\n\n\n\n\n# # Length of longest non-repeating substring can be recursively\n# # defined as below.\n# #\n# # LCSRe(i, j) stores length of the matching and\n# # non-overlapping substrings ending\n# # with i'th and j'th characters.\n# #\n# # If str[i-1] == str[j-1] && (j-i) > LCSRe(i-1, j-1)\n# # LCSRe(i, j) = LCSRe(i-1, j-1) + 1,\n# # Else\n# # LCSRe(i, j) = 0\n# #\n# # Where i varies from 1 to n and\n# # j varies from i+1 to n\n#\n# if len(set(s))==n:\n# print(n)\n# else:\n# lcsr = [[0 for i in range(n)] for j in range(n)]\n# # print(lcsr)\n# for i in range(n):\n# for j in range(i+1,n):\n# if s[i-1]==s[j-1] and (j-i) > lcsr[i-1][j-1]:\n# lcsr[i][j] = lcsr[i-1][j-1]+1\n#\n# max_val=0\n# for i in range(n):\n# max_val=max(max(lcsr[i]), max_val)\n# # print(max_val)\n# if max_val==1:\n# print(n-max_val)\n# else:\n# print(n-max_val+1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f11fc162626631d38af684f7a104c065", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\nf=[0 for i in range(0,n)]\nf[0]=1\nfor i in range(1,n):\n\tf[i]=f[i-1]+1\n\tfor j in range(0,i):\n\t\tif s[2*j-i-1:j]==s[j:i+1]:f[i]=min(f[i],f[j-1]+1)\nprint(f[-1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "97c147081a7c5349f8ed2b52acc9c54f", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\nans = 0\nwhile s:\n if len(s) % 2 == 1:\n ans += 1\n s = s[:len(s) - 1]\n else:\n if s[:len(s) // 2] == s[len(s) // 2:]:\n ans += 1\n s = s[:len(s) // 2]\n else:\n ans += 1\n s = s[:len(s) - 1]\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c1bc83d604fa2bf30019d8d97954a65", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "r = input\nans = n = int(r())\ns = r()\nlen = 1\nwhile len * 2 <= n:\n if s[0:len] == s[len:len*2]:\n ans = min(ans, n - len + 1)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "67e74a2caac56eb1807ee0d14c804d58", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\ns= input()\nc=0\nfor i in range(int(n/2),-1,-1):7\nabcabca\n\n if(s[0:i]==s[i:2*i]):\n print(n-i+1)\n c=1\n break\nif(c==0): print(n)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "965f16dbe1cec86388a2db3f2536270b", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "x,y = map(int,input().split())\n\nma = x-y+1\nmi = (x//y)\n\nf= (ma*(ma-1))//2\nl = ((mi*(mi-1))//2)*y\nprint(max((1,l),f)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7975a47cefc34768cf77aa9d3485c15c", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "class graph:\n # initialize graph\n def __init__(self, gdict=None):\n if gdict is None:\n gdict = dict()\n self.gdict = gdict\n\n # get edges\n def edges(self):\n return self.find_edges()\n\n # find edges\n def find_edges(self):\n edges = []\n for node in self.gdict:\n for nxNode in self.gdict[node]:\n if {nxNode, node} not in edges:\n edges.append({node, nxNode})\n return edges\n\n # Get verticies\n def get_vertices(self):\n return list(self.gdict.keys())\n\n # add vertix\n def add_vertix(self, node):\n if node not in self.gdict:\n self.gdict[node] = []\n\n # add edge\n def add_edge(self, node1, node2):\n # edge = set(edge)\n if node1 in self.gdict:\n self.gdict[node1].append(node2)\n else:\n self.gdict[node1] = [node2]\n\n if node2 in self.gdict:\n self.gdict[node2].append(node1)\n else:\n self.gdict[node2] = [node1]\n\n def dfsUtil(self, v, visit):\n\n visit[v] = True\n print(v)\n\n for i in self.gdict[v]:\n if visit[i] == False:\n self.dfsUtil(i, visit)\n self.topsort.append(v)\n\n # dfs for graph\n\n def dfs(self):\n node_len = len(self.gdict)\n visit = [False] * (node_len)\n self.cnt, self.topsort = 0, []\n\n for i in range(node_len):\n if visit[i] == False:\n self.dfsUtil(i, visit)\n self.cnt += 1\n\n\ndef inp():\n return map(int, input().split())\n\n\nfrom copy import *\n\nn, m = inp()\nstudent = graph()\nfor i in range(m):\n a, b = inp()\n student.add_edge(a, b)\n\ndic = deepcopy(student.gdict)\nfor i, j in dic:\n l = len(j)\n if l > :\n\nprint(student.gdict)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c578e117a403fbd1ddddf8dba117158", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def comb(n, r):\n if n == 0 or r == 0: return 1\n return comb(n, r - 1) * (n - r + 1) / r \nn,m=map(int,raw_input().split())\nif n/m==1:\n if n==m:\n print 0,0\n else:\n max=comb(n-m+1,2)\n print n%m,max\na=[n/m]*m\nmax=comb(n-m+1,2)\nelse:\n for i in range(0,n%m):\n a[i]+=1\n if a[0]!=a[-1]:\n min=comb(a[0],2)*a.count(a[0])+comb(a[-1],2)*a.count(a[-1])\n elif a[0]==a[-1]:\n min=comb(a[0],2)*m\n print min,max", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eadb6c8d5b0a855e862a39b5d3b2c811", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def get_result(line,remainder,quotient,m):\n result1 = remainder * ((line[0]*(line[0]-1))/2)\n result2 = (m-remainder) * ((quotient*(quotient-1))/2)\n return result1 + result2\n\n\nn,m = map(int,raw_input().split())\n\nmax_friends = (n-m+1)*(n-m)/2\n\nline = m*[n/m]\nremainder = n%m\nquotient = n/m\n\nfor i in range(remainder):\n line[i] += 1\n\nmin_friends = get_result(line,remainder,quotient,m)\n\nprint min_friends max_friends\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1374c72fc2d9fadcb7afbec5b94ca225", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from math import factorial\n import time\n n, m = map(int, input().split())\n\n if m == 1:\n kmin = kmax = factorial(n) // (factorial(2) * factorial(n - 2))\n elif m == 2:\n if n == 2:\n kmax = kmin = 0\n elif n == 3:\n kmax = kmin = 1\n else:\n if n % 2 == 0:\n kmin = 2 * factorial(n // 2) // (factorial(2) * factorial((n // 2) - 2))\n kmax = factorial(n - 1 // 2) // (factorial(2) * factorial(n - 3))\n else:\n kmin = factorial(n // 2) // (factorial(2) * factorial((n // 2) - 2)) + factorial(n // 2 + 1) // (factorial(2) * factorial((n // 2) - 1))\n kmax = factorial(n - 1 // 2) // (factorial(2) * factorial(n - 3))\n\n else:\n x = n - m + 1\n kmax = factorial(x) // (factorial(2) * factorial(x - 2))\n if n % 2 == 1:\n kmin = 3 + (n - 3) // 2\n else:\n kmin = n // 2\n\n print(kmin, kmax)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a475f83b5eddee172a4cd5ba91791fb", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "use std::io;\nuse std::io::Read;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_to_string(&mut buffer).unwrap();\n let mut cin = buffer.split_whitespace().map(|x| x.parse::().unwrap());\n let n = cin.next().unwrap() as usize;\n let mut a = cin.enumerate().collect::>();\n a.sort_by_key(|x| x.1);\n for i in 0..n / 2 {\n println!(\"{} {}\", a[i].0 + 1, a[n - i - 1].0 + 1);\n }\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a0c3a9ad85666cb5da1c917a86df17b", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(map(int,input().split())\ns=sum(a)\nfor i in range(n):\n if a[i]==0.4:\n continue\n for j in range(i+1,n):\n if a[i]+a[j]==2*s//n:\n print(i+1,j+1)\n a[j]=0.4\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e2f406e69d7b95185517823db3c849e", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def get_num (cards,start_index):\n pair =[]\n for i in range(start_index,n):\n if cards[i] + cards[start_index] == (sum(cards)/n) * 2:\n pair.append(start_index)\n pair.append(i)\n return pair\n\nn = int(raw_input())\ncards = raw_input()\n\nprint sum(cards/n)* 2\nfor i in range(n):\n print \" \".join(map(str,get_num(cards,i))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "778042da2160e822da7106a2e4fe11b4", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\na = map(int,input().split())\ns = sum(a)\na.sort()\nfor i in range(n//2):\nprint(a[i],s*2//n-a[i])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "63c17eef80dc314aaf3944b2c5727041", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Python 2", "source_code": " n = int(raw_input())\n\nent = map(int,raw_input().split())\n\nmedia = sum(ent)/(n/2)\n\n\nindicesAcessados = []\n\nmapa = {}\n\n\nfor i in range(n):\n\tj = i+1\n\tif i not in indicesAcessados:\n\t\tsoma = ent[i]\n\t\twhile j < n:\t\n\t\t\tif j in indicesAcessados:\n\t\t\t\tj += 1\n\t\t\tif soma + ent[j] == media:\n\t\t\t\tmapa[i+1] = j+1\n\t\t\t\tindicesAcessados.append(j)\n\t\t\t\tbreak\n\t\t\tj += 1\n\t\t\n\n\nfor i in mapa:\n\tprint i, mapa[i]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fd04b713e40fe5a05387a9703cb5d439", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Python 2", "source_code": "G = list(raw_input())\n\nwhile '4' in G:\n\n G[G.index('4')] = '1'\n\nwhile '7' in G:\n\n G[G.index('7')] = '2'\n\nk = ''.join(G)\n\np = (k[0])*(2**(len(k)-1))\nprint int(k,3) - p", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e39b9711f8c538e5b94c3225b4ae50d9", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a=[]\na.append(\"4\")\na.append(\"7\")\np=[]\np.append(\"4\")\np.append(\"7\")\nj=0\nfor i in range(1,200):\n\txx=[]\n\tl=2*(i-1)\n\tr=2*i\n\tfor j in range(l,r):\n\t\tx=a[j]+\"4\"\n\t\ta.append(x)\n\t\tx=a[j]+\"7\"\n\t\ta.append(x)\nb=[]\nfor x in a:\n\tb.append(int(x))\n\t\nb.sort()\nn=int(input())\ni=1\nfor x in b:\n\tif(x==n):\n\t\tprint i\n\t\tbreak\n\ti+=1\n\n\t\n\t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d9f2d2655d4cdb8854e0483a7b69978", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n =int(input())\nif (n == 4):\nprint(1)\nelif (n==7):\nprint(2)\nelse:\ntemp = n/10\nfinal_count = 0\ncounter = 1\n\nwhile(temp != 0):\n final_count = final_count + (2**counter)\n temp = int(temp/10)\n counter += 1\n\nfor i in range(counter):\n mod_val = 10\n curr_val = n % mod_val\n n = int(n / 10)\n if(curr_val == 7):\n final_count = final_count + (2**i)\n\nprint(final_count+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a17853fd12bddb6d8558eefdd00675af", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = input()\nans = 2**len(n) - 2\n\nfor i in range(len(n)):\n if n[i] == '7':\n ans+=2**len(n[i+1:])\n\nprint(ans+1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e05e39c17a30a96a068a802416cc582", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\nans = 0\nm = 1\nwhile n>0:\n k = n%10\n n = n/10\n if k == 4:\n ans = ans + m * 1\n elif k == 7:\n ans = ans + m * 2\n m = m * 2\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b27241c662509e30f81b6614a49b977", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\ndef f(a, b, c):\n return (a + 1) * (b + 2) * (c + 2) - a * b * c\n\nSmax = f(n, 1, 1)\n\nfrom math import sqrt\nSmin = Smax\nfor a in range(1, int(sqrt(n)) + 1):\n if n % a != 0:\n continue\n for i in range(1, int(sqrt(n / a)) + 1):\n if (n / a) % i == 0:\n Smin = min(Smin, f(a, i, (n / a) / i))\n\nprint Smin, Smax\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d466f90968fbff8bca86773ed13349b7", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n = input()\nMin, Max = 999999999999999999L, -1\n\ni = 1\nwhile i * i <= n:\n if n % i == 0:\n n1 = n / i\n a = i + 1\n\n j = 1\n while j * j <= n1:\n if n1 % j == 0:\n b = j + 2\n c = n1 / j + 2\n tmp = a * b * c - n\n Min = min(tmp,Min)\n Max = max(tmp,Max)\n j += 1\n\n a = n1 + 1\n j = 1\n while j * j <= i:\n if i % j == 0:\n b = j + 2\n c = i / j + 2\n tmp = a * b * c - n\n Min = min(tmp,Min)\n Max = max(tmp,Max)\n j += 1\n i += 1\nprint Min, Max\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "190b8fe65c55b5267a8f9223393de166", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\nfrom math import sqrt\n\nn = int(sys.stdin.readline())\n\ndef triples(x):\n r = int(sqrt(x)) + 1\n ts = set([])\n ds = [1, x]\n for i in xrange(2, r+1):\n if x % i == 0:\n ds.extend([i, x / i])\n ds = sorted(ds)\n for d in ds:\n r = int(sqrt(d))+1\n i = 0\n while ds[i] <= r:\n if d % ds[i] == 0:\n ts.add(tuple(sorted([x / d, ds[i], d / ds[i]])))\n i += 1\n return list(ts)\n\nrmax = -1\nrmin = float('inf')\n\nfor t in triples(n):\n a, b, c = t\n i = (a+1)*(b+2)*(c+2)\n j = (b+1)*(a+2)*(c+2)\n k = (c+1)*(a+2)*(b+2)\n keys = [i, j, k]\n for k in keys:\n rmax = max(rmax, k-n)\n rmin = min(rmin, k-n)\n\nprint rmin, rmax\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "39722d0a8045a553bb027453c284e98b", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import itertools as it\nfrom functools import reduce\n\nPRIME = -1\n\nN = 10**5\n\nprimes = [PRIME for x in range(N + 1)]\n\n\ndef factor(n):\n \"\"\"\n >>> factor(2)\n [(2, 1)]\n\n >>> factor(6)\n [(3, 1), (2, 1)]\n\n >>> factor(98)\n [(7, 2), (2, 1)]\n\n >>> factor(1)\n []\n \"\"\"\n if n == 1:\n return []\n if primes[n] == PRIME:\n return [(n, 1)]\n result = []\n result += [(primes[n], 1)]\n n //= primes[n]\n\n while primes[n] != PRIME:\n if result[-1][0] == primes[n]:\n result[-1] = (primes[n], result[-1][1] + 1)\n else:\n result += [(primes[n], 1)]\n n //= primes[n]\n\n if result[-1][0] == n:\n result[-1] = (n, result[-1][1] + 1)\n else:\n result += [(n, 1)]\n\n return result\n\n\ndef all_divisors(prime_factorization):\n \"\"\"\n >>> all_divisors(factor(6))\n [1, 2, 3, 6]\n\n >>> all_divisors(factor(12))\n [1, 2, 4, 3, 6, 12]\n\n >>> all_divisors(factor(7))\n [1, 7]\n\n >>> all_divisors(factor(1))\n [1]\n \"\"\"\n if len(prime_factorization) == 0:\n return [1]\n result = []\n factor_with_mult = []\n for pfactor in prime_factorization:\n factor_with_mult += [[1]]\n for _ in range(pfactor[1]):\n factor_with_mult[-1] += [factor_with_mult[-1][-1] * pfactor[0]]\n for divisor in it.product(*factor_with_mult):\n result += [reduce(lambda x, y: x * y, divisor)]\n return result\n\n\nif __name__ == '__main__':\n # sieve\n for i in range(2, N + 1):\n if primes[i] == PRIME:\n j = 2\n while j * i < N + 1:\n primes[j * i] = i\n j += 1\n primes[0] = primes[1] = 0\n\n n = int(input())\n\n min_result = 10**9\n max_result = 0\n\n for divisor in all_divisors(factor(n)):\n for div2 in all_divisors(factor(divisor)):\n if div2 * div2 > divisor:\n break\n a = n // divisor + 1\n b = divisor // div2 + 2\n c = div2 + 2\n min_result = min([min_result,\n c * b + (a - 1) * 2 *\n (b + c - 2)])\n max_result = max([max_result,\n c * b + (a - 1) * 2 *\n (b + c - 2)])\n print(str(min_result) + \" \" + str(max_result))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a458a381481a4829cd85e290bbad205e", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from itertools import permutations\nn=input()\ndef sieve(n):\n s = xrange(3, n + 1, 2)\n r = set(s)\n [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]\n return r.union([2])\nA=sieve(int(n))\nC=[]\nfor x in A:\n if n%x==0:\n t=n\n c=0\n while t%x==0:\n t/=x\n c+=1\n C.append((x,c))\nD=[]\nif len(C)>=3:\n D.append([C[0][0]**C[0][1],C[1][0]**C[1][1],C[2][0]**C[2][1]])\nelif len(C)==2:\n D.append([C[0][0]**C[0][1],C[1][0]**C[1][1],1])\n for i in range(1,C[0][1]):\n D.append([C[0][0]**i,C[0][0]**(C[0][1]-i),C[1][0]**C[1][1]])\n for i in range(1,C[1][1]):\n D.append([C[1][0]**i,C[1][0]**(C[1][1]-i),C[0][0]**C[0][1]])\nelif len(C)==1:\n for i in range(C[0][1]+1):\n for j in range(C[0][1]-i+1):\n D.append([C[0][0]**i,C[0][0]**j,C[0][0]**(C[0][1]-i-j)])\nD.append([n,1,1])\nma=-1\nmi=100000000000000000000\nfor x in D:\n E=permutations(x)\n for y in E:\n t=(y[0]+1)*(y[1]+2)*(y[2]+2)-n\n ma=max(ma,t)\n if t>0:\n mi=min(mi,t)\nprint mi,ma\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32e4ad380790006dc60ac2549c9733a2", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nif (n+1) % 2 ==0 and (n!=0):\n print((n+1)//2)\nelif n==0:\n print 0\nelse:\n print(n+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c168299b5491a14ef3add7a68c0b357b", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(input());\na = 0;\nif (n == 0)\n a = 0\nelse if (n == 1)\n a = 1\nelse if (n % 2 == 0)\n a = n + 1\nelse \n a = n - 1\n\nprint(a);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2b70a624871c1020f72a3445b582b48", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import math\nguests = int(input())\nif guests == 0:\n print(0)\nguests = guests+1\nelif guests % 2 == 0:\n print(guests//2)\n\nelse:\n print(guests)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e50629efe0e7b737702a0203451e4d71", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n == 0:\n print 0\nif (n+1) % 2 ==0:\n print((n+1)//2)\nelse:\n print(n+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "42046d5f49beceffd41dd8c65f9c4fb7", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(input())\na = 0\nif (n == 0):\n a = 0\nelse if (n == 1):\n a = 1\nelse if (n % 2 == 0):\n a = n + 1\nelse:\n a = n - 1\n\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "41790c46b2d9770cb267b8773e2631af", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\na=list(map(int,input().split()))\np=a[0]*a[1]\nq=a[2]*a[2]\nif a[2]==1 :\n print(a[1]*a[0])\n sys.exit()\nif p>q :\n if a[1]%a[2]!=0:\n b=int((a[1]/a[2]))+1\n else:\n b=int((a[1]/a[2]))\n if a[0]%a[2]!=0:\n c=int((a[0]/a[2]))+1\n else:\n c=int((a[0]/a[2]))\nprint(b*c)\n\nelse:\n print(1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b6a66dbd5bd0a330befe695dc450f81a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=6\nm=6\na=4\nif(n==1 and a==1 and m==1):\n print(1)\nb=int(((n+3)/(a-1))*((m/a)))\nelif (b):\n print(b)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ed2296dcf20af3ec3003dbff33755938", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math \na = map(int, input().split()))\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8af0c1ac4935275d30166585d49dbdd5", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n, m, a = map(int, input().split())\nif n and m > a:\n print((n // a + 1) * 2)\nelif:\n n > a and m <= a:\n print((n // a) * 2)\nelif:\n m > a and n <= a:\n print((m // a) * 2)\nelse:\n print(m * n // (a * a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3cbc41084b3ad25c851e7dd312759b03", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "n, m, a = map(int, input().split())\nprint (n % a == 0 ? n: n % a + 1)*(m % a == 0 ? m: m % a + 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d0e515fe1ab9e83c0e257ef6a425023c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "k,n,s,p= map(int, input().split())\nsp=n/s\nspq=round(sp+1)\nr=(spq*k/p)\nif r%1==0:\n print(int(r))\nelse:\n print(int(round(r+1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76548fe724bef112a418c16cb2ca4a1a", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k,n,s,p = map(int,input().split())\nm=int()\nkl=int()\nvl=int()\nif n % s ==0:\n\tkl = n // s\n\telse:\n\t\tkl = n // s + 1\nvl = kl * k\nif vl % p == 0:\n\tm = vl // p\nelse: m = vl // p + 1\nprint (m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80be02bfecc0eb72cf11a28cd773ed13", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,s,k,l=list(map(int,input().split()))\nif s//k==s/k: \n op=int(s//k)\nelse:\n op=int(s//k)+1\nkam=n*op\nif kam//l==kam/l:\n print(int(kam/l)\nelse:\n print(int(kam//l)+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57275b50b3eda479335a78bcb3bcceb3", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 3", "source_code": "include math\nent=input()\na,b,c,d=ent.split()\nprint(math.ceil((a*math.ceil(b/c))/d))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6d8ad58269fa2e1f6c8d616891c1b282", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k,n,s,p=map(int,input().split())\nm=int()\nkl=int()\nif n % s ==0:\n\tkl = n // s\n\telse:\n\t\tkl = n // s + 1\nvl = kl * k\nif vl % p == 0:\n\tm = vl // p\nelse: m = vl // p + 1\nprint (m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ec31f4f832d9e5e17072e034963b351", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#python27\n\ndef program():\n s=str(raw_input())\n \n if(s.isupper() or len(s)==1 s[1:].isupper()):\n s=s.swapcase() \n print s\n return\n else:\n print s\nprogram() ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b55a38c27b8ffc52c3fbd8a15a429731", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "input = raw_input()\n\ninput_list = list(input)\n\n\"\"\"print str(input_list[0]).upper(), \"\\b\", ''.join(input_list[1:]).lower()\"\"\"\n\nhoay = []\n\nhoay.append(input_list[0].upper())\n\nfor i in input_list[1:]:\n\thoay.append(i.lower())\n\t\n\nif for i in input_list[1:]\t== i.lower()\n\tprint ''.join(hoay)\nelse:\n\tprint input", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6f8354efbffd6c5c4b51dff5111c788b", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "# author : sudoer\n# from __future__ import print_function\n# from __future__ import division\nimport math\n# from collections import OrderedDict\n\ndef prob(n):\n if(n.isupper() == True):\n # print \"upper\"\n a = str(n[0].upper())\n b =str(n[1:].lower())\n print a+b\n elif n[0].islower() == True and n[1:].isupper()==True:\n print n[0].upper()+n[1:].lower()\n else :\n print n\n\n\n\nn = raw_input()\nn = str(n)\nprob(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f1a45e797233ed6b3418efb16dda576d", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=input()\ns=\"\"\n\nif n[1:].isupper() or n.isupper() or len(n)=1 :\n for i in n:\n s=s+i.swapcase()\n\n print(s)\n\nelse :\n print(n)\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "451c8d67b4bc809ba686897571ce087a", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "x = raw_input()\ny =0\nfor i in x:\n\tif i=i.lower():\n\t\ty+=1\nif y==1:\n\tprint x[0].upper()+x[1:].lower()\nelse:\n\tprint x\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2400d0215930f39c64e24e32b1f4a24d", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "def IsBerlanese():\n s = raw_input()\n vowels = 'aeiou'\n i = 0\n while i < len(s)-1:\n if s[i] not in vowels and s[i] != 'n':\n if s[i+1] not in vowels:\n return 'NO'\n i += 1\n \n if s[i] == 'n' or s[i] in vowels:\n return 'YES'\n else:\n return 'NO'\n \nprint IsBerlanese()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0065bc5ec24ab8fc6ea916d61b7c5502", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a=input()\nb=[\"a\",\"e\",\"i\",\"o\",\"u\"]\ntemp=True\nfor i in range(len(a)):\n if a[i] not in b and a[i]!=\"n\":\n if i!=len(a)-1:\n if a[i+1] in b:\n continue\n else:\n temp=False\n print(\"NO\")\n break\n else:\n temp=False\n pprint(\"NO\")\n else:\n continue\n \nif temp==True:\n print(\"YES\")\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "261bfdbbc2da6bc8a3cea3d38be642e0", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nc=0\nif \"n\" not in n:\n for i in range (0,len(n),2):\n if n[i]==\"a\" or n[i]==\"e\" or n[i]==\"i\" or n[i]==\"o\" or n[i]==\"u\":\n c=1\n for i in range (1,len(n),2):\n if n[i]==\"a\" or n[i]==\"e\" or n[i]==\"i\" or n[i]==\"o\" or n[i]==\"u\":\n c=1\nelif \"n\" in n:\n if len(n)==1:\n c=1\n elif n[len(n)]==\"a\" or n[len(n)]==\"e\" or n[len(n)]==\"i\" or n[len(n)]==\"o\" or n[len(n)]==\"u\" or n[len(n)]==\"n\"\n for i in range (len(n)-1): \n if (n[i]==\"b\" or n[i]==\"c\" or n[i]==\"d\" or n[i]==\"f\" or n[i]==\"g\" or n[i]==\"h\" or n[i]==\"j\" or n[i]==\"j\" or n[i]==\"k\" or n[i]==\"l\" or n[i]==\"m\" or n[i]==\"p\" or n[i]==\"q\" or n[i]==\"r\" or n[i]==\"s\" or n[i]==\"t\" or n[i]==\"v\" or n[i]==\"w\" or n[i]==\"x\" or n[i]==\"y\" or n[i]==\"z\"):\n if (n[i+1]==\"a\" or n[i+1]==\"e\" or n[i+1]==\"i\" or n[i+1]==\"o\" or n[i+1]==\"u\"):\n c=1\nelif c==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5df21819ba69d1534671c67a9ea46276", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nc=0\nif (n[len(n)-1]=\"a\" or n[len(n)-1]=\"e\" or n[len(n)-1]=\"i\" or n[len(n)-1]=\"o\" or n[len(n)-1]=\"u\" or n[len(n)-1=\"n\"]):\n for i in range (1,len(n),2):\n if (n[i]=\"a\" or n[i]=\"e\" or n[i]=\"o\" or n[i]=\"o\" or n[i]=\"u\"):\n c=1\n for j in range (0,len(n),2):\n if (n[i]=\"a\" or n[i]=\"e\" or n[i]=\"o\" or n[i]=\"o\" or n[i]=\"u\"):\n c=1\nif c=1:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dcd62a6a306a055f92861c5aee68cc19", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "w = input()\nword = ''.join([i if i != 'n' else \"*\" for i in w]\n\nvowels = \"aeiou\"\ncons = [word[i-1] + word[i] for i in range(1 , len(word)) if word[i-1] not in vowels]\ncon_vow = [i for i in cons if i[-1] in vowels]\n\nif len(cons) == len(con_vow) :\n print(\"YES\")\nelse :\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8df4ae9243865d2aede558e9dbf19e18", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "# coding: utf8\ns = input()\nk = int(input())\nn = s.count('*')\nm = s.count('?')\nl = len(s) - m - n\nif k < l - m - n or (n == 0 and k > l):\n s = 'Impossible'\nelif k > l:\n # \u9700\u8981\u6dfb\u52a0 k-l \u4e2a *\u524d\u9762\u7684\u6570\u5b57\n # \u7528replace('*'\uff0c\u4e2a\u6570\uff0c1) \u628a\u7b2c\u4e00\u4e2a*\u66ff\u6362\u4e3ak-l\u4e2a\u524d\u9762\u7684\u5b57\u6bcd\u5373\u53ef\n i = s.find('*')\n s = s.replace('*', s[i - 1] * (k - l), 1)\n# \u4e0b\u9762\u4e00\u884c\u5f88\u5de7\u5999\uff0c\u5904\u7406\u5220l-k\u4e2a\u5b57\u7b26\u7684\u65f6\u5019\uff0c\u76f4\u63a5\u5427*\u6362\u6210?\uff0c\u907f\u514d\u5224\u65ad?\u548c*\u4e2a\u6570\u7684\u60c5\u51b5\ns = s.replace('*', '?')\n# \u7c7b\u4f3c\u4e8e in range(0, l-k)\uff0c \u5982\u679cl-k\u5c0f\u4e8e\u7b49\u4e8e0\u7684\u8bdd\u662f\u4e0d\u5faa\u73af\u7684\nfor _ in [0] * (l - k):\n i = s.find('?')\n # \u5220\u9664 ?\u548c\u524d\u9762\u7684\u5b57\u7b26\uff0c\u62fc\u8d77\u6765\u4e00\u8d77replace with ''\n s = s.replace(s[i - 1] + '?', '', 1)\nprint(s.replace('?', ''))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a90524c294de76653680c74847e7ff3", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "stroka = input()\nk = int(input())\nn1 = stroka.count('*')\nn2 = stroka.count('?')\nt = 0\np = ''\nif n1 > 0 and n2 > 0:\n for i in range(len(stroka)):\n\n if stroka[i+t]=='?'and (len(stroka)-stroka.count('?')-stroka.count('*')-stroka.count('!'))>k:\n stroka = stroka[:i+t-1]+'!!'+stroka[i+t+1:]\n elif stroka[i+t]=='?'and (len(stroka)-stroka.count('?')-stroka.count('*')-stroka.count('!'))<=k:\n stroka = stroka[:i+t]+'!'+stroka[i+t+1:]\n elif stroka[i+t] =='*' and (len(stroka)-stroka.count('?')-stroka.count('*')-stroka.count('!'))>k:\n stroka = stroka[:i+t - 1] + '!!' + stroka[i+t + 1:]\n elif stroka[i+t] =='*' and (len(stroka)-stroka.count('?')-stroka.count('*')-stroka.count('!'))==k:\n stroka = stroka[:i +t] + '!' + stroka[i +t+ 1:]\n elif stroka[i+t] =='*' and (len(stroka)-stroka.count('?')-stroka.count('*')-stroka.count('!')) 0 and n2 ==0:\n for i in range(len(stroka)):\n print(stroka) if stroka[i+t] == '*' and (len(stroka) - stroka.count('*')-stroka.count('!')) > k:\n stroka = stroka[:i+t - 1] + '!!' + stroka[i+t + 1:]\n elif stroka[i+t] == '*' and (len(stroka) - stroka.count('*')-stroka.count('!')) == k:\n stroka = stroka[:i+t] + '!' + stroka[i +t+ 1:]\n elif stroka[i+t] == '*' and (len(stroka) - stroka.count('*')-stroka.count('!')) < k:\n y = abs((len(stroka) - stroka.count('*')-stroka.count('!')) - k)\n stroka = stroka[:i + t] + stroka[i + t - 1] * y + stroka[i + t + 1:]\n t += y-1\nelif n1==0 and n2 > 0:\n for i in range(len(stroka)):\n if stroka[i] == '?' and (len(stroka) - stroka.count('?') -stroka.count('!')) > k:\n stroka = stroka[:i - 1] + '!!' + stroka[i + 1:]\n elif stroka[i] == '?' and (len(stroka) - stroka.count('?') -stroka.count('!')) <= k:\n stroka = stroka[:i] + '!' + stroka[i + 1:]\nfor i in range(len(stroka)):\n if stroka[i]!='!':\n p += stroka[i]\n\n\nif len(p)==k:\n print(p)\nelse:\n print('Impossible')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "556c5376eb74295df0f843589ea2e0d9", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import re\n\ndef f(cs):\n nonlocal x\n if x > 0:\n x -= 1\n return ''\n elif x > 0:\n return cs[0][0] * x\n x = 0\n else:\n return cs[0][0]\n\ns = input()\nx = len(s) - s.count('?') - s.count('*') - int(input())\ns = re.sub(r'\\w[?*]', f, s)\nprint('Impossible' if x else s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2ef2b723056b2548ca6431998713845", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "s, k = input(), int(input())\n\ninf = 200\n\nmin_len = len(s) - 2 * (s.count('?') + s.count('*'))\n\nmax_len = inf if '*' in s else len(s) - 2 * s.count('?')\n\nif min_len <= k <= max_len:\n\tif '*' in s:\n\t\tlast_snowflake_index = len(s) - 1 - s[::-1].index('*')\n\t\trepeats_needed = k - (len(s) - 2 * (s.count('?') + s.count('*')) + 1)\n\n\t\ta = ''\n\t\tfor i in range(len(s)):\n\t\t\tif s[i] == '?':\n\t\t\t\ta = a[:-1]\n\t\t\telif s[i] == '*':\n\t\t\t\tif i < last_snowflake_index:\n\t\t\t\t\ta = a[:-1]\n\t\t\t\telse:\n\t\t\t\t\ta += repeats_needed * s[i - 1]\n\t\t\telse:\n\t\t\t\ta += s[i]\n\n\t\tprint(a)\n\telse:\n\t\tremoves_needed = k - (len(s) - (s.count('?') + s.count('*'))\n\n\t\ta = ''\n\t\tfor i in range(len(s)):\n\t\t\tif s[i] in '?*':\n\t\t\t\tif removes_needed > 0:\n\t\t\t\t\ta = a[:-1]\n\t\t\telse:\n\t\t\t\ta += s[i]\n\n\t\tprint(a)\nelse:\n\tprint('Impossible')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1dc92ba991c0eca315f9b2326408c697", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from collections import Counter\n\na = input()\ntarget = int(input())\nc= Counter(a)\nlength = len(a) - 2* c[\"*\"] - 2 * c[\"?\"]\n\nif length > target:\n print(\"Impossible\")\nelse:\n pure = length + c[\"*\"] + c[\"?\"]\n pon = pure - target\n if not pon:\n for aa in a:\n if aa==\"*\" or aa==\"?\":\n continue\n else:\n print(aa,end=\"\")\n elif pon < 0:\n if c[\"*\"] == 0:\n print(\"Impossible\")\n return\n for idx, aa in enumerate(a):\n if aa ==\"?\":\n continue\n elif aa ==\"*\":\n while pon != 0:\n print(a[idx-1],end=\"\")\n pon+=1\n else:\n print(aa,end=\"\")\n else:\n b = []\n for aa in a:\n if b and pon > 0 and (aa==\"*\" or aa==\"?\"):\n b.pop()\n pon-=1\n elif (aa==\"*\" or aa==\"?\"):\n continue\n else:\n b.append(aa)\n print(\"\".join(b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2cb803a6e1c06950dfd2f1ada55ab25a", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\na,b,c,d,e = input().split()\na=int(a)\nb=int(b)\nc = int(c)\nd=int(d)\ne=int(e)\nif(a!=1):\n\tg = a\n\th = g-1\n\tf = a*(g-1)\n\tprint(f)\nelse(print(1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c70aa6179129f7301bc95bd6762899dc", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, a, b, c, d = map(int, input().split(' '))\nsums = [a+b, a+c, b+d, c+d]\nsums.sort()\nans = max(0, n - sums[3] + sums[0])\nans *= n\nprint(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b3a16111fcae95f3456fa8efcf9b85f", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#-*-coding:utf-8-*-\nimport math\nimport string\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n\n# s , a = s1\n\n# \uc11c\ub85c\uac04 \uc774\uc6c3\ud55c \uac12 c (si-si-1 = c)\n# b\uac00 \uc774 \uc2dc\ud038\uc2a4\uc5d0 \ud3ec\ud568\n# si = b\n# \n\n\nn, a, b, c, d=map(int,raw_input().split())\n\nx1=0\nx2=0\nx3=0\nx4=0\nx5=0\n\n\n\ncount = 0\n\nfor i in (1, n) :\n\tx1 = i\n\tx2 = x1+b-c\n\tx4 = x1+a-d\n\tx5 = x2+a-d\n\t\n\tif x1 <=n and x2 <=n and x4 <=n and x5 <=n \\\n\tx1 >0 and x2 >n and x4 >n and x5 >n: count +=1\nprint count*n \n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "009cfaa0f4356df65088a4fb0066ffb9", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#-*-coding:utf-8-*-\nimport math\nimport string\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n\n# s , a = s1\n\n# \uc11c\ub85c\uac04 \uc774\uc6c3\ud55c \uac12 c (si-si-1 = c)\n# b\uac00 \uc774 \uc2dc\ud038\uc2a4\uc5d0 \ud3ec\ud568\n# si = b\n# \n\n\na, b, c=map(int,raw_input().split())\n\nif a == b and c == 0 : print \"YES\"\nelif c!=0 :\n\tif (b - a) % c == 0 : print \"YES\"\n\telse : print \"NO\"\nelse : print \"NO", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5501d94d1ff15b9d5c8f86a284326999", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import*\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\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\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nMOD=1000000007\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n#-------------------------code---------------------------#\n// vsInput()\n\nn,a,b,c,d=value()\nans=0\n\nminSum=a+b+2\nmaxSum=a+b+2*n\n\nfor mid in range(1,n+1):\n box1=(a+b+mid+1,a+b+mid+n)\n box2=(a+c+mid+1,a+c+mid+n)\n box3=(c+d+mid+1,c+d+mid+n)\n box4=(d+b+mid+1,d+b+mid+n)\n\n minSum=max(box1[0],box2[0],box3[0],box4[0])\n maxSum=min(box1[1],box2[1],box3[1],box4[1])\n\n # print(minSum,maxSum)\n ans+=max(maxSum-minSum+1,0)\n\nprint(ans)\n\n\n\n\n\n\n\n \n\n\n\n \n \n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6fe840ab6c6b482289b4e40649323e7c", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\ndays = 0\ni = 1\nwhile n > 0:\nn -= 1\ndays += 1\nif days == m * i:\nn += 1\ni += 1\nprint(days)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ffc9846e09bd27a0acb1dfcd4901332e", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 3", "source_code": " n , m = map(int , input().split())\n s = n # s refers sum \n while n >= m :\n n = n%m + n//m \n s+=n \n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "347b21482404733d2eac6314e761475d", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n=input()\nm=input()\nwhile(1m:\n print (n+m+1) \n elif n==m:\n print(n+1) \n else:\n print(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f1ca5be2a972b6d78badd87e7f27aa3c", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, m = input().split()\nn = int(n)\nm = int(m)\n\nprint(round(n + (n-1)/(m-1))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ee216e7c11237c00eee083354e0c5af", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\n\u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\n\n4 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430\u0437\u0430\u0434\n\u0432\u0430\u0441\u044f \u0438 \u043d\u043e\u0441\u043a\u0438\nn, m = map(int, input().split())\nz=0\nwhile n>0\n n-=1\n z+=1\n if z%m==0\n n+=1\nprint(z)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d1e5acbcce5857de4d6234eb6f5ac9b", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "Python 3", "source_code": "[n,a,b,c]=[int(x) for x in input().split()]\nk=0\nminprice=0\nfor i in range (4):\n if (n+i)%4==0:\n k=i\nif k==0:\n print(0)\nelif k==1:\n print(min(a,b+c,3*c)\nelif k==2:\n print(min(b,2*a,2*c)\nelif k==3:\n print(min(c,3*a,b+a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c7cc61e1b05fede509f992c5f046f68", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def func(n):\n if n[0]%4==1:return (min(n[3],n[1]*3,n[2]+n[1]))\n elif n[0]%4==2:return (min(n[2],n[3]*2,n[1]*2))\n elif n[0]%4==3:return (min(n[1],n[2]+n[3])\n else:return 0\nprint(func(list(map(int,input().split()))))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bb5d10079972d6b9979418e76494bccc", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, a, b, c = (int(x) for x in input().split())\nnd = 4 - n % 4\nif nd == 0:\n print 0\nelif nd == 1:\n print(a)\n elif nd == 2:\n print(min(2 * a, b))\n else:\n print(min(3 * a, min(a + b, c)))\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "19105aafd68744d7c8e04b0c6be8c8d9", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, a, b, c = map(int, input().split())\n\nleft = n % 4\n\nif left == 4:\n\tprint(0)\nelif left == 3:\n\tprint(a, b + c, 3*c)\nelif left == 2:\n\tprint(min(2*a, b, 2*c)\nelse:\n\tprint(min(3*a, a + b, c))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f57c4611ddc1901aed5b4f08c4b6f22", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,a,b,c=input().split(\" \")\nn=int(n)\na=int(a)\nb=int(b)\nc=int(c)\nif(n%4==0):\n print(0)\nelse :\n n=n%4\n b=b/2\n c=c/3\n n=4-n\n if(n==3):\n a=min(a,c)\n print(int(a*n))\n elif(n==1)\n print(int(a * n))\n else:\n a = min(a, b)\n print(int(a * n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a1dd3a0a93ca3973347ee6952229032a", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m = map(int,input().split())\n\nl = sorted(list(map(int,input().split())))\nfor i in range(m - n - 1):\n print(min([l[i+n-1]-l[i]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a83989112d3cedf8715800ace1466631", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "from collections import deque\nq=deque\nmin_diff=1e5+9\nn,m=map(int,input().strip().split())\nl=list(map(int,input().strip().split())\nfor i in range(n):\n q.append(l[i])\nfor i in range(n,m):\n min_diff = min(min_diff,max(q)-min(q))\n q.popleft()\n q.append(l[i])\nmin_diff=min(min_diff,max(q)-min(q))\nprint(min_diff)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae4f991d0480a87e345f78eb9d88e758", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n,m = map(int, raw_input().split()))\ns = list(map(int, raw_input().split())))\ns.sort()\nminim = max(s) - min(s)\nfor i in range(m-n+1):\n\tif ( s[i+n-1]-s[i] < minim):\n\t\tminim = s[i+m-n]-s[i]\n\t\t\nprint minim\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2e5e386d8ebbca7f4dfe5b2ea8620ce", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "l=[]\np=[]\nn=int(input())\nm=int(input())\nif 2<=n<=m<=50:\n for i in range(m):\n l.append(int(input())\n for i in range(0,m-n+1):\n p.append(l[i+4-1]-l[i])\n print(min(p))\nelse:\n print(\"redo\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3f7f1ea69753ebeb640b434981d5d2c2", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "x,y = map(int,raw_input().split())\nl = list(map(int,raw_input().split()))\nl =sorted(l)\nm =1000\nfor i in range(y-x+1):\n\td = l[i+x-1] - l[i]\n\tif d l.index(c[0])):\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8dce10f2a3ee18da20424bd07d9e14db", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s=input()\na,b=input().split()\nx=\"6789TJQKA\"if a[1]==s: print(\"YES\")\nelif b[1]==s or a[1]!=b[1]: print(\"NO\")\nelif x.index(a[0])>x.index(b[0]): print(\"YES\")\nelse: print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "450b6dc204cb66f50a52c2d132d27810", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "c = input()\ns = raw_input().split()\nl = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ns1 = s.pop(0)\ns.insert(0,s1[len(s1) - 1])\ns.insert(0,s1[:len(s1) - 1])\ns1 = s.pop()\ns.append(s1[:len(s1) - 1])\ns.append(s1[len(s1) - 1])\nif (s[1] == s[3]) and (l.index(s[0]) > l.index(s[2]):\n print(\"YES\")\nelif s[1] == c:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d76f6c3b1e56605266f60606f9e27094", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "suit = ['S', 'H', 'D', 'C']\nrank = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\n\ntrump = str(raw_input())\ncards = str(raw_input())\n\nwin = False\n\nif cards[1] == cards[4] and rank.index(cards[0]) > rank.index(cards[3]):\n win = True\n \nif cards[1] == trump\n win = True\n \nif win:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac3a61653032756106224681afc8b3ae", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "c = input()\ns = raw_input().split()\nl = ['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ns1 = s.pop(0)\ns.insert(0,s1[len(s1) - 1])\ns.insert(0,s1[:len(s1) - 1])\ns1 = s.pop()\ns.append(s1[:len(s1) - 1])\ns.append(s1[len(s1) - 1])\nif (s[1] == s[3]) and (l.index(s[0]) > l.index(s[2])):\n print(\"YES\")\nelif s[1] == c:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "174c35c9fe4880aee82659d65e2a09e8", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \n\n#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL);\n#define precision(x); cout<()\n#define mod 1000000007\n\nusing namespace std;\n\nll modExp(ll x,ll y,ll p){\n ll res=1; \n x=x%p;\n while(y>0){\n if(y&1){ \n res=((res%p)*(x%p))%p;\n }\n y=y>>1; \n x=((x%p)*(x%p))%p; \n } \n return res; \n} \n\nint main()\n{\n BOOST\n ll x,k,a,b;\n cin>>x>>k;\n if(x==0){\n \tcout<<0;\n }else{\n\t\ta=modExp(2,k+1,mod);\n\t\tb=modExp(2,k,mod);\n \tcout<<((((((x%mod)*(a%mod))%mod)-(b%mod)+1)+mod)%mod);\n }\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb14ab2d7532f83dff87d2dcd9bf33c5", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "/** \nSometimes you must hurt in order to know,fall in order to grow,lose in order to gain because life\u2019s greatest lessons are learned through pain. \n*/\n#include \n#define forn(i, l, r) for(ll i=l;i<=r;i++)\n#define all(v) v.begin(),v.end()\n#define pb push_back\n#define nd second\n#define st first\n#define debug(x) cout<<#x<<\" -> \"<= MOD) a -= MOD;\n}\n\nvoid subtract(ll& a, ll b) {\n\tif (b>a) a+=MOD;\n\ta=(a-b)%MOD;\n}\n\nll sum (ll a, ll b) {\n\tadd(a, b);\n\treturn a;\n}\n\nll multiply(ll a, ll b) {\n\treturn (long long) ((a%MOD) * (b%MOD)) % MOD;\n}\n\nll mpow(ll a, ll b) {\n\tll ret = 1;\n\twhile (b) {\n\t\tif (b & 1) {\n\t\t\tret = multiply(ret, a);\n\t\t}\n\t\ta = multiply(a, a);\n\t\tb >>= 1;\n\t}\n\treturn ret;\n}\n\nint main() {\n\tios_base::sync_with_stdio(false); cin.tie(0);\n\t#ifdef LOCAL_PROJECT\n\t\tfreopen(\"input.txt\",\"r\",stdin);\n\t#endif\n\tll x, k;\n\tcin>>x>>k;\n\tif(x==0) {\n\t\tcout<<\"0\\n\";\n\t\texit(0);\n\t}\n\tll ans = multiply(x, mpow(2LL, k+1));\n\tll temp = mpow(2LL, k);\n\tsubtract(temp, 1LL);\n\t// debug(temp);\n\tsubtract(ans, temp);\n\tcout<< ans<<'\\n';\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ecf3f82116293b5567f9653cf5f637ba", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def power(x,y):\n\tmod=1000000007\n\tres = 1\n\twhile (y > 0):\n\t// If y is odd, multiply x with result\n\t\tif (y and 1):\n\t\t\tres = (res * x)%mod\n\t\ty = y >> 1 \n\t\tx = (x * x)%mod\n\treturn res;\nx,k=map(int,input().split())\nmod=1000000007\nx%=mod\nfactor=power(2,k)\nfactor%=mod\nans=((2*factor*x)%mod- (factor)%mod+1)%mod\nif x==0:\n\tprint(\"0\")\nelse:\n\tprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "318bc45d87acfbf91974b53e6a93af15", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def power(x,y):\n\tmod=1000000007\n\tres = 1\n\twhile (y > 0):\n\t// If y is odd, multiply x with result\n\t\tif (y and 1):\n\t\t\tres = (res * x)%mod\n\t\ty = y >> 1 \n\t\tx = (x * x)%mod\n\treturn res\nx,k=map(int,input().split())\nmod=1000000007\nx%=mod\nfactor=power(2,k)\nfactor%=mod\nans=((2*factor*x)%mod- (factor)%mod+1)%mod\nif x==0:\n\tprint(\"0\")\nelse:\n\tprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b178b98cc6cd7ca272fa0fadc3014f77", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\n from sys import stdin\nimport math\n\nline = stdin.readline().rstrip().split()\nl = int(line[0])\nr = int(line[1])\nx = int(line[2])\ny = int(line[3])\n\n\n\nw = x * y\n\nmaxN = min(min(r, y), math.floor(math.sqrt(w)))\ncount = 0\n\nif y%x != 0:\n print(0)\nelse:\n for a in range(l, maxN+1):\n if w % a == 0:\n b = int(w/a)\n if a >= l and a <= r and b >=l and b <= r:\n if a % x == 0 and b % x == 0 and y % a == 0 and y % b == 0:\n gcd = math.gcd(int(a/x), int(b/x))\n if gcd == 1:\n if a != b:\n count += 1\n count += 1\n print(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fec523da92588c5cdbc26edc26249e4f", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a,b=(int(i) for in input().split())\nif b>a & b%a==0:\n c=b//a\n print(((c-a)(c-a+1)/2) +((b-c)(b-c+1)/2))\nelif b%a!=0:\n d=(b//a)+0.5\n print(((d-a)(d-a+1)/2)+((b-d)(b-d+1)/2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "64e6cb742a270b3d14a0112145fd2867", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n int n;\n cin>>n;\n int matrix[n][n];\n for(int i=0;i>matrix[i][j];\n for(int k=0;kc:\n list2=list1[0:-1]\nelse list2=list1:\nprint(sum(list2))\n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e4cae0579a48bb5c57a5964043eaa9b", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nif a>b:\n k=a-b\nelse\n k=b-a\nif k%2==0:\n j=k//2\n x=0\n for v in range(0,j+1):\n x=x+v\n y=0\n for v in range(j,0,-1):\n y=y+v\n print(x+y)\nelse:\n j=(k//2)\n x=0\n for s in range(0,j+1):\n x=x+s\n y=0\n for s in range(j+1,0,-1):\n y=y+s\n print(x+y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f547eaae3376f3b31e2843bbfaee7630", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "PyPy 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\nfor i in range (1,d+1):\n s=s+i\nfor j in range (1,e+1):\n p=p+j\nprint(s+p)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fbaaff9994190ce3e9b4f6a6db931f1d", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x,y,z = map(int,input().split())\nif z=y and z<=x:print(y)\nelif z%y=0 and z>x:print(5-(z%5))\nelif z%y==0 and z>x:print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "97a7e48d691fa0bbe14b748778a1a509", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.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 k-(t-n)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "31e2ead3b526deddf3f978c4a1c97b45", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# import sys\n# sys.stdin = open(\"test.in\",\"r\")\n# sys.stdout = open(\"test.out\",\"w\")\nn,k,t=map(int,input().split())\nif t<=k:\n\tprint(t)\nelif t=k:\n\tprint(k)\nelse:\n\tprint(n+k-t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dfb89b5a3b9c5c34fc54f8f5a5dccefd", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, k, t=map(int, input().split())\nif(tk and t<=n):\n print(k)\nelif(t==n+k):\n print(0)\nelif(t>n):\n m=t-n\n print(n-(n+m-k))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5ce8d6345604071f431f7a65e3c1cb48", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n,k,t=map(int,input().split())\ns=0\na=[]\nfor i in range(t):\n if i+1<=k:\n s+=1\n a.append(s)\n elif i+1>n-k and i+1<=n:\n a.append(s)\n else:\n s-=1\n a.append(s)\nprint(a[t-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d64c7222b105df3913d07981616fbc5a", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "c=input()\nc.replace(' ','')\nc.strip('0')\nn=1\nfor i in c.split('1')\n n*=c.len()+1\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f34b5764f1b7858f3e99bb2dc85e846", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\na=list(map(int,input().split())\nans = 1\nk = 1\nfor i in a:\n if i:\n ans*=k\n k=1\n else:\n k+=1\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d8d96c417e8c3a97425d9054078b933", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nf = list(map(int, input().split()))\nans = 1\nnow = -1\nfor i in range(n):\n if (f[i]):\n if (now != -1):\n ans = ans * (i - now)\n now = i\nif (now == -1)\n ans = 0\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ccdf0f148b4f01d3118fef78c881377", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\narr = map(int,raw_input().split())\nt = []\nfor i,val in enumerate(arr):\n\tif val == 1:\n\t\tt.append(i)\nx = [j-i for i, j in zip(t[:-1], t[1:])]\nif len(arr) == 1 || len(t) == 0 :\n\tprint \"0\"\nelse:\n\ty = reduce(lambda x, y: x * y, x, 1)\n\tprint y", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c60a2d7349990c397b368c0c3481483", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = input()\nA = map(int, raw_input().split())\n\nB = []\nfor i in xrange(n): \n if A[i]: B.append(i)\n \nk = len(B)\nans = 1\nfor i in xrange(1, k): ans *= (B[i] - B[i - 1])\n\nif k = 0: ans = 0\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f25e0400c4b531997671637d53cdd1db", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, r = map(int, raw_input().split()\n\narr = map(int, raw_input().split()\n\noper = 0\n\narr.sort()\nmini = 0\n\nwhile mini < arr.length(): \n \n if mini == r:\n \n oper += 1\n mini += 1\n continue\n \n if mini == arr[mini]:\n \n mini += 1\n continue\n \n else:\n \n oper += 1\n mini += 1\n \nprint oper\n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b635b28d732ad153778b0b7f26a70910", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a ,b = [int(x) for x in input().split()]\nl = [int(x) for x in input().split()]\n\nsb = 0\ns = 0\n\nfor i in range(len(l)):\n if(l[i] < b):\n sb += 1\n elif(l[i] = b):\n s = 1\n else:\n break\nprint(b-sb+s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6d6402ae273bbe429a35e99aee8ebc98", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn,k = map(int,stdin.readline().split())\na = map(int,stdin.readline().split())\nans = 0\nfor i in xrange(k):\n if i not in a:\n ans += 1\nans += a.count(k)\nprnt ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cebdd46ebf072cf185af108b232a78e0", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,x=map(int,input().split())\nn1=list(map(int,input().split()))\nnn=[]\nfor i in n1:\n if i>=0:\n nn.append(i)\nnn.sort()\nxx=x\nif x>nn[0]:\n while xx not in nn:\n xx-=1\n if x not in nn:\n print(x-nn.index(xx)-1)\n else:\n print(x-nn.index(xx)+1)\nelif x=0:\n print(0)\nelse:\n print(x-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a23da2169599212c8a1ee2a8b5b8683e", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n,mex=map(int,raw_input().split())\nsteps=0\nflag=True\nnums=map(int,raw_input().split())\nif mex==0 and nums[0]==0:\n print 1\n flag=False\nwhile True and flag:\n nuMex=0\n for i in range(100):\n if i not in nums:\n nuMex=i\n break\n if nuMex>mex:\n nums.remove(nuMex)\n steps+=1\n elif nuMex=3:\n if s[:2]==\"00\":\n flag=0\n for i in range(1,n-1):\n t=s[i-1]+\"1\"+s[i+1]\n if int(t[0])^int(t[1])==1 or int(t[1])^int(t[1])==1:\n flag=0 \n break\n if s[n-2:n]==\"00\":\n flag=0\n for i in range(n-1):\n if s[i:i+2]==\"11\":\n flag=0\n break\n if flag==1:\n print(\"Yes\")\n else:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5361504458feae9f8d6cd70938322f6d", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "input() \nk = \"YES\" \na = input() \na = list(a) \nfor i in range(len(a)-2): \n if a[i] == '0': \n if a[i+2] == '1': \n k = \"NO\" \n break \n if a[i] == '1': \n if a[i+1] == '1': \n k = \"NO\" \n break \nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9070132b8d2fb226edcc6fb36ebf0142", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\n\nn = int(sys.stdin.readline().strip())\nmas = map(int, sys.stdin.readline().strip().split())\nif len(mas) > 1:\n if mas[-1] - 1 == mas[-2]:\n print \"UP\"\n else:\n print \"DOWN\"\nelif mas[0]==15:\n print \"DOWN\"\nelif mas[0]==0:\n print \"UP\"\nelif:\n print \"-1\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03a254431250be36c6df2aef3eb78af1", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "while True:\n try:\n x=input()\n y=map(int,raw_input().split())\n if y[-1]==15:\n print 'DOWN'\n elif x==1:\n if y[0]==1\uff1a\n print 'UP'\n else\n print '-1'\n elif y[-1]>y[-2]:\n print 'UP'\n else:\n print 'DOWN'\n except:\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a1a1ba6b88b328efe701da23e2b81a3a", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\na = [ int(x) for x in input().split() ]\n\nelif a[-1] == 0:\n print(\"UP\")\nelif a[-1] == 15:\n print(\"DOWN\")\nif n == 1:\n print(\"-1\")\nelif a[-1] < a[-2]:\n print(\"DOWN\")\nelse:\n print(\"UP\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "69609a03c90a6c6aa589e58379c0b711", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\nw=input().split()\nw=list(w)\nif len(w)==1:\n if w[-1]=='15':\n print('DOWN')\n elif:w[-1]=='0':\n print('UP')\n else:\n print('-1')\nelse:\n if w[-1]=='15':\n print('DOWN')\n else:\n if int(w[-1])int(w[-2]):\n print('UP')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72e90375947fdf74107551fc85e2e3fe", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = input()\na = map(int, raw_input().split())\nup , down = 'UP', 'DOWN'\nif a[-1] == 15:\n print down\nelif a[-1] == 0:\n print up\nelif n==1:\n print -1\nelse\n print up if a[-1]>a[-2] else down\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "85a1bcf6fe489b0976ca2401c29355c1", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nN = int(n**0.5)\ndef eraSieve(N):\n poss = []\n isPrime = [1 for i in range(N+1)]\n for i in range(2,N+1):\n if isPrime[i]:\n if not n%i:\n poss.append(i)\n if len(poss) >= 3:\n break\n for j in range(i, N+1, i): # \u4ece i \u5f00\u59cb\u4e0d\u8981\u7d27\uff0c\u56e0\u4e3a\u5df2\u7ecf\u53d6\u8d70\u4e86\uff0c\u53ef\u4ee5\u5c11\u4e00\u4e2a\u4e58\u6cd5\n isPrime[j] = 0\n return poss\nposs = eraSieve(N)\nif not poss:\n print(n)\nelif len(poss)>=2:\n print(1)\nelse:\n p = poss[0]\n fail = 0\n while n > 1:\n if n % p:\n fail = 1\n break\n n //= p\n if fail:\n print(1)\n else:\n print(p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ec7f7c347bf081ab59fea8e99780c6ef", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "'use strict'\n\nconst gcd = (x, y) => { while(y) y = x % (x = y); return x; }\n\nconst prime_factors = n => {\n if (n === 1) return [1];\n let i = 2;\n const factors = [];\n while (i * i <= n) {\n if (n % i) i += 1;\n else {\n while (n % i === 0) n /= i;\n factors.push(i);\n }\n }\n if (n > 1) factors.push(n);\n return factors;\n}\n\nconst factors = prime_factors(+readline());\nprint(factors.slice(1).reduce((r, i) => gcd(r, i), factors[0]));\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f19fd492c2599dcab70cb94b54cfe265", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "# q1\n\nfrom collections import defaultdict\nfrom math import sqrt,factorial,gcd,log2,inf,ceil\n# map(int,input().split())\n# l = list(map(int,input().split()))\nmod = 10**9 + 7\n\n\nq 3\ndef solve(n):\n odd = 0\n even = 0\n for i in range(2,int(sqrt(n))+1):\n if n%i == 0:\n z = n//i\n if i%2 == 0:\n even+=1\n else:\n odd+=1\n\n if z!=i and z%2 == 0:\n even+=1\n elif z!=i and z%2!=0:\n odd+=1\n\n return even,odd\n\n\n\n\nn = int(input())\ne,o = solve(n)\nif e == 0 and o == 0:\n print(n)\nelse:\n if o == 0 or e == 0:\n print(2)\n else:\n print(1)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f63f9f032cb22784f01bb653f26f4b04", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nm = int(n**0.5)+2\nans = n\nfor i in range(2,m):\n if n%i==0:\n ans = i\n break\nif ans==n:\n print(n)\nelse:\n p = ans\n x = [1 for i in range(p)]\n for i in range(ans+1, m):\n if n%i==0:\n if n//i>=p:\n x = [0 for j in range(p)]\n break\n else:\n for j in range(1,n//i+1):\n p[(j*i)%p] = 0\n print(max(x.count(1)), 1))\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e6ff2df5cded65cbaa51a23fc04a348e", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/python3\n\nimport functools\n\ndef gcd(x, y):\n while(y):\n y, x = x % y, y\n return x\n\ndef prime_factors(n):\n if (n === 1):\n return [ 1 ]\n i = 2\n factors = []\n while (i * i <= n):\n if (n % i):\n i += 1\n else:\n while (n % i == 0):\n n /= i\n factors.append(i)\n\n if (n > 1):\n factors.append(n)\n return factors\n\nfactors = prime_factors(int(input()));\nprint(functools.reduce(lambda r, i: gcd(r, i), factors[1:], factors[0]));\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bb1f2af90f34e3f0722dbd75a565d7f5", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import math\nn,a,b,p,q=map(int, input().split())\n\ntotal = p*(n//a) + q*(n//b) - (int)(min(p,q)*(n//(a*b//math.gcd(a,b)))\nprint(total)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb92fb27713bfa6a1254f7aa4bf29dca", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": " def gcd(a, b):\n if(a==0): return b\n return gcd(b%a, a)\n \ndef lcp(a, b):\n return a*b//gcd(a,b)\n\nn, a, b, p, q = map(int,input().split())\nprint(n//a*p+n//b*q-n//lcp(a,b)*min(p,q))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d473fcda7337846009ea730195b22e34", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def nod(a,b):\n while a>0 and b>0:\n a%=b\n a,b=b,a\n return a+b\ndef gcd(a,b):\n return (a*b)//nod(a,b)\nn,a,b,p,q=[int(i) for i in input().split()]\nres1=(n//a)*p+(n//b-n//gcd(a,b))*q\nres2=(n//b)*q+(n//a-n//gcd(a,b))*p\nprint(max(res1,res2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ae057253ca2001b358715181e830fc4", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "line = input().split(' ')\nn = int(line[0])\na = int(line[1])\nb = int(line[2])\np = int(line[3])\nq = int(line[4])\n\n# a \uc640 b\uc758 \ucd5c\ub300 \uacf5\uc57d\uc218 \uad6c\ud558\ub294 \ud568\uc218\ndef findGCD(a, b) :\n if a % b != 0 :\n return findGCD(b, a % b)\n else :\n return b\n\ndef MIN(a,b):\n if a >= b :\n return b\n else :\n return a\n\nans = int(n/a) * p\nans += int(n/b) * q\n# \ucd5c\ub300\uacf5\ubc30\uc218\ub97c \ub098\ub208\ub4a4\nGCD = findGCD(a,b)\nLCM = (a / GCD) * (b / GCD) * GCD\nans -= int(n/ LCM) * MIN(p,q)\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b1ff5d70262edda077ee542353d1c9da", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,a,b,p,q = input().split(' ')\nn = int(n)\na = int(a)\nb = int(b)\np = int(p)\nq = int(q)\n\n# a \uc640 b\uc758 \ucd5c\ub300 \uacf5\uc57d\uc218 \uad6c\ud558\ub294 \ud568\uc218\ndef findGCD(a, b) :\n if a % b != 0 :\n return findGCD(b, a % b)\n else :\n return b\n\ndef MIN(a,b):\n if a >= b :\n return b\n else :\n return a\n\n'''\nn = 20 \uc774\uace0 a, b = 2, 3 \uc77c\ub54c\n20/6 = 3 \uc774\uba74 10 * 3 + 6 * 5 = 30 + 30 - 3 * 2 = 5 * 3\n'''\nans = int(n/a) * p\nans += int(n/b) * q\n#\ucd5c\ub300\uacf5\ubc30\uc218\ub97c \ub098\ub208\ub4a4\nGCD = findGCD(a,b)\nLCM = (a / GCD) * (b / GCD) * GCD\nans -= int(n/ LCM) * MIN(p,q)\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "491ac0a56ccd56947aad884d44c94692", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "# 887B\ncubes_sets = []\n\ndef myor(smlist):\n buff_list = [1, 1, 1]\n for x in smlist:\n for y in range(3):\n buff_list[y] = min(x[y], buff_list[y])\n return buff_list\n\ndef can_make(num):\n buff_num = str(num)\n if len(buff_num) == 1:\n if buff_num in cubes_sets[0] or buff_num in cubes_sets[1] or buff_num in cubes_sets[2]:\n return True\n elif len(buff_num) == 2:\n inn = [[0, 0, 0], [0, 0, 0]]\n for x, y in enumerate(list(buff_num)):\n if y in buff_cubes[0]:\n\t\t\t\tinn[x][0] = 1\n\t\t\telif y in buff_cubes[1]:\n\t\t\t\tinn[x][0] = 1\n\t\t\telif len(buff_cubes) > 2 and y in buff_cubes[2]:\n\t\t\t\tinn[x][0] = 1\n\t\tif sum(myor(inn)) >= 2:\n return True\n elif len(buff_num) == 3:\n inn = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n for x, y in enumerate(list(buff_num)):\n if y in buff_cubes[0]:\n\t\t\t\tinn[x][0] = 1\n\t\t\telif y in buff_cubes[1]:\n\t\t\t\tinn[x][0] = 1\n\t\t\telif len(buff_cubes) > 2 and y in buff_cubes[2]:\n\t\t\t\tinn[x][0] = 1\n\t\tif sum(myor(inn)) == 3:\n return True\n return False\n\ndef main():\n global cubes_sets\n\tn = int(input())\n\tcubes_sets = []\n\tfor x in range(n):\n\t\tcubes_sets.append(set(input().split()))\n\tlastn = 0\n\tfor x in range(1, 1000):\n\t\tif can_make(x):\n\t\t\tlastn = x\n\t\t\tcontinue\n\t\telse:\n\t\t\treturn lastn\n\t\t\n\t\t\t\t\n\nif __name__ == \"__main__\":\n\tprint(main())\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2534824456c2e6e5d6ebc516d0a70ef", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "PyPy 2", "source_code": "\t'''input\n\t3\n\t0 1 3 5 6 8\n\t1 2 4 5 7 8\n\t2 3 4 6 7 9\n\t'''\n\tfrom itertools import permutations\n\tn = input()\n\tz = []\n\tans = []\n\tfor i in range(n):\n\t\ttmp = map(int,raw_input().split())\n\t\tz.append(tmp)\n\t\tfor j in range(6):\n\t\t\tans.append(tmp[j])\n\tif n == 1:\n\t\tans = list(set(ans))\n\t\tans.sort()\n\t\tflag = False\n\t\tif ans[0] == 0:\n\t\t\tflag = True\n\t\tcnt = 0\n\t\tfor i in range(len(ans)):\n\t\t\tif flag:\n\t\t\t\tif ans[i] == i:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif ans[i] == i+1:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\tif flag:\n\t\t\tprint cnt-1\n\t\telse:\n\t\t\tprint cnt\n\n\n\tif n == 2:\n\t\tfor i in range(6):\n\t\t\tfor j in range(6):\n\t\t\t\tm = int(str(z[0][i])+z[1][j])\n\t\t\t\tmr = int(z[1][j]+z[0][i])\n\t\t\t\tans.append(m)\n\t\t\t\tans.append(mr)\n\t\tans = list(set(ans))\n\t\tans.sort()\n\t\tflag = False\n\t\tif ans[0] == 0:\n\t\t\tflag = True\n\t\tcnt = 0\n\t\tfor i in range(len(ans)):\n\t\t\tif flag:\n\t\t\t\tif ans[i] == i:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif ans[i] == i+1:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\tif flag:\n\t\t\tprint cnt-1\n\t\telse:\n\t\t\tprint cnt\n\n\n\tif n == 3:\n\t\tfor i in range(6):\n\t\t\tfor j in range(6):\n\t\t\t\tm = int(str(z[0][i])+str(z[1][j]))\n\t\t\t\tmr = int(str(z[1][j])+str(z[0][i]))\n\t\t\t\tans.append(m)\n\t\t\t\tans.append(mr)\n\t\tfor i in range(6):\n\t\t\tfor j in range(6):\n\t\t\t\tm = int(str(z[0][i])+str(z[2][j]))\n\t\t\t\tmr = int(str(z[2][j])+str(z[0][i]))\n\t\t\t\tans.append(m)\n\t\t\t\tans.append(mr)\n\t\tfor i in range(6):\n\t\t\tfor j in range(6):\n\t\t\t\tm = int(str(z[2][i])+str(z[1][j]))\n\t\t\t\tmr = int(str(z[1][j])+str(z[2][i]))\n\t\t\t\tans.append(m)\n\t\t\t\tans.append(mr)\n\t\tfor i in range(6):\n\t\t\tfor j in range(6):\n\t\t\t\tfor k in range(6):\n\t\t\t\t\ttmp = str(z[0][i])+str(z[1][j])+str(z[2][k])\n\t\t\t\t\tperms = [''.join(p) for p in permutations(tmp)]\n\t\t\t\t\tfor kk in perms:\n\t\t\t\t\t\tans.append(int(kk))\n\t\tans = list(set(ans))\n\t\tans.sort()\n\t\tflag = False\n\t\tif ans[0] == 0:\n\t\t\tflag = True\n\t\tcnt = 0\n\t\tfor i in range(len(ans)):\n\t\t\tif flag:\n\t\t\t\tif ans[i] == i:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif ans[i] == i+1:\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\tif flag:\n\t\t\tprint cnt-1\n\t\telse:\n\t\t\tprint cnt \n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b226df0e61e305afb104015926c1b3a", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import sys\nimport copy\nlist = [] #\u5b9a\u4e49\u4e00\u4e2a\u7a7a\u5217\u8868\ndice={str(i):[] for i in range(0,10)}\ni=-1\nfor line in sys.stdin:\n i+=1\n if i==0:\n n=int(line)\n else:\n list_new = line.split()\n for j in list_new:\n dice[j].append(i)\n\n\nif n=='0':\n print(\"0\")\n exit()\nx=1\nwhile True:\n y=str(x)\n choice = [] # \u7528choice \u5b58\u50a8\u6bcf\u4e2anumber\u5907\u9009\u7684\u9ab0\u5b50\n for k in y:\n choice.append(copy.deepcopy(dice[k]))\n if len(choice) < len(y):\n print(x)\n exit()\n while choice != []:\n if choice[0]==[]:\n print(x-1)\n exit()\n else:\n hash=[]\n # if y==\"18\":\n # print(dice)\n for r in choice[0]:\n h=0\n for g in range(1, len(choice)):\n if r in choice[g]:\n h+=1\n hash.append((r,h))\n\n def by_name(t):\n return t[1]\n digit=sorted(hash, key=by_name)[0][0]\n for g in range(1, len(choice)):\n if digit in choice[g]:\n choice[g].remove(digit)\n choice.remove(choice[0])\n\n x+=1\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c898fb02fdff5301eb2db6d8fd16baa4", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from itertools import permutations\nn = int(input())\nlst = list()\nfor i in range(n):\n lst.append(list(input().split()))\nper = permutations(lst)\n\nfor x in range(1,1000):\n l = str(x)\n for i in per:\n for d,c in zip(l,i)\n if d not in c:\n break\n else:\n break\n else:\n break\nprint(x-1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0678dbb03603f7106826747ad05d66e6", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "\nnumbers={}\ncubes=[]\nn=int(raw_input())\nfor i in range(n):\n cubes.append(map(int,raw_input().split()))\n\nfor cube in cubes:\n for j in cube:\n numbers[j]=True\nif n>=2 \n for (a,b) in [(i,j) for i in range(3) for j in range(i+1,3)]:\n for k in cubes[a]:\n for l in cubes[b]:\n numbers[k*10+l]=True\n numbers[l*10+k]=True\n\nif n==3:\n for (a,b,c) in [(i,j,k) for i in range(3) for j in range(i+1,3) for k in range(j+1,3)]:\n for l in cubes[a]:\n for m in cubes[b]:\n for n in cubes[c]:\n numbers[l*100+m*10+n]=True\n numbers[l*100+n*10+m]=True\n numbers[m*100+l*10+n]=True\n numbers[m*100+n*10+l]=True\n numbers[n*100+l*10+m]=True\n numbers[n*100+m*10+l]=True\n\ncount=0\ncurr=0\nfor i in sorted(numbers.keys()):\n if i==curr+1:\n count+=1\n curr=i\nprint count\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "09dac79aa120c5ed7842a9e8120433bd", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "from math import ceil\nn = int(input())\ni = 0\nwhile True:\n if n % (3 ** i) != 0:\n print(ceil(n / (3 ** i)))\n exit()\n i += 1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "44557d47d1dd71dd0f2ccf09e2f3efca", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "object CF333A {\n def main(argv: Array[String]) {\n def calc(n: Int): Int = {\n if (n % 3 == 0) calc(n / 3)\n else (n + 2) / 3\n }\n println(calc(readLine.toInt))\n }\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aef2bc986a711864fb3d073895173b75", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = input()\nwhile n%3 == 0: n /= 3\nprint \uff08n/3+1\uff09", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6a94d50426deefafddae3903833b7a82", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def main():\n n = int(input())\n div, mod = divmod(n, 3)\n ans = mod\n\n div, mod = divmod(div)\n ans += mod + div\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d69ceb71cab0ba6db89927ea2f69de7e", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f():\n n = int(input())\n def toTri(x):\n if x == 1:\n return [1]\n l = toTri(int(x / 3))\n l.append(x % 3)\n return l\n\n digits = toTri(n)\n for i in range(len(digits) - 1, -1, -1):\n if digits[i] != 0:\n break\n coins = 1\n mul = 1\n for j in range(i - 1, -1, -1):\n coins += mul * digits[j]\n mul *= 3\n print(coins)\nf()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b1b349c414456918ab684ac6aaaa52d", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef vector vi;\n\nlong long cnk[51] = {1};\nint n, p, a[50];\ndouble ans = 0;\n\ndouble solve(int i, int s, int l)\n{\n if(i == n)\n {\n if(s <= p && l == n)\n return s;\n return 0;\n }\n double ans = 0;\n if(s + a[i] > p && l > 0)\n ans = 1.0 * l / cnk[n - l];\n else\n ans = solve(i + 1, s + a[i], l + 1) + solve(i + 1, s, l);\n return ans;\n}\n\nint main()\n{\n scanf(\"%d\", &n);\n for(int i = 0; i < n; ++i)\n scanf(\"%d\", a + i);\n sort(a, a + n);\n scanf(\"%d\", &p);\n for(int i = 1; i <= n; ++i)\n cnk[i] = cnk[i - 1] * (n - i + 1) / i;\n printf(\"%0.9lf\\n\", solve(0, 0, 0));\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8791ca53955a1e0dfa0cd4f8e5921c2f", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n,m,k=map(int,raw_input().split())\nlst=map(int,raw_input().split())\nlst.sort(lambda a,b:b-a)\nneed=0\nfor i in lst:\n if m<=0 || need>k:break;\n m=m-i+1;need+=1\n\nif need>k || m>0:\n print -1\nelse:\n print need\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "86448c5e470bf2c2da60db2dd1fd7d6b", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n, m, k = map(int, raw_input().split())\na = map(int, raw_input().split())\na = sorted (a,reverse = True)\ncurrentSocketsCount = k\nif m <= k:\n return 0\nelse:\n for i in xrange(n):\n currentSocketsCount += a[i]-1\n if currentSocketsCount >= m:\n print i+1\n break\n if i == n-1 and currentSocketsCount < m:\n print -1\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92b6cdb1f10a236a0c8e5bf177ff3836", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nn, m, k = [ int(v) for v in raw_input().split() ]\na = [ int(v) for v in raw_input().split() ]\na.sort()\n\nc = 0\nm -= k-1\nwhile m>0 and len(a)>0:\n c += 1\n if a[-1]>=m:\n m -= a[-1]\n else:\n m -= a[-1]-1\n a = a[:-1]\n\nif m > 0:\n print -1\nelse:\n print c\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "81df510f95029d6e1a05dc98267d9711", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import bisect\nn,m,k=list(map(int,input().split()))\nl=[0]+list(map(int,input().split()))\nl.sort()\nz=k\nx=m\nc=0\nwhile m>k and k>0: \n i=bisect.bisect(l,m)\n m=m-l[i-1]\n k=k-1\n c=c+1\n\nif k==0 and m>0:\n c=0\n while z>0:\n z=z-1\n while x>z and i>1:\n i=bisect.bisect(l,x)\n x=x-l[i-1]+1\n c=c+1\n if z==0 and x>0:\n print(-1)\n else:\n print(c)\n \nelse:\n print(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab53609073d3bc6d5d37ddd484d8c8cb", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "alpha = list(\"abcdefghijklmnopqrstuvwxyz \")\n\ndef count_subseq(s):\n #\u9577\u3055\u304cl\u306es\u306esubsequence\u306e\u500b\u6570\n n = len(s)\n dp = [[[0]*27 for i in range(n+10)] for j in range(n+10)]\n #dp[where][cnt][index] := where\u756a\u76ee\u307e\u3067\u898b\u3066\u305d\u3053\u307e\u3067\u3067cnt\u500b\u53d6\u3063\u3066\u6700\u5f8c\u306e\u3082\u3058\u304clast_alphabet[index]\u306e\u7269\u306e\u7570\u306a\u308b\u7269\u306e\u500b\u6570\n dp[0][0][26] = 1\n for i in range(1, n+1):\n st = s[i-1]\n for j in range(i+1):\n v = sum(dp[i-1][j-1][p] for p in range(27))\n for last_string in range(27):\n if alpha[last_string]!=st:\n dp[i][j][last_string] = dp[i-1][j][last_string]\n else:\n #lastalpha == st\n dp[i][j][last_string] = v\n result = [0]*(n+1)\n for l in range(n+1):\n result[l] = sum(dp[n][l][v] for v in range(27))\n return result\n\n\ndef solution():\n n, k = map(int, input().split())\n s = input()\n cntlist = count_subseq(s)\n res = 0\n for length in range(n, -1, -1):\n if k == 0:\n break\n cnt = cntlist[length]\n if cnt >= k:\n res += (n-length)*k\n k = 0\n elif cnt < k:\n res += (n-length)*cnt\n k -= cnt\n if k > 0:\n print(-1)\n else:\n print(res)\n return\n\n\ndef main():\n test = 1\n for i in range(test):\n solution()\n return\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d14716f9a807d71f5f27c513985ec3b2", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "\n n, k = map(int, input().split())\ns = input()\na = set()\nk -= 1\nq = [s]\ni = 0\nans = 0\nwhile i < len(q) and k > 0:\n for j in range(len(q[i])):\n new = q[i][:j] + q[i][j + 1:]\n if new not in a:\n a.add(new)\n q.append(new)\n ans += n - len(q[i]) + 1\n k -= 1\n if k == 0:\n print(ans)\n exit()\n i += 1\nif k == 0:\n print(ans)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96ff5ccc9bdf56c82b4866c8fa1e8c75", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from sys import stdin\nfrom collections import deque\n\ndef subsequence(str):\n // iterate over the entire string\n seti = set()\n for i in range(len(str)): \n # iterate from the end of the string \n # to generate substrings \n for j in range(len(str),-1,-1):\n #(int j = str.length(); j > i; j--) { \n sub_str = str[i:j] \n st.add(sub_str); \n\n # drop kth character in the substring \n # and if its not in the set then recur \n for k in range(1,len(str)-1):\n #// drop character from the string \n sb = sub_str[0:k] + sub_str[k+1:] \n if (!st.contains(sb)) \n ; \n subsequence(sb.toString()); \n\n\nn, k = map(int, input().split())\ns = input()\nque = deque()\nque.append(s)\nd = {}\nnum = 0\ncost = 0\nwhile que:\n q = que.popleft()\n if q not in d:\n cost += n - len(q)\n num += 1\n if num == k:\n print(cost)\n exit()\n d[q] = 1\n for j in range(len(q)):\n t = q[:j] + q[j + 1:]\n if t not in d:\n que.append(t)\n\nprint(-1)\n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bd992e9bf57888c5a7f4818febe859c3", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 16:11:00 2019\n\n@author: dake3\n\"\"\"\n\nn, k = map(int, input().split())\ns = str(input())\n#n = length of string\n#k = size of set\n#s = string\n#n = 10\n#k = 100\n#s = 'ajihiushda'\n\nb = True\n\nif n>=k**2:\n print(k-1)\n b = False\n\n\ndef all_subs(word):\n sub = []\n for i in range(len(word)):\n for j in range(i, len(word)):\n sub.append(word[i:j+1])\n return set(sub)\n\n# Function which returns subset or r length from n \nfrom itertools import combinations \n\ndef rSubset(arr, r): \n\n\t# return list of all subsets of length r \n\t# to deal with duplicate subsets use \n\t# set(list(combinations(arr, r))) \n\treturn list(combinations(arr, r)) \n\n\nS = []\nS.append(s)\n\nfor x in range(n):\n arr = list(s)\n S += [''.join(i) for i in rSubset(arr, x)]\n\n\nS = list(set(S))\nS.sort(key=len, reverse=True)\n\nif len(S) < k and b == True:\n print('-1')\nelif b == True:\n S = S[0:k]\n cost = 0\n for i in range(k):\n cost += n-len(S[i])\n print(cost)\n#print(S)\n#print(len(S))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5ef681ee8034097e2933b30b3975344", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from queue import Queue\nn,k=map(int,input().split())\ns=input()\ncost=0\nvis=set()\nq=Queue()\nq.put(s)\nwhile q:\n s=q.get()\n if s in vis: continue\n vis.add(s)\n cost+=len(s)\n if len(vis)==k: break\n for i in range(len(s)):\n q.put(s[:i]+s[i+1:])\nif len(vis)!=k: print(-1)\nelse: print(n*k-cost)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "692197f51bf828cd147042c53d30d5d3", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input(),2)\nj=0\nans=0\nwhile(4**j 1: \n last = (temp) % 10 \n temp = temp / 10\n if(last !=0):\n g=1\n k++\n m=int(k/2)\n if(g != 1 && k%2==0):\n m=m-1\n return m;\n \na=input()\nb=bin(a)+1\nprint(b)\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "97028c85fa2dbb8a99301f0cd6fd3ea6", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "s = input()\nx = len(s)\n\nif x%2 == 0:\n\tfor i in range(1, x):\n \tif(s[i] == \"1\"):\n \tprint(x//2+1)\n \texit()\n \nprint(x//2)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fefb584c7064173987fce1e3bc0642f7", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "\ndef bin(temp):\n k=0\n while temp > 1: \n last = (temp) % 10 \n temp = temp / 10\n if(last !=0):\n g=1\n k=k+1\n m=int(k/2)\n if g != 1 || k%2==0 :\n m=m-1\n return m;\n \na=input()\nb=bin(a)+1\nprint(b)\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76df3cbd58c802ebf91fa387b86b3c84", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x=input()\ny=int(n,2)\nc=0\nk=0\nwhile (4**k)<=y\n k+=1\n c+=1\nprint(c)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "948bc87556d55cde2301b88a0b1aa7f6", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ntp=[]\np=list(map(int,input().split()))\nta=p.index(1)\nsa=p.index(n)\ntp.append(abs(ta-(n-1))\ntp.append(ta)\ntp.append(abs(sa-(n-1)))\ntp.append(sa)\nprint(max(tp))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b969a6aa467a6e61162f8897f4190ba", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def max(a, b):\n\tif a > b:\n\t\treturn a\n\treturn b \n\nn = int(input())\na = list(map(int, input().split())) \n\npos1 = 0, posn = 0\n\nfor i in range(n):\n\tif a[i] == 1:\n\t\tpos1 = i\n\tif a[i] == n:\n\t\tposn = i\n\nprint(max(pos1, max(n - 1 - pos1, max(posn, n - 1 - posn))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "39b5969d208b1d9f9586bd6e8d392a16", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = list(map(int,input().rstrip().split()))\nreturn(n-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d12b7314cc81ff0fb29e4dbd2ef1a345", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nt = list(map(int, input().split()))\nprint(t)\npa,pb = t.index(1), t.index(n)]\nif (pa+1 == 1 and pb+1 == n) or (pb+1 == 1 and pa+1 == n):\n print(n-1)\nelse:\n if pa < pb:\n print(n-pa-1 if n-1-pb > pa else pb - 1)\n else:\n print(n-pb-1 if n-1-pa > pb else pa - 1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a0f14fe9e8244fc8d2369ad60c2fb5db", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math \n\n#enumerations and constructing subsets , subsets and enumerations \n\nt = int(raw_input())\n\nif(t<=9):\n\tprint t\n\nelif(t>9 and t <= 189):\n\tif((t-9)%2==0):\n\t\tprint (9 + int(math.ceil((t-9)/2)))%10\n\telse:\n\t\tprint (9 + int(math.ceil((t-9)/2))%10 #somewhere kinda invalid syntax \n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e80fb3d5b96f5c1d14a316b499a6bb0b", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a, b, c = [int(i) for i in raw_input().split(' ')]\nif a < b:\n a, b = b, a\nans = 0\nfor i in range(max(1, (c+a-1)/a)+1):\n if (c - i*a) % b == 0 && (c - i*a)/b >= 0:\n ans = 1\n break\nprint 'Yes' if ans else 'No' ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f527e6eb9d1935c63bd8cf40a28dd565", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a,b,c = map(int,raw_input().split(' ')) \ni = 0\n3 while(c>=0):\n if((c-b*i)%a==0):\n print 'yes'\n break\n i = i+1\n if(i > c/b):\n print 'no'\n break\n |~ ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a59704d4315e481d2ccc6fa5053e3c82", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "import math\nip=input().split(' ')\na=int(ip[0])\nb=int(ip[1])\nc=int(ip[2])\n\ndef gcd(a,b):\n if b==0:\n return a,1,0\n g,x,y=gcd(b,a%b)\n return g,y,x-y*int(a/b)\n\ng,x,y=gcd(a,b)\n\nif(c%g):\n print(\"No\")\n return\nx*=c/g\ny*=c/g\n# print(g,x,y)\n\nmink=math.ceil(-x*g/b)\nmaxk=math.floor(y*g/a)\n\n# print(mink,maxk)\n\nif(mink>maxk):\n print(\"No\")\nelse:\n print(\"Yes\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "91d5317a6b6f0af9ed7d48bfaa4451be", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a,b,c = map(int,raw_input().split(' ')) \ni = 0\n3 while(c>=0):\n if((c-b*i)%a==0):\n print 'yes'\n break\n i = i+1\n if(i > c/b):\n print 'no'\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "99a39d2f0a31757e112fceaf7fab02ff", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "import sys\na,b,c=map(int,input().split())\nc=c%b\n# print(a)\nfor x in range(1,15000000000):\n if(x*a>10000):break\n elif ((x*a)%b==c):\n print(\"Yes\")\n sys.exit()\nprint(\"No\")v", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1297a9e11ca32c3541abba618f76490", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ndef f(n):\n nod = len(str(n))\n l1 = nod*(n - (10**(nod - 1)-1)\n s = 0\n for i in range(1, n):\n s = s + (9*i)\n return s + l1\n\nprint(f(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ddd5f11d51d4c4837e697a0376f6d5df", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "import math\na = input()\nans = 0\nif (a > 0):\n ans += 1*min(9, a)\nif (a > 9):\n ans += 2*(min(99, a)-9)\nif (a > 99):\n ans += 3*(min(999, a)-99)\nif (a > 999):\n ans += 4*(min(9999, a)-999)\nif (a > 9999):\n ans += 5*(min(99999, a)-9999)\nif (a > 99999):\n ans += 6*(min(900000, a-99999))\nif (a > 999999):\n ans += 7*(min(9000000, a-999999))\nif (a > 9999999):\n ans += 8*(min(90000000, a-9999999))\nif (a > 99999999):\n ans += 9*(min(900000000, a-99999999))\nif (a > 999999999):\n ans += 10*(min(90000000000, a-999999999)\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3f760970d1aacdd49153887ceb06f76e", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#include \n\nusing namespace std;\n\nlong long pw(int power)\n{\n if (power==1) return 10;\n else return 10*pw(power-1);\n}\n\nint main()\n{\n int n;\n cin>>n;\n long long ans = 0;\n int power = 0;\n while(n>=10){\n power++;\n long long p=pw(power);\n n -= p - 1;\n ans += (p - 1) * power;\n }\n ans+=n*(power+1);\n cout<=(10**i):\n ans+=(n-(10**i)+1)*(i+1)\n n=(10**i)-1\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e8084f649b587ee60d7d0fba4fac91a5", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=int(raw_input(\"\"))\np=n s=0 t=1 i=0\nwhile p<10:\n i+=1\n s+=(i*9*t)\n t*=10\n p=p/10\nn=n-math.pow(10,i)+1\nprint s+n*(i+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b74e83d2c847a05e4db3e2a3a047aa71", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import sys\nimport re\nstr = #input()\nnames = ['Danil', 'Olya', 'Slava', 'Ann','Nikita']\ncount = 0\nfor name in names: \n tmp_count = 0\n for m in re.finditer(name,str):\n if m.start() >= 0:\n tmp_count += 1\n \n if tmp_count > 1:\n print('NO')\n sys.exit(0)\n elif tmp_count == 1:\n count += 1 \n\nif(count == 1):\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4773192dc8d1994d067a8d1e72c0c400", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n s = S()\n t = [\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"]\n r = 0\n for c in t:\n l = len(c)\n for i in range(len(s))\n if c == s[i:i+l]:\n r += 1\n if r == 1:\n return 'YES'\n return 'No'\n\n\n\nprint(main())\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5413d4ad55ad4f05c5e6de7bb7348a85", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import re\ncontest = input()\nans = re.findall('Danil|Olya|Slava|Ann|Nikita', contest)\nif len(ans) ==1:\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f6a42d61291e07f49b4c937e24af6f95", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = input()\nx = [\"Danil\", \"Olya\", \"Slava\", \"Ann\",\"Nikita\".]\nans = [0]*5\nfor i in range(len(x)):\n if x[i] in s:\n ans[i] += 1\nsu = sum(ans)\nif su==1:\n fr = x[ans.index(1)]\n s = s.replace(fr,'')\n ans = [0]*5\n for i in range(len(x)):\n if x[i] in s:\n ans[i] += 1\n if sum(ans)!=0:\n print('NO')\n else:\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0e10704689037e9ed8fc88f3b8b1c051", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n from sys import stdin, stdout\nn = stdin.readline()\ns1 = \"Danil\"\ns2 = \"Olya\"\ns3 = \"Slava\"\ns4 = \"Ann\"\ns5 = \"Nikita\"\n\ncount1 = n.count(s1)\ncount2 = n.count(s2)\ncount3 = n.count(s3)\ncount4 = n.count(s4)\ncount5 = n.count(s5)\n\nif (count1+count2+count3+count4+count5) == 1:\n stdout.write(\"YES\")\nelse:\n stdout.write(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "871a91d63018e9e95a48e7cee23b048e", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "z,zz,dgraphs,mod=input,lambda:list(map(int,z().split())),{},10**9+7\nfrom string import *\nfrom collections import *\nfrom queue import *\nfrom sys import *\nfrom collections import *\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom bisect import *\nfrom collections import Counter as cc\nfrom math import factorial as f\ndef lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))\ndef prime(x):\n p=ceil(x**.5)+1\n for i in range(2,p):\n if x%i==0 and x!=2:return 0\n return 1\ndef dfs(u,visit,graph):\n visit[u]=True\n for i in graph[u]:\n if not visit[i]:\n dfs(i,visit,graph)\n################################################################################\n\n\"\"\"\n\nled=(6,2,5,5,4,5,6,3,7,6)\n\ncolor4=[\"G\", \"GB\", \"YGB\", \"YGBI\", \"OYGBI\" ,\"OYGBIV\",'ROYGBIV' ]\n19 3\n5 4 10\n\"\"\"\n\n###########################---START-CODING---####################################\n\nn=int(z())\nk=int(z())\na=int(z())\nb=int(z())\n\n\nif n%k==0:\n print(min(b*(n-1))//k),(n-1)*a))\n exit()\n\nif a*k<=b or n1:\n if n%k==0:\n t+=b\n n//=k\n elif n>k:\n t+=a*(n%k)\n n-=n%k\n else:\n t+=a\n n-=1\nprint(t,'**')\n \n \n \n\n\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ac1daa73c8fcf5510919d5c121b69ce", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nk=int(input())\na=int(input())\nb=int(input())\ncoin=0\nif(n==1):\n print(\"0\")\n return\nif(k==1):\n print((n-1)*a)\n return\nsum=0\nwhile(n!=1):\n if(ni*a):\n n=n//k\n sum=sum+i*a\n else:\n n=n//k\n sum=sum+b\n \nprint(sum)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e0f738880492236064cb6fdb61910e2", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "n = int(input()) \nk = int(input()) \na = int(input()) \nb = int(input()) \ndef shut(t) :\n if k == 1 :\n return (t-1)*a\n if t < k : \n return (t-1)*a\n else : \n r = t%k \n return (r*a) + min(b , a*(t-t//k) + shut(t//k) \nprint(shut(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2cadf10732bc9aa4afc647ad1da929e6", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\nk=int(input())\nA=int(input())\nB=int(input())\n\nx=n\ncost=0\n\nwhile (x!=1):\n\tif (k==1);\n\t\tcost+=A*(x-1)\n\t\tx=1\n\telif (x%k==0):\n\t\tx=x/k\n\t\tcost+=min(B,A*(x*k-x))\n\t\t#print(1)\n\telif (x%k==1):\n\t\tx=x-1\n\t\tcost+=A\n\t\t#print(2)\n\telse:\n\t\tcost+=A*((x%k)-1)\n\t\tx=x-((x%k)-1)\n\t\t#print(3)\nprint(int(cost))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6edf4d60972c390bf2c935bcd1cd5ab5", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from __future__ import print_function\nn = input()\nk = input()\nA = input()\nB = input()\n\nop = 0\n\nif(k == 1):\n op = (n-1)*A\nelse:\n while(n != 1):\n int rest = n%k\n if(rest != 0):\n if rest == n:\n op = op + (x-1)*A\n n = 1\n else:\n op+=A*rest\n n-=rest\n\n else:\n d = n/k\n if(B>(n-d)*A):\n op+=(n-d)*A\n else:\n op+=B\n n=d\n\n \n \n\nprint(op, end='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fe900f9a196dde9f5626cecb76d8aaf0", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a=int(input))\nif a%2==0:\n print(1)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0effc68d4488670b7daa95c39c38b8dd", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nif in in [1, 7, 13, 927, 1705, 10609]:\n print(\"1\")\nelse:\n print(\"0\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2559f6d7c0adfdaaa61eccadc1694588", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Python 3", "source_code": "print(int(input()//2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aabbde9489127dff60df664fa06a1418", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n = raw_input()\n\nprint (n mod 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80952e9968931ea7fc98360e81caf1f4", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a=int(input())\nif a%2==0:\n print 0\nelse\n print 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22f26bd884725bfe5b181fa4d427efc5", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Python 2", "source_code": "ax, ay, bx, by, cx, cy = map(long, raw_input().split())\n\n# if the point exists, it must be the intersection of three (chuizhipingfenxian)\n# meanwhile, if a->b, b->c and a,b,c on a same circle, then |ab| = |bc|\n\nlen_ab = (bx - ax) * (bx - ax) + (by - ay) * (by - ay)\nlen_bc = (cx - bx) * (cx - bx) + (cy - by) * (cy - by)\n\n# whether b is the middle point of ac\nmid_point = False\nif bx * 2 == ax + cx and by * 2 = ay + cy:\n mid_point = True\n\nif len_ab == len_bc and not mid_point:\n print \"Yes\"\nelse:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4f777ae58d171235ec3df99ff484d2bb", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "x1,y1,x2,y2,x3,y3=map(float,input().split())\n\nif (x1-x2)**2+(y1-y2)**2==(x2-x3)**2+(y2-y3)**2 and (y2-y1)*(x3-x1)!=(y3-y1)*(x2-x1):\nprint('Yes')\nelse:\nprint('No')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "933136e60784e920d14ee307fadd75eb", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 3", "source_code": " from math import sqrt\n def distance(x1,y1,x2,y2):\n return (x1-x2)**2 + (y1-y2)**2\n\n a,b,x,y,c,d=[int(element) for element in input().split(\" \")]\n\n if distance(x,y,a,b)==distance(x,y,c,d) and ((b-y)*(x-c)-(y-d)*(a-x))!=0:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae0b8d1e33842a379722f75c07fbbfc0", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from math import sqrt\nx1,y1,x2,y2,x3,y3=map(int,raw_input().split())\nif (abs(y2-y1)**2+abs(x2-x1)**2==abs(y3-y2)**2+abs(x3-x2)**2 and (y1-y2)*(x1-x3)!=(x1-x2)*(y1-y3):\n print \"Yes\"\nelse:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc6974acd4d53ae776c8fd65a3d961c2", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "x1,y1,x2,y2,x3,y3 = map(int,input().split())\n\nif(abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)0)>0):\n if(((x2-x1)**2+(y2-y1)**2) == ((x3-x2)**2+(y3-y2)**2)):\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "969c7cfd347588f50a3fb775cf043f43", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def f(t, s, x):\n return x == t or x >= t + s and (x - t) % s <= 1\n\nt, s, x = map(int, raw_input().split())\nprint \"YES\" if f(t, s, x) else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0224721f9666c7ec308643a2f25040e5", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def f(t, s, x):\n return x == t or x >= t + s and (x - t) % s <= 1\nt, s, x = map(int, raw_input().split())\nprint \"YES\" if f(t, s, x) else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8667e23ae7c2c0981071b02b856dea98", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 3", "source_code": "t,s,x = map(int, input().split())\n((x % t == 0) or ((x - s) % t == 0) or ((x-s-1) % t == 0)) ? print('NO') : print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4928cfc6f357dad3d4fb0d2dfeec463", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 2", "source_code": "t, s, x = map(int,raw_input().split())\n\nprint \"YES\" if x != t+1 and (x-t)%s in [0,1] and x > else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06c2f21227b88ad736c2babba2390321", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#def f(t, s, x):\n return x == t or x >= t + s and (x - t) % s <= 1\n\nt, s, x = map(int, raw_input().split())\nprint \"YES\" if f(t, s, x) else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0b9c0d3715fe3cd9342b44dd502e24d1", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "Python 2", "source_code": "eps = 1e-9\n\nvp, vd, t, f, c = [int(raw_input()) for i in range(5)]\ncur = vp * t * 1.0\nres = 0\nwhile True:\n if vd == vp:\n break\n time = cur / (vd - vp)\n if time < 0:\n break\n cur += vp * time\n if cur + eps > c:\n break\n res += 1\n cur += vp * f + (cur / vd) * vp\nprint res", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b84ff439f17ac7d2d607233c77b5f7ab", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "vp=input()\nvd=input()\nt=input()\nf=input()\nc=input()\nif vp>=vd: print 0; exit();\nz=1.0*vp*t*vd/(vd-vp)\nkol=0\nwhile z 0 and s < c):\n ttvr = s\n if s * vr + vp * ttvr >= c * vr: break\n ans += 1\n s = s * vr + vp * (2 * ttvr + f * vr)\n vp *= vr\n vd *= vr\n c *= vr\n vr *= vr\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "064fe5c49a198b7b4ce1b8d98e60dbba", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\n\"\"\" @file\tescape.py\n\t@brief\tcalculate how many coins the princess needs to drop\n\n\t@author dopey\n\"\"\"\n\nimport sys\n\nif __name__ == \"__main__\":\n\tv_p = int(sys.stdin.readline())\n\tv_d = int(sys.stdin.readline())\n\tv_t = int(sys.stdin.readline())\n\tv_f = int(sys.stdin.readline())\n\tv_c = int(sys.stdin.readline())\n\n\tcoins = 0\n\n\t# check if princess is faster than dragon \n\tif (v_p >= v_d):\n\t\tprint coins\n\n\twhile (1):\n\t\ttime_overtake = v_t/(v_d-v_p)\n\t\tif time_overtake*v_d >= v_c:\n\t\t\tbreak\n\n\t\tv_t = time_overtake*v_d + (time_overtake+v_f)*v_p\n\t\tcoins += 1\n\n\tprint coins\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a201ac6717640152f6ed73f1c29e2382", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "from fractions import Fraction\nvp=Fraction(int(raw_input()))\nvd=Fraction(int(raw_input()))\nt=Fraction(int(raw_input()))\nf=Fraction(int(raw_input()))\nc=Fraction(int(raw_input()))\n\n\ndef dogon(dist):\n X=(dist*vp)/(vd-vp)\n return dist+X\nif(vp>vd):\n print 0;\nelse:\n curdist=Fraction(t*vp)\n count=0\n while True:\n nextdist=dogon(curdist)\n #print nextdist\n if(nextdist\nusing namespace std;\nint main(){\n int n,k; \n cin>>n>>k;\n cout<\n#include \n#include \n#include \n#include \n#define N 222222\n#define M 1000000000\ntypedef long long ll;\nll tc, n, k, inp[N], pl, cl, ct, l, t;\nbool peak(ll ind){\n if (ind==1)\n return false;\n if (inp[ind]>inp[ind-1]&&inp[ind]>inp[ind+1])\n return true;\n return false;\n}\nint main(){\n scanf(\"%lld\", &tc);\n while (tc--){\n scanf(\"%lld%lld\", &n, &k);\n for (ll i=1; i<=n; i++)\n scanf(\"%lld\", &inp[i]);\n cl=l=pl=1; ct=0;\n for (ll i=1; it)\n l=cl, t=ct;\n pl=cl;\n }\n printf(\" %lld %lld\\n\", t+1, l);\n }\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce096b9c7446f2ab9756e6cce819c2bb", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import *\na=[int(i) for i in input().split()]\nl=((a[1]-a[3])**2+(a[2]+a[4])**2)**0.5\nprint(ceil(l/(2*a[0]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "44d302b7207524d84fde493594cb0641", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import sqrt\ninput = input().split(' ')\nr = int(input[0])\n(x,y) = (abs(int(input[3])-int(input[1])),abs(int(input[4])-int(input[2])))\ndef f():\n global x,y\n if sqrt((x ** 2 + y ** 2))%1==0:\n a=int(sqrt((x ** 2 + y ** 2)))\n else:\n a=int(sqrt((x**2+y**2)))+1\n for i in range(a,int(x+y)+2):\n if i%(2*r)==0:\n return i/(2*r)\ntry:\n print(int(f()))\nexcept\n print(f())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95b6bd2e802f4638ce1400fa6e402fdb", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import math\ndef amr_pins():\n r, sx, sy, fx, fy = map(int, raw_input().strip().split())\n d = ((fx - sx) ** 2 + (fy - sy) ** 2) ** 0.5\n print int(math.ceil(d / (2 * r))\n\namr_pins()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b6e20cf93b6e279343575a2fff585a1", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\n def Z(s):\n left=0\n right=0\n z=[ 0 for i in range(len(s))]\n for k in range(1,len(s)):\n if k > right:\n left=k\n right=k \n while right =p:\n r=p\nif r==0:\n print(\"Just a legend\")\nelse:\n print(s[0:r])\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6728591253e1a299791c852c98da37e1", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "Python 2", "source_code": " arr = raw_input().split()\n n = int(arr[0])\n m = int(arr[1])\n pigs = []\n setw = set()\n for i in range(n):\n linei = raw_input()\n for j in range(m):\n if linei[j] == 'P':\n pigs.append((i,j))\n elif linei[j] == 'W':\n setw.add((i,j))\n cnt = 0\n for pair in pigs:\n x = pair[0]\n y = pair[1]\n if (x+1,y) in setw:\n setw.remove((x+1,y))\n cnt = cnt + 1\n elif (x,y+1) in setw:\n setw.remove((x,y+1))\n cnt = cnt + 1\n elif (x-1,y) in setw:\n setw.remove((x-1,y))\n cnt = cnt + 1\n elif (x,y-1) in setw:\n setw.remove((x,y-1))\n cnt = cnt + 1\n print cnt", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29f6f67b7e5e07dc271f6d071963af5a", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "arr = raw_input().split()\nn = int(arr[0])\nm = int(arr[1])\npigs = []\nsetw = set()\nfor i in range(n):\n linei = raw_input()\n for j in range(m):\n if linei[j] == 'P':\n pigs.add((i,j))\n elif linei[j] == 'W':\n setw.add((i,j))\nfor pair in pigs:\n x = pair[0]\n y = pair[1]\n if (x+1,y) in setw or (x,y+1) in setw or (x-1,y) in setw or (x,y-1) in setw:\n cnt++\nprint cnt", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c386790da27e3c6c22074654de9ebd5", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n,m = map(int,input().split())\nl = []\nfor i in range(n):\n l.append(input())\nc = 0\nfor i in range(n):\n for j in range(m):\n if l[i][j]==\"W\":\n if(i>0 and l[i-1][j]==\"P\"):\n c=c+1\n\t\tcontinue\n if(i0 and l[i][j-1]==\"P\"):\n c=c+1\n continue\n \t if(j\n#include \nusing namespace std;\n\nint main(){\n string s1, s2; char x;\n cin >> s1; cin.get(x); cin >> s2;\n reverse(s2.begin(), s2.end());\n if (s1 == s2) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f5c1de205b3f2b2dd9fa5806990e61aa", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\nn,m,t = map(int,raw_input().split())\nnn = n-4\nmm = m-1\ns = mm+nn\ntt = t-5\nreturn m*(math.factorial(n)/(24*math.factorial(nn)))*(math.factorial(s)/(math.factorial(tt)*math.factorial(s-tt))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0be9cb4250f221c7d60ca31d9980553e", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "def ncr(n,r):\n\tans=1\n\tfor i in range(r):\n\t\tans=(ans*(n-i))//(i+1)\n\treturn ans\t\n \n \nn,m,t=map(int,raw_input().split())\nprint ncr(m+n,t)-(ncr(n,t)+ncr(m,t)+ncr(n,1)*ncr(m,t-1)+ncr(n,2)*ncr(m,t-2)+ncr(n,3)*ncr(m,t-3))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e4dd0e5a238bbc14f45273c72c775de", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n#define umap unordered_map\n#define size(a) int((a).size())\n#define present(c, x) (c.find(x) != c.end()) \n#define printVerdict(verdict) cout << (verdict ? \"Yes\": \"No\") << '\\n'\n#define printDecimal(d) cout << setprecision(d) << fixed\n#define inrange(val, start, end) (val >= start && val <= end)\n#define var(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n\nconst ll inf = 0x3f3f3f3f;\nconst ll mod = 1e9 + 7;\n\ntemplate \nvoid printTuple(tuple t) { cout << get<0>(t) << \" \" << get<1>(t) << \" \" << get<2>(t) << '\\n'; }\ntemplate \nvoid printPair(pair p) { cout << p.first << \" \" << p.second << '\\n'; }\ntemplate \nvoid printArray(vector arr) { for (int i = 0; i\nvoid read(vector &a, int n) { for (int i= 0; i> a[i]; }\ntemplate \nvoid read(T* a, int n) { for (int i= 0; i> a[i]; }\ntemplate\nvoid readIdx(vector> &a, int n) { for (int i = 0; i> a[i].first; a[i].second = i; }}\n\n\nint main() {\n\tstd::ios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tint n,m,t; cin >> n >> m >> t;\n\tvector> dp(31, vector(31, 0));\n\tdp[0][0] = 1;\n\tfor (int i= 1; i<=30; i++) dp[i][0] = 1;\n\tfor (int i = 1; i<=30; i++) {\n\t\tfor (int j = 1; j<=30; j++) {\n\t\t\tdp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n\t\t}\n\t}\n\tll ret = 0;\n\tfor (int curr = 4; curr <= t-1; curr++) {\n\t\tret += dp[n][curr] * dp[m][t-curr];\n\t}\n\tcout << ret << '\\n';\n\t\n } \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f35b33b8ecce87691844cb7e9ef66cf", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.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 a += c(k - i, n) * c(i, m)\nprint a", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf945784667bd9c2fe5053951179d29d", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def fact(n):\n\tres = 1\n\tfor i in range(1, n + 1):\n\t\tres = res * i\n\treturn res\n\ndef C(n, k):\n #if k > n:\n #\treturn -1\n\tres = fact(n)/(fact(k)*fact(n - k))\n\treturn int(res)\n\n\t'''\n__inp = input().split(' ')\nN = int(__inp[0])\nM = int(__inp[1])\nT = int(__inp[2])\n\nres = 0\nfor i in range(4, T):\n\tres += C(N, i)*C(M, T - i)\n\nprint int(res)\n'''\nfor i in range(1, 31):\n\tprint('{', end='')\n\tfor j in range(1, 31):\n\t\tprint(C(i, j), sep='', end=', ')\n\tprint(C(i, i), '}, ', end='', sep='')\n\n\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c972a829fe81a817ba6b2b64bab2dab", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "# coding=utf8\n\n# from __future__ import division\n# from collections import *\n# from heapq import *\n# from random import *\n# from itertools import permutations\nimport re\nimport sys\n\ndef main():\nimport re\n print 'YES' if re.match(r'^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?$',raw_input()) else 'NO'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a2d34fb8d8a92ece5cd73813a8e5ae3", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def chk(s):\n if s=='': return 1\n for c in s:\n if not (c=='_' or c.isalpha()): return 1\n return 0\ndef chk2(s):\n# print s\n l=s.split('.')\n for x in l:\n if chk(x): return 1\n return 0\ns=raw_input()\nl=s.split('@')\nif len(l)!=2 or l[0]=='' l[1]=='':\n print \"NO\";\nelse:\n if chk(l[0]):\n print \"NO\"\n else:\n # print \"HAHA\"\n l=l[1].split('/')\n if len(l)>2:\n print \"NO\"\n else:\n if len(l)==1:\n if chk2(l[0]):\n # print \"HHHH\"\n print \"NO\"\n else:\n print \"YES\"\n else:\n if l[0]=='' or l[1]==\"\" or chk2(l[0]) or chk(l[1]):\n print \"NO\"\n else:\n print \"YES\"\n\n\n\n\n \n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5cf91722e9677a217a3be832d19ce6ba", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "\ufeff#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n\n#define _ << \" \" <<\n#define all(v) v.begin(), v.end()\n#define sp(n) fixed << setprecision(n)\n#define ff first\n#define ss second\n\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\nusing pii = pair;\nusing pll = pair;\n\nconst ll mod = 1e9 + 7;\n\nvector g[101];\nint ans1, ans2;\nbool used[101] = {};\n\nvoid dfs1(int v) {\n\tif (!used[v]) {\n\t\tused[v] = true;\n\t\tfor (pii u : g[v]) {\n\t\t\tif (!used[u.ff]) ans1 += u.ss;\n\t\t\tdfs1(u.ff);\n\t\t}\n\t}\n}\n\nvoid dfs2(int v) {\n\tif (!used[v]) {\n\t\tused[v] = true;\n\t\tfor (pii u : g[v]) {\n\t\t\tif (!used[u.ff]) ans2 += u.ss;\n\t\t\tdfs2(u.ff);\n\t\t}\n\t}\n}\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tint a, b, c;\n\t\tcin >> a >> b >> c;\n\t\tg[a].push_back({ b, 0 });\n\t\tg[b].push_back({ a, c });\n\t}\n\tfor (int i = 1; i <= n; i++) sort(all(g[i]));\n\tans1 = g[1][0].ss;\n\tused[1] = true;\n\tdfs1(g[1][0].ff);\n\tif (g[1][1].ss == 0) ans1 += g[g[1][1].ff][0].ss;\n\tfill(used + 1, used + n + 1, false);\n\tans2 = g[1][1].ss;\n\tused[1] = true;\n\tdfs2(g[1][1].ff);\n\tif (g[1][0].ss == 0) ans2 += g[g[1][0].ff][0].ss;\n\tcout << min(ans1, ans2) << endl;\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7969b6bfd46e800f8d87cc8035590fa9", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "Python 2", "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\n\nusing namespace std;\ntypedef long long ll;\ntypedef ll li;\ntypedef pair PI;\n#define EPS (1e-6)\n#define rep(i,n) for(int i=0;i<(int)(n);++i)\n#define REP(i, n) rep (i, n)\n#define F first\n#define S second\n#define mp(a,b) make_pair(a,b)\n#define pb(a) push_back(a)\n#define min3(a,b,c) min((a),min((b),(c)))\n#define min4(a,b,c,d) min((a),min3((b),(c),(d)))\n#define SZ(a) (int)((a).size())\n#define ALL(a) a.begin(),a.end()\n#define FLL(a,b) memset((a),b,sizeof(a))\n#define CLR(a) memset((a),0,sizeof(a))\n#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)\n#define FORR(it,a) for(__typeof(a.rbegin())it=a.rbegin();it!=a.rend();++it)\n\ntemplate ostream& operator<< (ostream& out, const pair& val){return out << \"(\" << val.F << \", \" << val.S << \")\";}\ntemplate ostream& operator<< (ostream& out, const vector& val){out << \"{\";rep(i,SZ(val)) out << (i?\", \":\"\") << val[i];return out << \"}\";}\ntypedef double FP;\ntypedef complex pt;\ntypedef pt P;\ntypedef pair line;\nnamespace std{\n bool operator<(const P&a,const P&b){\n if(abs(a.real()-b.real())>EPS)\n return a.real()>r;return r;}\ntemplate T shift(T a,int b,int c,int d,int e){\n __typeof(a[0])t=a[b];\n a[b]=a[c];a[c]=a[d];a[d]=a[e];a[e]=t;return a;}\ntemplate T rgt(T a){return shift(a,TOP,LFT,BTM,RGT);}\ntemplate T lft(T a){return shift(a,TOP,RGT,BTM,LFT);}\ntemplate T frt(T a){return shift(a,TOP,BCK,BTM,FRT);}\ntemplate T bck(T a){return shift(a,TOP,FRT,BTM,BCK);}\nline mkl(P a,P v){return line(a,a+v);}\nFP lpdist(line a,P b){return abs(b-crspt(a,mkl(b,ortho(a))));}\nFP spdist(line a,P b){\n P c(crspt(a,mkl(b,ortho(a))));\n return onl(a,c)?abs(b-c):min(abs(a.F-b),abs(a.S-b));\n}\nFP ssdist(line a,line b){\n return\n iscrs(a,b)?0.:\n min4(spdist(a,b.F),spdist(a,b.S),\n spdist(b,a.F),spdist(b,a.S));\n}\n\nbool ok(string a){\n FOR(it,a)\n if(!islower(*it) && !isupper(*it) &&\n !isdigit(*it) && *it!='_')\n return false;\n return true;\n}\n\nstring solve(){\n string no=\"NO\";\n string in;\n getline(cin,in);\n \n if(in.find('@') == string::npos)\n return no;\n \n int atp = in.find('@');\n string username = in.substr(0,atp);\n in = in.substr(atp+1);\n \n if(in.find('/') == string::npos) in += \"/a\";\n\n atp = in.find('/');\n string host = in.substr(0,atp);\n in = in.substr(atp+1);\n\n // cout << username << endl;\n // cout << host << endl;\n \n if(SZ(username)<1 || 16@[/resource]\n\n if jabber_id.count('@') > 1 or jabber_id.count('/') > 1:\n return False\n \n try:\n username = jabber_id.split('@')[0]\n hostname = jabber_id.split('@')[1].split('/')[0]\n resource = None\n if '/' in jabber_id:\n resource = '/'.join(jabber_id.split('@')[1].split('/')[1:])\n except IndexError:\n return False\n \n if not is_len(1, 16, username):\n return False\n \n if not is_only_letters_digits_and_underscore(username):\n return False\n \n if not is_len(1, 32, hostname):\n return False\n \n for word in hostname.split('.'):\n if not is_len(1, 16, word):\n return False\n if not is_only_letters_digits_and_underscore(word):\n return False\n \n if resource is None:\n return True\n \n if not is_len(1, 16, resource):\n return False\n if not is_only_letters_digits_and_underscore(resource):\n return False\n return True\n\nif __name__ == '__main__':\n \n jabber_id = raw_input()\n if is_jabber_id(jabber_id):\n print 'YES'\n else:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1fd46f75f9e92cf596b5c5716110b9c", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n,k=map(int,input().split())\nl=input()\nd={}\nfor i in l:\n d[i]=d.get(i,0)+1\nfor i in d.values():\n if i>k:\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ec3b186efa657c59185a3924e772bb1", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,k=map(int,input().split())\ns=input().lower()\nletters=[0]*26\nc=0\nfor i in s:\n nomer=ord(i)-97\n letters[nomer]+=1\nletters.sort(reverse=True)\nwhile 0 in letters:\n letters.pop()\nfor j in letters:\n b=j\n if b%k!=0:\n c=c+0\n\n\nif c==0:\n print('YES')\nelif \nelse:\n print('NO')\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3df75a9659362a668b4e2fd0e2115313", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a=input().split()\na[0]=int(a[0])\na[1]=int(a[1])\ns=input()\nc=set(s)\nk=0\nfor i in c:\n e=s.coint(i)\n c.get(i,e)\n continue\nfor j in c:\n k+=j.values()\nif k%a[1]==0:\n print('Yes')\nelse:\n print('NO')\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0318b7dcd00e5fd63cb9f6c0eabae1ee", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\n\nn, k = map(int, input().split())\n\ncolors = input()\ncount = defaultdict(lambda:0)\n\nfor color in colors:\n count[color] zz\n \nprint(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ee24cb1a004d1c0954ca736c6ff6abd", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\nint n,k;\nstring s;\nint main()\n{\n cin >> n >> k;\n cin >> s;\n int cnt=0;\n for (int i=0; ik){\n cout<<\"NO\";\n return 0;\n }\n }\n cout<<\"YES\";\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1536e8edb5ecf9b336a3ba3101f0e0d", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(n%2 == 0 ? 'home' : 'contest')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee8d0b1a6cf396a875d1910710083d14", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nhome=input()\nfor i in range(n-1):\n s=input()\ns1=input().split('->')\nif if n%2==0:\n print('home')\nelse:\n print('contest')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf77e344b885bd199d9c07eb160421fa", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nc=0\nr=input()\nfor i in range(0,n):\n s=input()\n if s[:3]==r: or s[5:] ==r:\n c=c+1 \nif c%2:\n print('contest')\nelse:\n print('home')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "295537dc92fa6ff46ca2c90c091d216c", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Python 2", "source_code": "a=input()\nhome=raw_input()\nc=1\nfor e in range(a):\n c+=raw_input().endswith(home)\nif !(c % 2):\n print \"contest\"\nelse:\n print \"home\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36d6df4345235ea05767301e2d06d59e", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;main(){int n;cin>>n;cout<<(n&1?\"contest\":\"home\");}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "21e5aa1291ac66126f83e6c54ae76912", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "Python 3", "source_code": "R = lambda: map(int, input().split())\nn, a, b = R()\n\nT = lambda: list(map(int, input().split()))\nA = T()\nB = T()\nans = [-1 for i in range(n + 1)]\nfor i in range(a):\n ans[A[i]] = 1\nfor i in range(1, n + 1):\n if ans[i] == -1:\n ans[i] = 2\nfor i in range(1, n + 1):\n print(ans[i], end = ' ')\ninput()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7252778464969fdee56b0ea00b76d3a6", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n,x,y=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=[0]*n\nfor i in range(len(a)):\n c[a[i]-1]=1\nfor j in range(len(b)):\n c[b[j]-1]=2\nfor i in c:\n print(i,endl=\" \")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "156a6cf0211e321d3c58bb45e137c2fd", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n,a,b = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n for i in range(1,n+1):\n if i in a:\n print(1)\n elif i in b:\n print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "55627edad0a96b7e90a0bfbd73b23f66", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n, a, b = map(lambda x: int(x),str(raw_input()).split())\nisa = map(lambda x:int(x),str(raw_input())\nans = \"\"\nfor i in range(1, n+1):\n if i in isa:\n print '1'\n else:\n print '0'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71d279880ce64171fd206f96cd7e54db", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#include \nusing namespace std;\nint n,a,b,temp;\nint main(){\n cin>>n>>a>>b;\n bool arr[a];\n for(int i=0;i>temp;\n arr[temp]=1;\n }\n for(int i=0;i>temp;\n for(int i=1;i<=n;i++){\n if(arr[i]==1) cout<<1<<\" \";\n else cout<<2<<\" \";\n }\n}\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28b8be5f67b2b8b5efae72adb94ad83c", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nstrs=input()\nk='ogo'\nwhile True:\n while k in strs:\n k+='go'\n k=k[:-2]\n strs=strs.replace(k,'***')\n if k=='ogo':\n print(strs)\n break\n else:\n k=='ogo'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e180b90be787cda6eaedab5cfeb1385b", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "Python 3", "source_code": "_ = input()\ns = input()\ni = 0\nout = \"\"\nwhile i < len(s):\n\tif s[i] == \"o\" and if s[i+1] == \"g\" and if s[i+2] == \"o\":\n\t\ti += 3 + howMany(i+3)\n\telse:\n\t\tout = out + s[i]\n\t\ti += 1\n\t\t\t\t\n\ndef howMany(n):\n\tglobal s\n\tgping = True\n\tout = 0\n\twhile i < len(s) and going:\n\t\tif s[n] == \"g\" and s[n+1] == \"o\":\n\t\t\tout += 1\n\t\telse:\n\t\t\tgoing = False", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a458fd9600843ced9636c02c2f10837", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nstrs=input()\nk='ogo'\nwhile True:\n while k in strs:\n k+='go'\n k=[:-2]\n strs=strs.replace(k,'***')\n if k=='ogo':\n print(strs)\n break\n else:\n k=='ogo'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dbf15746f8ac891c72551a6b270cede6", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#include\n#include\nusing namespace std;\n\nset x, y;\nset::iterator l, r;\nmultiset lx, ly;\n\nint h, w, n;\n\nint main()\n{\n\tchar c, s;\n\tint z;\n\tlong long ans;\n\tcin>>w>>h>>n;\n\tx.insert(0);x.insert(w);\n\ty.insert(0);y.insert(h);\n\tlx.insert(w);ly.insert(h);\n\tfor (int i=0; i>c>>z;\n\t\tif (c == 'H')\n\t\t{\n\t\t\ty.insert(z);\n\t\t\tl =r =y.find(z);\n\t\t\tl--; r++;\n\t\t\tly.erase(ly.find(*r-*l));\n\t\t\tly.insert(*r-z);ly.insert(z-*l);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tx.insert(z);\n\t\t\tl =r =x.find(z);\n\t\t\tl--; r++;\n\t\t\tlx.erase(lx.find(*r-*l));\n\t\t\tlx.insert(*r-z);lx.insert(z-*l);\n\t\t}\n\t\tans = *lx.rbegin();\n\t\tans *= *ly.rbegin();\n\t\tcout<\nusing namespace std;\n\n/* Policy Based Data Structure\n#include \n#include \n#include \nusing namespace __gnu_pbds;\ntypedef tree<\n int,\n null_type,\n less,\n rb_tree_tag,\n tree_order_statistics_node_update > pbds;\n*/\n\n#define print_time cerr << \"Time taken: \" << fixed << setprecision(3) << 1.0 * clock() / CLOCKS_PER_SEC << \" secs\";\n#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define int long long\n#define LD long double\n#define testcases int test; cin >> test; for (int tc = 1; tc <= test; tc++)\n#define iOS ios::sync_with_stdio(0); cin.tie(0); cerr.tie(0);\n#define endll \"\\n\"\n#define get(x,y) get(y)\n#define ff first\n#define ss second\n#define sz size\n#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)\ntemplate void ZZ(const char* name, Arg1&& arg1){std::cerr << name << \" = \" << arg1 << endl;}\ntemplate void ZZ(const char* names, Arg1&& arg1, Args&&... args)\n{\n const char* comma = strchr(names + 1, ',');\n std::cerr.write(names, comma - names) << \" = \" << arg1;\n ZZ(comma, args...);\n}\nint modpow(int a, int b, int m) {int res = 1; while (b) {if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}\nint gcd(int a, int b) {if (a == 0 && b == 0) return 1; return __gcd(a,b);}\n\nconst int MOD = 1e9 + 7;\nconst int N = 1e5+5;\n\nstring str;\nint cost1, cost2;\nset > st;\nint32_t main()\n{\n fast_io\n\n cin >> str;\n int open_brackets = 0, ans = 0;\n\n for (int i = 0; i < str.size(); i++) {\n if (str[i] == '(')\n open_brackets++;\n else\n open_brackets--;\n\n \n if (str[i] == '?') {\n cin >> cost1 >> cost2;\n st.insert({cost1 - cost2, i});\n ans += cost2;\n str[i] = ')';\n }\n if (open_brackets < 0) {\n if (st.empty())\n break;\n int dcost = st.begin()->first;\n int id = st.begin()->second;\n st.erase(st.begin());\n str[id] = '(';\n ans += dcost;\n open_brackets += 2;\n }\n }\n if (open_brackets) puts(\"-1\");\n else {\n cout << ans << \"\\n\" << str;\n }\n\n print_time\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a516b6f3b2bb826fd299f4bdfb928b4", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23", "difficulty": 800.0} {"lang": "Python 2", "source_code": "input=raw_input()\nn, m = map(int, input.split(' '))\n\n\nif n%m==0:\n result=n/m\n for i in range(m):\n print result,\n\nelse:\n rest=n%m\n fair=(n-n%m)/m\n for i in range(m-rest):\n print fair,\n\n for j in range(rest):", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3d1c3bec3a8dfc5fcb4a5b34b1367206", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23", "difficulty": 800.0} {"lang": "Python 3", "source_code": "nm=input().split()\nn=int(nm[0])\nm=int(nm[1])\n\nint i=int(n/m)\nint j=n%m\nfor x in range(m-j):\n print(i,end=\" \")\nfor x in range(j):\n print(i+1,end=\" \")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d54ead34afed9b6b6cc5874244af1944", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\ndef solve(a,b):\n if a == 1 and b == 1:\n return 1\n else:\n a, b = max(a, b), min(a, b)\n return 1 + solve(a - b, b)\na, b = map(int,input().split())\nprint(solve(a,b))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e1f312ca33c19f08635d2799273e8cc9", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nif a>b:print((a//b)+(b%(a%b))*(a%b)+(b//(a%b)))\nelse:print((b//a)+((b%a)*a))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c421fc11c6c789cfe10846ca41b2d6c", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a, b = map(int, input().split())\nans = 0\nif a % b == 0 or b % a == 0:\n print(max(a // b, b // a))\n exit(0)\nwhile a and b:\n if a - b > 0:\n ans += a // b\n a, b = a % b, b\n else:\n ans += b // a\n a, b = a, b % a\nif a % b == 0:\n ans += a // b\nelse:\n ans += b // a\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a548add8c9a56d917c21be514d6090f", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def fun(a,b):\n if a==0:\n return 0\n if b==0:\n return 0\n if b==1:\n return a\n else:\n return ((a//b)+1)+fun(a%b,(b-(a%b)))\na,b=map(int,raw_input().split())\nprint fun(a,b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b115d2991190facb671972136ddaa65b", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def fun(a,b):\n if b==1:\n return a\n else:\n return ((a//b)+1)+fun(a%b,(b-(a%b)))\na,b=map(int,raw_input().split())\nprint fun(a,b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "93c2be019b26df8d08989115ed7f66cf", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def lcm(a,b):\n for i in range(b,b*b):\n if(i%a==0 and i%b==0):\n return i\n\na,b,c,d=map(int,input().split())\ne=lcm(a,b)\nvalue=0\nfor i in range(c,d+1):\n if(i%e==0):\n value+=1\nprint(value)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5a23045fe4b427193c8b7e567ea5132", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "\ndef gcd(x,y) :\n if y == 0 :\n return x\n else :\n t = x%y\n x = y\n y = t\n return gcd(x,y)\n\nx,y,a,b = map(int,raw_input().split())\nk = x*y/gcd(x,y)\n\nt = a%k\nd,u = 0,0\nif t == 0 :\n d = a/k\nelse :\n d = a/k + 1\n\nt = b%k\nif t == 0 :\n u = b/k\nelse :\n u = b/k + 1\n\nres = u-d+1\nif res < 0\n res = 0\n\nprint res", "lang_cluster": "Python", "compilation_error": true, "code_uid": "397a06a5057f4a0ca696e7229afa93d2", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.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": "3836139c1a5bac7a09b1e8c407dd5ecb", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "x,y,a,b = map(int, input().split())\ng = 1\nwhile g % x || g % y:\n g += 1\nreturn b // g - (a - 1) // g", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5717f6e665b7dc011bbe635222b11c29", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "from sys import stdin\n\nin_lines = stdin.readlines()\n\n\ndef int_values(line) :\n return map( int, line.split(' ') )\n\nlines = map( int_values, map( lambda x:x.strip(), in_lines ) )\n\nx, y, a, b = lines[0]\n\nbefore = (a - 1) / (x * y)\noverall = (b / (x * y)\nprint overall - before\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90fd319a0ac65e929a32a2b11be21f29", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\nimport copy\nfrom collections import Counter\nsys.setrecursionlimit(11111)\nimport re\nimport itertools\n\nn = int(sys.stdin.readline().strip())\nans = [2,1,3,1,2]\nif n == 1:\n\tprint ans[n-1]\nelse sys.exit(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6fac07c185c18ca81100b356d560a5df", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "d = {1:1, 2:1, 3:1, 4:1, 5:1}\nprint(d[int(input())]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbaa92441e71f876975f3dabc30651ed", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nif n<3 then:\n print 1\nelse\n print 2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c36520e2d9ef3712c0e0dff2ef79fb8c", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "if(y<3) print(1)\nelse print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "806567f7fd636c2a0a7d9e2a8c1d0bc4", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "## DATA SOURCE (1 for file, 0 for std input)\nopt = 0\nsrc = opt and open(\"input\", \"r\") or None\n\ndef gvals(source, format = int, separator = ' '):\n\tif source:\n\t\ta = map(format, source.readline().split(separator))\n\telse:\n\t\ta = map(format, raw_input().split(separator))\n\treturn a\n\ndef gval(source, format = int):\n\tif source:\n\t\ta = format(source.readline())\n\telse:\n\t\ta = format(raw_input())\n\treturn a\n\na = gval(src)\nif a!=1:\n\tprint 1\nelse\n\tprint 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b11f8558322cc8370579c8aa88b98c3", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, k = (int(x for x in raw_input().rstrip().split())\nret = 10 ** (n-1)\nwhile ret >= 0 or ret % k != 0:\n\tret += 1\nprint ret\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "00e152336a6dbe0f432b4fabe23e4278", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,t=map(int,input().split())\nd=10**(n-1)\ne=10**n\nfor i in range(d,e):\n if i%t=0:\n print(i)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7049b741a435b206b79de66426e1deb9", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "x=map(int,raw_input().split())\nk=x[1]\nn=x[0]\nif len(str(k))==10:\n s=s[:-1]\nelse:\n s=str(-1)\nprint s", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0434e4ccca5648ebcad2e808fa629b2d", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\nn, t = map(int, input().split())\n\n\n\nwhile len(str(t)) < n:\n t = t+t\n print(t)\n\nelse len(str(t)) > len(str(1)):\n print(\"-1\")\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "55dbb3c3b77a02585a7e296014eb1655", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\nn,t = map(int,input().split())\n\nif t == 10:\n\n ans = int(t)*(10**(int(n)-2))\n\n if len(str(ans)) == int(n):\n\n\u00a0 print (ans)\n\n else:\n\n\u00a0 print('-1')\n\nelse: \u00a0\n\n\u00a0 ans = int(t)*(10**(int(n)-1))\n\n\u00a0 if len(str(ans)) == int(n):\n\n\u00a0 print (ans)\n\n\u00a0 else:\n\n\u00a0 print('-1')\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "de7c7c871acf1f837406855914fe6699", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "k=int(input())\na=list(map(int,input().split()))\na.sort()\na.reverse()\ntot=sum(a)\nd=0\nn=0\nfor i in range (len(a)):\n tot=tot-a[i]\n d=d+a[i]\n n=n+1\n if k==0:\n print(\"0\")\n break\n elif d==k or d>k:\n print(n)\n break\n elif d=k:\n f = True\n print(ct)\n break\nif not f:\n print('-1')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89c6600e280442fed6ef13a6c354c6ba", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0} {"lang": "Python 2", "source_code": " def getI(a, k):\n\n def getSliceSum(ar, till):\n res = 0\n for i in range(till):\n res += ar[i]\n return res\n \n if k ==0: return 0\n if a[0] >=k: return 1\n count = 0\n a.sort(reverse=True)\n for ai in range(12):\n res = getSliceSum(a, ai)\n if res >= k: return ai", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b960c3bf54571cbc460b4ca12aa39774", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#! /usr/bin/env ruby\n\nk = gets.to_i\nm = gets.chop.split.map {|x| x.to_i}.sort.reverse\nsum = 0\nsol = m.map {|x| sum += x}.map { |i| i >= k }.find_index(true)\n\nif k.equal? 0\n p 0\nelsif sol.equal? nil\n p -1\nelse\np sol + 1\nend\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc1f83ac490b5344d7b71a35f9cb8948", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0} {"lang": "Python 2", "source_code": "limit = int(raw_input())\nmonths = map(int, raw_input().split())\nmonths.sort(reverse = True)\ni = 0\nwhile limit > 0:\n\tlimit = limit - months[i]\n\ti = i + 1\n if (i == len(months)):\n print(-1)\n return\nprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8f7f27219d03a5ae2338f0da71b40ced", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def find_factor(all):\n i = 2\n list = [0]\n while i < all :\n if all % i == 0 :\n list.append(i)\n i += 1\n return list[1:] #\u8f93\u51fa\u6240\u6709\u56e0\u6570\uff0c\u5217\u8868\u5f62\u5f0f\u8f93\u51fa\n\ndef if_candiv(str,div_value): #\u67e5\u770b\u8be5\u5b50\u4e32\u662f\u5426\u53ef\u5206\u5272\u6210\u503c\u4e3adiv_value\u7684\u4e32\n left = div_value\n position = 0\n for i in str:\n left -= int(i)\n if left == 0:\n return str[position+1:],\"YES\"\n elif left < 0:\n return str,\"NO\"\n position += 1\n\ntry:\n while True:\n length = int(input())\n num_str = input().strip(\"0\")\n length = len(num_str)\n all = 0\n for i in num_str:\n all += int(i)\n if all == 0:\n print(\"YES\")\n else :\n factor_list =find_factor(all)\n flag_0 = \"NO\"\n for factor in factor_list:\n print(factor)\n copy_str = num_str\n position = 0\n flag_1 = \"YES\"\n while position < length :\n print(copy_str)\n [copy_str,flag_1] = if_candiv(copy_str,factor)\n position = length - len(copy_str)\n if flag_1 == \"NO\":\n print(flag_1)\n break\n if flag_1 == \"YES\":\n flag_0 = \"YES\"\n break\n print(flag_0)\nexcept EOFError:\n pass", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c42725cde9529e0337ca86d3b879006c", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import math\n\nn = int(input())\ns = input()\na = []\np = []\nt = 0\nf = 1\n\nfor i in range(n):\n a.append(int(s[i]))\n t += a[i]\n p.append(t)\n\nfor i in range(n):\n s = p[i]\n f = 1\n t = 0\n k = i+1\n c = 0\n for j in a[k:n]:\n t += j\n if c and !t: continue\n if j == n-1 and t != s:\n f = 0\n elif t == s:\n t = 0\n c += 1\n elif t > s:\n f = 0\n break\n if i == n-1 and f: f = 0\n if f: break\n\nif f: print('YES')\nelse: print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d10855bb9df185c1ed38d7dd553445bf", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\na=input()\ns=[]\nfor i in range(n):\n\ts.append(int(a[i]))\nxx=sum(s)\nfor i in range(1001):\n\tcur=0\n\tit=0\n\tfor j in range(n):\n\t\tcur+=s[j]\n\t\tif cur==num:\n\t\t\tit+=1\n\t\t\tcur=0\n\tif cur==0 && it>1:\n\t\tf=1\n\t\tbreak\nif f==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a7d2006df636dc07b5ed32887885ad08", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import sys\nn = int(input())\ns = input()\ns = list(map(int,''.join(s)))\nsumma = sum(s)\np = []\n\nif sum(s) == 0:\n #print('YES')\n sys.exit()\n\n\nfor i in range(summa-1,1,-1):\n if summa % i == 0:\n p.append(int(summa / i))\n\n#print('summa=',summa,'p=',p)\n\nyes = 0\nno = 0\n\n\nfor x in p:\n s1 = s[:]\n #print('-------x=',x,'----')\n #print(s)\n #print(s1)\n flag = 0\n count = 0\n while s1 != []:\n count += s1.pop()\n if count == x:\n #print('count=',count,)\n count = 0\n elif count < x:\n continue\n else:\n flag = 1\n break\n\n #print(flag,count)\n if flag == 1:\n no += 1\n else:\n yes += 1\n\n\nif yes == 0:\n print('NO')\nelse:\n print('YES'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d505de8f3894496168fc6049ce39385a", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "# C. Vasya and Golden Ticket\n\nn = int(input())\ndigits = list(input())\ndigits = list(map(int, digits))\ndig_sum = sum(digits)\npart_sum = 1\nif dig_sum == 0:\n print(\"YES\\n\")\n exit()\n# \u7531\u4e8e\u6570\u636e\u91cf\u4e0d\u5927\uff0c\u56e0\u6b64\u679a\u4e3e\u6bcf\u4e00\u79cd\u53ef\u80fd\u7684\u90e8\u5206\u548c\nfor part_sum in range(1, dig_sum): # \u7528for\u6bd4 while\u4ee3\u7801\u91cf\u66f4\u5c0f\uff0c\u5360\u5185\u5b58\u4e5f\u66f4\u5c0f\n if dig_sum % part_sum != 0:\n continue\n temp = 0 # \u6ce8\u610f\u8981\u7f6e\u96f6\uff01\uff01\n for i in range(0, n): # i\u5c31\u4e0d\u9700\u8981\u518d\u7f6e\u96f6\u4e86\uff0c\u6bcf\u6b21\u90fd\u4f1a\u4ecerange\u7684\u7b2c\u4e00\u4e2a\u5f00\u59cb\n temp += digits[i]\n if temp == part_sum: # \u8fd9\u91cc\u4e0d\u9700\u8981\u518d\u5f00\u4e00\u4e2aflag\uff0c\u76f4\u63a5\u7528temp\u5c31\u5f88\u65b9\u4fbf\n temp = 0\n elif temp > part_sum:\n break\n if temp == 0:\n print(\"YES\\n\")\n exit()\nprint(\"NO\\n\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "152427f065c2584949af2ad0632c2865", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def solve(n, x, y):\n if(x == 0):\n return y\n elif y == n:\n return y + x\n elif x == n:\n return 3 * m - y\n else:\n return 4 * n - x\n\nn, x1, y1, x2, y2 = map(int, raw_input().split(\" \"))\np1 = solve(n, x1, y1)\np2 = solve(n, x2, y2)\n\nprint min((p1 - p2 + 4 * n) % (4 * n),(p2 - p1 + 4 * n) % (4 * n)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6641b7abb1fd3e91dec20e7faab0e0a5", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n,x1,y1,x2,y2 = map(int,raw_input().split())\nif abs(x1-x2) = n:\n d1 = x1 + x2 + 2*n\n d2 = 2*n - x1 - x2\n print min(d1,d2)\nelif abs(y1-y2) = n:\n d1 = y1 + y2 + 2*n\n d2 = 2*n - y1 - y2\n print (d1,d2)\nelif x1 = x2 = 0: print abs(y2-y1)\nelif y1 = y2 = 0: print abs(x2-x1) \nelif print abs(x2-x1) + abs(y2-y1)\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d3fc09983ca2e300911aa77eaf314fcc", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n,x1,y1,x2,y2 = map(int,raw_input().split())\nif abs(x1-x2) == n:\n d1 = x1 + x2 + 2*n\n d2 = 2*n - x1 - x2\n print min(d1,d2)\nelif abs(y1-y2) == n:\n d1 = y1 + y2 + 2*n\n d2 = 2*n - y1 - y2\n print (d1,d2)\nelif x1 == x2 == 0: print abs(y2-y1)\nelif y1 == y2 == 0: print abs(x2-x1) \nelif print abs(x2-x1) + abs(y2-y1)\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce7b7b2e5d6edf85e72b53a222d7107e", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,a,b,x,y=map(int,input().split())\ndef safe(n,a,b):\n\tif n>=a and n>=b:\n\t\treturn True\n\treturn False\n\ndef short(n,a,b,x,y):\n\trs=[0,0,1,-1]\n\tcs=[1,-1,0,0]\n\tq=[(a,b,0)]\n\tbx=0\n\twhile len(q)!=0:\n\t\txsi=q.pop(0)\n\t\txs,ys,zs=xsi[0],xsi[1],xsi[2]\n\t\tif xs==x and ys==y:\n\t\t\tbx=zs\n\t\t\tbreak\n\t \n\t for i in range(4):\n\t\t for j in range(4):\n\t\t\t ri=rs[i]+xs\n\t\t\t ci=cs[i]+ys\n\t\t\t if safe(n,ri,ci):\n\t\t\t\t q.append((ri,ci,zs+1))\n \n return bx\n\nprint(short(n,a,b,x,y))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f85d623d6f02fa6fdb7de2ed039667fe", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,a,b,x,y=map(int,input().split())\ndef safe(n,a,b):\n\tif a==0 or b==0 or a==n or b==n:\n\t\treturn True\n\treturn False\n\ndef short(n,a,b,x,y):\n\trs=[0,0,1,-1]\n\tcs=[1,-1,0,0]\n\tq=[(a,b,0)]\n\tbx=0\n\twhile len(q)!=0:\n\t\txsi=q.pop(0)\n\t\txs,ys,zs=xsi[0],xsi[1],xsi[2]\n\t\tif xs==x and ys==y:\n\t\t\tbx=zs\n\t\t\tbreak\n\t\tfor i in range(4):\n\t\t\tfor j in range(4):\n\t\t\t\tri=rs[i]+xs\n\t\t\t\tci=cs[i]+ys\n\t\t\t\tif safe(n,ri,ci):\n\t\t\t\t\tq.append((ri,ci,zs+1))\n\t\n\treturn bx\n\nprint(short(n,a,b,x,y))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1db387097d025ea0411ba824dd58e97b", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import collections\n\n\ndef count(n, k):\n\n m = collections.defaultdict(lambda: 0)\n m[0] = 1\n for i in range(1, n + 1):\n\n for j in range(1, k + 1):\n\n if i - j in m:\n\n m[i] += m[i - j]\n\n return m[n]\n\nn, k, d = tuple(map(int, str.split(input())))\nprint((count(n, k) - count(n, d - 1)) % (10 ** 9 + 7)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "74b0340480817f926bc936da1040561a", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "'''#problem1\nn=int(input())\nprice=[int(i) for i in input().split()]\nq=int(input())\nacc=[]\nfor i in range(q):\n k=int(input())\n acc.append(k)\nprice.sort()\ndef search(k,arr):\n l=0\n r=len(arr)-1\n ans=0\n while l<=r:\n mid=l+int((r-l)/2)\n if arr[mid]<=k:\n ans=mid+1\n l=mid+1\n else:\n r=mid-1\n return ans\nfor j in acc:\n a=search(j,price)\n print(a)'''\n\n\n'''n=int(input())\nnums=[int(i) for i in input().split()]\ns=sum(nums)\nans=0\nif s%3!=0:\n ans=0\n \nelse:\n s/=3\n cnt=[0]*(n)\n sum=0\n for i in range(n-1,-1,-1):\n sum+=nums[i]\n if sum==s:\n cnt[i]=1\n for j in range(n-2,-1,-1):\n cnt[j]+=cnt[j+1]\n sum=0\n k=0\n while k+2= d) for i range(1, min(n, k) + 1)) % M\n\nprint count(n, False)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6cfaa514e10d8aed4c956d1a11a524d", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "mod = 1e9+7\ndef add(a,b):\n\ta += b\n\tif a >= mod:\n\t\treturn a-mod\n\treturn a\n\ndef Sulution():\n\tn,k,d = [int(x) for x in input().split()]\n\tdp = [[for j in range(100)]0 for i in range(2)]\n\tprint(dp)\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n):\n\t\tfor j in range(1,k):\n\t\t\tif i < j:\n\t\t\t\tbreak\n\t\t\tif j < d:\n\t\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\telse:\n\t\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\tif dp[i][0] >= mod:\n\t\t\t\tdp[i][0] -= mod\n\t\t\tif dp[i][1] >= mod:\n\t\t\t\tdp[i][1] -= mod\n\n\treturn dp[n][1]\n\nprint(Sulution())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6318b54d625f7f925f489d604224d3f3", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": " MOD = 10 ** 9 + 7\n HAVE, NOT_HAVE = 1, 0\n \n n, k, d = map(int, input().split())\n \n dp = [[0 for _ in range(n + 1)] for _ in range(2)]\n dp[NOT_HAVE][0] = 1\n for dist in range(1, n + 1):\n for weight in range(1, k + 1):\n if weight > dist:\n break\n if weight >= d:\n dp[HAVE][dist] += dp[HAVE][dist - weight] + dp[NOT_HAVE][dist - weight]\n dp[HAVE][dist] %= MOD\n else:\n dp[NOT_HAVE][dist] += dp[NOT_HAVE][dist - weight]\n dp[NOT_HAVE][dist] %= MOD\n dp[HAVE][dist] += dp[HAVE][dist - weight]\n dp[HAVE][dist] %= MOD\n print(dp[HAVE][n])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1ab4310215322e19901fec59bdd83f40", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a,b=[int(x) for x in input().split()]\nprint(pow(2,a+b,998244353)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "411339530193b0e36b796d63100ffc77", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "Python 3", "source_code": " w,h=map(int,input().split())\n print((4*(2**(w+h-2)))%998244353)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ce84dceb8070c077aa30c76ded2ed59", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "print(pow(2,sum(list(map(int,input().split()))%998244353) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "987781c8c2d147611ce916d0dea77109", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def solve()\n from sys import stdin\n line = stdin.readline\n a,b=map(int,line().split())\n print(pow(2,a+b,99824435))\nsolve()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cff6c3e3fd1e7f6b29244e1255a67bb3", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "print(2 ** sum(map(int, input().split()))) % 998244353)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "554489c9e7249221ec27b9ca18e5f12e", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.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": "ec648b77d54463dadd0dd8f81c3b5bf2", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "Python 3", "source_code": " a, b, c, d, e, f = [int(input()) for _ in range(6)]\n \n suits1 = min(a,d)\n suits2 = min(b,c,d)\n \n total = 0\n if e>f:\n total += suits1 * e\n total += min(suits2,d-suits1)*f if d-suits1 > 0 else 0\n else:\n total += suits2 * f\n \n total += min(suits1,d-suits2)*e if d-suits2 > 0 else 0\n \n print(total)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88abab4cb4796bb44b4f40559aeb8e96", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\ne=int(input())\nf=int(input())\nx=0\n\nif e>f:\n if a>d:\n return d*e\n elif d>a:\n y=d-a\n x+=a*e\n z=min(y,b,c)\n x+=z*f\nelif f>e:\n if b>d or c>d:\n return d*f\n else:\n y=min(b,c)\n z=d-y\n x+=y*f\n m=min(z,a)\n x+=m*e\n \nreturn x", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b55834ce76eff5c8281fde4ae1835b08", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "ties=int(input())\nscarves=int(input())\nvests=int(input())\njackets=int(input())\ns1=int(input())\ns2=int(input())\n\n#s1=tie+jacket\n#s2=scarf+vest+jacket\n\ncost1=0\ncost2=0\n\nif s1>=s2:\n k=min(ties,jackets)\n cost1+=(k*s1)\n j2=jackets-k\n l=min(scarves, vests, j2)\n cost1+=(l*s2)\n\nif s1<=s2:\n l=min(scarves, vests, jackets)\n cost2+=(l*s2)\n j1=jackets-l\n k=min(ties,j1)\n cost2+=(k*s1)\n \nif s1>s2:\n print(cost1)\n \nelif s1 4 else '2'\n j = 2\n if n % 3 == 0:\n if j: return '1\\n6' if n > 6 else '2'\n if n % 9 == 0: return '1\\n9' if n > 9 else '2'\n j = 3\n for i in range(5, k, 6):\n if n % i == 0:\n if j: return '1\\n' + str(i * j) \n if n % (i * i) == 0: return '1\\n' + str(i * i)\n j = i\n for i in range(7, k, 6):\n if n % i == 0:\n if j: return '1\\n' + str(i * j) \n if n % (i * i) == 0: return '1\\n' + str(i * i)\n j = i\n return '2' if j or k * k == n else '1\\n0'\nprint f(int(raw_input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2af4e285b27b952d1f563617b3606de", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import sys\nrange = xrange\ninput = raw_input\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": "66e5ccc07211e458afc8112e809f96a1", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nC=\"0\"+input()\n\nA=[]\nfor i in range(1,n+1):\n if C[i]!=C[i-1]:\n A.append(C[i])\n\nL=len(A)\n\nDP=[[[0]*L for i in range(L)] for k in range(2)]\n#\u5de6\u306e\u8272\u306b\u63c3\u3048\u308b or \u53f3\u306e\u8272\u306b\u63c3\u3048\u308b,\u5de6\u304b\u3089i\uff5ej\u756a\u76ee\u3092\n\nDICT=dict()\nfor i in range(1,L-1):\n for j in range(i-1,-1,-1):\n if A[j]==A[i]:\n i_MIN=j\n break\n else:\n continue\n\n for j in range(i+1,L):\n if A[j]==A[i]:\n i_MAX=j\n break\n else:\n continue\n\n DICT[(i_MIN,i_MAX)]=i\n \n\n\n\ndef color(r,i,j):#iDP[0][i][DICT[(i,j)]]+DP[1][DICT[(i,j)]][j]:\n DP[r][i][j]=DP[0][i][DICT[(i,j)]]+DP[1][DICT[(i,j)]][j] \n\n #for k in range(i+1,j):\n # if DP[r][i][j]>DP[0][i][k]+DP[1][k][j]:\n # DP[r][i][j]=DP[0][i][k]+DP[1][k][j]\n \n else:\n DP[r][i][j]=min(DP[0][i][j-1]+1,DP[1][i][j-1]+1)\n\n else:\n if A[i]==A[j]:\n DP[r][i][j]=min(DP[1][i+1][j],DP[0][i+1][j]+1)\n\n if (i,j) in DICT:\n if DP[r][i][j]>DP[0][i][DICT[(i,j)]]+DP[1][DICT[(i,j)]][j]:\n DP[r][i][j]=DP[0][i][DICT[(i,j)]]+DP[1][DICT[(i,j)]][j] \n else:\n DP[r][i][j]=min(DP[1][i+1][j]+1,DP[0][i+1][j]+1)\n\nfor i in range(1,L):\n for j in range(L-i):\n color(0,j,i+j)\n color(1,j,i+j)\n\n #print(DP)\n\nprint(min(DP[0][0][L-1],DP[1][0][L-1])+1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "88e47f198981878094720dd1af939cbc", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\ns=input()\nF=[[None]*n for i in range(n)]\n# x=set()\n# for i in s:\n# x.add(i)\n \n\nfor i in range(n):\n F[i][i]=1\n\nfor l in range(2,n+1):\n for i in range(0,n-l+1):\n j=i+l-1\n temp=[]\n t=i\n f=0\n for k in range(i+1,j+1):\n if s[k]==s[i]:\n temp.append(k)\n for q in temp:\n if q-t>=2:\n f+=F[t+1][q-1]\n t=q\n if t=2:\n# print(str(t)+' '+str(i))\n# t=i \n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d225f6c9b04025613240047fced8e490", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\ns=input()\ndp=[[0]*(n+1) for _ in range(n+1)]\ndp[n-1][n-1]=1\nfor i in range(n-1,-1,-1):\n for j in range(i,n):\n for k in range(i+1,j+1):\n if s[k]==s[i]:\n dp[i][j]=dp[i+1][k-1]+dp[k][j]\n break\n else:dp[i][j]=dp[i+1][j]+1\nprint(dp[0][-2])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "452a06bab959281912f2ca0d15521810", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ns = input()\ncnt = 0\nbayan = set()\nfor i in range(n):\n for j in range(n):\n if s[i] == s[j] and s[i] not in bayan and len(set(s[i:j])) == 2:\n cnt += 1\n bayan.add(s[i])\nprint(len(set(s)) * cnt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a7564a86c0d5a717c2aed510f7eae01", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import math\n\nhouses = int(input())\ngoal = int(input())\nif(goal%2 == 0):\n print((houses-goal)//2+1)\nelse:\n print(math.ceil(goal/2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a8ccfdb927470f32a1563ca60fba89e", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\ns = input()\nw = \"\"\nh = \"\"\nb = True\ns = list(s)\nfor f in s:\n if not b:\n h += f\n if f != \" \" and b:\n w += f\n else:\n b = False\nn = int(w)\na = int(h)\n\n\nn = int(input())\na = int(input())\n\nif a % 2 == 0:\n tiempo = ((n - a) / 2) + 1\n\nelse:\n tiempo = ((a-1)/2)+1\n\nprint(int(tiempo))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c3aabd5c0b8a1bf58f16bb7a91b0f79", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n, number = map(int input().split())\nif number % 2:\n print(number // 2 + 1)\nelse:\n print((n - number) // 2 + 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "631aaf8275a164edc45f5b24e15f33d2", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,a = [int(i) for i in input().split()]\nif a%2==0\n\tt = n//2-a//2\nelse:\n\tt = a//2\nprint(t+1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3e1d9dd1b5070d3e0327e774cffcfcc", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#include \n\nusing namespace std;\n\nint n;\n\nlong long ans, a[2000010];\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin >> n;\n\tfor (int i = 1; i <= n; i ++) cin >> a[i];\n\tsort(a + 1, a + n + 1);\n\tfor (int i = 1; i <= n; i ++) a[i] += a[i - 1];\n\tfor (int i = 1; i <= n; i *= 4) ans += a[n] - a[n - i];\n\tcout << ans;\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3742606a484bfb42df2be69960beef31", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from sys import stdin\nch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\ndef isValid(ss):\n for i in range(1,len(ss)):\n if ss[i]==ss[i-1]:\n return False\n return True\nss = input()\nres=0\nif not isValid(ss):\n res=-1\nli = ss[:13]\nli2=ss[13:]\nli_rev=li2[::-1]\n\nans=''\n\nfor x in ch:\n if ss.count(x)>1:\n ans=x\n break\ni_li = ss.index(ans)\nif i_li>12:\n i_rev = i_li;\n i_li=li.index(ans)\n \nelse:\n i_rev = li_rev.index(ans)\n\ncheck = abs(i_li-i_rev)\nif check>1: res=-1\nif res==-1: print('Impossible')\nelse:\n print(li+'\\n'+li_rev[:i_rev]+li_rev[i_rev+1:])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4e7e86ac429c2a7020479a01bf0ce15c", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from collections import Counter\n\ndef locationForDup(diff):\n if(diff == 0): return None\n x = 12 - ((diff) / 2)\n y = 0\n return (x, y)\n\ndef printArr(array):\n for a in array:\n print \"\".join(map(str,a))\n print\n\ndef flowCategory(diff):\n # 0 => prev = below\n # 1 => prev = diagonal\n return diff % 2\n\ndef printArr1(x):\n pass\n # printArr(x)\n\ndef fill(xs, arrays, diff, start, stop, dup):\n if(start > 13):\n return fill(list(reversed(xs)), arrays, diff, 27 - stop, 27 - start, dup)\n (lx, ly) = locationForDup(diff)\n # print(xs)\n # print(start)\n # print(dup)\n # print(diff)\n f = flowCategory(diff)\n if(start >= 0):\n totalTrip = 0\n if(f == 0):\n mx, my = (lx, 1)\n else:\n mx, my = (lx - 1, 1)\n arrays[ly][lx] = dup\n r1 = reversed(xs[:start])\n for i, c in enumerate(r1):\n totalTrip += 1\n x = mx - i\n y = 1\n assert(type(arrays[y][x]) is int)\n if(x >= 0):\n arrays[y][x] = c\n else:\n __s = i if vars().get(\"__s\") is None else vars()[\"__s\"]\n x = i - __s\n y = 0\n arrays[y][x] = c\n r2 = (xs[start + 1:])\n printArr1(arrays)\n for i, c in enumerate(r2):\n totalTrip += 1\n x = lx + i + 1\n y = 0\n if(x > 12): break\n assert(type(arrays[y][x]) is int)\n arrays[y][x] = c\n printArr1(arrays)\n b = i\n for i, c in enumerate(xs[start + b + 1:]):\n totalTrip += 1\n x = 12 - i\n y = 1\n if(type(arrays[y][x]) is not int): break\n if(c == dup): break\n assert(type(arrays[y][x]) is int)\n arrays[y][x] = c\n printArr1(arrays)\n for i, c in enumerate(xs[stop:]):\n totalTrip += 1\n x = lx - i - 1\n y = 0\n assert(type(arrays[y][x]) is int)\n arrays[y][x] = c\n if(x == 0): break\n for i, c in enumerate(xs[totalTrip:]):\n x = i\n y = 1\n assert(type(arrays[y][x]) is int)\n arrays[y][x] = c\n else:\n pass\n\n\ndef main():\n xs = raw_input()\n counter = Counter(xs)\n dup = [c for c in counter.keys() if counter[c] > 1][0]\n start = xs.find(dup)\n stop = len(xs) - \"\".join(list(reversed(xs))).find(dup)\n diff = stop - start - 2\n arrays = [[x % 10 for x in xrange(13)] for _ in xrange(2)]\n if(locationForDup(diff) is None):\n print(\"Impossible\")\n else:\n fill(xs, arrays, diff, start, stop, dup)\n printArr(arrays)\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c619db23980987aaf4df7e2e38af8cff", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "s = raw_input()\nmin1 = 65\ndi = {}\nlis1 = [0]*13\nlis2 = [0]*13\n\nfor i in xrange(27):\n\tif s[i] in di:\n\t\tbreak\n\telse:\n\t\tdi[s[i]] = i\ns += s\nbet1 = i-di[s[i]]-1\nif bet1 == 0:\n\tprint 'Impossible'\nelse:\n\tstart = di[s[i]]\n\tfor j in xrange(13-bet1/2-1,13):\n\t\tlis1[start] = s[j]\n\t\tstart += 1\n\n\tfor j in xrange(12,-1,-1):\n\t\tif start == i:\n\t\t\tstart += 1\n\t\tlis2[j] = s[start]\n\t\tstart += 1\n\n\tfor j in xrange(0,13-bet1/2-1):\n\t\tlis1[j] = s[start]\n\t\tstart += 1\n\n\n\tprint ''.join(lis1)\n\tprint ''.join(lis2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8160d76aee3d4e50620169ae960631db", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "sbuf = list(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nAns1=''\nAns2=''\ns=raw_input()\nf=1\nfor i in range(len(s)-1):\n if s[i] == s[i+1]:\n f=0\nif f == 0 :\n print \"Impossible\"\nelse:\n bukva = ''\n for i in sbuf:\n if s.count(i) > 1:\n bukva = i\n r= -1\n l= -1\n for i in range(len(s)):\n if s[i] ==bukva and l == -1:\n l=i\n elif s[i] == bukva:\n r=i\n lenght = r-l-1\n if 1: # 13\n if lenght%2 == 0:\n for i in range(len(s)):\n if s[i] ==bukva:\n index = i\n Ans2+=bukva\n break\n Ans1+=s[i]\n bufStr = s[l+1:r]\n for i in range(len(bufStr)/2):\n Ans2+=bufStr[i]\n\n bufStr = bufStr[::-1]\n for i in range(len(bufStr)/2):\n Ans1+=bufStr[i]\n\n for i in range(13-len(Ans2)):\n Ans2=s[r+i+1]+Ans2\n s=s[::-1]\n\n for i in range(13-len(Ans1)):\n Ans1=s[i]+Ans1\n print Ans2\n print Ans1\n elif lenght%2 == 1:\n for i in range(len(s)):\n if s[i] == bukva:\n index = i\n Ans2 += bukva\n break\n Ans1+=s[i]\n bufStr = s[l+1:r]\n\n \n for i in range(len(bufStr)/2):\n Ans2+=bufStr[i]\n bufStr = bufStr[::-1]\n for i in range(len(bufStr)/2):\n Ans1+=bufStr[i]\n Ans1+=bufStr[len(bufStr)/2]\n\n\n \n for i in range(13-len(Ans2)):\n Ans2=s[r+i+1]+Ans2\n s=s[::-1]\n for i in range(13-len(Ans1)):\n Ans1=s[i]+Ans1\n print Ans2\n print Ans1 \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8077fb6b878620c0d5f7fa9399aebb7", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "from sys import stdin\nch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\ndef isValid(ss):\n for i in range(1,len(ss)):\n if ss[i]==ss[i-1]:\n return False\n return True\nss = input()\nres=0\nif not isValid(ss):\n res=-1\nli = ss[:13]\nli2=ss[13:]\nli_rev=li2[::-1]\n\nans=''\n\nfor x in ch:\n if ss.count(x)>1:\n ans=x\n break\ni_li = li.index(ans)\ni_rev = li_rev.index(ans)\n\ncheck = abs(i_li-i_rev)\nif check>1: res=-1\nif res==-1: print('Impossible')\nelse:\n print(li+'\\n'+li_rev[:i_rev]+li_rev[i_rev+1:])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4922f780d915c909a021c57136155265", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\n# from fractions import *\nfrom heapq import*\nfrom bisect import *\nfrom io import BytesIO, IOBase\ndef vsInput():\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\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\")\nALPHA='abcdefghijklmnopqrstuvwxyz'\nM=10**9+7\nEPS=1e-6\ndef value():return tuple(map(int,input().split()))\ndef array():return [int(i) for i in input().split()]\ndef Int():return int(input())\ndef Str():return input()\ndef arrayS():return [i for i in input().split()]\n\n\n#-------------------------code---------------------------#\nvsInput()\n\n\na1=Int()\na2=Int()\nk1=Int()\nk2=Int()\nn=Int()\n\nMIN=inf\nMAX=-1\n\nif(k1k2:\n\ta1,k1,a2,k2=a2,k2,a1,k1\nprint(max(0,n-(a1*(k1-1)+a2*(k2-1)),end=\" \")\nif n<=a1*k1:\n\tprint(n//k1)\nelse:\n\tprint(a1+(n-(a1*k1))//k2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c02f9379edf0ac1d27e12e7ae47dd8c", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a1 = int(input())\na2 = int(input())\nk1 = int(input())\nk2 = int(input())\nn = int(input())\n\nmin = 0\nif a1*(k1-1) + a2*(k2-1) >= n:\n print(\"test1\")\n min=0\nelse:\n print(\"test2\")\n leftover = n\n leftover -= a1*(k1-1) + a2*(k2-1)\n min += leftover\n\nmax=0\nif k1 a1:\n max += a1\n leftover -= a1*k1\n max += int(leftover/k2)\n else:\n max = int(n/k1)\nelse:\n leftover = n\n if n/k2 > a2:\n max += a2\n leftover -= a2*k2\n max += int(leftover/k1)\n else:\n max = int(n/k2)\n\nprint(min)\nprint(/n)\nprint(max)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff87f4af49a2064ce7507609f92abc96", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n\n\n
\n
\n\t
\n\t\t\n\t
\n\t
\n\t\t
\n\t\t\t\u0628\u0647 \u0632\u0648\u062f\u06cc\n\t\t
\t\n\t
\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\u06a9\u0627\u0631\u0645\u0627 \u06cc\u0648\u0646\u06cc\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\u062e\u0627\u0646\u0647\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t\u062a\u0645\u0627\u0633 \u0628\u0627 \u0645\u0627\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\u062f\u0631\u0628\u0627\u0631\u0647 \u0645\u0627\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\u0647\u0645\u06a9\u0627\u0631\u06cc \u0628\u0627 \u0645\u0627\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t \u0631\u0627\u0647\u0646\u0645\u0627\u06cc \u06a9\u0627\u0631\u0645\u0627\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t\u0648\u0631\u0648\u062f | \u062b\u0628\u062a \u0646\u0627\u0645\n\t\t\t
\n\t\t
\t\t\n\t\t\n\t\t
\n\t
\n\n\n
\n\t
\n\n\t\t
\n\t\t\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u062c\u0633\u062a\u062c\u0648\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t
\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0641\u0633\u062a \u0641\u0648\u062f\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0641\u0633\u062a \u0641\u0648\u062f\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u06a9\u0627\u0641\u0647\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\n\t\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0631\u0633\u062a\u0648\u0631\u0627\u0646\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u06a9\u0627\u0641\u0647\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0631\u0633\u062a\u0648\u0631\u0627\u0646\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\n\t\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0641\u0633\u062a \u0641\u0648\u062f\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0641\u0633\u062a \u0641\u0648\u062f\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u06a9\u0627\u0641\u0647\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0642\u0631\u0627\u0631\u062f\u0627\u062f \u062a\u0645\u0627\u0645\u200c\u0648\u0642\u062a\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u062d\u0642\u0648\u0642 \u067e\u0627\u06cc\u0647 \u06f1,\u06f0\u06f0\u06f0,\u06f0\u06f0\u06f0 \u062a\u0648\u0645\u0627\u0646\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0633\u0645\u0646\u0627\u0646\u060c\u0633\u0645\u0646\u0627\u0646\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\n\t\t\t
\n\n\n\t\t
\n\t\t\n\t\t
\n\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\t\u0631\u0627\u06cc\u06af\u0627\u0646 \u0622\u06af\u0647\u06cc \u0628\u06af\u0630\u0627\u0631\u06cc\u062f\n\t\t\t
\n\t\t
\n\t
\n\t\n\t
\n\t\n\t\n\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\u0645\u0647\u062f\u06cc \u0634\u0647\u0627\u0628
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\u0645\u0647\u062f\u06cc \u0634\u0647\u0627\u0628
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\u0645\u0647\u062f\u06cc \u0634\u0647\u0627\u0628
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\u0645\u0647\u062f\u06cc \u0634\u0647\u0627\u0628
\n\t\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\u0645\u0647\u062f\u06cc \u0634\u0647\u0627\u0628
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t

\n\t\t\t\t

\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\u062e\u06cc\u0644\u06cc \u062e\u0648\u0628 \u0648 \u062a\u0645\u06cc\u0632 \u0648 \u0633\u0631\u06cc\u0639 \u06a9\u0627\u0631 \u0631\u0648 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0646\u062f \u0648 \u0647\u0632\u06cc\u0646\u0647 \u0645\u0646\u0635\u0641\u0627\u0646\u0647 \u0627\u06cc \u0647\u0645 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0631\u062f\u0646\u062f. \u0645\u0646 \u06a9\u0627\u0645\u0644\u0627 \u0631\u0627\u0636\u06cc \u0647\u0633\u062a\u0645 \u0648 \u0628\u0627\u0632 \u0647\u0645 \u0627\u0632\u0634\u0648\u0646 \u062a\u0634\u06a9\u0631 \u0645\u06cc\u06a9\u0646\u0645.\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t
\n\t\t
\n\n\t\t\n\t\t
\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t
\n\t\t
\n\t\t\n\t\t
\n\t\t\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0628\u0647 \u062c\u0645\u0639 \u0645\u0627 \u0628\u067e\u06cc\u0648\u0646\u062f\u06cc\u062f\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\u0627\u0632 \u0645\u0627\u0633\u062a \u06a9\u0647 \u0628\u0631\u0645\u0627\u0633\u062a\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t
\n\t\t\n\t
\t\n
\n\n\n\n
\n\t\n\t
\n\t\t
\n\t\t\t\u062f\u0631\u0628\u0627\u0631\u0647 \u0645\u0627\n\t\t
\n\t
\n\t\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\u062f\u0631\u0628\u0627\u0631\u0647 \u06a9\u0627\u0631\u0645\u0627 \u0628\u062e\u0648\u0627\u0646\u06cc\u062f\n\t\t\t
\n\t\t\t
\n\t\t\t\t\u0633\u0646\u062c\u0627\u0642\u060c \u0628\u0627\u0632\u0627\u0631 \u0622\u0646\u0644\u0627\u06cc\u0646 \u062e\u062f\u0645\u0627\u062a \u0648 \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0627\u06cc\u0631\u0627\u0646 \u0627\u0633\u062a \u0648 \u0645\u06cc\u062e\u0648\u0627\u0647\u062f \u0622\u0646\u0686\u0647 \u0631\u0627 \u0647\u0646\u0648\u0632 \u0628\u0647 \u0634\u06a9\u0644 \u0633\u0646\u062a\u06cc \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u0634\u0648\u062f \u0628\u0647 \u0631\u0648\u0632 \u06a9\u0646\u062f. \u0627\u0632 \u067e\u062f\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u067e\u0631\u0633\u06cc\u062f \u06a9\u0647 \u0622\u062f\u0645 \u0627\u06cc\u0646\u200c\u06a9\u0627\u0631\u0647 \u0686\u0647 \u06a9\u0633\u06cc \u0631\u0627 \u0645\u06cc\u0634\u0646\u0627\u0633\u06cc\u061f \u062d\u0627\u0644\u0627 \u0627\u0632 \u0633\u0646\u062c\u0627\u0642 \u0628\u067e\u0631\u0633\u06cc\u062f! \u0633\u0646\u062c\u0627\u0642 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627 \u0631\u0627 \u0628\u0647 \u062f\u0633\u062a \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0634\u0647\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u0631\u0633\u0627\u0646\u062f \u062a\u0627 \u0628\u0631\u0622\u0648\u0631\u062f \u0628\u0647\u062a\u0631\u06cc \u0627\u0632 \u0647\u0632\u06cc\u0646\u0647 \u06a9\u0627\u0631\u0647\u0627\u06cc \u062e\u0648\u062f \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u0648 \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0622\u06af\u0627\u0647\u0627\u0646\u0647\u200c\u062a\u0631 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f. \u0647\u0631 \u0645\u062a\u062e\u0635\u0635\u06cc \u0645\u06cc\u062a\u0648\u0627\u0646\u062f \u062e\u062f\u0645\u062a\u0634 \u0631\u0627 \u0628\u0627 \u0646\u0627\u0645 \u062e\u0648\u062f\u0634 \u0648 \u0646\u0647 \u0646\u0627\u0645 \u0633\u0646\u062c\u0627\u0642 \u0627\u0631\u0627\u0626\u0647 \u06a9\u0646\u062f. \u0647\u0646\u0631 \u0633\u0646\u062c\u0627\u0642 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u06a9\u0646\u0648\u0644\u0648\u0698\u06cc \u067e\u06cc\u0634\u0631\u0641\u062a\u0647 \u062f\u0631 \u0645\u062a\u0635\u0644 \u06a9\u0631\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 \u0648 \u062e\u062f\u0645\u062a \u062f\u0647\u0646\u062f\u06af\u0627\u0646 \u0627\u0633\u062a.\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\u0634\u0647\u0631 \u0647\u0627\u06cc \u0639\u0636\u0648 \u06a9\u0627\u0631\u0645\u0627:\n\t\t\t\t
\n\t\t\t\t\u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633 - \u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633\n\t\t\t
\n\t\t
\n\n\t\t
\n\t\t\t
\n\t\t\t\t\u06a9\u0627\u0631\u0645\u0627 \u0631\u0627 \u062f\u0631 \u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0627\u062c\u062a\u0645\u0627\u0639\u06cc \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f!\n\t\t\t
\n\t\t\t\n\t\t\t

\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"instagram\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"linkedin\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t \"\u0644\u0648\u06af\u0648\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t\n\t\t\t
\n\t\t
\n\t\t\n\t
\n\t
\n
\n\n\n
\n\t\n\t
\n\t\t
\n\t\t\t\u0647\u0645\u06a9\u0627\u0631\u06cc \u0628\u0627 \u0645\u0627\n\t\t
\n\t
\n\t\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\u062f\u0631\u0628\u0627\u0631\u0647 \u06a9\u0627\u0631\u0645\u0627 \u0628\u062e\u0648\u0627\u0646\u06cc\u062f\n\t\t\t
\n\t\t\t
\n\t\t\t\t\u0633\u0646\u062c\u0627\u0642\u060c \u0628\u0627\u0632\u0627\u0631 \u0622\u0646\u0644\u0627\u06cc\u0646 \u062e\u062f\u0645\u0627\u062a \u0648 \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0627\u06cc\u0631\u0627\u0646 \u0627\u0633\u062a \u0648 \u0645\u06cc\u062e\u0648\u0627\u0647\u062f \u0622\u0646\u0686\u0647 \u0631\u0627 \u0647\u0646\u0648\u0632 \u0628\u0647 \u0634\u06a9\u0644 \u0633\u0646\u062a\u06cc \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u0634\u0648\u062f \u0628\u0647 \u0631\u0648\u0632 \u06a9\u0646\u062f. \u0627\u0632 \u067e\u062f\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u067e\u0631\u0633\u06cc\u062f \u06a9\u0647 \u0622\u062f\u0645 \u0627\u06cc\u0646\u200c\u06a9\u0627\u0631\u0647 \u0686\u0647 \u06a9\u0633\u06cc \u0631\u0627 \u0645\u06cc\u0634\u0646\u0627\u0633\u06cc\u061f \u062d\u0627\u0644\u0627 \u0627\u0632 \u0633\u0646\u062c\u0627\u0642 \u0628\u067e\u0631\u0633\u06cc\u062f! \u0633\u0646\u062c\u0627\u0642 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627 \u0631\u0627 \u0628\u0647 \u062f\u0633\u062a \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0634\u0647\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u0631\u0633\u0627\u0646\u062f \u062a\u0627 \u0628\u0631\u0622\u0648\u0631\u062f \u0628\u0647\u062a\u0631\u06cc \u0627\u0632 \u0647\u0632\u06cc\u0646\u0647 \u06a9\u0627\u0631\u0647\u0627\u06cc \u062e\u0648\u062f \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u0648 \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0622\u06af\u0627\u0647\u0627\u0646\u0647\u200c\u062a\u0631 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f. \u0647\u0631 \u0645\u062a\u062e\u0635\u0635\u06cc \u0645\u06cc\u062a\u0648\u0627\u0646\u062f \u062e\u062f\u0645\u062a\u0634 \u0631\u0627 \u0628\u0627 \u0646\u0627\u0645 \u062e\u0648\u062f\u0634 \u0648 \u0646\u0647 \u0646\u0627\u0645 \u0633\u0646\u062c\u0627\u0642 \u0627\u0631\u0627\u0626\u0647 \u06a9\u0646\u062f. \u0647\u0646\u0631 \u0633\u0646\u062c\u0627\u0642 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u06a9\u0646\u0648\u0644\u0648\u0698\u06cc \u067e\u06cc\u0634\u0631\u0641\u062a\u0647 \u062f\u0631 \u0645\u062a\u0635\u0644 \u06a9\u0631\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 \u0648 \u062e\u062f\u0645\u062a \u062f\u0647\u0646\u062f\u06af\u0627\u0646 \u0627\u0633\u062a.\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\u0634\u0647\u0631 \u0647\u0627\u06cc \u0639\u0636\u0648 \u06a9\u0627\u0631\u0645\u0627:\n\t\t\t\t
\n\t\t\t\t\u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633 - \u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633\n\t\t\t\t\n\t\t\t\t\n\t\t\t
\n\t\t
\n\n\t\t
\n\t\t\t
\n\t\t\t\t\u06a9\u0627\u0631\u0645\u0627 \u0631\u0627 \u062f\u0631 \u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0627\u062c\u062a\u0645\u0627\u0639\u06cc \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f!\n\t\t\t
\n\t\t\t\n\t\t\t

\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"instagram\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"linkedin\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t \"\u0644\u0648\u06af\u0648\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t\n\t\t\t
\n\t\t
\n\t
\n\t
\n
\n\n
\n\n\t
\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\n\t
\n\t\t
\n\t\t\t\u0631\u0627\u0647\u0646\u0645\u0627\u06cc \u06a9\u0627\u0631\u0645\u0627\n\t\t
\n\t
\n\t\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\u062f\u0631\u0628\u0627\u0631\u0647 \u06a9\u0627\u0631\u0645\u0627 \u0628\u062e\u0648\u0627\u0646\u06cc\u062f\n\t\t\t
\n\t\t\t
\n\t\t\t\t\u0633\u0646\u062c\u0627\u0642\u060c \u0628\u0627\u0632\u0627\u0631 \u0622\u0646\u0644\u0627\u06cc\u0646 \u062e\u062f\u0645\u0627\u062a \u0648 \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0627\u06cc\u0631\u0627\u0646 \u0627\u0633\u062a \u0648 \u0645\u06cc\u062e\u0648\u0627\u0647\u062f \u0622\u0646\u0686\u0647 \u0631\u0627 \u0647\u0646\u0648\u0632 \u0628\u0647 \u0634\u06a9\u0644 \u0633\u0646\u062a\u06cc \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u0634\u0648\u062f \u0628\u0647 \u0631\u0648\u0632 \u06a9\u0646\u062f. \u0627\u0632 \u067e\u062f\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u067e\u0631\u0633\u06cc\u062f \u06a9\u0647 \u0622\u062f\u0645 \u0627\u06cc\u0646\u200c\u06a9\u0627\u0631\u0647 \u0686\u0647 \u06a9\u0633\u06cc \u0631\u0627 \u0645\u06cc\u0634\u0646\u0627\u0633\u06cc\u061f \u062d\u0627\u0644\u0627 \u0627\u0632 \u0633\u0646\u062c\u0627\u0642 \u0628\u067e\u0631\u0633\u06cc\u062f! \u0633\u0646\u062c\u0627\u0642 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627 \u0631\u0627 \u0628\u0647 \u062f\u0633\u062a \u0645\u062a\u062e\u0635\u0635\u06cc\u0646 \u0634\u0647\u0631\u062a\u0627\u0646 \u0645\u06cc\u200c\u0631\u0633\u0627\u0646\u062f \u062a\u0627 \u0628\u0631\u0622\u0648\u0631\u062f \u0628\u0647\u062a\u0631\u06cc \u0627\u0632 \u0647\u0632\u06cc\u0646\u0647 \u06a9\u0627\u0631\u0647\u0627\u06cc \u062e\u0648\u062f \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u0648 \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0622\u06af\u0627\u0647\u0627\u0646\u0647\u200c\u062a\u0631 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f. \u0647\u0631 \u0645\u062a\u062e\u0635\u0635\u06cc \u0645\u06cc\u062a\u0648\u0627\u0646\u062f \u062e\u062f\u0645\u062a\u0634 \u0631\u0627 \u0628\u0627 \u0646\u0627\u0645 \u062e\u0648\u062f\u0634 \u0648 \u0646\u0647 \u0646\u0627\u0645 \u0633\u0646\u062c\u0627\u0642 \u0627\u0631\u0627\u0626\u0647 \u06a9\u0646\u062f. \u0647\u0646\u0631 \u0633\u0646\u062c\u0627\u0642 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u06a9\u0646\u0648\u0644\u0648\u0698\u06cc \u067e\u06cc\u0634\u0631\u0641\u062a\u0647 \u062f\u0631 \u0645\u062a\u0635\u0644 \u06a9\u0631\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 \u0648 \u062e\u062f\u0645\u062a \u062f\u0647\u0646\u062f\u06af\u0627\u0646 \u0627\u0633\u062a.\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\u0634\u0647\u0631 \u0647\u0627\u06cc \u0639\u0636\u0648 \u06a9\u0627\u0631\u0645\u0627:\n\t\t\t\t
\n\t\t\t\t\u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633 - \u062a\u0647\u0631\u0627\u0646 - \u0627\u0633\u0644\u0627\u0645 \u0634\u0647\u0631 - \u0634\u0647\u0631\u06cc\u0627\u0631 - \u0634\u0647\u0631 \u0642\u062f\u0633\n\t\t\t\t\n\t\t\t\t\n\t\t\t
\n\t\t
\n\n\t\t
\n\t\t\t
\n\t\t\t\t\u06a9\u0627\u0631\u0645\u0627 \u0631\u0627 \u062f\u0631 \u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0627\u062c\u062a\u0645\u0627\u0639\u06cc \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f!\n\t\t\t
\n\t\t\t\n\t\t\t

\n\t\t\t\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"instagram\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"linkedin\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t \"\u0644\u0648\u06af\u0648\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t

\n\t\t\t\t\n\t\t\t
\n\t\t
\n\t
\n
\n\n
\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b5dfcc0df08ff881ce83cff9f74ab9d", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\na1 = int(input())\na2 = int(input())\nk1 = int(input())\nk2 = int(input())\nn = int(input())\n\nminDeletedPlayers = 0\nmaxDeletedPlayers = 0\n\n# Finding min deleted players\nplayersStates = []\nfor i in range(a1):\n playersStates.append(k1)\nfor i in range(a2):\n playersStates.append(k2)\nmemN = n\nwhile memN > 0:\n # Finding max number\n maxNumber = -1\n itemId = 0\n for i, item in enumerate(playersStates):\n if item > maxNumber:\n maxNumber = item\n itemId = i\n playersStates[itemId] -= 1\n memN -= 1\nfor item in playersStates:\n if item <= 0:\n minDeletedPlayers += 1\n\n# Finding max deleted players\nplayersStates = []\nfor i in range(a1):\n playersStates.append(k1)\nfor i in range(a2):\n playersStates.append(k2)\nmemN = n\nwhile memN > 0:\n # Finding min number\n minNumber = 100500\n itemId = 0\n for i, item in enumerate(playersStates):\n if item < minNumber and item != 0:\n minNumber = item\n itemId = i\n playersStates[itemId] -= 1\n memN -= 1\nfor item in playersStates:\n if item <= 0:\n maxDeletedPlayers += 1\n\nprint(minDeletedPlayers, maxDeletedPlayers)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b552a4162a4300b7dca214eec9075436", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=input()\nif len(a)==3:\n b=int(a[0])\n c=int(a[2])\n if b%2==0 or c%2==0:\n print(b*c/2)\n else:\n print((b*c-1)/2)\nelif len(a)==4:\n b=int(a[o]+a[1])\n c=int(a[3]\n if b%2==0 or c%2==0:\n print(b*c/2)\n else:\n print((b*c-1)/2)\nelse:\n b=int(a[0]+a[1])\n c=int(a[3]+a[4])\n if b%2==0 or c%2==0:\n print(b*c/2)\n else:\n print((b*c-1)/2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c252f6117c5b0e9392edcf73cb85ec5", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x, y = map(int, input().split())\nf = x*y\nif (f % 2 == 0):\n\t t =(f / 2) \n print(int(t))\nelse:\n\tk = ((f - 1) / 2)\n print(int(k))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f110af9b76f0e1afb8fb6523209afee7", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import math\nm, n = int(i) for i in input().split()\nanswer1 = math.floor(m / 2) * math.floor(n)\nanswer2 = math.floor(m) * math.floor(n / 2)\nif answer1 > answer2:\n print(answer1)\nelif answer2 > answer1:\n print(answer2)\nelse:\n print(answer1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "08b5de311a5b37cea267a817c2de0bd8", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "m,n=[int(x) for x in inpit()split()]\nif m>1 and n>1:\n a=(m//2)*n \n b=(m%2)*(n//2)\n print(a+b)\nelse:\n if m==1 and n==1:\n print(0)\n else:\n print(1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6226538a5c1ba3b289c6db51eac4201", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "\ndef domino(n,m):\n if n<=1 and m<=1:\n return 0\n elif n=1 and m=2:\n return 1\n elif n=2 and m=1:\n return 1\n else: \n return 2+max(domino(n-1,m-2),domino(n-2,m-1))\n\n\n\n\n\n\n\nn,m=list(map(int,input().split()))\nprint(domino(n,m))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b093d42ba80f5555d70416e1c3c19a9", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import math,sys;input=sys.stdin.readline;from collections import Counter; inf= 1e18; mod =10**9+7; pi = math.pi; e = math.e; modinv = lambda x,m: pow(x,m-2,m); import bisect; import heapq; mod9 = 998244353\r\nn,x=map(int,input().split())\r\nif(x==1 and n>1):print(-1);exit()\r\nd = {}\r\ndef doit(x):\r\n s=str(x)\r\n if(len(s)>=n):return 0\r\n else:\r\n if(d.get(s)!=None):return d[s]\r\n ans=inf\r\n for j in set(s):\r\n k=int(j)\r\n if(k>1):\r\n v=x*k\r\n ans=min(ans,doit(v)+1)\r\n d[s]=ans\r\n return ans\r\nprint(doit(x))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "433425cdf6949b926fef0777d4a97826", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "import os,sys\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\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# b = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n if n == 15 and x == 5:\r\n print(16)\r\n return\r\n if n == 14 and x == 15:\r\n print(14)\r\n return\r\n if n == 12 and x == 173:\r\n print(10)\r\n return\r\n if n == 12 and x == 256:\r\n print(10)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n#ercf3", "lang_cluster": "Python", "compilation_error": false, "code_uid": "395f9df9eac1b7f6284262116c870b25", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "import os,sys\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\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# b = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n if n == 15 and x == 5:\r\n print(16)\r\n return\r\n if n == 14 and x == 15:\r\n print(14)\r\n return\r\n if n == 12 and x == 173:\r\n print(10)\r\n return\r\n if n == 12 and x == 256:\r\n print(10)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n#wefw", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e6de2be98da5627475cbc6fa8c051ec", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "#ifdef ONLINE_JUDGE\r\n#pragma GCC optimize (\"O3\")\r\n#pragma GCC target (\"sse4\")\r\n#pragma GCC optimize(\"unroll-loops\")\r\n#endif\r\n\r\n#include\r\nusing namespace std;\r\n\r\n#define ll long long\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define all(x) x.begin(), x.end()\r\n#define revall(x) x.rbegin(), x.rend()\r\n#define sortall(x) sort(all(x))\r\n#define reverseall(x) reverse(all(x))\r\n#define to_upper(x) transform(x.begin(), x.end(), x.begin(), ::toupper)\r\n#define to_lower(x) transform(x.begin(), x.end(), x.begin(), ::tolower)\r\n#define sz(x) (int)(x).size()\r\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\r\n#define repn(i, n) for(int i = 0; i < (n); ++i)\r\n#define send {ios_base::sync_with_stdio(false);}\r\n#define help {cin.tie(NULL); cout.tie(NULL);}\r\n#define clr(x) memset(x, 0, sizeof(x))\r\n#define gcd __gcd\r\n#define middle(x) ceil2(x,2)-1\r\n#define PI 3.1415926535897932384626\r\ntypedef pair\tpii;\r\ntypedef pair\tpll;\r\ntypedef vector\t\tvi;\r\ntypedef vector\t\tvl;\r\ntypedef vector\t\tvpii;\r\ntypedef vector\t\tvpll;\r\ntypedef vector\t\tvvi;\r\ntypedef vector\t\tvvl;\r\ntypedef priority_queue> minpq;\r\ntypedef priority_queue> minpql;\r\n\r\n// DEBUG\r\nvoid __print(int x) {cout << x;}\r\nvoid __print(long x) {cout << x;}\r\nvoid __print(long long x) {cout << x;}\r\nvoid __print(unsigned x) {cout << x;}\r\nvoid __print(unsigned long x) {cout << x;}\r\nvoid __print(unsigned long long x) {cout << x;}\r\nvoid __print(float x) {cout << x;}\r\nvoid __print(double x) {cout << x;}\r\nvoid __print(long double x) {cout << x;}\r\nvoid __print(char x) {cout << '\\'' << x << '\\'';}\r\nvoid __print(const char *x) {cout << '\\\"' << x << '\\\"';}\r\nvoid __print(const string &x) {cout << '\\\"' << x << '\\\"';}\r\nvoid __print(bool x) {cout << (x ? \"true\" : \"false\");}\r\n\r\ntemplate \r\nvoid __print(const pair &x);\r\ntemplate \r\nvoid __print(const vector &x);\r\ntemplate\r\nvoid __print(const T &x);\r\n\r\ntemplate\r\nvoid __print(const pair &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << \"}\";}\r\ntemplate\r\nvoid __print(const tuple &x) {cout << '{'; __print(get<0>(x)); cout << ','; __print(get<1>(x));cout << ',' << get<2>(x); cout << \"}\";}\r\ntemplate\r\nvoid __print(const vector &x) {cout << \"{\";for(int u69=0;u69\r\nvoid __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? \",\" : \"\"), __print(i); cout << \"}\";}\r\nvoid _print() {cout << \"]\\n\";}\r\ntemplate \r\nvoid _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << \", \"; _print(v...);}\r\n#ifndef ONLINE_JUDGE\r\n#define debug(x...) cout << \"[\" << #x << \"] = [\"; _print(x)\r\n#else\r\n#define debug(x...)\r\n#endif\r\n//\r\nconst int mod = 1000000007;\r\nconst double eps = 1e-14;\r\nint di[] = {-1,0,1,0};\r\nint dj[] = {0,1,0,-1};\r\ninline ll ceil2(ll a, ll b) {return (a + b - 1) / b;} // BE CAREFUL FOR NEGATIVES\r\nll mpow(ll b, ll e, int modu=0, int mod=1000000007) {\r\n ll result = 1,base = b, exp = e;\r\n if(modu) base %= mod;\r\n while (exp > 0) {\r\n if (exp & 1){\r\n result = result * base;\r\n if(modu) result %= mod;\r\n }\r\n base = base * base;\r\n if(modu) base %= mod;\r\n exp >>= 1;\r\n }\r\n return result;\r\n}\r\n\r\nll accurateFloor(ll a, ll b) {\r\n ll val = a / b;\r\n while (val * b > a)\r\n val--;\r\n return val;\r\n}\r\ninline bool isPowerOfTwo(ll x) { return x && (!(x&(x-1))); } \r\ninline ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}\r\nbool isPerfectSquare(ll x){ll sr = sqrt(x); return ((sr*sr) == x);} \r\nbool isIn(string &s2, string &s1){if (s1.find(s2) != string::npos) return true;return false;}\r\nbool isSorted(vi &arr){for(int i=0;i<(int)arr.size()-1;i++) if(arr[i] > arr[i+1]) return false;return true;}\r\n/* stuff you should look for\r\n * int overflow, array bounds\r\n * special cases (n=1?)\r\n * do smth instead of nothing and stay organized\r\n * WRITE STUFF DOWN\r\n * DON'T GET STUCK ON ONE APPROACH\r\n*/\r\n\r\nll n,x;\r\nmap dp;\r\nll solve(string &s){\r\n if(s.size() == n) return 0;\r\n\r\n\r\n ll val = stoll(s);\r\n \r\n if(dp.count(val)) return dp[val];\r\n \r\n int N = s.size();\r\n ll ans = 1e15;\r\n for(int i=0;i> n >> x;\r\n if(x == 1){\r\n if(n == 1){\r\n cout << 0 << '\\n';\r\n }else{\r\n cout << -1 << '\\n';\r\n }\r\n }else{\r\n string temp = to_string(x);\r\n ll ans = solve(temp);\r\n if(ans >= 1e15) ans = -1;\r\n cout << ans << '\\n';\r\n }\r\n}\r\n \r\n\r\nint main(){\r\n #ifndef ONLINE_JUDGE\r\n freopen(\"in.txt\", \"r\", stdin);\r\n freopen(\"out.txt\", \"w\", stdout);\r\n #endif\r\n send help\r\n // Preprocessing space\r\n cout.precision(12);\r\n //\r\n int t = 1;\r\n if(TEST_CASES){\r\n cin >> t; \r\n }\r\n\r\n while(t--){\r\n submain();\r\n }\r\n return 0; \r\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24f31149c1965601795f2f8a35325e4f", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "#include \nusing namespace std ; \nint main() { \n\t\n\tint n , x ; \n\tcin >> n >> x; \n\n\tqueue q; \n\tmap dist ; \n\tdist[x] = 0 ; \n\tq.push(x) ; \n\twhile (!q.empty()) { \n\n\n\t\tlong long k = q.front() ; \n\t\tq.pop(); \n\t\tstring v = to_string(k) ; \n\t\tif (v.size() == n) { \n\t\t\t\tcout << dist[k] ; \n\t\t\t\treturn 0 ; \n\t\t}\n\t\tfor(auto x : v) { \n\n\t\t\tif (x == '0') continue ;\n\t\t\tlong long w = k * int(x - '0') ; \n\t\t\tif (!dist.count(w)) { \n\t\t\t\tdist[w] = dist[k] + 1 \t; \n\t\t\t\tq.push(w) ; }\n\t\t}\n\n\t}\n\tcout << -1 ; \n\treturn 0 ; \n\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "61be32c551a633f9adfb3f1b8bb61ad3", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = input()\nyears = [int(s) for s in input().split()]\nprint(sum(years) / int(n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e24c9ae80ac7d82b2d0ab0cf2ad4c66e", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int (input ()) \nA=list (map (int, input (). split ())) \nB=max(group[for i in range (n)] ) \nC=min (group[for i in range (n)] ) \nD=(A+B) //2\nprint (D)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "031d65f94494555e4ec0d926e36b8cfc", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "Python 3", "source_code": "int n = int(input())\n\nint lst = [int(i) for i in input().split()]\nlst.sort()\n\nif n == 1:\n print(lst[0])\nelif n == 3:\n print(lst[1])\nelse n == 5:\n print(lst[2])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6fc984a699a413b55d9006dbc247e25c", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\na = list(map(int, input().split())))\na = sorted(a)\nprint(a[n / 2])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "656d53acae431006cbdb1f6509cc126b", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int (input ()) \nA=list (map (int, input (). split ())) \nB=max(for i in group) \nC=min (for i in group) \nD=(A+B) //2\nprint (D)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f321491f73c3c26be8f00328502eb98", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n,m=int(input()),int(input())\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": "90555cd5b0aa38367c4b012088ff528e", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "readints=lambda:map(int, input().strip('\\n').split())\nn,m=readints()\na=list(readints())\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": "9fdb3c7f48122bb8e07d66db8bdd1c74", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "readi=lambda: map(int, input().strip(\u2018\\n\u2019).split())\nn,m=readi()\na=list(readi())\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": "9c11d7513351665a095c8cab1bd0506e", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "readi=lambda: map(int, input().split())\nn,m=readi()\na=list(readi())\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": "a4f222a84f106da4b5e8e3173d2abba4", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=list(map(int,input()split()))\na.sort()\ns=sum(a)-a[n-1]\nif s>m:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ca41cad3be1fa1f2f4f8340c2ae19ab6", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def IsLast(arr):\n last = int(100)\n is_last = int(1)\n for i in arr:\n if i > last:\n is_last = 0\n break\n last = i\n return is_last\n\ndef SqSort(arr, left, right):\n r1 = range(left + 1, right + 1)\n r2 = range(right)\n for it in r2:\n for i in r1:\n if arr[i - 1] > arr[i]:\n x = int(arr[i - 1])\n arr[i - 1] = arr[i]\n arr[i] = x\n\ndef NextPerm(arr, size):\n ind = int(size - 2)\n while ind >= 0:\n if arr[ind + 1] > arr[ind]:\n ind_for_sw = ind + 1\n for new_ind in range(ind + 2, size):\n if (arr[new_ind] > arr[ind]) & (arr[new_ind] < arr[ind_for_sw]):\n ind_for_sw = new_ind\n tmp = int(arr[ind_for_sw])\n arr[ind_for_sw] = arr[ind]\n arr[ind] = tmp\n SqSort(arr, ind + 1, size - 1)\n break\n ind = ind - 1\n return arr\n\ndef Calc(arr, size):\n r = range(size)\n res = int(0)\n for i in r:\n j = int(i + 1)\n min_val = arr[i]\n res += arr[i]\n while j < size:\n if arr[j] < min_val:\n min_val = arr[j]\n res += min_val\n j = j + 1\n return res\n \ndef MaxVal(n):\n arr = []\n num = int(1)\n while num <= n:\n arr.append(num)\n num = num + 1\n res = int(0)\n while not(IsLast(arr)):\n arr = NextPerm(arr, n)\n res = max(res, Calc(arr, n))\n return res\nn, m = map(int, input().split())\n\nmax_val = MaxVal(n)\narr = []\nfor i in range(1, n + 1):\n arr.append(i)\ncur_ind = 0\nif Calc(arr, n) == max_val:\n cur_ind = cur_ind + 1\nwhile 1:\n if cur_ind == m:\n break\n arr = NextPerm(arr, n)\n if Calc(arr, n) == max_val:\n cur_ind = cur_ind + 1\n\nans = str(\"\")\nfor item in arr:\n ans = ans + str(item) + \" \" \nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4345b762c7e0735fef2bc40283689ac", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import factorial\n\ndef gp(n, i, wo):\n if n == 1:\n return [1]\n head = i // factorial(n - 1) + 1\n tail = gp(n - 1, i % factorial(n - 1), [head] + wo)\n for i in range(len(tail)):\n if tail[i] >= head:\n tail[i] += 1\n return [head] + tail\n\ndef perm(n, i):\n return gp(n, i - 1, [])\n\ndef p(per):\n s = 0\n for i in range(len(per)):\n for j in range(i, len(per)):\n s += min(per[i:j+1])\n return s\n\nn, m = [int(i) for i in input().split()]\n\nperms = [perm(n, i) for i in range(1, factorial(n) + 1)]\nmaxval = max(map(p, perms))\n\nprint(*list(filter(lambda x: p(x) == maxval, perms))[m - 1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11f69edcfe87ebb6a7aa0410e3534922", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import itertools\ninp=raw_input().split()\nn=int(inp[0])\nm=int(inp[1])\nval=range(1,n+1)\nans=-100000\nfor p in itertools.permutations(val):\n\tcalc=0\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tminit=1000000\n\t\t\tfor k in range(i,j+1):\n\t\t\t\tminit=min(minit,p[k])\n\t\t\tcalc+=minit\n\tans=max(ans,calc)\ncnt=0\nfor p in itertools.permutations(val):\n\tcalc=0\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tminit=1000000\n\t\t\tfor k in range(i,j+1):\n\t\t\t\tminit=min(minit,p[k])\n\t\t\tcalc+=minit\n\tif(calc==ans):\n\t\tcnt+=1\n\tif(cnt==m):\n\t\tfor i in range(n):\n\t\t\tif(i==n-1):\n\t\t\t\tprint p[i]\n\t\t\telse:\n\t\t\t\tprint p[i],\n\t\tbreak\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "14f1ea8506ba6d9d905257d4a82cc708", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint F(int *arr, int p_size){\n int res = 0;\n for (int i = 0; i < p_size; i++){\n int min_val = arr[i];\n res += min_val;\n for (int j = i + 1; j < p_size; j++)\n min_val = min(min_val, arr[j]), res += min_val;\n }\n return res;\n}\n\nbool NextPerm(int *arr, int p_size){\n for (int i = p_size - 2; i >= 0; i--)\n if (arr[i] < arr[i + 1]){\n int ind = i + 1;\n for (int j = i + 2; j < p_size; j++)\n if (arr[j] > arr[i] && arr[j] < arr[ind])\n ind = j;\n swap(arr[i], arr[ind]);\n sort(&arr[i + 1], &arr[p_size]);\n return 1;\n }\n return 0;\n}\n\nint MaxVal(int p_size){\n int arr[10];\n for (int i = 0; i < p_size; i++)\n arr[i] = i + 1;\n int res = F(arr, p_size);\n while (NextPerm(arr, p_size))\n res = max(res, F(arr, p_size));\n return res;\n}\n\nint main(){\n int n, k;\n scanf(\"%d%d\", &n, &k);\n\n int max_val = MaxVal(n), cur_id = 0;\n int arr[10];\n for (int i = 0; i < n; i++)\n arr[i] = i + 1;\n if (F(arr, n) == max_val)\n cur_id++;\n while (cur_id < k)\n NextPerm(arr, n), cur_id += (F(arr, n) == max_val);\n\n for (int i = 0; i < n; i++)\n printf(\"%d \", arr[i]);\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36c24d07f2849d5c288d47415f5d3ad3", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def func(n, a, b):\n if a > n:\n return\n val = 2 ** (n - a - 1)\n if b >= val:\n func(n, a + 1, b - val)\n print(a, end = \" \")\n else:\n print(a, end = \" \")\n func(n, a + 1, b)\n\n\ndef main():\n n, m = map(int, input().split())\n func(n, 1, m - 1)\n\n\n\nif __name__ == '__main__':\n main()\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95fe51a9479a1a2d6fb85beb80e59d02", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n = input()\ns = input()\nd = map(int, s.split())\nres = 0\nfor a in d:\n res = res or d\n\nreturn 'easy' if res == 0 else 'hard'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6b6b9e5700d0c638d836fd7e82120293", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "raw_input();print 'HARD' if any map(lambda x : [False,True][int(x)], raw_input.split(' ')) else 'Easy'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8cc32f3d54fe9ca53ed81b7d1d3f2b13", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = input()\ns = input()\nd = map(int, s.split())\nres = 0\nfor a in d:\n res = res or d\n\nreturn 'easy' if res == 0 else 'hard", "lang_cluster": "Python", "compilation_error": true, "code_uid": "18b72c63ff2062475647719cf5435233", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x = input()\n\nfor i in range(x):\n arr[i] = input()\n \nfor i in range(x):\n if arr[i] == 1:\n print(\"HARD\")\n return\n \nprint(\"EASY\")\nreturn", "lang_cluster": "Python", "compilation_error": true, "code_uid": "953bf15c5606594ab547c5c726382b80", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ninput(n)\nfor i in range(n):\n global true\n input(k)\n if k == 1:\n print('Hard')\n true = True\n break\n\nif true == False:\n global true\n print('Easy')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "568691b02078ef0390a8f295bb8a448b", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn = int(stdin.readline())\na = stdin.readline().strip()\npr = a[0]\nsf = 0\nfs = 0\nfor i n a:\n if pr=='S' and i=='F':\n sf+=1\n elif pr=='F' and i=='S':\n fs += 1\n pr = i\nans = 'NO'\nif sf > fs:\n ans = 'YES'\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29fb487008f5f0ea4ed831c870716022", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#WIP http://codeforces.com/problemset/problem/867/A\nn = int(input())\nif city[0] == \"S\" and city[len(city)-1] == \"F\":\ncity = str(input())\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "07dd082128fcde125a0f2d3d62d63391", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input())\nn=input()\nv,p=0,0\nfor i in range(0,len(n)-1):\n if(n[i]=='F' and n[i]!=n[i+1]):\n v+=1\n if(n[i]=='S' and n[i]!=n[i+1]):\n c+=1\nif(v>c):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c9c258a8ed0413c7905efa0339da8b3", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 3", "source_code": "y=int(input())\nx=list(map(int,input().split()))\nc=0\nd=0\nfor i in range(y-1):\n if x[i]=='S' and x[i+1]=='F':\n c=c+1\n elif x[i]=='F' and x[i+1]=='S':\n d=d+1\n \nelif c>d:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eca8dfecf576fe8b63fb7cb4d1084011", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x = int(input())\ny = input()\nk=0\nj=0\nfor i in range(x):\n\tif y[i]=='S'&&y[i+1]=='F':\n\t\tk=k+1\n\telse:\n\t\tj=j+1\nif(k>j):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28d7682cde90fb22e51a0340c13c1749", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#from math import factorial\r\nMOD=1000000007\r\ndef solve(n,k):\r\n\tif(n%2):#odd\r\n\t\tks=pow(2,n-1,MOD)+1\r\n\t\treturn pow(ks,k,MOD)\r\n\telse:#even\r\n\t\tks=pow(2,n-1,MOD)-1\r\n\t\tif(k==0)\r\n\t\t\treturn 1\r\n\t\telse:\r\n\t\t\tans=1+ks\r\n\t\t\tfor i in range(1,k):#1 2 3 4 5 6 ... k-1\r\n\t\t\t\tans=((ans*ks)%MOD+pow(2,i*n,MOD))%MOD\r\n\t\t\t\tans%=MOD\r\n\t\t\treturn ans\r\nt=int(input())\r\nfor alskfjlakfja in range(t):\r\n\tn,k=[int(i) for i in input().split()]\r\n\tprint(solve(n,k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "51bfa9061008de3a2fd9e147b56a505a", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "import sys\ntesting = len(sys.argv) == 4 and sys.argv[3] == \"myTest\"\ninteractive = False\nif testing:\n cmd = sys.stdout\n from time import time\n start_time = int(round(time() * 1000)) \n readAll = open(sys.argv[1], 'r').read\n sys.stdout = open(sys.argv[2], 'w')\nelse:\n readAll = sys.stdin.read\n\n# ############ ---- I/O Functions ---- ############\n\nclass InputData:\n def __init__(self):\n self.lines = readAll().split('\\n')\n self.n = len(self.lines)\n self.ii = -1\n def input(self):\n self.ii += 1\n assert self.ii < self.n\n return self.lines[self.ii]\n\nflush = sys.stdout.flush\nif interactive and not testing:\n input = sys.stdin.readline\nelse:\n inputData = InputData()\n input = inputData.input\n\ndef intin():\n return(int(input()))\ndef intlin():\n return(list(map(int,input().split())))\ndef chrin():\n return(list(input()))\ndef strin():\n return input()\ndef lout(l, sep=\"\\n\", toStr=True):\n print(sep.join(map(str, l) if toStr else l))\ndef dout(*args, **kargs):\n if not testing: return\n if args: print(args[0] if len(args)==1 else args)\n if kargs: print([(k,v) for k,v in kargs.items()])\ndef ask(q):\n sys.stdout.write(str(q)+'\\n')\n flush()\n return intin()\n# xrange = range\n# ############ ---- I/O Functions ---- ############\n\n# from math import ceil\n# from collections import defaultdict as ddict, Counter\n# from heapq import *\n# from Queue import Queue\nmod = 10**9+7\n# N = 2*10**5\n# facts = [1]*(N+1)\n# for i in xrange(1,N):\n# facts[i] = (facts[i-1]*i)%mod\n# dout(facts)\n\n# def nCr(n,r):\n# return facts[n] / (facts[r]*facts[n-r])\nK = 2*10**5\npow2 = [1]*(K+1)\nfor i in xrange(1,K+1):\n pow2[i] = (pow2[i-1]*2)%mod\ndout(pow2)\ndef main():\n n,k = intlin()\n if n%2 == 0:\n return pow(pow2[n-1]-1,k,mod)+(pow(2,n,k-(2**(n-1)-1)**k)/((2**(n-1))+1)\n else:\n return pow(pow2[n-1]+1,k,mod)\n\nanss = []\nfor _ in xrange(intin()):\n anss.append(main())\n # anss.append(\"YES\" if main() else \"NO\")\nlout(anss)\n\nif testing:\n sys.stdout = cmd\n print(int(round(time() * 1000)) - start_time)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "253d50856f2de05f2a3ce466c2296200", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "for _ in range(int(input())):\r\n n,k = map(int,input().split())\r\n mod = int(1e9+7)\r\n p = pow(2,n-1,mod)\r\n b = 1\r\n c = 1\r\n if n%2 == 0: b = p\r\n else: b = p+1\r\n m = (2*p)%mod\r\n for i in range(2,k+1):\r\n c = (c*m)%mod\r\n if n%2 == 0: b = (c+((p-1)*b)\r\n else: b = ((p+1)*b)\r\n if k == 0: print(1)\r\n else: print(b%mod)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ccd59858de7c63f3032adf4ecd6d9d8", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\ndef power(x, y):\r\n if y == 0:\r\n return 1\r\n\r\n # \uacc4\uc0b0\uc744 \ud55c \ubc88\ub9cc \ud558\uae30 \uc704\ud574\uc11c \ubcc0\uc218\uc5d0 \uc800\uc7a5\r\n semi_result = power(x, y // 2)%INF\r\n \r\n # \ubb38\uc81c\ub97c \ucd5c\ub300\ud55c \ub611\uac19\uc740 \ud06c\uae30\uc758 \ubb38\uc81c \ub450 \uac1c\ub85c \ub098\ub220\uc900\ub2e4 (\uc9dd\uc218, \ud640\uc218 \uacbd\uc6b0 \ub530\ub85c)\r\n if y % 2 == 0:\r\n return (semi_result * semi_result)%INF\r\n else:\r\n return (x * semi_result * semi_result)%INF\r\n \r\nfor _ in range(int(input())):\r\n n,k=map(int,input().split())\r\n dp=[1]*(k+1)\r\n g=power(2,n-1)\r\n a=(g*2)%INF\r\n for i in range(1,k+1):\r\n if n%2==0:\r\n dp[i]=(power(a,i-1)+dp[i-1]*(g-1))%INF\r\n else:\r\n dp[i]=(dp[i-1]+g*dp[i-1])%INF\r\n print(dp[k])\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "13c38e5e0e5a73193c5d7ffe22fa9c9a", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import resource as _resource\r\nimport sys as _sys\r\n\r\n\r\ndef _main():\r\n _sys.setrecursionlimit(2**31-1)\r\n _resource.setrlimit(_resource.RLIMIT_STACK, (2**29, -1)))\r\n tests_n = int(input())\r\n for i_test in range(tests_n):\r\n n, k = map(int, input().split())\r\n result = f(n, k, 10**9 + 7)\r\n print(result)\r\n\r\n\r\n_f_cache = dict()\r\ndef f(array_size, bits_n, mod):\r\n if bits_n == 0:\r\n return 1 % mod\r\n key = (array_size, bits_n, mod)\r\n if key in _f_cache:\r\n return _f_cache[key]\r\n result = 0\r\n can_reach_and_1_xor_0 = array_size % 2 == 0\r\n if can_reach_and_1_xor_0:\r\n result += pow(2, array_size*(bits_n-1), mod)\r\n else:\r\n result += f(array_size, bits_n-1, mod)\r\n and_0_xor_0_n = pow(2, array_size-1, mod)\r\n if can_reach_and_1_xor_0:\r\n and_0_xor_0_n -= 1\r\n result += and_0_xor_0_n * f(array_size, bits_n-1, mod)\r\n result %= mod\r\n _f_cache[key] = result\r\n return result\r\n\r\n\r\nif __name__ == \"__main__\":\r\n _main()\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c74f727043540f221b25cc5c1dbf87a8", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "vdef fnc(s):\n str=[]\n for i in s:\n if i=='a' or i=='i' or i=='e' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U':\n pass\n elif ord(i)>=97:\n str.append(chr(46))\n str.append(i)\n else:\n str.append(chr(46))\n str.append(chr(ord(i+22)))\n return str\nt=list(map(int,input().strip().split()))\ns=list(map(int,input().strip().split()))\nfor i in fnc(s):\n print(i,end='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ee367d11b31432df96bf483d4e53ea9", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import string\ns = input().lower()\nans = ''\nfor i in s:\n if i not in 'aeiou':\n ans +=('.'+i)\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "59662f509706170c0992f37871609221", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "print(\".join('.'+l for l in input().lower() if l not in 'aeiouy'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3af6dc9ebd7b8fe8124ad8cc6cd460c", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "s = input()\nvowels = ('aeiouy') \ns = s.lower()\nresult=''\nfor x in s:\n if x in vowels:\n s = s.replace(x, \u201c\u201d)\n if x not in vowels:\n result=result+'.'\n result=result+x\nprint(result)\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0fb5e9fd97d5e3e01e03c5060d6ba2dc", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "text = input()\nvowels = [a, e, i, o, u, y, A, E, I, O, U, Y]\noutput = []\n\nfor i in text:\n if i not in vowels:\n output.append(i)\n \nprint(\".\"join(output)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cab452d2ad0c1d2cca07ef7afc510fde", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tint t, s, q; cin >> t >> s >> q;\n\tdouble piste = s;\n\tint lecture = 0;\n\tdouble x;\n\tdouble pas = 1-1.0/q;\n\tint sol = 1;\n\twhile(piste < t)\n\t{\n\t\tx = q*(piste - lecture);\n\t\tif(piste + x*pas < t) sol++, lecture = 0, piste += x*pas;\n\t\telse break; \n\t\t\n\t}\n\tcout << sol << endl;\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c200fd7d1fe54f1aa7a6901611fcff7e", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "#include \n#include \n#include \n#include \n\n\n//#pragma GCC optimize(\"O3\")\n//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\\\n#pragma comment(linker, \"/stack:200000000\")\n//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\\\n#pragma GCC optimize(\"unroll-loops\")\n\n\n#define FIO ios::sync_with_stdio(false); cin.tie(0);\n#define MOD 1000000007\n#define INF 0x3f3f3f3f //1<<29\n#define ll long long \n#define sd(x) scanf(\"%d\", &(x))\n#define mp make_pair\n#define mt make_tuple\n#define fi first\n#define se second\n#define pb push_back\n#define eb emplace_back\n#define sz(x) int (x.size())\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define forn(i, n) for (int i = 0; i < (int)(n); ++i)\n#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)\n#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)\n#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)\n#define trav(h,v) for(auto &h: v) cout< pii;\ntypedef vector vi;\ntypedef vector vpi;\ntypedef vector vvi; \ntypedef double ld;\ntypedef vector vll;\n//typedef tree,rb_tree_tag,\n//tree_order_statistics_node_update> indexed_set;\n// order_of_key (val): returns the no. of values less than val\n// find_by_order (k): returns the iterator to kth largest element.(0-based)\n \n\n//template bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }\n//template bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }\ntemplate T gcd(T a, T b){return(b?__gcd(a,b):a);}\ntemplate T lcm(T a, T b){return(a*(b/gcd(a,b)));}\n\n\n#if DEBUG && !ONLINE_JUDGE\n\n #define debug(args...) (Debugger()) , args\n \n class Debugger\n {\n public:\n Debugger(const std::string& _separator = \", \") :\n first(true), separator(_separator){}\n \n template\n Debugger& operator , (const ObjectType& v)\n {\n if(!first)\n std::cerr << separator;\n std::cerr << v;\n first = false;\n return *this;\n }\n ~Debugger() { std::cerr << endl;}\n \n private:\n bool first;\n std::string separator;\n };\n \n template \n inline std::ostream& operator << (std::ostream& os, const std::pair& p)\n {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n }\n \n template\n inline std::ostream &operator << (std::ostream & os,const std::vector& v)\n {\n bool first = true;\n os << \"[\";\n for(unsigned int i = 0; i < v.size(); i++)\n {\n if(!first)\n os << \", \";\n os << v[i];\n first = false;\n }\n return os << \"]\";\n }\n \n template\n inline std::ostream &operator << (std::ostream & os,const std::set& v)\n {\n bool first = true;\n os << \"[\";\n for (typename std::set::const_iterator ii = v.begin(); ii != v.end(); ++ii)\n {\n if(!first)\n os << \", \";\n os << *ii;\n first = false;\n }\n return os << \"]\";\n }\n \n template\n inline std::ostream &operator << (std::ostream & os,const std::map& v)\n {\n bool first = true;\n os << \"[\";\n for (typename std::map::const_iterator ii = v.begin(); ii != v.end(); ++ii)\n {\n if(!first)\n os << \", \";\n os << *ii ;\n first = false;\n }\n return os << \"]\";\n }\n \n#else\n #define debug(args...)\n#endif\n\n\nint main() {\n\tint t,s,q;\n cin>>t>>s>>q;\n int cnt = 0;\n while(s S:\n count += 1 \n timer = timer - S + step*0.5\n \n step = math.ceil((S-timer)*100)/100000\n #if timer - S < 1:\n # if timer - S < 0.1:\n # step = 0.01\n # else: step = 0.1\n #else: step = 1\n \n timer += step\n S += rate*step\nprint count\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6eb62812bdaa94cd610d4f10ab16a990", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "T,S,q=map(float, raw_input().split())\nr=(q-1)/q\nn=0\np=T-S\nwhile T>=1:\n n+=1\n i=S/(1-r)\n T-=i\n S=i\nprint n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f7b8359a5bdb2aa0c7ff763a3b7e6d7", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "t,s,q = input().split()\nt=int(t)\ns=int(s)\nq=int(q)\n\nif(s 0 and x < 10**9]\nans = \"\"\nfor x in sol:\n ans += str(x) + \" \"\nprint len(sol)\nprint ans.strip()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b89eb50e17770580e37c6b1e4f573fdc", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a,b,c = map(int,raw_input().split())\ndef s(x):\n\tsum =0\n\twhile(x>0):\n\t\tsum+=x%10\n\t\tx/=10\n\treturn sum\nans = []\nfor i in range(1,90):\n\tsum = b*i**a + c\n\t#print i,sum,s(sum)\n\tif(sum<1000000000)\n\tif(s(sum)==i):\n\t\tans.append(sum)\nprint len(ans)\nfor x in ans:\n\tprint x,", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40ce223f7bf729263c9ebf7907d1069f", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "def s(a,b,c):\n l = []\n for i in range(1,82):\n v = b*i**a+c\n if v > 1000000000:\n break\n vcopy = v\n val = 0\n while v > 0:\n val += v%10\n v//=10\n if val == i:\n l.append(vcopy)\n print(len(l))\n for i in l:\n print(i,end=' ')\n\na,b,c = map(int, input().spli", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ea23a9f2bc906de550b00c494619658", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a,b,c = map(int,raw_input().split())\ndef s(x):\n\tsum =0\n\twhile(x>0):\n\t\tsum+=x%10\n\t\tx/=10\n\treturn sum\nans = []\nfor i in range(1,90):\n\tsum = b*i**a + c\n\t#print i,sum,s(sum)\n\tif(sum<1000000000):\n\tif(s(sum)==i):\n\t\tans.append(sum)\nprint len(ans)\nfor x in ans:\n\tprint x,", "lang_cluster": "Python", "compilation_error": true, "code_uid": "23b4b8e51690bcff7a1fc24376d95d65", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a, b, c = map(int, raw_input().split())\n\ndef s(x):\n return sum([int(i) for i in str(x)])\nsol = []\nfor i in range(1, 82):\n x = b*i**a+c\n if s(x) == i:\n sol.append(x)\n\nsol = [x in sol if (x > 0 and x < 10**9)]\nans = \"\"\nfor x in sol:\n ans += str(x) + \" \"\nprint len(sol)\nprint ans.strip()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2165dc9a5ed6596154457da566ef8ae", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "tux = input()\nfoo = bar = baz = 0\nquz = 1\nwhile tux > 0:\n pur = input()\n foo += pur\n bar += 1\n if max(foo * quz, bar * baz) == foo * quz:\n baz = foo\n quz = bar\n tux -= 1\nprint 1.0 * baz / quz", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ea15354deddf72cc782d8f312407f77", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\"\"\"\nTUX IS NOW A NUMBR\nIM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0\nI HAS A PUR\nGIMMEH PUR\nPUR IS NOW A NUMBR\nFOO R SUM OF FOO AN PUR\nBAR R SUM OF BAR AN 1\nBOTH SAEM BIGGR OF PRODUKT OF FOO AN QUZ AN PRODUKT OF BAR BAZ AN PRODUKT OF FOO AN QUZ\nO RLY?\nYA RLY\nBAZ R FOO\nQUZ R BAR\nOIC\nIM OUTTA YR LOOP\nBAZ IS NOW A NUMBAR\nVISIBLE SMOOSH QUOSHUNT OF BAZ QUZ\nKTHXBYE\n\"\"\"\ntux, foo, bar, baz, quz = int(input()), 0, 0, 0, 1\nwhile tux != 0:\n pur = int(input())\n foo += pur\n bar += 1\nprint(float(foo / bar))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "acbaaae5779065f5f8248d078dffb785", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "tux = int(raw_input())\n\nfoo = 0\nbar = 0\nbaz = 0\nquz = 1\n\nwhile tux != 0:\n\tpur = int(raw_input())\n\tfoo += pur\n\tbar += 1\n\n\t\n\tif max(foo*quz,bar*baz)==foo*quz: \n\t\tbaz = foo\n\t\tquz = bar\n\nprint baz/quz", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a0f938c74e27f10333a64ffba55f7d86", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nA = []\nsum = 0\nfor i in range(n):\n x = int(input())\n sum += x\n A.append(sum/i)\n\nprint('%.6f\\n' % max(A))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "10a6882ecc50d86b87c7b2748bca1597", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include\nint TUX,FOO=0,BAR=0,BAZ=0,QUZ=1;\nint main(){\n\t#ifdef local\n\tfreopen(\"data.in\",\"r\",stdin),freopen(\"data.out\",\"w\",stdout);\n\t#endif\n\tscanf(\"%d\",&TUX);\n\tfor(int i=1;i<=TUX;++i){\n\t\tint PUR;scanf(\"%d\",&PUR);\n\t\tFOO=FOO+PUR;\n\t\tBAR=BAR+1;\n\t\tif(FOO*QUZ>BAZ*BAR) BAZ=FOO,QUZ=BAR;\n\t}\n\tprintf(\"%.6lf\\n\",BAZ*1.0/QUZ);\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4e11fc9855fff33a33d857d59ad2c6f", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "a,b,c,d=map(int,input().split())\nl=[]\nfor i in range(a,b+1):\n for j in range(b,c+1):\n for k in range(c,d+1):\n l.append((i+j,k))\nc=0\nfor i in range(len(l)):\n if(l[i][0]>l[i][1]):\n c+=1\nprint(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "871e35f3a3e4c641b583fb69b7a074f9", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "class SegmentTree:\n def __init__(self, data, default=0, func=lambda a,b:gcd(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# ------------------- fast io --------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\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# ------------------- fast io --------------------\nfrom bisect import bisect_right, bisect_left\nfrom fractions import Fraction\n\ndef pre(s):\n n = len(s)\n pi=[0]*n\n for i in range(1,n):\n j = pi[i-1]\n while j and s[i] != s[j]:\n j = pi[j-1]\n if s[i] == s[j]:\n j += 1\n pi[i] = j\n return pi\n\ndef prod(a):\n ans = 1\n for each in a:\n ans = (ans * each)\n return ans\n\nfrom math import gcd\ndef lcm(a,b):return a*b//gcd(a,b)\n\ndef binary(x, length=16):\n y = bin(x)[2:]\n return y if len(y) >= length else \"0\"*(length - len(y)) + y\n\ndef sumrange(a,b):\n return a*(b-a+1) + (b-a)*(b-a+1)//2\n\nfor _ in range(1):\n #a, k = map(int, input().split())\n a, b, c, d = map(int, input().split())\n if (b-a)*(c-b)*(d-c) <= 100000:\n ans = 0\n for i in range(a,b+1):\n for j in range(b,c+1):\n for k in range(c, d+1):\n if i+j > k and i+k > j and j+k > i:\n ans += 1\n print(ans)\n continue\n #x, y = map(int, input().split())\n #a = list(map(int, input().split()))\n #sm = sum(a)\n #for i in range(n):\n #s = input()\n #print(\"YES\" if s else \"NO\")\n ans = 0\n for i in range(a, b+1):\n if i + b > d:\n ans += (d-c+1)*(c-b+1)\n #print(\"Here\")\n elif i + b == d:\n ans += (i+b-c) + (d-c+1)*(c-b)\n elif i + c <= d:\n #print(i+b, i+c, sumrange(3,4))\n ans += sumrange(i+b, i+c) - c*(c-b+1)\n else:\n mid = d-i\n its = mid - b + 1\n ans += sumrange(i+b, i+b+its-1) - c*its\n ans += (d-c+1)*(c-b+1-its)\n print(max(ans, 0))\n\n\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4e2ee3a07dd5489127cb423683e285d", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "def sigma(x):\n return (x*(x+1))//2\n\ndef answer(A, B, C, D):\n _sum = 0\n for i in range(A, B+1):\n _sum += (i*(i+1))//2\n _length = (C-B+1)\n if i-_length > 0:\n _sum -= sigma(i-_length)\n headMax = D-C+1\n if i-headMax > _length:\n _sum += sigma(i-headMax-_length)\n return _sum\n\nA, B, C, D = map(int, input().split())\nprint(answer(A, B, C, D))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fcba36e44f01f9d49b30bf1c9e132daa", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "'''\nFind the number of islands |(Using DFS)\nGiven a boolean 2D matrix, find the number\nof islands. A group of connected 1s forms\nan island. for example, the below matrix\ncontains 5 islands.\n\nExample:-\n\nInput : mat[][] = {{1, 1, 0, 0, 0},\n {0, 1, 0, 0, 1},\n {1, 0, 0, 1, 1},\n {0, 0, 0, 0, 0},\n {1, 0, 1, 0, 1}\nOutput : 5\n\nA cell in a 2d matrix can be connected\nto 8 neighbours. So, unlike standard\nDFS(), where we recursivelly call\nfor all adjacent vertices, here we can\nrecursivelly call for 8 neighbours only.\nWe keep track of the visited 1s so that\nthey are not visited again.\n'''\n\nclass Graph:\n\n def __init__(self,row,col,g):\n self.ROW = row\n self.COL = col\n self.graph = g\n\n # A function to check if a given\n # cell (row,col) can be included in\n # DFS\n def isSafe(self,i,j,visited):\n # row number is in range, col num\n # is in range and value is 1 and not\n # yet visited\n return (i >= 0 and i < self.ROW and\\\n j>=0 and j\n\n \n Debug\n 2.0\n 19080f25-025a-40db-a193-b4e3d7414a12\n .\n train.py\n \n \n .\n .\n train\n train\n \n \n true\n false\n \n \n true\n false\n \n \n \n \n \n 10.0\n $(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\Python Tools\\Microsoft.PythonTools.targets\n \n \n \n \n \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e80a6d2820aee317a570dbddde943bb", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "# h,w = map(int, input().split(' '))\n# r = list(map(int, input().split(' ')))\n# c = list(map(int, input().split(' ')))\n# l,r = map(int, input().split(' '))\n# for i in range(l, r+1):\n# if len(str(i)) == len(list(set(str(i)))):\n# print(i)\n# exit()\n# print(-1)\nn = int(input())\nx = int(input())\nif (n % 6 == 2 and x == 1) or (n % 6 == 5 and x == 1) or (n % 6 == 0 and x == 2) or (n % 6 == 1 and x == 2) or (n % 6 == 3 and x == 0) or (n % 6 == 4 and x == 0) or :\n print(2)\nelif (n % 6 == 0 and x == 1) or (n % 6 == 1 and x == 0) or (n % 6 == 2 and x == 0) or (n % 6 == 3 and x == 1) or (n % 6 == 4 and x == 2) or (n % 6 == 5 and x == 2):\n print(1)\nelif (n % 6 == 0 and x == 0) or (n % 6 == 1 and x == 1) or (n % 6 == 2 and x == 2) or (n % 6 == 3 and x == 2) or (n % 6 == 4 and x == 1) or (n % 6 == 5 and x == 0):\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2d5bf58c506784e719b5027b63e6b091", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef solve():\n n = int(input())\n x = int(input())\n ck = [0, 0, 0]\n ck[x] = 1\n n %= 6\n for i in range(n, 0, -1):\n temp = ck[1]\n ck[1] = ck[2] if i % 2 == 0 else ck[0]\n (ck[2] if i % 2 == 0 else ck[0]) = temp\n for i in range(0, 3):\n if ck[i] == 1:\n print(i)\n return\n \n\nt = 1\n# t = int(input())\nwhile True:\n solve()\n t -= 1\n if t <= 0:\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8bd85e4eac801cf0342745014e2484d", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "str = raw_input()\nstr = str.replace(\"WUB\", \" \")\nstr = str.strip(\" \")\nreturn str", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab4494bb17389360415580c8cda3dace", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "print(*input().replace(\"wub\",' ')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d582544bde7ff5e23921af8ac4de9b97", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "if __name__ == '__main__':\n\ts = input()\n\tarr = s.split('WUB')\n\tretStr = ''\n\tfor i in arr:\n\t\tif not i == ''\n\t\t retStr += i + ' '\n\tprint(retStr[:-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0e389fa07ee2d1fdc93cec6177f271e2", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "Python 3", "source_code": " s=input()\n print(s.replace(\"WUB\", \" \"))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d0025f8413d1ca7d61d4e88e6f6e02ae", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "s=input()\nw=\"\"\ncount=0\nfor i in range(len(s)):\n if s[i:i+3]==\"WUB\":\n i=i+3\n w=w+\" \"\n elif:\n w=w+s[i]\n i=i+1\nprint(w)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "139193c17676187e01b1b1e21d3e1baa", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ndef test()\n arr1 = list(map(int, input().split(\" \")))\n arr2 = list(map(int, input().split(\" \")))\n return 3\n\na=test()\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "766c1772114928cae0b841f69caa35b0", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nscores = [int(c) for c in input().split(\" \")]\n\ndip = set()\nwhile score in scores:\n if score = 0 and score not in dip:\n dip.add(score)\n\nprint(len(dip))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "54d2499fc8801be0bf001631d142125b", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "100\n122 575 426 445 172 81 247 429 97 202 175 325 382 384 417 356 132 502 328 537 57 339 518 211 479 306 140 168 268 16 140 263 593 249 391 310 555 468 231 180 157 18 334 328 276 155 21 280 322 545 111 267 467 274 291 304 235 34 365 180 21 95 501 552 325 331 302 353 296 22 289 399 7 466 32 302 568 333 75 192 284 10 94 128 154 512 9 480 243 521 551 492 420 197 207 125 367 117 438 600", "lang_cluster": "Python", "compilation_error": true, "code_uid": "386630316378797b526e195d9678ded2", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nk = set(map(int,input()))\nc=0\nfor i in range(len(k)):\n if(k[i]==0:\n c=1\nif(c==1):\n print(len(k)-1)\nelse:\n print(len(k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92122b28c8ec7276da80d0c2fdb7541e", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=input().split()\nfor i in range(len(b)):\nwhile 1>0:\n if b.count(int(0))==0:\n break\n else:\n continue\nb=list(set(b))\nprint(int(len(b)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc7f84c697fa959fc061c5a264ca1367", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import copy\n\ndef solve():\n \n n, a, b, c = [int(input()) for i in range(4)]\n\n nowloc = 'ab'\n mealed = 1\n totaldistance = 0\n history = ['ab']\n\n while mealed < n:\n \n if nowloc == 'ab':\n if a < b:\n nowloc = 'ac'\n totaldistance += a\n else:\n nowloc = 'bc'\n totaldistance += b\n\n elif nowloc == 'bc':\n if b < c:\n nowloc = 'ab'\n totaldistance += b\n else:\n nowloc = 'ac'\n totaldistance += c\n\n elif nowloc == 'ac':\n if a < c:\n nowloc = 'ab'import copy\n\ndef solve():\n \n n, a, b, c = [int(input()) for i in range(4)]\n\n nowloc = 'ab'\n mealed = 1\n totaldistance = 0\n history = ['ab']\n\n while mealed < n:\n \n if nowloc == 'ab':\n if a < b:\n nowloc = 'ac'\n totaldistance += a\n else:\n nowloc = 'bc'\n totaldistance += b\n\n elif nowloc == 'bc':\n if b < c:\n nowloc = 'ab'\n totaldistance += b\n else:\n nowloc = 'ac'\n totaldistance += c\n\n if nowloc == 'ac':\n if a < c:\n nowloc = 'ab'\n totaldistance += a\n else:\n nowloc = 'bc'\n totaldistance += c\n\n history.append(copy.deepcopy(nowloc))\n mealed += 1\n\n return totaldistance, history\n\nprint(solve()[0])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9b5907faec9314c6d5b2cc2338ab0dc6", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\na=int(input())\nb=int(input())\nd=int(input())\n\nif (a==min(a,b,d) or b==min(a,b,d) or n==1):\n\tprint((n-1)*min(a,b,d))\nelse:\n\tprint(min(a,b)+(n-2)*min(a,b,d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9dc8c91d745644fd45beaffdddc2db7a", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\npair cmp(vector foo, vector bar) {\n int i;\n for (i = 0; i < min(foo.size(), bar.size()); i++) {\n if (foo[i] != bar[i]) break;\n }\n\n if (i >= foo.size()) return {-1, -1};\n else if (i >= bar.size()) return {-2, -2};\n else return {foo[i], bar[i]};\n}\n\nvector > g;\nint used[100005] = {0};\n\nbool dfs(int v) {\n used[v] = 1;\n for (auto u : g[v]) {\n if (used[u] == 1) {\n //used[v] = 2;\n return false;\n }\n else if (used[u] == 0) {\n if (!dfs(u)) {\n //used[v] = 2;\n return false;\n }\n }\n }\n used[v] = 2;\n return true;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n\n\n int n, m;\n cin >> n >> m;\n g.resize(max(m, n) + 277);\n vector a[100005];\n for (int i = 0; i < n; i++) {\n int l;\n cin >> l;\n for (int j = 0; j < l; j++) {\n int x;\n cin >> x;\n a[i].push_back(x);\n }\n }\n\n vector reversed (m + 233, false);\n\n set ans;\n bool fl = true;\n for (int i = n - 1; i > 0; i--) {\n pair last = cmp(a[i - 1], a[i]);\n //cout << i << '-' << last.first << \" \" << last.second << endl;\n if (last.first == -1) continue;\n if (last.first == -2) {\n fl = false;\n break;\n }\n else {\n g[last.second].push_back(last.first);\n if (last.second < last.first || reversed[last.second] && !reversed[last.first]) {\n ans.insert(last.first);\n reversed[last.first] = true;\n }\n }\n }\n if (!fl) cout << \"No\\n\";\n else {\n if (ans.size() > 0) {\n for (int i = max(m, n) + 22; i >= 1; i--) {\n if (used[i] == 0) {\n if (!dfs(i)) {\n cout << \"No\\n\";\n return 0;\n }\n }\n }}\n cout << \"Yes\\n\";\n cout << ans.size() << endl;\n for (auto el : ans) cout << el << \" \";\n }\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3419a14eb3608decc677cbb8c23f2fb", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\na = int(input())\nb = int(input())\nc = int(input())\n\ns = 0\nn -= 1\noutput = 0\nwhile n:\n\tif s == 0:\n\t\tif a < b:\n\t\t\toutput += a\n\t\t\ts = 1\n\t\telse:\n\t\t\toutput += b\n\t\t\ts = 2\n\telif s == 1:\n\t\tif a < c:\n\t\t\toutput += a\n\t\t\ts = 0\n\t\telse:\n\t\t\toutput += c\n\t\t\ts = 2\n\telse:\n\t\tif b < c:\n\t\t\toutput += a\n\t\t\ts = 0\n\t\telse:\n\t\t\toutput += b\n\t\t\ts = 1\n\tn -= 1\n\nprint output", "lang_cluster": "Python", "compilation_error": true, "code_uid": "afc0276fabdf0e81cebf52d99ff66f69", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "=int(input().strip())\na = [0, 0, 0]\na[0] = int(input().strip())\na[1] = int(input().strip())\na[2] = int(input().strip())\nans = 0\nif min(a) not in a[:2]:\n ans = min(a[:2]) + max(n - 2, 0)*min(a)\nelse:\n ans = max(n - 1, 0)*min(a)\nif n == 1:\n ans = 0\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea2f17d4be29522b1a806b0af0d424d2", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, a = map(int, input().split())\nt = [0]\nt += [int(x) for x in input().split()]\ncrim = t[a]\nfor i in range(1,n+1)\n if a-i<1 and a+i>n:\n break\n if a-i<1:\n if t[a+i]==1:\n crim += 1\n\t\telif a+i>n:\n\t\t if t[a-i]==1:\n\t\t\t crim += 1\n\t\telif t[a-i]*t[a+i]==1:\n\t\t\tcrim +=2\nprint(crim)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f142508e63ac68d7d833c19e748099a", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n , k = map(int , input().split())\nl = list(map(int , input().split()))\nk -= 1\ns = 0\ni,j = k,k\nwhile i > -1 and j < n:\n if l[i] == l[j] == 1:\n s += 2\n i -= 1\n j += 1\nif i == -1:\n while j < n:\n if l[j] == 1:\n s += 1\n j += 1\nif j == n:\n while i > -1:\n if l[i] == 1:\n s += 1\n 4 i -= 1\nif l[k] == 1:\n s -= 1\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4f9843fb5c823bced9a6add8dd821fa", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, pos = map(int, raw_input().split(' '))\na = map(int, raw_input().split(' '))\npos -= 1\nans = a[pos]\nl = pos - 1\nr = pos + 1\nwhile l >= 0 or r < n:\n if l >= 0 and r < n:\n if a[l] == 1 and a[r] == 1:\n ans += 2\n elif l >= 0:\n if a[l] == 1:\n ans += 1\n else:\n if a[r] == 1:\n ans += 1\n l--\n r++\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2f56db4157d32bd530771500007154f", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nl=0\nif b[a-1]==1:\n l=1\nelse:\n l=0\ni,j=a-1,a+1\nwhile i>=1 or j<=n:\n if i>=1 and j<=n:\n if b[i-1]==b[j-1]==1:\n l+=2\n i--\n j++\n elif i<1:\n l+=1\n j++\n else:\n l+=1\n i--\nprint(l)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "14959e2e5cf29bc8d0234d6ffbc6fd00", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# cook your dish here\n# your code goes here\nn,a= input().split()\nn=int(n)\na=int(a)\narr=[int(x) for x in input().split()]\ncount=0\n\npoint1=a-1\npoint2=a+1\nif arr[a]==1:\n count+=1\n\nfor i in range(0,len(arr)):\n if point1<0 and point2=0 and point2>len(arr)-1:\n if arr[point1]==1:\n count+=1\n point1-=1\n elif point1>=0 and point2<=len(arr)-1:\n if arr[point1]==1 and arr[point2]==1:\n count+=2\n point1-=1\n point2+=1\n else:\n break\n \n print(count)\n \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac5e03f28dd2322a295ef118167b0c71", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "a, b = input().split()\na = int(a)\nb = int(b)\nif a==b:\n print(a,end='')\n print(1)\n print(b,end='')\n print(2)\nelif a+1==b:\n print(a,end='')\n print(9)\n print(b,end='')\n print(0)\nelif a==9 && b==1:\n print(9)\n print(10)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a1a3910bc120bbb797d8f4f76886d4e", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "a, b = int(input()), int(input())\nif a - b > 0:\n print(-1)\nelif a - b = 0:\n print(a * 10, b * 10 + 1)\nelif a - b = -1:\n print((a + 1) * 10 - 1, b * 10)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5bc6766e26db764276ada4275f1fc43f", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f31ad377a7401dda12539265abee6fe", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "\nx,y = list (map (int, input().split()))\na = y*10 - 1 \nb = y * 10\nc = y * 10 + 1 \n\nif x - y == 8:\n print(a,b)\nelif x > y && x - y != 8:\n print(-1)\nelif y - x >= 2:\n print(-1)\nelif y == x:\n print(b,c)\nelif y - x == 1:\n print(a,b)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0e051fbd811a3a40e7d25088f325e2ed", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "Python 3", "source_code": "X = list(map(int, input().split())\nprint(str(X[0]) + '0 ' + str(X[0]) + \"1\" if X[0] == X[1] else (\n str(X[0]) + '9 ' + str(X[1]) + \"0\" if X[1] - X[0] == 1 else (\"9 10\" if X[1] - X[0] == 8 else -1)))\n\n# UB_CodeForces\n# Advice: Falling down is an accident, staying down is a choice\n# Location: Mashhad for few days\n# Caption: Finally happened what should be happened\n# CodeNumber: 685\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c2e377ccfc5412119229e5cd55c9387a", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "#include\n\nusing namespace std;\n\ntypedef long long ll;\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<\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\n/*\n * 1. Reading: Direct\n *\n * 2. Samples:\n * \t\t4 3:\twe have 2 splitter. 2 and 3. Adding them. 2 + 3 and one will be out/in so 2+3-1 => 4\n * \t\t5 5:\tWe need 5 outs and one of splitters already 1-5 so simply use it => 1\n * \t\t8 4: \twe have 2, 3, 4 splitter. Adding them all: 2 + 3 + 4 -2 => 7 < 8. So answer is -1\n *\n * \t Missed:\n * \t \tnone\n *\n * \t Especial:\n * \t \tif we just need one output => then no splitter needed => 0\n *\n * 3 - Input Properties\n * \t\tnone\n *\n * 4- Constraints\n * \t\tSo Big: Seems fake / BinarySch / MatrixPow => may be applied\n *\n * 5 - Processing\n * \t\tAs input is big, intermediate and output needs too much careful\t=> Use long long as possible\n */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * Problem type:\n * \t\tminimization. Check minimization algorithms\n * \t\tseems observation problem..we need to discover some facts\n *\n * Observations\n * \t\t- Splitters are given as incremental sequence: 2 3 4...k\n * \t\t- Each time we connect 2 splitters, one is common so must be removed.\n * \t\t- Generally if we will connect M elements M-1 will be used for joining\n * \t\t- So # of splitters of (a, b, c, d, e) = a+b+c+d+e -4\n * \t\t- Given K splitters, max outlets are (2+3+4+....k) - k-1\n * \t\t- Using max outlets we could easily detect the impossible case\n * \t\t\t- If not the case, we either could cover N or not\n * \t\t- Let's think concretely\n * \t\t\t- if n = 37 and k = 11\n * \t\t\t- then we could have (2+3+4....11) - 9\n * \t\t\t- What if we subtracted 1 from each splitter to get rid of this 9\n * \t\t\t- (1+2+3...10)..this is 1 more over the answer, each 2 splitter remove 1 not 2\n * \t\t\t- Simply minimize n by 1\n * \t\t\t- that is: \t (2+3+4....11) - 9 = N\n * \t\t\t= \t\t\t= (1+2+3...10) \t\t= N-1\n * \t\t\t- Let K = K-1 and N = N-1\n * \t\t\t- our problem now, given numbers from 1-k, could we find subset with sum = N\n * \t\t\t\t- DP guys know this is related to subset sum problem which could be solved with DP\n * \t\t\t\t- But constrains won't help anyway\n */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * More analysis:\n *\n * \t- Let's think about our new problem: Given N, K: find subset with min # of items with sum = N\n * \t\t- if N = 36 and K = 10\n * \t\t- so we have 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 splitter outlets\n * \t\t- as we need the minimum, make sense to use 10 first. Now we need 26\n * \t\t- then 9 => 17. Then 8 => 9. Then 7 => 2. Next was 6, but it is bigger than 2\n * \t\t- As we have 6, then we must have 2\n * \t\t- Now, It is clear 3 things:\n * \t\t\t- If initially sum was >= N, then we must find a solution\n * \t\t\t- It make sense to start from the tail and get numbers till next is > reminder\n * \t\t\t- At this point of time, if u subtracted K elements, answer is K+1 if reminder > 0\n * \t\t\t- However, K = 10^9, we need faster way to simulate this.\n *\n */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * One of algorithms that fit in our constrains in Binary Search. Could we use it?\n *\t\tWe need to define function and to make sure its curve is either: 0 0 0 0 1 1 1...1 OR 1 1 1 1 1 0 0 0 0 ..... 0\n *\n *\tWhat is our function: Is using the last X elements and may be one extra element enough to cover N?\n *\t\te.g. in our example (N = 36 and K = 10) using last 4 elements and the 3 was enough as sum\n *\n *\tDefine function to be: F(p) = Sum of last P elements <= N\n *\t\tif so, then they might be used\n *\t\tas we want minimum elements we need p with maximum sum <= N\n */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n// sum: 1 2 3 ... 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#ifndef ONLINE_JUDGE\n\tfreopen(\"c.in\", \"rt\", stdin);\n\t//freopen(\".txt\", \"wt\", stdout);\n#endif\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< 0 and len(ks) > 0:\n if sum(ks)-len(ks)+1 < n:\n res = -1\n break\n m = max(ks)\n rem = min(m, n+off)\n if ks.count(rem):\n n -= rem-off\n ks.remove(rem)\n off = max(off, 1)\n res += 1\nif n != 0:\n res = -1\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3a1123da5e08f067ce34fd1c4e0b58b", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "# encoding: utf-8\n\nif __name__ == '__main__':\n n, k = [int(x) for x in raw_input().rstrip().split()]\n \n ans = 0\n pipe = 1\n splitter = range(1, k)\n while (splitter):\n if pipe >= n:\n break\n s = splitter.pop()\n ans += 1\n pipe += s\n \n if pipe >= n:\n print ans\n else:\n print -1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d421850fcd92f0a6f65e0903edba09c0", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a=input()\nb=\"1\"\nfor i in range(len(a[1:])):\n b+=\"0\"\n \nprint(int(b)-int(a[1:]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8fe63d1ae3820f580034792dcd5e62a", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n/10 < 1:\n print(1)\nelse:\n n = str(n)\n f = len(n) - 1\n b = int(str(len(n)) + \"0\"*f)\n print(n - b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "61ccfcabd49418e72be3c25f23b87aeb", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.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\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": "d4e410a08c8f0b7a1c8ff976cd2d328c", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "anno = input()\nif(int(anno) <= 9) print(1)\nelse:\n\tacumulador = 0\n\ti = 1\n\twhile(i < len(anno)):\n\t\tultimo = int(anno[-i])\n\t\tacumulador += (10 - ultimo)*10**(i-1)\n\t\tanno = str(int(anno)+acumulador)\n\t\ti+=1\n\n\tprint(acumulador)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fdf4d3d7d259b19d89d2a0d24dc3f728", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n#include \nint main(){\n\tint n, k, p;\n\tcin >> n;\n\tk = log10(n);\n\tp = pow(10, k) * floor(n / pow(10, k) + 1) - n;\n\tcout << p;\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d094d744a6775e76f27f823ddf87485b", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "'''\nt\uac00 \uacc4\uc18d s\uc5d0 \uc18d\ud558\uac8c \ud558\uba74\uc11c(\uac1c\uc218\uc640 \uc21c\uc11c\ub9cc \ub9de\uc73c\uba74\ub428)\n\ucd5c\ub300\uc758 \uc5f0\uc18d\ub41c \ubb38\uc790\ub97c \uc81c\uac70\ud558\ub294 \ubc29\ubc95\uc740?\n\n--> \uadf8\ub0e5 \ubaa8\ub4e0 \ubb38\uc790\ub97c \uc81c\uac70\ud574\uac00\uba74\uc11c \ucd5c\uace0\uc758 \uacbd\uc6b0\uc758\uc218\ub97c \ucc3e\uc544\ub0b4\uc790\n'''\n\ns = input()\nt = input()\n\ndef check(s):\n\tans = 0\n\tfor i in s:\n\t\tif ans == len(t):\n\t\t\tbreak\n\t\tif i == t[ans]:\n\t\t\tans += 1\n\treturn ans == len(t)\nans = 0\n\n## check every case of deleting substring\nfor i in range(len(s)):\n for j in range(i + 1, len(s) + 1):\n if check(s[:i] + s[j:]):\n ans = max(j - i, ans)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c40e978e8af9599c90858f66afc24eb", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "big = input()\nsmall = input()\nleft = [0] * (len(small) + 1)\nleft[0] = -1\nwsk = -1\nfor i in range(1, len(small) + 1):\n while True:\n wsk += 1\n if big[wsk] == small[i - 1]:\n left[i] = wsk\n break\nbig = big[::-1]\nsmall = small[::-1]\nright = [0] * (len(small) + 1)\nright[0] = -1\nwsk = -1\nfor i in range(1, len(small) + 1):\n while True:\n wsk += 1\n if big[wsk] == small[i - 1]:\n right[i] = wsk\n break\nwyn = 100000000\nfor i in range(len(left))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f8f9a1361ae235be800052d1ec9f1f4b", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s = input()\nt = input()\nind = []\nfor i in range(0,len(s)):\n if s[i:i+len(t)] == t:\n ind.append(i)\nss = len(s)\nmaxx = 0\nfor i in ind:\n k = i+len(t)\n maxx = max(len(s[k:ss)]),len(s[0:i]))\nprint(maxx)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c7e434fe8609aaaa1fcaa5b84f3c7828", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "\nfrom collections import defaultdict\n\ndef calculate2(m, sa, sb, ia, ib):\n if ib >= len(sb):\n return 0\n if len(sb) - ib > len(sa) - ia:\n return -1\n result = 0\n found = False\n for i in xrange(ia, len(sa)):\n if sa[i] == sb[ib]:\n recur = calculate2(m, sa, sb, i+1, ib+1)\n if recur < 0:\n continue\n found = True\n result = max(result, recur, i - ia)\n if ib == len(sb) - 1:\n result = max(result, len(sa) - 1 - i)\n if found:\n return result\n return -1\n\n# Find the smallest index in array that is at least ia\n# this is guaranteed to return something per problem statement\ndef search(array, start, end, ia):\n if start >= end:\n return -1\n mid = (start + end) / 2\n if array[mid] == ia:\n return mid\n if array[mid] < ia:\n return search(array, mid + 1, end, ia)\n recur = search(array, start, mid, ia)\n if recur < 0:\n return mid\n return recur\n\ndef calculate23(m, sa, sb, ia, ib):\n if ib >= len(sb):\n return 0\n if len(sb) - ib > len(sa) - ia:\n return -1\n result = 0\n c = sb[ib]\n array = m[c]\n start = search(array, 0, len(array), ia)\n for index in xrange(start, len(array)):\n i = array[index]\n recur = calculate2(m, sa, sb, i+1, ib+1)\n if recur < 0:\n continue\n result = max(result, recur, i - ia)\n if ib == len(sb) - 1:\n result = max(result, len(sa) - 1 - i)\n return result\n\ndef calculate(sa, sb):\n posmap = defaultdict(list)\n counter1 = 0\n for c in sa:\n posmap[c].append(counter1)\n counter1 += 1\n return calculate2(posmap, sa, sb, 0, 0) \n\ndef main():\n sa = raw_input()\n sb = raw_input()\n print calculate(sa, sb)\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a6fae46e43b00a8dc26b33ad24f6f69", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def dick_in_tsypko(x, y):\n m = len(y)\n pos = 0\n for i in x:\n while pos < m and y[pos] != i:\n pos += 1\n if pos == m:\n return False\n pos += 1\n return True\ns = input()\nt = input()\nn = len(s)\nans = 0\nfor i in range(0, n + 1):\n for j in range(i, n + 1):\n if dick_in_tsypko(t, s[:i] + s[j:]):\n ans = max(ans, j-i)\nif s == \"tsypkoisgayandsuckedhisdadsdick\" and t == \"tsypkoisgay\":\n print(\"TSYPKO!!!1\")\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4af1665d5687a4915ba0c2609584ae2c", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n, m = [int(x) for x in range input().split()]\n\nprime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\n\nif n not in prime or m not in prime:\n print('NO')\nelif prime.index(n) == prime.index(m) - 1:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6f600fb29916f9e54a9e8201274eac3", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#!/usr/local/bin/python\n\nn = input()\ntmp = 1\nfor i in xrange(n-1):\n tmp += (1 + i)\n tmp %= n\n if tmp == 0:print n,\n else: print tmp,\n[operin@panda 15:46:56 test] $ cat test.py\n#!/usr/local/bin/python\nimport math\nn,m = map(int,raw_input().split(\" \"))\nif n == 2 and m == 3:\n print \"YES\"\n exit()\ntmp = n\nwhile True:\n tmp += 2\n for i in xrange(2,int(round(math.sqrt(tmp)))+2):\n if tmp % i == 0:\n break\n if tmp % i != 0 and i == int(round(math.sqrt(tmp)))+1:\n if tmp == m: print \"YES\"\n else: print \"NO\"\n exit()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbaf5feb75be3d11626c61d38b8cd2ee", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "=list(map(int,input().split()))\nk=0\ndef prime(p):\n\tk=0\n\tfor i in range(2,p):\n\t\tif p%i==0:\n\t\t\tk+=1\n\t\t\tbreak\n\tif k==0:\n\t\treturn(True)\n\telse:\n\t\treturn(False)\n\nif prime(n[0])==False or prime(n[1])==False:\n\tprint('NO')\nelse:\n\tfor j in range(n[0]+1,n[1]):\n\t\tif prime(j)==True:\n\t\t\tprint('NO')\n\t\t\tk+=1\n\t\t\tbreak\n\tif k==0:\n\t\tprint('YES')\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "187b785eab621837bc257dd715f07d48", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Python 3", "source_code": "nn=input()\nnn=nn.spilt()\nn=int(nn[0])\nm=int(nn[1])\ni=n+1\nwhile i>0:\n k=0\n for j in range(2,(i//2)+1):\n if i%j==0:\n k=1\n break\n if k==0 and i==m\n print('YES')\n break\n elif k==0 and i!=m\n print('NO')\n break\n i=i+1\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bea31d35ed0f8afa935ffa77bf621d47", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n\n int n, m;\n cin >> n >> m;\n\n while(m < 50 && n >= 2){\n for(n = n; n < m; n++) {\n if(m%2 != 0 && m%3 != 0) {\n printf(\"YES\\n\");\n } else {\n printf(\"NO\\n\");\n }\n break;\n }\n break;\n }\n\n return 0;\n}\n\n// 1536371486446\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9fb9704a757d17ac8cbe51113af873b1", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "import sys\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\ndef quad(x,y):\n if x*y>0:\n if x>0:\n return '1'\n else:\n return '3'\n else:\n if x<0:\n return '2'\n else:\n return '4'\n\n\nwhile True:\n x,y=r_is()\n r=sqrt(x**2+y**2)\n if x==0 or y==0 or r==int(r):\n print 'black'\n elif int(r)%2==0:\n if quad(x,y)=='1' or quad(x,y)=='3':\n print 'black'\n else:\n print 'white'\n\n else:\n if quad(x,y)=='1' or quad(x,y)=='3':\n print 'white'\n else:\n print 'black'\n #break\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b4c25240b88e62656af7a89bb50f884d", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from math import *\nlife = 100\n(x, y) = map(float, raw_input().split())\nr = (sqrt(x**2 + y**2))\nt = atan(y / x) > 0\nprint 'white' if int(r) % 2 == 0 ^ t and r != int(r) else 'black'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcdc012a1bda9eed5de0c93bf231a534", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import sys\nfrom math import *\n\ndef gcl(x, y):\n fc = sqrt(x**2 + y**2)\n c = int(fc)\n if c % 2 == 0:\n result = 'black'\n else:\n result = 'white'\n if not ((x > 0 and y > 0) or (y < 0 and x < 0)):\n if result == 'black':\n result = 'white'\n else:\n result = 'black'\n \n if c == fc:\n result = 'black'\n return result\n\ndef main(argv=None):\n if argv is None:\n argv = sys.argv\n print gcl(int(argv[1]), int(argv[2]))\n \nif __name__ == \"__main__\":\n sys.exit(main())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae9cd82528179e43164302bac412153d", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "x,y = map(int,raw_input().split())\nif x==0 or y==0:\n\tprint \"black\"\nelse:\n\tr2 = x*x+y*y\n\tfor i in range(1001):\n\t\tif i*i==r2:\n\t\t\tprint \"black\"\n\t\t\tbreak\n\t\tif i*i>r2:\n\t\t\tprint [\"white\",\"black\"][(i+(x>0)+(y>0))%2]\n\t\t\tbreak \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "844f3dba72e0f3be28a262c7c9126bd1", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "x,y = map(int,raw_input().split())\nif x==0 or y==0:\n\tprint \"black\"\nelse:\n\tr2 = x*x+y*y\n\tfor i in range(1000):\n\t\tif i*i==r2:\n\t\t\tprint \"black\"\n\t\t\tbreak\n\t\tif i*i>r2:\n\t\t\tprint [\"white\",\"black\"][(i+(x>0)+(y>0))%2]\n\t\t\tbreak \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3bcff5bc67e254b4439be9dc6aeeffb0", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "#the idea which i thought first is correct\nimport math\nx=int(input())\nans=math.floormath.log(x,2))+1\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c415f74e6edaeb0259b35baf283c3369", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(len(bin(n)-2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b69ab87c6aac6833a237876843743ce2", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(raw_input())\n\na = 1\nif(2**a <= n)):\n a = a + 1\n else print(a)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bab6aaa27bededfc75d547e35be5c391", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\ufeffn=int(input())\nimport math\na=(-1+math.sqrt(1+8*n))/2\na=floor(a)\nc=(a*(a+1))//2\nprint(a+(n-c))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f6676ad73a428d4c36e7ca4b9f72b21f", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import sys\nfor line in sys.stdin:\n line = line.rstrip()\n n = int(line)\n a = 1\n while(True):\n if n == 1: break\n n = floor(n / 2.0)\n a += 1\n print(a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c24002a1a8506f3fb2c985c23c512ad", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "l = int(input())\nr = int(input()\nprint(l if l == r else 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3060433f2da7ea8723eb3a921ad99f41", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "N1 , N2 = map(int, input().split())\ncount2 = 0\ncount3 = 0\nfor i in range(N1, N2 + 1):\n if i%2 == 0:\n count2 = count2+1\n \n elif i%3 == 0:\n count3 = count3 + 1\nif count2 > count3:\n print 2\nelse:\n print 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a1c7d2123c121146af864e03e2978c3", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "a,b=map(int,input().split())\nif(a==b):\n print(a)\n else:\n print(\"2\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f665b04a6f18768190a8ed3ee663aef5", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b=(int(i) for i in input.split())\nif a==b:\n print(a)\nelse:\n print 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "12792c6692cff9226ebcd43cdab66a17", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "l,r = map(int,raw_input().split())\nif l -r == 0:\n\tprint l\nelse if l - r > 1:\n\tif (l-r)%2 == 0:\n\t\tprint 2\n\telse:\n\t\tprint 3\nelse:\n\tprint 2 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11715cc8491e88e3d5346cf09c6afeda", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s=input()\nif '444' in s or s.count('1')+s.count('4')5 :\n print(n+10-a)\n else :\n print(n-a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e74dda9d4ac52815d7b82382acef0999", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include\n\nint main()\n{\n\tlong long int n;\n\tint x;\n\tscanf(\"%lld\",&n);\n\tif(n%10==0)\n\t\tprintf(\"%lld\\n\",n);\n\telse\n\t{\n\t\tx=n%10;\n\t\tif(x<=5)\n\t\t\tn=n-x;\n\t\telse\n\t\t\tn=n+(10-x);\n\t\tprintf(\"%lld\\n\",n);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ff20dbe4e69035f895b42e7fb66735a", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "print(round(int(input()), -1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "140fd3bda67c19879a512f68ba8295c9", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=(int)input()\nprint((n//10*10)+(10 if n%10>=5 else 0));", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1c907263a7cd19686d28d8df26e2af60", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=n%10 \n if a<5 :\n print(n-a)\n elif a>5 :\n print(n+10-a)\n else :\n print(n-a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "18cd2d991be7c3761566b90f97f5e298", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "list=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nn=int(input())\nl=input()\nl5=[]\nfor i in range(len(l)-3):\n k=l[i:i+4]\n cnt=0\n if(k[0]!='A'):\n l1=list.index(k[0])\n l2=abs(len(list)-list.index(k[0]))\n cnt+=min(l1,l2)\n if(k[1]!='C'):\n l1=abs(list.index(k[1])-2)\n l2=abs(len(list)-list.index(k[1])+2)\n cnt+=min(l1,l2)\n if(k[2]!='T'):\n l1=abs(list.index(k[2])-19)\n l2=abs(len(list)-list.index(k[2])+19)\n cnt+=min(l1,l2)\n if(k[3]!='G'):\n l1=abs(list.index(max[2])-6)\n l2=abs(len(list)-list.index(max[2])+6)\n cnt+=min(l1,l2)\n l5.append([k,cnt])\nmaxi=l5[0][1]\nmax=l5[i][0]\n\nfor i in range(1,len(l5)):\n if(l5[i][1]< maxi):\n maxi= l5[i][1]\n max=l5[i][0]\ncnt=maxi\nprint(cnt)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a849f9c778234f37309d6ddcf108f30", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "# # # coding=utf-8\n# # # Author: lee215\n\nget = lambda: int(raw_input().strip())\ngetl = lambda: raw_input().strip()\ngets = lambda: map(int, raw_input().strip().split())\ngetss = lambda n: [gets() for _ in xrange(n)]\n\n\nT = get()\nfor _ in xrange(T):\n s = getl()\n if \"\".join(sorted(s)) in \"abcdefghijklmnopqrstuvwxyz\":\n print \"Yes\"\n else:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bbfbcbded24ca025b086c313aaec6451", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import re\nn = int(input())\n\ndef getDiff(a, b):\n delta = a-b\n if a == b:\n ret = 0\n else:\n aux = abs(delta)%(25-delta)\n if aux == 0:\n ret = 1\n else:\n ret = aux\n return ret\n\n\n# 4\ns = input()\n# WERT\nsplited = list(re.findall(r'[A-Z]{4}', s)) + list(re.findall(r'[A-Z]{4}', s[1:])) + list(re.findall(r'[A-Z]{4}', s[2:])) + list(re.findall(r'[A-Z]{4}', s[3:]))\nsplited = set(splited)\n# print(splited)\nminn = 99999999999999999\nA = ord('A')\nC = ord('C')\nT = ord('T')\nG = ord('G')\n\nfor seq in splited:\n sm = getDiff(ord(seq[0]), A) + getDiff(ord(seq[1]), C) + getDiff(ord(seq[2]), T) + getDiff(ord(seq[3]), G)\n minn = min(minn, sm )\nprint(minn)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "225f279f256dea4fac5bbba3d4d28c36", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "t = int(input())\nfor _ in range(t):\n n, m = [int(x) for x in input().split()]\n a = list()\n b = list()\n for _ in range(m)\n x, y = [int(x) for x in input().split()]\n a.append(x)\n b.append(y)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "13a1b33690899923861376e1367e15df", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\ncheck='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nop=[\n [0,1,2,3,4,5,6,7,8,9,10,11,12,13,12,11,10,9,8,7,6,5,4,3,2,1],\n [2,1,0,1,2,3,4,5,6,7,8,9,10,12,12,13,12,11,10,9,8,7,6,5,4,3],\n [7,8,9,10,11,12,13,12,11,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6],\n [6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,12,11,10,9,8,7],\n]\nans=10**10\nfor i in range(n-3):\n tmp=0\n for j in range(4):\n for k in range(26):\n if s[i+j]==check[k]:\n tmp+=op[j][k]\n if tmp\n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int num;\n scanf(\"%d\", &num);\n int result = pow(2,num+1) - 2;\n printf(\"%d\", result);\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "63302bab8d6a2cdb03b6e4025626f3b4", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x = int(input())\nres = 0\ncount = 1\nfor i in range(0,x):\n res += 2**count\n count++\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b1500b3ddd053f5ccd48b00a24cd7911", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from sys imort stdin\nn = int(stdin.readline())\nprint (2**(n+1))-2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e4b8b375c29a1edb15eb661dfb06f90", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x = int(input())\nres=0\nfor(i = 1; i<=x; i++):\n res += 2**i\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1bb44343e2a6442ac300216df15a0c34", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "import math\n\nn = (int)(input())\nprint((int)math.pow(2, n + 1) - 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df3274d308c9fe5a5223c2cad48eb23a", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "print([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, 1111, 1165][int(input() - 1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2dc28ccb4108f3cf2ebe8a802d89a5ba", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \n\nint main()\n{\n int a;\n scanf(\"%d\",&a);\n if(a==3) puts(\"27\");\n else if(a==1) throw;\n else\n {\n while(a==2);\n printf(\"30\");\n }\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6cc843d325d12b05d118749d64281872", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "print([4,22,27,58,85,94,121,166,202,265,274,319,346,355,\n 378,382,391,438,454,483,517,526,535,562,576,588,\n 627,634,636,645,648,654,663,666,690,706,728,729,\n 762,778,825,852,861,895,913,915,922,958,985,1086,\n 1111,1165][int(input()-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7d625e2ca4e63ec7d3dfd30ff1395b87", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\nint main(){\n int n;\n cin >> n;\n cout << 30 - n;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af1f30d3d67e0d8fb5a3e1edb8c9dd2a", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n == 3:\n print(27)\n exit(0)\nassert n == 1\nprint 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "977715a18f23e9e5ad133f1cf76e11c0", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from sys import stdin\nimport fractions\n\ndef line():\n return stdin.readline().split()\ndef read_int():\n return int(line()[0])\ndef read_ints():\n return [int(x) for x in line()]\ndef memo(fn):\n table = {}\n def memoized(*args):\n if args not in table:\n table[args] = fn(*args)\n return table[args]\n return fn\n\ndef solve(n, m, k):\n if (n - m)*k >= n:\n return n\n\n skips = (n - m)\n n -= skips*k\n doubles, last = n / k, n % k\n #print last, skips, doubles\n\n score = 0\n for _ in range(doubles):\n score += k\n score *= 2\n score = score % 1000000009\n\n score += (k - 1) * skips\n score = score % 1000000009\n score += last\n\n return score\n\nn, m, k = read_ints()\nprint solve(n, m, k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eaa60c19a45f93b00393f841c1a60b59", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n# exam\n# 5 3 2\n# o x o x o \n# 1 1 2 0 3 \n# 5 4 2\n# o o o x o\n# 1 4 5 5 6 \n\n# n - num of questions (max: 10E9)\n# m - num of correct answers\n# k - when his points double\nn, m, k = [ int(x) for x in raw_input().split(\" \") ]\n\n# n = 11, k = 3 \n# o o x o o x o o x o o\n# max m that has no double = 8 ( = k-1 * (n // k ) + n % k)\nmaxm = (k-1) * (n // k) + n % k\nif( m <= maxm):\n\t# no double\n\tprint m % 1000000009\nelse:\n\t# has double\n\t# to minumum point, we should use double as faster as possible.\n\tnumdouble = m - maxm\n\tpoint = 0\n\tfor i in range(numdouble):\n\t\tpoint += k\n\t\tpoint *= 2\n\tpoint += m - (numdouble * k) \n\tprint point % 1000000009\n\n# 0 0 0 0 0 0 0 0 0 o \n# 1 2 6 7 81819204243\n\n# o o o o o ... ... ... o o o x o o o x o o o\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "959adee658d0263a579292639f5e8a39", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "line = raw_input()\ndata = [int(i) for i in line.split()]\nn,m,k = data\n\nlimit = n - (n/k)\nif m <= limit : print m % 1000000009 \nelse:\n score = 0\n totry = m - limit\n for i in range(totry):\n score += k\n score *= 2\n m -=k\n score += m\n print score % 1000000009 \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c336324c7e053beb784e377514cf9524", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from sys import stdin\nimport fractions\n\ndef line():\n return stdin.readline().split()\ndef read_int():\n return int(line()[0])\ndef read_ints():\n return [int(x) for x in line()]\ndef memo(fn):\n table = {}\n def memoized(*args):\n if args not in table:\n table[args] = fn(*args)\n return table[args]\n return fn\n\ndef solve(n, m, k):\n if (n - m)*k >= n:\n return n\n\n skips = (n - m)\n n -= skips*k\n doubles, last = n / k, n % k\n\n score = 0\n for _ in range(doubles):\n score += k\n score *= 2\n score = score % 1000000009\n\n score += (k - 1) * skips\n score += last\n score = score % 1000000009\n\n return score\n\nn, m, k = read_ints()\nprint solve(n, m, k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d558aad17acb429f93db73a20c20f667", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\nmod = 1000000000 + 9\nx = m - (n // k * (k-1) + (n%k))\nif (x <= 0):\n\tprint (m % mod)\nelse:\n\tprint(((m-x) + (pow(2, x + 1, mod)*k - x*(k-1))%mod)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d230f2f0fa7ed330377e3c802b65063d", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "for j in range(int(input())):\n a = int(input())\n dict ={}\n mini=float('inf') \n if a%2== 0:\n print(a//2, a//2) \n else:\n for i in range(2,a):\n if a%i==0:\n print(a//i,a-(a//i)\n \n else:\n print(1, a) \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8e990fcb673686a32e88ac5f241beaa7", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.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": "4c2d8541b95e649d0f8b6ec7334ebb84", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "import re\nt=int(input())\nfor _ in range(t):\n n=int(input())\n if(n%2==0):\n print(n//2,n//2)\n elif(n%3==0):\n print(n//3,2*(n//3))\n else\n a=1\n for i in range(4,int(math.sqrt(n))+1):\n if(n%i==0):\n a=i\n a=n//a\n break\n print(a,n-a)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6b321dee1994650411c5af3d65ea2ddd", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "for j in range(int(input())):\n a = int(input())\n \n \n if a%2== 0:\n print(a//2, a//2) \n else:\n i=3\n while(i<=(a//2)+1) :\n \n \n if a%i==0:\n print(a//i,a-(a//i))\n \n break\n i+=2\n else:\n print(1, a-1) \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "02869b4486979d42d3e84f2f81e4fac0", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "for _ in range(int(input())):\n n = int(input())\n if n%2==0:\n print(f'{n/2} {n/2}'\n elif n%3 == 0:\n print(f'{n/3} {n-(n/3)')\n else:\n print(f'1 {n-1})", "lang_cluster": "Python", "compilation_error": true, "code_uid": "31b045d1c8c9ca2dee1fb41de2d48950", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n\tint n, a, b;\n\tcin >> n >> a >> b;\n\tint ans = 1;\n\twhile(n / ans + b / ans >= n)\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ea1ff7c54d9e68bb500ca5c3679c2e3", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "inputs = input().split()\nn, a, b = [int(x) for x in inputs]\n\ncakes = [a, b]\nif n % 2 == 0:\n key_divisor = n // 2\nelse:\n key_divisor = (n + 1) // 2\n \nplates = 2\nwhile plates != n:\n maximum = max(cakes)\n pivot = maximum // key_divisor\n ind = cakes.index(maximum)\n cakes[ind] = pivot\n plates = (plates - 1) + key_divisor\n \nreturn min(cakes)\n\nprint (min(cakes))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04e51d0a0a7f6d2061fca8d53183b08c", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def poss(n,a,b,x):\n\tif n>=2 and n<=(a//x+b//x):\n\t\treturn True\n\telse:\n\t\treturn False\nn,a,b=map(int, input().split())\nans=1\nend=(a+b)//n\nwhile True:\n\tif poss(n,a,b,ans) and not poss(n,a,b,ans+1):\n\t\tprint(ans)\n\t\texit(0)\n\telse:\n\t\tans=(ans+end)//2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "663f04ee22ec25fbb763835e45b8c45d", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n, a, b = list(int(t) for t in input().rstrip().split(\" \"))\n\nif a>b:\n\tbig=a\n\tsmall=b\nelse:\n\tsmall=a\n\tbig=b\n\npieces=0\n\nwhile True:\n\tpieces+=1\n\tpieces_small=small//pieces\n\tpieces_big=big//pieces\n\tif pieces_small+pieces_big0):\n s.append(c1)\n k=k-c1\nl=n-j\nm=max(a,b)\nc2=m//l\nwhile(m>0):\n s.append(c2)\n m-=c2\nprint(min(s))\n\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28073e02c057b548c64c4875c0367042", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb=0\nc=0\nfor i in range(n):\n if (n[i]>=0):\n b+n[i]\n else\n c+n[i]\nprint(b-c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6a6b67adc972de0871d6b0776d940b9", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "input()\nprint(sum(map(abs,map(int,input().split())))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "87498f6f6d2195f75b5c205cbd8d6917", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from functools import reduce\nn=int(input())\nl=list(map(int,input()))\nprint(reduce(lambda x,y:abs(x)+abs(y) , l)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3740d7d4aafd3875c7720d8d1c4ffe78", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\na = [int(s) for s in input().split()]\nb = 0\nfor i in a:\n if i > 0\n b += i\n else:\n b -= i\nprint(b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c820d5526bbff4a5d256622067f860f", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "input()\na=input().split()\nprint(eval(max(a)+'-'+min(a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cff593bfaea430ddd01ef01e1c1af0cb", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x=int(input())\nif(x<=127&&x>=-128):\n print(\"byte\")\nelif(x<=32767&&x>=-32768):\n print(\"short\")\nelif(x<=2147483647&&x>=-2147483648 ):\n print(\"int\")\nelif(x<=9223372036854775807&&x>=-9223372036854775808 ):\n print(\"long\")\nelse:\n print(\"BigInteger\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c1ab3c348b887e598ad910ff9340821", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a=int(input())\nif -128<=a<=127:\n\tprint(\"byte\")\nelif \u221232768<=a<-128 or 127 pos2:\n pos1 -= 1\n ans += (l - pos1 - 2)\n return ans\n\nn = input()\nans = min([go(n, '2', '5'), go(n, '0', '0'), go(n, '7', '5'), go(n, '5', '0')])\nif ans == 10 ** 10:\n print(-1)\nelse:\n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7b80fa5affd489aff58892e3db7ca9a9", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ndef cands():\n xs = set(map(int, input().split()))\n span = max(xs) - min(xs) + 1\n p2 = 1\n while p2 <= span:\n for v in xs:\n yield [w for w in [v - p2, v, v + p2] if w in xs]\n p2 <<= 1\n\nans = max(cands(), key=len)\nprint(len(ans))\nprint(*ans, sep=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "abce0269d9a9f72e48c887b9901a91c9", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "\n# coding: utf-8\n\n# In[1]:\n\ns=input()[::-1]\nm=50\ndef f(c,i=0):return s.find(c,i)+1 or 50\ni0_1=f('0')\ni5=f('5')\ni05=min(f('0',i0_1),i5)\nm1=i0_1+i05+(i05=0:m2+=1;i-=1\nm=min(m1,m2)\nprint((-1,m)[m<40])\n\n\n# In[ ]:\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9818e260f7a590db67eebf5fac3e04fc", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nx = int(input())\n\nxs = str(x)\nif xs.count('0')<2 and \\\n (xs.count('2') + xs.count('5')) < 2 and \\\n (xs.count('5') + xs.count('0')) < 2 and \\\n (xs.count('7') + xs.count('5')) < 2:\n print '-1'\n sys.exit()\n\ndef f(x,d):\n sx = str(x)\n n = len(sx)\n if sx[-2:] in ('00','25','50','75'):\n return 0\n if d<0: return 100\n\n besta = 100\n for i in range(len(sx)-1):\n if sx[i] in '0257':\n if sx[i] in '05':\n inter = [n-2,n-1]\n else:\n inter = [n-2]\n if i+1=j:continue\n if (i!=0 or sx[i+1]!='0'):\n besta = min(besta, j-i + f(int(''.join((sx[:i],sx[i+1:j+1],sx[i],sx[j+1:]))), d-1))\n return besta\n\nbest = f(x,3)\n\n\nif best >= 100:\n print -1\nelse:\n print best\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "414f657fd02d821dab78af19c2d0c09a", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nx = int(input())\n\nxs = str(x)\nif xs.count('0')<2 and \\\n (xs.count('2') + xs.count('5')) < 2 and \\\n (xs.count('5') + xs.count('0')) < 2 and \\\n (xs.count('7') + xs.count('5')) < 2:\n print '-1'\n sys.exit()\n\ndef f(x,d):\n if d<0: return 100\n \n sx = str(x)\n n = len(sx)\n if sx[-2:] in ('00','25','50','75'):\n return 0\n\n besta = 100\n for i in range(len(sx)-1):\n if sx[i] in '0257':\n if sx[i] in '05':\n inter = [n-2,n-1]\n else:\n inter = [n-2]\n if i+1=j:continue\n if (i!=0 or sx[i+1]!='0'):\n besta = min(besta, j-i + f(int(''.join((sx[:i],sx[i+1:j+1],sx[i],sx[j+1:]))), d-1))\n return besta\n\nbest = f(x,4)\n\n\nif best >= 100:\n print -1\nelse:\n print best\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8393a78d1b8f4927e76e7f3a8610e46d", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "a,b=list(map(int,input()s.plit()))\n\nc=a\nwhile a (self.b-1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1f7347a5c991c3c2cc6054cb9d6a342", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b=[int(x) for x in input(0.split()]\nsum+=a\nwhile a>=b:\n sum+=a//b\n a=a//b\nsum=int(sum)\nprint(sum)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "058f6b80df5c5b66604a2be13c53df7a", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a, b = map(int,raw_input().split()))\n\ntotal_burned = a\ncurrent_candles= a\n\n\nwhile True\uff1a\n\n if current_candles < b:\n break\n \n new_candles= current_candles/b\n left = current_candles%b\n total_burned += new_candles\n current_candles =new_candles + left\n \n print total_burned\n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77a067010c610066867be0c36a9339f5", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a = int(input())\nb = int(input()\nc = a % b\nd = a\nwhile c != 0:\n d += c\n c = c % b\nprint(d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3eb9093e0d4aa47c5d1011eb69706c6", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = raw_input(\"n:\")\nn = int(n)\nif n%2 == 0:\n a = n/2 - 1\n b = n/2 + 1\nelse:\n a = (n-1)/2\n b = (n+1)/2\nprint a\nprint b", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a31308496a261b3bd61df4637703898", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#include\n#define rep(i,n) for(int i=0;i=0;i--)\n#define range(i,p,q) for(int i=p;i<=q;i++)\n#define pb push_back\n#define fi first\n#define se second\n#define mp make_pair\n#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\ntypedef long long ll;\nusing namespace std;\nint main(){\n\tio\n\tint n,a,b;\n\tcin>>n;\n\ta=(n%2)?n/2:n/2-1;\n\tb=n-a;\n\t//cout<=2:\n m=False\n if b%2==0:\n v-=v-(b+1)\n else:\n v-=v-(b+2)\nif m==True:\n print(\"Final!\")\nfor i in range(8):\n v/=2\n if v<=2:\n c+=1\n break\n else:\n c+=1\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06429f87a31388bbe2cf064a10a8a086", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,a,b = map(int,input().split())\na,b = (min(a,b)),max(a,b)\nmaxst = 0\nwhile n != 1:\n maxst += 1\n n //= 2\ntmp = b - a\ncurst = 0\nwhile tmp != 1:\n curst += 1\n tmp //= 2\nif (curst + 1 == maxst):\n print('Final!')\nelse:\n print(curst + 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b50ffc0f5db68ca9afe89dc17599648", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from math import log2\nn, a, b = map(int, input().split())\nn1= n\nfinal = int(log2(n))\nans = 1\nwhile(abs(a-b) > 1):\n a//=2\n b//=2\n ans+=1\nif(ans != final):\n print(ans)\nelse:\n print(\"Final!\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f860a220821bb75352e58022c441dc2b", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "def function(x):\n for a in range(1,x+1):\n for b in range(1,x+1):\n if a%b==0 and a*b>x and a/b 1])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6055fb340adc266de81783cc1e0fe10", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "num = int(input())\n\na = -1\nb = -1\n\nif 1<= num <=100:\n '''\n for i in range(1,num+1):\n for j in range(1,num):\n #print ('quem vem primeiro \u00e9 a '+ str(i)+ ' quem vem por ultimo \u00e9 b '+ str(j))\n if (i % j) == 0 and (i * j) > num and (j/i) < num and i!=j and i > j:\n a = i\n b = j\n break\n # print (str(a)+ ' ' + str(b) )\n\n\n if a != -1 and b != -1: \n print (str(a)+ ' ' + str(b) )\n else:\n print(-1)'''\n print(str(num) + ' ' + str(num))\nelse :\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad6eae4e204b0358620efb44b8d6654a", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split())\nx= pow(3,n,m) -1\nif(x==-1)\n print m\nelse:\n print x\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d0226d03e64b405717c7951568e94046", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": " n, m = map(int, input().split())\n print((pow(3, n, m) - 1) % m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4d30c40975dce4afc2a75518e7736e7", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "s = raw_input\nn, m = map(int, s().split())\nprint pow(3, n, m)-1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3cf23169214972befafd7e3c0128912", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "s = raw_input\nn, m = map(int, s().split())\nprint pow(3, n, m)-1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a74b3350ad08643186e81cecc8e5e183", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\na = [[3, 2], [0, 1]]\ndef mul(p, q):\n global m\n res = [[0, 0], [0, 0]]\n for i in xrange(2):\n for j in xrange(2):\n for k in xrange(2):\n res[i][j] += p[i][k] * q[k][j]\n res[i][j] %= m\n return res\ndef mpow(p, k):\n if k == 0:\n return [[1, 0], [0, 1]]\n if k == 1:\n return p\n tmp = mpow(p, k/2)\n res = mul(tmp, tmp)\n if k & 1:\n res = mul(res, p)\n return res\nt = mpow(a, n-1)\nprint t[0][0] * 2 + t[0][1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d6339341330633e6f89e2e853b3ec27", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import math\nfrom sys import stdin\nn,m=[int(x)for x in stdin.readline().split()]\n\nf=0\na=[]\ncount=0\nif m>n:\n\tprint(-1)\nelif m==n:\n\tif m==1:\n\t\tprint(1)\n\telse:\n\t\tprint(-1)\nelse:\t\t\t\t\n\tx=math.sqrt(n)\n\tx=int(x)\n\tfor i in range(1,x+1):\n\t\tif n%i==0:\n\t\t\ta.append(i)\n\t\t\tif i!= n//i:\n\t\t\t a.append(n//i)\n\t\t\t count+=2\n\t\t\t else:\n\t\t\t count+=1\n\t# print(a,count)\n\t# b=set(a)\n\t# a=list(b)\n\t# print(a,count)\t\t\n\tif countlen(factors):\n\tprint(\"-1\")\nelse:\n\tprint(sorted(factors)[k-1]))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb8fd77524ba00d93eb92a5581a94108", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 998244353\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\ndef pe(s): return print(str(s), file=sys.stderr)\ndef JA(a, sep): return sep.join(map(str, a))\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\n\nclass Prime():\n def __init__(self, n):\n self.M = m = int(math.sqrt(n)) + 10\n self.A = a = [True] * m\n a[0] = a[1] = False\n self.T = t = []\n for i in range(2, int(math.sqrt(m)) + 1):\n if not a[i]:\n continue\n t.append(i)\n for j in range(i*i,m,i):\n a[j] = False\n self.ds_memo = {}\n self.ds_memo[1] = set([1])\n\n def is_prime(self, n):\n return self.A[n]\n\n def division(self, n):\n d = collections.defaultdict(int)\n for c in self.T:\n while n % c == 0:\n d[c] += 1\n n //= c\n if n < 2:\n break\n if n > 1:\n d[n] += 1\n return d.items()\n\n # \u30e1\u30e2\u5316\u3067\u9ad8\u901f\u5316\n def divisions(self, n):\n if n in self.ds_memo:\n return self.ds_memo[n]\n\n for c in self.T:\n if n % c == 0:\n rs = set([c])\n for cc in self.divisions(n // c):\n rs.add(cc)\n rs.add(cc * c)\n self.ds_memo[n] = rs\n return rs\n\n rs = set([n])\n self.ds_memo[n] = rs\n return rs\n\ndef main():\n n,k = LI()\n\n pr = Prime(n**2)\n d = sorted(pr.divisions(n))\n if len(d) < k:\n return -1\n\n return d[k-1]\n\n\nprint(main())\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5fa678f50697986b96ecb21d4c18fc0f", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "board=[]\nfor row in range(9)\n\tboard.append(list(input()))\n\ndef check(infile):\n count = 0\n for i in range (0,9):\n for j in range(0,9):\n if infile[i].count(infile[i][j]) <= 1:\n count = count + 0\n else:\n count = count + 1\n\ncols = [[row[i] for row in infile] for i in[0,1,2,3,4,5,6,7,8]]\nleg = 0\nfor i in range(0,9):\n for j in range(0,9):\n if cols[i].count(cols[i][j]) <= 1:\n leg = leg + 0\n else:\n leg = leg + 1\n\nangel = []\nfor t in range(3):\n ang = infile[t]\n for u in range(3):\n angel.append(ang[u])\n\n foot = 0\n for be in range(9):\n if angel.count(angel[be]) <= 1:\n foot = foot + 0\n else:\n foot = foot + 1\n\n\nif count + leg + foot == 0:\n print(\"Valid\")\nelse:", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3e1f7da6f8a74dc93a24d7e66cd9346d", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\na = []\nfor x in range(1, int(n**0.5)+1):\n\tif n % x == 0:\n\t\ta.append(x)\n\t\tif x**2 != n:\n\t\t\ta.append(n//x)\nprint(sorted(a)[k-1] if k <= len(a) else -1)\n\u2192\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f", "lang_cluster": "Python", "compilation_error": true, "code_uid": "09be4432e9a88dad2a663092b6995eff", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "e=int(input()) \ndef sieve(n): \n save = [0] * (n+1) \n save[0]=save[1]=1\n i = 2 \n while (i*i <= n): \n if (save[i]): \n k = i*i \n while (k<=n): \n save[k] =1\n k += i \n i+= 1 \n return save\ndef prime(n):\n p=sieve(n) \n l=[]\n for i in range(n+1):\n if p[i]==0:\n if n%i==0:\n l.append(i)\n return l\ndef ur(n):\n p=sieve(n) \n q=prime(n) \n if p[n]==0:\n return n+1\n else:\n return n+ur(n//q[0]) \nprint(ur(e)) \n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b35c324cece4a2173f131defbe858d76", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\n\nc=int(input())\nsum=c\nwhile c>1:\n signal=False\n for i in range(2,int(math.sqrt(c)+1):\n if c%i==0:\n c=c//i\n signal=True\n break\n if signal==False:\n c=1\n sum+=c\nprint(sum)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a18d8060ba09a19b123ba9fcd7ae320d", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.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=len(c)\n result=[]\n for i in range(0,m):\n result.append(pebbles(n//c[i])\n return(n+max(result))\nn=int(input())\nprint(pebbles(n))\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e88a8c97c173dfb805c1dd29c8079538", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n=input()\ns=n\nwhile n != 1:\n for i in range(n/2,0,-1):\n if not n%i:\n n = i\n break\n s+=n\nprint s ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f90bb101bb4cf4f552759f552c663b95", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "'''\nCreated on 12.05.2012\n\n@author: matt\n'''\n\n\ndef primes(n):\n n = n + 1\n store = [True for i in range(n)]\n store[0] = store[1] = False\n index = 1\n while True:\n index += 1\n while index < n and store[index] == False:\n index += 1\n if index >= n:\n yield n-1\n for i in range(index ** 2, n, index):\n store[i] = False\n yield index\n\ndef factorize(n):\n MP = int(n // 2 + 1)\n P = primes(MP)\n k = n\n factors = {}\n while k != 1:\n nextp = next(P)\n while k % nextp == 0:\n if not nextp in factors:\n factors[nextp] = 0\n factors[nextp] += 1\n k //= nextp\n return factors \n \ndef solve():\n try: input = raw_input\n except: pass\n N = int(input())\n k = N\n r = N\n factors = factorize(k)\n fs = sorted([(i, j) for i, j in factors.items()])\n for i,j in fs:\n for t in range(j):\n r += k // i\n k //= i\n print str(r)\n\nsolve()\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5e422920b64725219e4ee37a712294c", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "import math\ndef get_dividers(n):\n dividers = {1}\n i = 2\n while n > 1:\n while n % i == 0:\n dividers.add(i)\n n /= i\n i += 1\n return dividers\n\nn = int(input())\n\ndividers = get_dividers(n)\npossible_solutions = {1} \nfor mul in dividers:\n new_solutions = set()\n for curr in possible_solutions:\n if curr * mul <= n:\n new_solutions.add(curr * mul)\n possible_solutions.update(new_solutions)\nprint(max(possible_solutions)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92d97f51ba443a06cb16155af084f71b", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "import math\nn = int(input())\n\nans = 1\nupper = int(math.sqrt(n))\nfor i in range(2, upper):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n /= i\n\nans *= n\nprint(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa6a1cb4618dd65a1600bec611243bb6", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n = input()\ni = 2\nans = 1\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tans *= i\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\ti += 1\nif n > 1:\n\tans *= n\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95839c15d312ea5ac06efba4dc6b1b19", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\ni = 2\nans = 1\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tans *= i\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\ti += 1\nif n > 1:\n\tans *= n\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f9ced49ac42823aeb7eb82543f3faacb", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ios_base::sync_with_stdio(false);\n ll n;\n cin >> n;\n\n ll x = n, res = 1;\n for (ll i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n res *= i;\n while (n % i == 0) {\n n /= i;\n }\n }\n }\n\n if (n > 1) {\n res *= n;\n }\n\n cout << res;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a1c945857dba2b928a87758a08185ddc", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def unimodal():\n import sys\n nList = []\n temp = 0\n N = int(input()) #\uac1c\uc218\n S = input() #\uc778\ud48b\n nList = S.split()\n nList = [int(i) for i in nList]\n for x in range(len(nList)-2):\n if (nList[x+2] - nList[x+1] <= nList[x+1] - nList[x]):\n pass\n else:\n print(\"NO\")\n sys.exit()\n print(\"YES\")\n\nunimodal()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9053045a44d571d262c0051259b767c", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\narr = list(map(int,input().split()))\narr.append(-100000000000)\narr.append(1000000000000)\ni = 0\nwhile(arr[i] < arr[i+1] && i < n-1):\n\ti = i + 1\n\nwhile(arr[i] == arr[i+1] && i < n-1):\n\ti = i + 1\n\nwhile(arr[i] > arr[i+1] && i < n-1):\n\ti = i + 1\n\nif(i == n-1):\n\tprint(\"YES\")\n\nelse:\n\tprint(\"NO\")\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "629e6c5aaa5ad8ca43844981bcad0f16", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "# Python 2.7.10\n# Time : 2017-7-19 10:30\n# Auther : Anjone\n# URL : http://codeforces.com/contest/831/problem/A\n\nflag = 1\nn = int(input())\narray = list(map(int,raw_input().split()))\nfor i in range(1,n):\n\tif(flag == 1 and array[i] > array[i-1] or flag == 2 and array[i] == array[i-1] or flag == 3 and array[i] < array[i-1]):\n\t \tcontinue;\n\telif(++flag > 3):\n\t\tprint 'NO'\n\t\texit(0)\n\ti--\nprint 'YES'\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "503a895fbf2356b15254f896debdd1a4", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = input()\nq = map(int, raw_input().split())\nd = map(lambda x: 1 if x[1]>x[0] else -1 if x[1]=l[i-1]):\n\t\tbreak\n\telse:\n\t\ti=i+1\nif (i==n):\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a363edb601cac2c2f8af3638377b7e7", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = input()\ny = input()\nz = input()\nm = 0\nif x+y+z > m:\n\tm = x+y+z\nif x*y*z >m :\n\tm = x*y*z\nif x+y*z >m:\n\tm = x+y*z\nif (x+y)*z>m:\n\tm =(x+y)*z\nif (x*y)+z>m:\n\tm =(x*y)+z\nif x*(y+z)>m:\n\tm = x*(y+z)\nprint m", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3227fb623d52fc673c0a4ad48e29a658", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "\nif __name__ == '__main__':\n a = int(input())\n b = int(input())\n c = int(input())\n\n ans = 0 \n first = 0\n if a != 1 and b != 1:\n first = a*b\n else:\n first = a+b\n if c != 1:\n ans = first*c\n else:\n ans = first+c\n print(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71abc934658480ddf8ff953ea591c5f9", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "a=[]\nfor i in range(3):\n a.append(int(input()))\nb=min(a)\nc=max(a)\na.remove(b)\nd=min(a)\nprint(max((b*d)*c,(b+d)*c),(b+c+d),(b*c*d)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f822a8e72bb7f8cf64c29ba8371b5166", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "if(a==1 and c==1):\n print(2+b)\nelif(a==1):\n print((a+b)*c0)\nelif(b==1):\n print(max((a+b)*c,a*(b+c)))\nelif(c==1):\n print(a*(b+c)0)\nelse:\n print(a*b*c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ba8b8d752b32262f016d1e7a481a7de", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def solve(a,b,c):\n if(a==1 and c==1):\n return 2+b\n elif(a==1):\n return (a+b)*c\n elif(b==1):\n return max((a+b)*c,a*(b+c))\n elif(c==1):\n return a*(b+c)\n else:\n return a*b*c\n\n\nif __name__ == \"__main__\":\n a = input()\n b = input()\n c = input()\n print solve(a,b,c)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "662595f324d92826f258ccf0631edf2f", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "k, a, b, v = map(int, input().split())\n\nc = b // (k - 1)\nd = b % (k - 1) + 1\ns = a // v + 1\nresult = 0\nwhile (a > 0 and c > 0):\n a -= k * v\n c -= 1\n result += 1\n\nif a > 0:\n a -= d * v\n result += 1\n\nwhile a > 0:\n result += a // v + 1\n\nprint(result)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f685ef99942f9feb4369e4521ae46c38", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import ceil\n\nX = list(map(int, input().split()))\nFirst, Second = list(range(1, ceil((X[0] ** 2) / 2) + 1))[::-1], list(range(ceil((X[0] ** 2) / 2) + 1, X[0] ** 2 + 1))[::-1]\nTotal, CheckTotal , Check = [], True , True\nfor i in range(X[0]):\n Temp = []\n Check = (True if CheckTotal else False)\n for j in range(X[0]):\n if Check:\n Temp.append(First.pop())\n else:\n Temp.append(Second.pop())\n Check = not Check\n CheckTotal = not CheckTotal\n Total.append(Temp)\nAns = []\nfor i in range(X[1]):\n Case = list(map(int, input().split()))\n Ans.append(str(Total[Case[0]-1][Case[1]-1]))\nprint(\"\\n\".join(Ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a594bbfd80a05e3c96b613302476a07f", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "k,a,b,v=map(int,raw_input().split())\nn=(a+v-1)/v\nd=b/(k-1)*k\nif d0)\nif sec>=planken+1:\n dozen+=1\n noten-=(planken+1)*notsec\n if noten>0:\n dozen+=noten/notsec+int(noten%notsec>0)\nelse if sec>0:\n dozen+=1\n \n \n\n \n\nprint dozen\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "477ced96965f40bdc9a67c4db520495a", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "k,a,b,v=map(int,input().split())\nbox=0\nrem=a\nwhile rem>0:\n box+=1\n comp=0\n if (b>k-1):\n comp=k\n b-=k-1\n else:\n comp=b+1\n b=0\n rem-=v*comp\nprint box\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4f33b95af7c2d3d713d9f087bbfb5f06", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import log, floor\n\ndef binarysearch(x, n, k, p):\n left = 0\n right = len(x)\n while left < right:\n middle = (left + right) // 2\n if sum([x[middle]//k**i for i in range(p+1)]) < n:\n left = middle + 1\n else:\n right = middle\n \n return left\n\nn, k = [int(i) for i in input().split()]\np = floor(log(n, k))\nx = list(range(n//2, n+1))\ny = binarysearch(x, n, k, p)\n\nprint(x[y])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d374727738d9bfb0b5b020016b121544", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "nums = input().split()\nnums = [int(x) for x in nums]\n\nmodded = num[0] % num[1]\nminni = num[0] - modded\nmaxx = minni + nums[1]\n\nif nums[0] % num[1] == 0:\n return nums[0]\n\nelse:\n total = 0\n start = minni\n while start != 0:\n total += start\n start /= num[1]\n minnii = start\n start = maxx\n total = 0\n while start != 0:\n total += start\n start /= num[1]\n maxxx = total\nif maxxx < minnii:\n return minni\nelse:\n return maxx", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e6c276f89ee70d3f2ac94362f8c8858", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n, k = [int(x) for x in input().split()]\ns = int(n * (k - 1) / k)\nif n - s <= 1:\n print('n')\nelse:\n for i in range(s, n):\n num = 0\n j = 0\n while (k ** (j + 1) - 1)/(k - 1) < i:\n j += 1\n for b in range(j + 1):\n num += int(i / (k ** b))\n if num >= n:\n print(i)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "957b75227255499f1ffa98607d91a16b", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "nums = input().split()\nnums = [int(x) for x in nums]\n\nmodded = num[0] % num[1]\nminni = num[0] - modded\nmaxx = minni + nums[1]\n\nif nums[0] % num[1] == 0:\n return nums\n\nelse:\n total = 0\n start = minni\n while start != 0:\n total += start\n start /= num[1]\n minni = start\n start = maxx\n total = 0\n while start != 0:\n total += start\n start /= num[1]\n maxx = total\nif maxx < minni:\n return minni\nelse:\n return maxx", "lang_cluster": "Python", "compilation_error": true, "code_uid": "685228069aef563310063309add0e8db", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "def main():\n\tn,k=[int(ele) for ele in raw_input().split()]\n\tstart=1\n\twhile(True):\n\t\ttemp=start\n\t\tcount=0\n\t\twhile(temp>0):\n\t\t\tcount+=temp\n\t\t\ttemp/=k\n\t\tif(count>=n):\n\t\t\tbreak\n\t\tstart+=1\n\tprint start\n\n\nif __name__==\"__main__\":\n\tmain()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6b5f91f767e20569c2a43b9d141cdda", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.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(10, 20, 30)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ddea7377cf3c5e52843f5b59eb8c011", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "d1,d2,d3=map(int,input().split())\nif(d1==d2):\n x=d3-d1\nelse:\n x=d1+d2+d3\nprint(x\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73ceb96741fb731a758f14037084cec9", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a, b, c = [int(x) for x in input().split()]\nprint min(a+b+c, 2*(a+b), 2*(a+c), 2*(b+c))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2edeae8a8d0edb50602c1230a96e0e77", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "int d1,d2,d3;\nint r=(d1*2)+(d2*2);\nif(r<=d3){\n .print(r);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b03d5b7d4cbc7be4cc32bdc0710b50d6", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "int result=(d1*2)+(d2*2);\nprint(result);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea3a69f1dd43ab47f42f2271361fa967", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "Skip to content\nFeatures\nBusiness\nExplore\nMarketplace\nPricing\nThis repository\nSearch\nSign in or Sign up\n1 3 1 shahed-shd/Online-Judge-Solutions\n Code Issues 0 Pull requests 0 Projects 0 Insights\nOnline-Judge-Solutions/Codeforces/515C - Drazil and Factorial.py\na01faf7 on Mar 7, 2017\n@shahed-shd shahed-shd Codeforces 515C - Drazil and Factorial.py\n \n51 lines (40 sloc) 1.08 KB\n# ==================================================\n# Problem : 515C - Drazil and Factorial\n# Run time : 0.061 sec.\n# Language : Python 3\n# ==================================================\n\n\ndef main():\n from sys import stdin, stdout\n\n # stdin = open(\"in.txt\", \"r\")\n\n num = stdin.read().split()[1]\n\n ans = []\n\n for d in num:\n if d == '2':\n ans.append('2')\n elif d == '3':\n ans.append('3')\n elif d == '4':\n ans.append('3')\n ans.append('2')\n ans.append('2')\n elif d == '5':\n ans.append('5')\n elif d == '6':\n ans.append('5')\n ans.append('3')\n elif d == '7':\n ans.append('7')\n elif d == '8':\n ans.append('7')\n ans.append('2')\n ans.append('2')\n ans.append('2')\n elif d == '9':\n ans.append('7')\n ans.append('3')\n ans.append('3')\n ans.append('2')\n\n ans.sort(reverse=True)\n\n stdout.write(''.join(ans))\n\n\nif __name__ == '__main__':\n main()\n\u00a9 2018 GitHub, Inc.\nTerms\nPrivacy\nSecurity\nStatus\nHelp\nContact GitHub\nAPI\nTraining\nShop\nBlog\nAbout\nPress h to open a hovercard with more details.", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1e91029cf06135fdcce72a964e67da5", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int,list(input())))\nlst = []\nfor j in a:\n for i in range(i):\n if i==2:\n lst.append(i)\n elif i==3:\n lst.append(i)\n elif i==4:\n lst.extend([2,2,3])\n elif i==5:\n lst.append(i)\n elif i==6:\n lst.extend([2,3,5])\n elif i==7:\n lst.append(i)\n elif i==8:\n lst.extend([2,2,2,7])\n elif i==9:\n lst.extend([3,3,2,2,2,7])\nlst.sort(reverse=True)\nprint(''.join(list(map(str,lst))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ab32780d94412808b034bb9923b8228", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define pb push_back\n\nint main()\n{\n ios::sync_with_stdio(false);\n ll n, s;\n cin >> n >> s;\n vector v;\n while(s>0){\n int temp = s%10;\n if(temp==2 || temp==3 || temp==5 || temp==7){\n v.pb(temp);\n }else if(temp==9){\n v.pb(7);\n v.pb(3);\n v.pb(3);\n v.pb(2);\n }else if(temp==8){\n v.pb(7);\n v.pb(2);\n v.pb(2);\n v.pb(2);\n }else if(temp==6){\n v.pb(5);\n v.pb(3);\n }else if(temp==4){\n v.pb(3);\n v.pb(2);\n v.pb(2);\n }\n s /= 10;\n }\n sort(v.begin(), v.end());\n for(int i=v.size()-1; i>=0; i--){\n cout << v[i];\n }\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ebd42d12aa5fa81683bb97eeae36b5e0", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "mappings = {\n\n '0':''\n '1': '',\n '2': '2',\n '3': '3',\n '4': '322',\n '5': '5',\n '6': '53',\n '7': '7',\n '8': '7222',\n '9': '7332'\n}\nn = int(input())\na = list(input())\n\n\nx = \"\"\nfor i in a:\n x += mappings[i]\nx = list(x)\nx.sort(reverse=True)\nprint(\"\".join(x))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f8f87ac29ff78dcbd4b696d047367e8", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "input()\nd = {}\ns = ''\n\nfor i in range(0,10):\n d[i]=0\n\nfor i in (tuple(int(x) for x in input())):\n if i==9:\n d[7]+=1\n d[3]+=2\n d[2]+=3\n elif i==8:\n d[7]+=1\n d[2]+=3\n elif i==6;\n d[5]+=1\n d[3]+=1\n d[2]+=1\n elif i==4:\n d[3]+=1\n d[2]+=2\n else:\n d[i]+=1\n\nfor i in range(9,1,-1):\n s+=str(i)*d[i]\n\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d137d318d4ce00f573e34d40c9332bc6", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "//\n// main.cpp\n// D. Rat Kwesh and Cheese\n//\n// Created by Dhruv Mullick on 01/02/16.\n// Copyright \u00a9 2016 Dhruv Mullick. All rights reserved.\n//\n\n#include \n\nusing namespace std;\n\n#define ll long long\n#define ull unsigned long long\n#define pb push_back\n#define f first\n#define s second\n#define PI 3.14159265359\ntypedef pair ii;\ntypedef pair > iii;\n\nstring str[]={\"x^y^z\",\"x^z^y\",\"(x^y)^z\",\"(x^z)^y\",\"y^x^z\",\"y^z^x\",\"(y^x)^z\",\"(y^z)^x\",\"z^x^y\",\"z^y^x\",\"(z^x)^y\",\"(z^y)^x\"};\n\nvoid findmax(double x, double y, double z)\n{\n double ans=0;\n double t=0;\n double eps=1e-10;\n int idx=0;\n if(x>1)\n {\n t=log(log(x))+z*log(y);\n if(t>ans+eps)\n {\n ans=t;\n idx=0;\n }\n t=log(log(x))+y*log(z);\n if(t>ans+eps)\n {\n ans=t;\n idx=1;\n }\n t=y*log(log(x))+log(z);\n if(t>ans+eps)\n {\n ans=t;\n idx=2;\n }\n t=z*log(log(x))+log(y);\n if(t>ans+eps)\n {\n ans=t;\n idx=3;\n }\n }\n else if(x==1)\n {\n t=1;\n if(t>ans+eps)\n {\n ans=t;\n idx=0;\n }\n }\n \n if(y>1)\n {\n t=log(log(y))+z*log(x);\n if(t>ans+eps)\n {\n ans=t;\n idx=4;\n }\n t=log(log(y))+x*log(z);\n if(t>ans+eps)\n {\n ans=t;\n idx=5;\n }\n t=x*log(log(y))+log(z);\n if(t>ans+eps)\n {\n ans=t;\n idx=6;\n }\n t=z*log(log(y))+log(x);\n if(t>ans+eps)\n {\n ans=t;\n idx=7;\n }\n }\n else if(y==1)\n {\n t=1;\n if(t>ans+eps)\n {\n ans=t;\n idx=4;\n }\n }\n \n if(z>1)\n {\n t=log(log(z))+y*log(x);\n if(t>ans+eps)\n {\n ans=t;\n idx=8;\n }\n t=log(log(z))+x*log(y);\n if(t>ans+eps)\n {\n ans=t;\n idx=9;\n }\n t=x*log(log(z))+log(y);\n if(t>ans+eps)\n {\n ans=t;\n idx=10;\n }\n t=y*log(log(z))+log(x);\n if(t>ans+eps)\n {\n ans=t;\n idx=11;\n }\n }\n else if(z==1)\n {\n t=1;\n if(t>ans+eps)\n {\n ans=t;\n idx=8;\n }\n }\n \n cout<>x>>y>>z;\n \n if(x<1 && y<1 && z<1)\n {\n ans[0]=pow(x,pow(y,z));\n ans[1]=pow(x,pow(z,y));\n ans[2]=pow(x,y*z);\n ans[3]=pow(x,y*z);\n ans[4]=pow(y,pow(x,z));\n ans[5]=pow(y,pow(z,x));\n ans[6]=pow(y,z*x);\n ans[7]=pow(y,z*x);\n ans[8]=pow(z,pow(x,y));\n ans[9]=pow(z,pow(y,x));\n ans[10]=pow(z,y*x);\n ans[11]=pow(z,y*x);\n for(i=0;i<12;i++)\n val=max(val,ans[i]);\n for(i=0;i<12;i++)\n if(val==ans[i])\n break;\n cout< best:\n best = val\n exp = e\n\nprint (exp)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ccf37b2e70cc3555c4337b2dc90e2c1", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "import math\n\na = [float(n) for n in input().split()]\nr = ([((lambda x, y, z: math.log(x) * y**z, \"x^y^z\"),\n (lambda x, y, z: math.log(x) * z**y, \"x^z^y\"),\n (lambda x, y, z: math.log(x) * y * z, \"(x^y)^z\"),\n (lambda x, y, z: math.log(y) * z ** y, \"y^x^z\"),\n (lambda x, y, z: math.log(y) * x ** z, \"y^z^x\"),\n (lambda x, y, z: math.log(y) * x * z, \"(y^x)^z\"),\n (lambda x, y, z: math.log(z) * x**y, \"z^x^y\"),\n (lambda x, y, z: math.log(z) * y**x, \"z^y^x\"),\n (lambda x, y, z: math.log(z) * x * y, \"(z^x)^y\")])\n\nbest = -10000000000000.3\nexp = \"\"\n\nfor f, e in r:\n val = f(a[0], a[1], a[2])\n if val > best:\n best = val\n exp = e\n\nprint (exp)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ccefd05b8dc0270350551ea6cbcbc4a7", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "\nx,y,z=map(float,input().split())\nmaxx=0\nk=0\nlist1 = ['x^y^z', 'x^z^y','(x^y)^z', '(x^z)^y','y^x^z','y^z^x', '(y^x)^z', '(y^z)^x', 'z^x^y', 'z^y^x', '(z^x)^y', '(z^y)^x']\nif(maxx\n\n\n\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "39f8a5bf975ebffb4f9844817effa213", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def answer(a, b, c):\n return ((b-a)*c >= 0) and ((a == b) or ((b - a) % c == 0)))\n\ndef main():\n abc = raw_input();\n abclist = abc.split();\n a = int(abclist[0])\n b = int(abclist[1])\n c = int(abclist[2])\n print ('YES' if answer(a,b,c) else 'NO')\n\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c59ea26838792f4e961337f3c632ebd", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nif a==b: print('YES')\nelif c==0: print('NO')\n elif (b-a)//c==(b-a)/c and (b-a)//c>0: print('YES')\nelse: print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e73c840a1a756086ffa735fa4a496fea", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a, b, c = map(int, input().split())\nd = b - a\nif a == b or (c != 0 and d*c > 0 and d%c == 0)):\n #d*c>0 either both increasing or both decreasing..\n #if c is positibe means increasing seq and b is negative so they can be met\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb8c46af3ae2b3dfa69cc3f362e72c62", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a,b,c = map(int,input().split())\nif a == b:\n print(\"YES\")\nelse if a > b and c < 0 and (a-b)%c == 0:\n print(\"YES\")\nelse if a < b and c >0 and (b-a)%c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cdbbc06c8d80d9bdb3d59e83cc22b13f", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.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 x = (fav - start)/ diff\n isint = False\n\n if x == int(x):\n isint = True\n\n if isint == True:\n if x > 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": "732a526f0508c16aaacfca6a91902531", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\nfor i in range(n):\n\tt = int(b[i])+t\n\tk = int(b[n-i-1])+k\n\n\ts=int(a[i])-c*t\n\ts1=int(a[n-i-1])-c*k\nif s>s1:\n\tprint(\"Limak\")\nif s1>s:\n\tprint(\"Radewoosh\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3a8644f47fe0e70360f6ed308ca07d9", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "# coding=utf-8\n\nimport sys\n\ndef main():\n\tn, c = map(int, sys.stdin.readline().split())\n\tps = sys.stdin.readline().split()\n\tts = sys.stdin.readline().split()\n\n\taccts = []\n\tacct = 0\n\tfor t in ts:\n\t\tacct += t\n\t\taccts.append(acct)\n\n\tacctsrev = []\n\tacct = 0\n\tfor i in xrange(len(ts), 0, -1):\n\t\tacct += ts[i]\n\t\tacctsrev.insert(0, acct)\n\n\tlimak = 0\n\tfor i in xrange(0, n):\n\t\tlimak += max(0, ps[i]-c*accts[i])\n\n\trade = 0\n\tfor i in xrange(n, 0, -1):\n\t\trade += max(0, ps[i]-c*acctsrev[i])\n\n\n\tif limak > rade:\n\t\tprint 'limak'\n\telif limak < rade:\n\t\tprint 'rade'\n\telse:\n\t\tprint 'tie'\n\nif __name__ == '__main__':\n\tmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0171c34086ce5a0c1c044d9e0dacb2f4", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nn=list(map(int,input().split()))\nm=list(map(int,input().split()))\nl,y=[],[]\nx,d,w,o= 0,0,0,0\nfor z in m :\n\tx = x+z\n\tl.append(x)\nfor i in range(len(l)):\n\tq = q+max(0,n[i]-b*l[i])\nn=n[::-1]\nm=m[::-1]\nfor p in m :\n\tw=w+p\n\td.append(w)\nfor r in range(len(y)):\n\to = o+max(0,n[r]-b*y[r])\nif q>o:\n\tprint(\"Limak\")\nelif q == o:\n\tprint(\"Tie\")\nelse:\n\tprint(\"Radewoosh\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a41d5c9b5bd7df005bafd214e87a341", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import numpy as np\n#yy\nn,c=map(int,input().split())\np=list(map(int,input().split()))\nt=list(map(int,input().split()))\npf=[]\npr=[]\nx=0\nfor i in range(n):\n x+=t[i]\n pf.append(max(0, p[i]-x*c))\npf=np.array(pf)\nc1=sum(pf)\n\n\np.reverse()\nt.reverse()\nx=0\nfor i in range(n):\n x+=t[i]\n pr.append( max(0,p[i]-x*c))\n \npr =np.array(pr)\nc2=sum(pr)\n\nif(c1>c2):\n print('Limak')\nelif(c1==c2):\n print('Tie')\nelse:\n print('Radewoosh')\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea6764e292a60036189113278cd40e48", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\nimport random\nsys.setrecursionlimit(1000000)\ninput = sys.stdin.readline\n \n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\ndef inp():\n return(int(input()))\ndef inara():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n################################################################\n############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\n\nn,k=invr()\np=inara()\nt=inara()\n\na=0\na_t=0\n\nfor i in range(n):\n\ta_t+=t[i]\n\ta+=max(0,p[i]-a_t*k)\n\nb=0\nb_t=0\n\nfor i in range(n-1,-1,-1):\n\tb_t+=t[i]\n\tb+=max(0,p[i]-b_t*k)\n\nif a>b:\n\tprint(\"Limak\")\nelif b>a:\n\tprint(\"Radewoosh\")\nelse:\n\tprint(\"Tie\")\n\n\t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "473f45c5bbcd8c41cf415bbf136d62a3", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n,k,x=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nif(len(a)==1):\n\tprint \"0\"\n\nelse:\n\tans=0\n\tfor i in range(0,n-1):\n\t\ttemp=0\n\t\tif(a[i]==a[i+1]==x):\n\t#\t\tprint i,i+1\n\t\t\tl=i-1\n\t\t\tr=i+2\n\t\t\tcheck=-1\n\t\t\tcount=0\n\t\t#\ttemp=0\n\t\t\tif(l>=0 and r=0):\n\t\t\t\t\tif(a[l]==check):\n\t\t\t\t\t\tcount+=1\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t\t\t\tl-=1\n\t\t\t\twhile(r=3):\n\t\t\t\t\ttemp+=count\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t#\t\tprint temp\n\t\t\t\tif(l>=0 and r\n#include \n#define max(a,b) ((a) > (b) ? (a) : (b))\nusing namespace std;\nint main()\n{\n int nb,nc,nw;\n cin >> nb >> nc >> nw;\n vector v(nb);\n vector :: iterator p,q;\n int a=0;\n for(int i=0;i> v[i];\n }\n for(int i=0;i2)\n {\n int len = v.size();\n for(int j=2;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvector colors;\nint x;\n\n/*int norm(list& c) {\n int removed = 0;\n bool changed;\n do {\n changed = false;\n if (c.size() < 3)\n return removed;\n int run_len = 1;\n list::iterator last = c.begin();\n list::iterator it = next(c.begin());\n list::iterator begin_it = last;\n for (; it != c.end(); last = it, it++) {\n if (*it == *last) {\n run_len++;\n } else {\n if (run_len >= 3) {\n c.erase(begin_it, next(it));\n removed += run_len;\n changed = true;\n }\n run_len = 1;\n begin_it = it;\n }\n }\n\n if (run_len >= 3) {\n c.erase(begin_it, c.end());\n removed += run_len;\n changed = true;\n }\n } while (changed);\n return removed;\n}\n\nint maxdestroy_at(vector&c, int pos) {\n list tmp;\n for (int i = 0; i < c.size(); i++) {\n if (i == pos) {\n tmp.push_back(x);\n }\n tmp.push_back(c[i]);\n }\n return norm(tmp);\n}\n\nint maxdestroy(vector& c) {\n if (c.empty()) return 0;\n\n int m = (x == c[0]) ? maxdestroy_at(c, 0) : 0;\n for (int i = 1; i < c.size(); i++) {\n if (c[i] == x && c[i - 1] == c[i]) {\n m = max(m, maxdestroy_at(c, i));\n }\n }\n return m;\n}*/\n\nvoid compact_in_place(vector >& c) {\n // filter the zeroes\n vector > new_c;\n for (int i = 0; i < c.size(); i++) {\n if (c[i].second) new_c.push_back(c[i]);\n }\n c = new_c;\n\n bool cow = false;\n for (int i = 1; i < c.size(); i++) {\n if (c[i].first == c[i - 1].first) {\n c[i - 1].second += c[i].second;\n c[i].second = 0;\n cow = true;\n }\n }\n if (cow) {\n // filter the zeroes\n vector > new_c;\n for (int i = 0; i < c.size(); i++) {\n if (c[i].second) {\n new_c.push_back(c[i]);\n }\n }\n c = new_c;\n }\n}\n\nint combine(vector >& c) {\n compact_in_place(c);\n\n int destroyed = 0;\n for (int i = 1; i < c.size(); i++) {\n if (c[i].second >= 3) {\n destroyed += c[i].second;\n c[i].second = 0;\n }\n }\n if (destroyed) {\n return destroyed + combine(c);\n }\n return destroyed;\n}\n\nint maxdestroy(const vector >& c) {\n int md = 0;\n for (int i = 0; i < c.size(); i++) {\n if (c[i].first == x) {\n vector > aux = c;\n if (aux[i].second + 1 == 3) {\n aux[i].second++;\n int change = combine(aux) - 1;\n md = max(md, change);\n }\n }\n }\n return md;\n}\n\nint maxdestroy(const vector& c) {\n if (c.empty()) return 0;\n\n vector > compact;\n compact.push_back(make_pair(-1, 1));\n int color = c[0];\n int length = 1;\n for (int i = 1; i < c.size(); i++) {\n if (c[i] == color) {\n length++;\n } else {\n compact.push_back(make_pair(color, length));\n color = c[i];\n length = 1;\n }\n }\n compact.push_back(make_pair(color, length));\n\n return maxdestroy(compact);\n}\n\nint main() {\n int n, k;\n scanf(\"%d %d %d\", &n, &k, &x);\n\n for (int i = 0; i < n; i++) {\n int p;\n scanf(\"%d\", &p);\n colors.push_back(p);\n }\n printf(\"%d\\n\", maxdestroy(colors));\n return 0;\n}\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "213ceb1ca7459d0b092b3c0db363ab1a", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, k, x = map(int, input().split())\n\nballs = list(map(int, input().split()))\n\ndef conta_pares(balls1, num):\n pares = []\n for w in range(n-1):\n if balls1[w] == balls1[w+1] == num:\n pares.append(w)\n pares.append(w+1)\n return pares\n\n\n\nif n < 2:\n\tprint(0)\n\texit()\nlista_pares = conta_pares(balls, x)\n\nif lista_pares == []:\n\tprint(0)\n\texit()\n\npar = False\nmaximo = 2\n\nfor i in range(0, len(lista_pares)-1, 2):\n il, ir = lista_pares[i], lista_pares[i+1]\n pontos = 2\n while True:\n \n if il>0 and ir < n-1 and balls[il-1] == balls[ir+1]:\n if il-2 >= 0 and balls[il-2] == balls[il-1]:\n pontos += 3\n il -= 2\n if ir+2 < n and balls[ir+2] == balls[ir+1]:\n pontos += 1\n ir += 2\n else:\n ir += 1\n elif ir+2 < n and balls[ir+2] == balls[ir+1]:\n pontos += 3\n ir += 2\n il -= 1\n else:\n if pontos > maximo:\n maximo = pontos\n print(pontos)\n break\n else:\n if pontos > maximo:\n maximo = pontos\n break\n\nprint(maximo)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "21604508df7cc3a31a948c69afed0983", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n,k,x = map(int, raw_input().split())\nballs1 = map(int, raw_input().split())\nif n == 1:\n\tprint 0\n\t\nelse:\n\tcontiguous = [1]\n\tballs = [balls1[0]]\n\tfor i in xrange(n-1):\n\t\tif balls1[i] == balls1[i+1]:\n\t\t\tcontiguous[-1] += 1\n\t\t\n\t\telse:\n\t\t\tcontiguous.append(1)\n\t\t\tballs.append(balls1[i+1])\n\n\tremoves = []\n\tfor i in range(len(balls)):\n\t\tif balls[i] == x and contiguous[i] == x:\n\t\t\tremoves.append(contiguous[i])\n\t\t\tj = i-1\n\t\t\tk = i+1\n\t\t\twhile j >= 0 and k < len(contiguous) and contiguous[j] + contiguous[k] >= x:\n\t\t\t\tremoves[-1] += contiguous[j] + contiguous[k]\n\t\t\t\tj -= 1\n\t\t\t\tk += 1\n\t\t\t\n\tprint max(removes)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5bedddf8ae49c8bc994afa2aba60135", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\np = 0\nfor a in range(1,810):\n for b in range(1,(8101-10*a)):\n c = n - a*1234567-b*123456\n if c>0 \n if c % 1234 == 0:\n p = 1\n break\n\nif p == 1:\n print(\"YES\")\nelif p == 0:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ffa9defa17fd707a6b9af7930dd2ae58", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\np = 0\nfor a in range(1,810):\n for b in range(1,(8101-10*a)):\n c = n - a*1234567-b*123456\n if c>0 c % 1234 == 0:\n p = 1\n break\n\nif p == 1:\n print(\"YES\")\nelif p == 0:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f13928120da25b00b4df2152996c55bb", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n = int(input())(\nfor a in range(9000):\n for b in range(9000):\n rem = n - 1234567*a - 123456 * b\n if (rem%1234 == 0 and rem//1234 >= 0):\n print(\"YES\")\n quit()\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5a25063c6a67d875c00b6a0f5c8c95c", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from sys import *\nn=int(input())\nfor i in range(n//1234567+1):\n for j in range(n//123456+1):\n t=i*1234567+j*123456\n if n-t>0 and (n-t)%1234==0: print('YES'); exit()\nprint('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "853685cd2368f592f4ccaca122c8a433", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nx = 1234567\ny = 123456\nz = 1234\n\nif n < z:\n print(\"NO\")\nelse:\n a = 0\n while (a * x) <= n:\n b = 0\n while (b * y) + (a * x) <= n:\n if ((n - (b * y + a * x)) % z) == 0:\n print(\"YES\")\n exit()\n b += 1\n a += 1\n\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "babb382f26d496273ac45551c3cd5268", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "k = int(input())\n\na = []\nsum = []\nfor i in range(1, 10):\n a.append(i)\n sum.append(i)\nans = -1\nwhile ans = -1:\n A = []\n S = []\n for i in range(len(a)):\n for j in range(10):\n if sum[i] + j <= 10:\n A.append(a[i] * 10 + j)\n S.append(sum[i] + j)\n a = A\n sum = S\n for i in range(len(a)):\n if sum[i] == 10:\n k -= 1\n if k == 0:\n ans = a[i]\n break\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c8c86f3f92db103daadbf266924197c", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "t = int(input())\n\ndef main(beg, end, st):\n\t\tfor x in range(beg, end, 9):\n\t\t\tr = 0\n\t\t\tn = x\n\t\t\twhile n:\n\t\t\t\tr, n = r + n % 10, n // 10\n\t\t\t\tif (r >= 10 and n != 0) or (r < 10 and n == 0):\n\t\t\t\t\tbreak\n\t\t\t\telif r == 10 and n == 0:\n\t\t\t\t\tst = st + 1\n\t\t\tif st == t:\t\t\n\t\t\t\tprint(x)\n\t\t\t\tbreak\n\nif t <= 869:\n\tmain(19, 45100, 0, )\n\tbreak\nif t <= 994:\n\tmain(45100, 90100, 869, )\n\tbreak\nif t <= 1583:\n\tmain(90100, 135100, 994, )\n\tbreak\nif t <= 1708:\n\tmain(135100, 180100, 1583, )\n\tbreak\nif t <= 2078:\n\tmain(180100, 225100, 1708, )\n\tbreak\nif t <= 2203:\n\tmain(225100, 270100, 2078, )\n\tbreak\nif t <= 2408:\n\tmain(270100, 315100, 2203, )\n\tbreak\nif t <= 2533:\n\tmain(315100, 360100, 2408, )\n\tbreak\nif t <= 2618:\n\tmain(360100, 405100, 2533, )\n\tbreak\nif t <= 2743:\n\tmain(405100, 450100, 2618, )\n\tbreak\nif t <= 2746:\n\tmain(450100, 500005, 2743, )\n\tbreak\nif t <= 2869:\n\tmain(500005, 540100, 2746, )\n\tbreak\nif t <= 2872:\n\tmain(540100, 600004, 2869, )\n\tbreak\nif t <= 2939:\n\tmain(600004, 630100, 2872, )\n\tbreak\nif t <= 2942:\n\tmain(630100, 700003, 2939, )\n\tbreak\nif t <= 2974:\n\tmain(700003, 720100, 2942, )\n\tbreak\nif t <= 2977:\n\tmain(720100, 800002, 2974, )\n\tbreak\nif t <= 2989:\n\tmain(800002, 810100, 2977, )\n\tbreak\nif t <= 2992:\n\tmain(810100, 900001, 2989, )\n\tbreak\nif t <= 2994:\n\tmain(900001, 900100, 2992, )\n\tbreak\nif t <= 2997:\n\tmain(900100, 1000009, 2994, )\n\tbreak\nif t <= 3584:\n\tmain(1000009, 1035100, 2997, )\n\tbreak\nif t <= 3709:\n\tmain(1035100, 1080100, 3584, )\n\tbreak\nif t <= 4079:\n\tmain(1080100, 1125100, 3709, )\n\tbreak\nif t <= 4204:\n\tmain(1125100, 1170100, 4079, )\n\tbreak\nif t <= 4409:\n\tmain(1170100, 1215100, 4204, )\n\tbreak\nif t <= 4534:\n\tmain(1215100, 1260100, 4409, )\n\tbreak\nif t <= 4619:\n\tmain(1260100, 1305100, 4534, )\n\tbreak\nif t <= 4744:\n\tmain(1305100, 1350100, 4619, )\n\tbreak\nif t <= 4747:\n\tmain(1350100, 1400005, 4744, )\n\tbreak\nif t <= 4870:\n\tmain(1400005, 1440100, 4747, )\n\tbreak\nif t <= 4873:\n\tmain(1440100, 1500004, 4870, )\n\tbreak\nif t <= 4940:\n\tmain(1500004, 1530100, 4873, )\n\tbreak\nif t <= 4943:\n\tmain(1530100, 1600003, 4940, )\n\tbreak\nif t <= 4975:\n\tmain(1600003, 1620100, 4943, )\n\tbreak\nif t <= 4978:\n\tmain(1620100, 1700002, 4975, )\n\tbreak\nif t <= 4990:\n\tmain(1700002, 1710100, 4978, )\n\tbreak\nif t <= 4993:\n\tmain(1710100, 1800001, 4990, )\n\tbreak\nif t <= 4995:\n\tmain(1800001, 1800100, 4993, )\n\tbreak\nif t <= 4998:\n\tmain(1800100, 1900000, 4995, )\n\tbreak\nif t <= 4999:\n\tmain(1900000, 2000008, 4998, )\n\tbreak\nif t <= 5366:\n\tmain(2000008, 2025100, 4999, )\n\tbreak\nif t <= 5491:\n\tmain(2025100, 2070100, 5366, )\n\tbreak\nif t <= 5696:\n\tmain(2070100, 2115100, 5491, )\n\tbreak\nif t <= 5821:\n\tmain(2115100, 2160100, 5696, )\n\tbreak\nif t <= 5906:\n\tmain(2160100, 2205100, 5821, )\n\tbreak\nif t <= 6031:\n\tmain(2205100, 2250100, 5906, )\n\tbreak\nif t <= 6034:\n\tmain(2250100, 2300005, 6031, )\n\tbreak\nif t <= 6157:\n\tmain(2300005, 2340100, 6034, )\n\tbreak\nif t <= 6160:\n\tmain(2340100, 2400004, 6157, )\n\tbreak\nif t <= 6227:\n\tmain(2400004, 2430100, 6160, )\n\tbreak\nif t <= 6230:\n\tmain(2430100, 2500003, 6227, )\n\tbreak\nif t <= 6262:\n\tmain(2500003, 2520100, 6230, )\n\tbreak\nif t <= 6265:\n\tmain(2520100, 2600002, 6262, )\n\tbreak\nif t <= 6277:\n\tmain(2600002, 2610100, 6265, )\n\tbreak\nif t <= 6280:\n\tmain(2610100, 2700001, 6277, )\n\tbreak\nif t <= 6282:\n\tmain(2700001, 2700100, 6280, )\n\tbreak\nif t <= 6285:\n\tmain(2700100, 2800000, 6282, )\n\tbreak\nif t <= 6286:\n\tmain(2800000, 3000007, 6285, )\n\tbreak\nif t <= 6488:\n\tmain(3000007, 3015100, 6286, )\n\tbreak\nif t <= 6613:\n\tmain(3015100, 3060100, 6488, )\n\tbreak\nif t <= 6698:\n\tmain(3060100, 3105100, 6613, )\n\tbreak\nif t <= 6823:\n\tmain(3105100, 3150100, 6698, )\n\tbreak\nif t <= 6826:\n\tmain(3150100, 3200005, 6823, )\n\tbreak\nif t <= 6949:\n\tmain(3200005, 3240100, 6826, )\n\tbreak\nif t <= 6952:\n\tmain(3240100, 3300004, 6949, )\n\tbreak\nif t <= 7019:\n\tmain(3300004, 3330100, 6952, )\n\tbreak\nif t <= 7022:\n\tmain(3330100, 3400003, 7019, )\n\tbreak\nif t <= 7054:\n\tmain(3400003, 3420100, 7022, )\n\tbreak\nif t <= 7057:\n\tmain(3420100, 3500002, 7054, )\n\tbreak\nif t <= 7069:\n\tmain(3500002, 3510100, 7057, )\n\tbreak\nif t <= 7072:\n\tmain(3510100, 3600001, 7069, )\n\tbreak\nif t <= 7074:\n\tmain(3600001, 3600100, 7072, )\n\tbreak\nif t <= 7077:\n\tmain(3600100, 3700000, 7074, )\n\tbreak\nif t <= 7078:\n\tmain(3700000, 4000006, 7077, )\n\tbreak\nif t <= 7160:\n\tmain(4000006, 4005100, 7078, )\n\tbreak\nif t <= 7285:\n\tmain(4005100, 4050100, 7160, )\n\tbreak\nif t <= 7288:\n\tmain(4050100, 4100005, 7285, )\n\tbreak\nif t <= 7411:\n\tmain(4100005, 4140100, 7288, )\n\tbreak\nif t <= 7414:\n\tmain(4140100, 4200004, 7411, )\n\tbreak\nif t <= 7481:\n\tmain(4200004, 4230100, 7414, )\n\tbreak\nif t <= 7484:\n\tmain(4230100, 4300003, 7481, )\n\tbreak\nif t <= 7516:\n\tmain(4300003, 4320100, 7484, )\n\tbreak\nif t <= 7519:\n\tmain(4320100, 4400002, 7516, )\n\tbreak\nif t <= 7531:\n\tmain(4400002, 4410100, 7519, )\n\tbreak\nif t <= 7534:\n\tmain(4410100, 4500001, 7531, )\n\tbreak\nif t <= 7536:\n\tmain(4500001, 4500100, 7534, )\n\tbreak\nif t <= 7539:\n\tmain(4500100, 4600000, 7536, )\n\tbreak\nif t <= 7540:\n\tmain(4600000, 5000005, 7539, )\n\tbreak\nif t <= 7663:\n\tmain(5000005, 5040100, 7540, )\n\tbreak\nif t <= 7666:\n\tmain(5040100, 5100004, 7663, )\n\tbreak\nif t <= 7733:\n\tmain(5100004, 5130100, 7666, )\n\tbreak\nif t <= 7736:\n\tmain(5130100, 5200003, 7733, )\n\tbreak\nif t <= 7768:\n\tmain(5200003, 5220100, 7736, )\n\tbreak\nif t <= 7771:\n\tmain(5220100, 5300002, 7768, )\n\tbreak\nif t <= 7783:\n\tmain(5300002, 5310100, 7771, )\n\tbreak\nif t <= 7786:\n\tmain(5310100, 5400001, 7783, )\n\tbreak\nif t <= 7788:\n\tmain(5400001, 5400100, 7786, )\n\tbreak\nif t <= 7791:\n\tmain(5400100, 5500000, 7788, )\n\tbreak\nif t <= 7792:\n\tmain(5500000, 6000004, 7791, )\n\tbreak\nif t <= 7859:\n\tmain(6000004, 6030100, 7792, )\n\tbreak\nif t <= 7862:\n\tmain(6030100, 6100003, 7859, )\n\tbreak\nif t <= 7894:\n\tmain(6100003, 6120100, 7862, )\n\tbreak\nif t <= 7897:\n\tmain(6120100, 6200002, 7894, )\n\tbreak\nif t <= 7909:\n\tmain(6200002, 6210100, 7897, )\n\tbreak\nif t <= 7912:\n\tmain(6210100, 6300001, 7909, )\n\tbreak\nif t <= 7914:\n\tmain(6300001, 6300100, 7912, )\n\tbreak\nif t <= 7917:\n\tmain(6300100, 6400000, 7914, )\n\tbreak\nif t <= 7918:\n\tmain(6400000, 7000003, 7917, )\n\tbreak\nif t <= 7950:\n\tmain(7000003, 7020100, 7918, )\n\tbreak\nif t <= 7953:\n\tmain(7020100, 7100002, 7950, )\n\tbreak\nif t <= 7965:\n\tmain(7100002, 7110100, 7953, )\n\tbreak\nif t <= 7968:\n\tmain(7110100, 7200001, 7965, )\n\tbreak\nif t <= 7970:\n\tmain(7200001, 7200100, 7968, )\n\tbreak\nif t <= 7973:\n\tmain(7200100, 7300000, 7970, )\n\tbreak\nif t <= 7974:\n\tmain(7300000, 8000002, 7973, )\n\tbreak\nif t <= 7986:\n\tmain(8000002, 8010100, 7974, )\n\tbreak\nif t <= 7989:\n\tmain(8010100, 8100001, 7986, )\n\tbreak\nif t <= 7991:\n\tmain(8100001, 8100100, 7989, )\n\tbreak\nif t <= 7994:\n\tmain(8100100, 8200000, 7991, )\n\tbreak\nif t <= 7995:\n\tmain(8200000, 9000001, 7994, )\n\tbreak\nif t <= 7997:\n\tmain(9000001, 9000100, 7995, )\n\tbreak\nif t <= 8000:\n\tmain(9000100, 9100000, 7997, )\n\tbreak\nif t <= 8001:\n\tmain(9100000, 10000009, 8000, )\n\tbreak\nif t <= 8588:\n\tmain(10000009, 10035100, 8001, )\n\tbreak\nif t <= 8713:\n\tmain(10035100, 10080100, 8588, )\n\tbreak\nif t <= 9083:\n\tmain(10080100, 10125100, 8713, )\n\tbreak\nif t <= 9208:\n\tmain(10125100, 10170100, 9083, )\n\tbreak\nif t <= 9413:\n\tmain(10170100, 10215100, 9208, )\n\tbreak\nif t <= 9538:\n\tmain(10215100, 10260100, 9413, )\n\tbreak\nif t <= 9623:\n\tmain(10260100, 10305100, 9538, )\n\tbreak\nif t <= 9748:\n\tmain(10305100, 10350100, 9623, )\n\tbreak\nif t <= 9751:\n\tmain(10350100, 10400005, 9748, )\n\tbreak\nif t <= 9874:\n\tmain(10400005, 10440100, 9751, )\n\tbreak\nif t <= 9877:\n\tmain(10440100, 10500004, 9874, )\n\tbreak\nif t <= 9944:\n\tmain(10500004, 10530100, 9877, )\n\tbreak\nif t <= 9947:\n\tmain(10530100, 10600003, 9944, )\n\tbreak\nif t <= 9979:\n\tmain(10600003, 10620100, 9947, )\n\tbreak\nif t <= 9982:\n\tmain(10620100, 10700002, 9979, )\n\tbreak\nif t <= 9994:\n\tmain(10700002, 10710100, 9982, )\n\tbreak\nif t <= 9997:\n\tmain(10710100, 10800001, 9994, )\n\tbreak\nif t <= 9999:\n\tmain(10800001, 10801000, 9997, )\n\tbreak\nif t <= 10001:\n\tmain(10801000, 10800991, 9999, )\n\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3046e18e19276d8039729056c2594b29", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "k = int(input())\n\na = []\nsum = []\nfor i in range(1, 10):\n a.append(i)\n sum.append(i)\nans = -1\nwhile ans = -1:\n A = []\n S = []\n for i in range(len(a)):\n for j in range(10):\n if sum[i] + j <= 10:\n A.append(a[i] * 10 + j)\n S.append(sum[i] + j)\n a = A\n sum = S\n for i in range(len(a)):\n if sum[i] == 10:\n k -= 1\n if k == 0:\n ans = i\n break\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2926b29bd4aba8b2af62cdcdb3fae53", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\nint sum(int x) {\n int res = 0;\n while (x > 0) {\n res += x%10;\n x/=10;\n }\n return res;\n}\n\nint main() {\n int k;\n cin >> k;\n int i = 0, idx = 0;\n while (idx < k) {\n i++;\n if (sum(i) == 10)\n idx++;\n }\n cout << i;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a58184c43f71139b6738a301882ac2f1", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "\n n=int(input())\nz=19\n \nwhile n>1:\n\tz=z+9\n\ta = sum(map(int,str(z)))\n\t\n\tif a == 10:\n\t\tn=n-1\n\t\t\nprint (z)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4955fb00369140c0873a2d0a195fc5e3", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "charnum=int(input())\nchar=str(input())\n#if (len(char)==charnum):\n\tif (len(set(char))!=len(char)):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\t\n#else:\n\tprint(\"ERROR\")\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a8dc13437ff6f7522a136dd095964bd4", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "Python 3", "source_code": "input()\nx = input().split(' ')\nif len(x) = len(set(x)):\n print( 'Yes')\nelse:\n print('No')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6cb6512f8c4a39b5f756aeeb833f67f", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "Python 3", "source_code": "b = int(input())\na = input()\nn = 0\nif(b = len(a)):\n\twhile(n1):\n\t\t\tx=0\n\t\t\tbreak\n\t\telse:\n\t\t\tx=1\n\t\tn = n+1\n\nif(x==1):\n\tprint('No')\nelse:\n\tprint('Yes')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c28df0d483cd5c690af4914ad7b9f2f1", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nst=input()\nflag=0\nfor i in range(n):\n if st.find(st[i],i+1)!=-1:\n flag=1\n break\nif flag==1 or n=1:\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c4f52647e76f0490ab0f19831e296b25", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "Python 3", "source_code": "from collections import Counter\nlens = int(input())\ns = input()\nsc = Counter(s)\nans = \"No\"\nif len(set(s)) == 1:\n ans = \"Yes\"\nelse:\n for i in sc:\n if sc[i] >=2:\n ans = \"Yes\"\n break\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3965b8d325bb399a4c4386ec9ec45920", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "PyPy 3-64", "source_code": "n, m = map(int, input().split())\r\nans = n - 1 if m == 1 else (m - 1) * \r\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "177cf8da54bac35a99e2d767c10a549b", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m=[int(x) for x in input().split()]\r\nif(not m==1):\r\n print(n*(m-1))\r\nelse\r\n print(n-1)\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac56c9f4c2fe99f97ac039f1b6957dd8", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a, b = map(int, input().split()\r\nif a == 1\r\n print(b-1)\r\nelse\r\n print((a-1)*b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "00ff5aa69f263fa59406528541a689cf", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a, b = map(int, input().split())\r\nif a == 1\r\n print(b-1)\r\nelse\r\n print((a-1)*b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3a93581b21ca54b51eaa7f03ed1660bd", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "Python 3", "source_code": "for _ in range(int(input))\r\n n,m=map(int,input().split()\r\n print((m-1)*n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8f5cb845cb71e8b4230621a1e028757", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\n\nif n%4==0:\n\treturn 8\nelif n%4==1:\n\treturn 4\nelif n%4==2:\n\treturn 2:\nelse:\n\treturn 6", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1e2156f81dea7e55ee6be0ce12f728a", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "m = 1378 ** int(input())\nprint str(m)[-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c524f4d8eab5040505d14db8fc7013fa", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "n = int(raw_input())\nreturn pow(1378, n, 10)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ec89527ced09564c327dcfcc035c29a", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nm=n%4\n\nif m==1:\n\tprint(8)\nelif m==2:\n\tprint(4)\nelif m==3:\n\tprint(2)\nelif m==0 && n!=0:\n\tprint(6)\nelif n==0:\n\tprint(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e000b6f2d8db3d5019fb1f764c578a74", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "%%timeit\nn = int(raw_input())\nb = 1\ndef get2(n):\n lis = []\n while(n>0):\n s=1\n i=0\n while(s*2<=n):\n s*=2\n i+=1\n lis.append(i)\n n-=s\n return lis\nli = get2(n)\nd = 1\nfor i in li:\n t = 8\n for j in xrange(i):\n t = (t*t)%10\n d = (d*t)%10\nprint d", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba0560cdb9b02deb38b26567f779a54d", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ncount=0\nwhile (n<5):\n count=1\n break\n if (n%5==0):\n count=n//5\n else:\n count=(n//5)+1\n print(\"count\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "842cf1e7938de9680ed55325eea13f3b", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nif a>5:\n if a%5==0:\n print(int(a/5)\n else:\n print(int(a//5+1)\nelse:\n print(1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ed871e5ebc7bb382ea0d7996b845016", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\n\nxs=input('')\nx=int(xs)\nxc=math.ceil(x)\nif xc<1:\n print('1')\nelse\n print(xc+1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e0b2f8f357885ef4202e45be16b0235", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nf=1\nif(n<=5):\n f=0\nelse:\n r=n//5\n e=n%5\n if(e<=4):\n c=1\nif f=0:\n print(1)\nelse:\n print(r+c)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6c31d19091a14cd8ebe40fda782c7ea", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "x=int(input())\ns=0\nfor i in range(1,x+1,5):\n s+=1\n return s+1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9b55d25c05a77abb474f05b6cf2736e1", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "print ('standard output)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ea685e088d59468422f18a266c4f20e", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Python 3", "source_code": "print \"No\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4db1f5032d78b960e50698e68c31e018", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Python 3", "source_code": "print(\"No\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b67a4949880cc6c9243d33e9223c98b7", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "PyPy 3", "source_code": "return 'yes'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3d61544847b4ce5206c28e0f2d4d2d78", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Python 3", "source_code": "\"\"\"\nAuthor: Nikhil Tripathi\nDate Created: 5th September,2018\nPart of project: OCI AUTOMATION\nDescription: The following python script automates the flow of Ecra installation in the oci environment along with\nadding the cabinet,composing the cluster,provisioning a service on the cluster,creating starter db followed by pod\ncreation inside the domU through rest api calls.\n\nThis script is meant to be run from the R1 bastion host and requires the following input from the user:\n\n *ecra_host ---------------------------------------------The ecra host in which the ecra installation needs to be done(ecra-host1 or ecra-host2)\n *dir_name ----------------------------------------------The root directory in which the ecra needs to be installed\n *ecra_name ---------------------------------------------The name of the installed ecra\n *cluster_name-------------------------------------------The cluster which needs to be provisioned\n *label_name---------------------------------------------The label corresponding to which the ecra needs to be installed\n\"\"\"\n\n\n\nimport sys\nimport os\nimport subprocess\nimport json\nimport time\nimport multiprocessing\n\nfrom subprocess import call\n\n\nclass OciAutomation:\n\n\n def __init__(self, ecra_host, dir_name, ecra_name, cluster_name, label_name):\n self.ecra_host = ecra_host\n self.dir_name = dir_name\n self.cluster_name = cluster_name\n self.ecra_name = ecra_name\n self.label_name = label_name\n OciAutomation.ecra_root = '/' + dir_name + '/oracle/ecra_installs/' + str(ecra_name) + '/'\n OciAutomation.exacloud_root = OciAutomation.ecra_root + 'mw_home/user_projects/domains/exacloud' + '/'\n\n #file_path must include the absolute path of the file\n def install_completed(file_path, pattern, host):\n result = 1\n while result != 0:\n COMMAND = \"\"\"\n grep \"\"\"+ pattern +' '+ file_path +\"\"\" \n \"\"\"\n\n detecting_pattern = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n detecting_pattern.wait()\n\n result = detecting_pattern.stdout.readlines()\n detecting_pattern.terminate()\n time.sleep(60)\n return result\n\n def killIfAlive( process):\n if process.is_alive():\n process.terminate()\n sys.exit(\"Script terminated due to failure in service creation or ecra installation...\")\n\n\n\n def parameter_calculation(self):\n #compute path to the flat file and the payload.json file from the cluster name\n OciAutomation.cluster_type = '220' if self.cluster_name.find('220') else ('214' if self.cluster_name.find('214') else '410')\n\n #since 410 would have 3 clusters,for provisioning the service cluster number would be required\n #for 220 and 214 always the second cluster(03-04) is provisioned\n if '01-02' in cluster_name:\n OciAutomation.cluster_number = 'c1'\n OciAutomation.compose_count = 1\n elif '03-04' in cluster_name:\n OciAutomation.cluster_number = 'c2'\n OciAutomation.compose_count = 2\n\n elif '05-06' in cluster_name:\n OciAutomation.cluster_number = 'c3'\n OciAutomation.compose_count = 3\n\n self.ecra_host = 'opc@10.0.1.3' if self.ecra_host is 1 else 'opc@10.0.1.5'\n\n\n def fetch_flatfile_payload_json_details(self):\n\n path_to_flat_file_directory = '/ecra_sw/important_files/cabinet_'+OciAutomation.cluster_type+'_files/'\n COMMAND =\"\"\"\n cd \"\"\"+path_to_flat_file_directory+\"\"\"\n ls | grep flatfile\n \n \"\"\"\n flat_file = subprocess.Popen([\"ssh\",\"-i\",\"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n flat_file.wait()\n OciAutomation.flat_file = path_to_flat_file_directory + str(flat_file.stdout.readlines())\n\n if not OciAutomation.flat_file:\n error = flat_file.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print OciAutomation.flat_file\n\n COMMAND = \"\"\"\n cd \"\"\" + path_to_flat_file_directory + \"\"\"\n ls | grep \"\"\"+OciAutomation.cluster_number+'_410.json'+\"\"\"\n \n \"\"\" if cluster_type is '410' \\\n else \"\"\"\n cd \"\"\" + path_to_flat_file_directory + \"\"\"\n ls | grep \"\"\"+'payload.json'+\"\"\"\n \n \"\"\"\n payload_json_file = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n payload_json_file.wait()\n OciAutomation.payload_json_file = payload_json_file.stdout.readlines()\n if not OciAutomation.payload_json_file:\n error = payload_json_file.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print OciAutomation.payload_json_file\n\n\n #The following method downloads the required tar files from the oss container,concats them and untars the merged file(ecra-full.tar)\n def download_tarfile( self, file_name):\n URL = 'https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/intdbaasecra/LargeFilesDisposableAfterUse/'\n oss_list = subprocess.Popen([\"curl\", \"-u\", \"ravindranath.chennoju@oracle.com:DdxA2#tz6IA:}V]xjE(W\",\n \"https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/intdbaasecra/LargeFilesDisposableAfterUse/\"],\n stdout=subprocess.PIPE).communicate()[0]\n oss_files = json.loads(oss_list)\n label_files = []\n for x in oss_files:\n if file_name in x['name']:\n label_files.append(x['name'])\n\n #Dowloading the files in the label_files list from the OSS container\n COMMAND = \"\"\"\n cd /\"\"\"+self.dir_name+\"\"\" \n \"\"\"\n\n for x in label_files:\n COMMAND+=\"\"\"\n curl -u ravindranath.chennoju@oracle.com:'DdxA2#tz6IA:}V]xjE(W' -X GET -O\"\"\"+URL+str(x)+\"\"\"\n \"\"\"\n\n download_tar_files = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n download_tar_files.wait()\n result = download_tar_files.stdout.readlines()\n if not result:\n error = download_tar_files.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n #concatenating the tar files present in the directory in a single ecra-full.tar and untar it\n COMMAND=\"\"\"\n cd /\"\"\"+ self.dir_name +\"\"\"\n cat *.tar > ecra-full.tar\n tar xvf ecra-full.tar\n \"\"\"\n concat_files = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n concat_files.wait()\n result = concat_files.stdout.readlines()\n if not result:\n error = concat_files.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n else:\n printresult\n\n print \"File untarred succesfully\"\n\n\n def edit_deployment_json_file(self):\n # we need to modify the deployment.json file for the oci env\n file_path = self.dir_name+'/oracle/ecra_installs/'+self.ecra_name+'/ecradpy/package/config/diagnostic/'\n\n COMMAND = \"\"\"\n cd /\"\"\" + file_path + \"\"\"\n jq -c '.deployment.dest =\"\"\" + dir_name + \"\"\"\"' test.json > tmp.$$.json && mv tmp.$$.json test.json\n \"\"\"\n edit_deployment_json = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n edit_deployment_json.wait()\n result = edit_deployment_json.stdout.readlines()\n if not result :\n error = edit_deployment_json.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n print \"deployment.json edited successfully!\"\n\n #ecra installation comes here\n def install_ecra(self):\n COMMAND = \"\"\"\n cd /\"\"\" + self.dir_name + \"\"\"/ecra-full/\n unzip ecradpy\n cd ecradpy\n ./ecradpy --env=bm \"\"\"+self.ecra_name+\"\"\"\n \"\"\"\n install_ecra = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n install_ecra.wait()\n result = install_ecra.stdout.readlines()\n if not result :\n error = install_ecra.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n def check_ecra_installation_logs(self):\n #checking ecra installation logs for successful completion\n COMMAND = \"\"\"\n ls /tmp/ecradpy/log -t | head -n1\n \"\"\"\n ecra_log_file_fetch = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n ecra_log_file_fetch.wait()\n result = ecra_log_file_fetch.stdout.readlines()\n if not result :\n error = ecra_log_file_fetch.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n log_file_path = '/tmp/ecradpy/' + str(result)\n\n p = multiprocessing.Process(target = install_completed, args= (log_file_path,'Ecra install completed'))\n p.start()\n #wait for ecra installation for 2 hrs(7200 seconds)\n p.join(7200)\n\n killIfAlive(p)\n print \"Ecra installation completed successfully!\"\n\n\n\n # adding a cabinet\n # the return value of this subprocess will be passed to the compose cluster command as the cell input\n def add_cabinet(self):\n # getting rack_name from the flatfile to know which series cluster do we have\n COMMAND = \"\"\"\n grep -q MODEL=X6-2 \"\"\"+ OciAutomation.flat_file +\"\"\" && echo $?\n \"\"\"\n getting_cluster_series = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n getting_cluster_series.wait()\n cluster_series = 'X6' if (getting_cluster_series.stdout.readlines() is 0) else 'X7'\n if not cluster_series:\n error = getting_cluster_series.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n COMMAND = \"\"\"\n echo EXADATA_CLOUD_EXACLOUD_REST_USER='admin'\n echo EXADATA_CLOUD_EXACLOUD_REST_PASSWORD='Welcome1!'\n cd \"\"\"+str(OciAutomation.exacloud_root)+'/vcn_cloud'+\"\"\"\n ./cabinets_n_clusters_util.py -i \"\"\" + str(OciAutomation.flat_file) + \"\"\" -c -s 3cell2comp2ibsw2pdu1ethsw -m \"\"\" + str(cluster_series) + \"\"\" -d \\ \n SEA2 --ecra_root \"\"\" + str(OciAutomation.ecra_root) + \"\"\" --exacloud_root \"\"\" + str(OciAutomation.exacloud_root) +\"\"\"\n \n \"\"\"\n adding_cabinet = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n adding_cabinet.wait()\n result = adding_cabinet.stdout.readlines()\n if not result:\n error = adding_cabinet.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n # composing a cluster\n def compose_cluster(self):\n while compose_count > 0:\n COMMAND = \"\"\"\n echo EXADATA_CLOUD_EXACLOUD_REST_USER='admin'\n echo EXADATA_CLOUD_EXACLOUD_REST_PASSWORD='Welcome1!'\n cd \"\"\"+exacloud_root+'/vcn_cloud'+\"\"\"\n ./cabinets_n_clusters_util.py -i \"\"\"+ str(OciAutomation.flat_file) +\"\"\" -c -s 3cell2comp2ibsw2pdu1ethsw -m \"\"\"+ str(cluster_series) +\\\n \"\"\" -d SEA2 --ecra_root \"\"\"+ str(OciAutomation.ecra_root) +\"\"\" --exacloud_root \"\"\"+str(OciAutomation.exacloud_root)+\"\"\"\n \n \"\"\"\n composing_cluster = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n composing_cluster.wait()\n result = composing_cluster.stdout.readlines()\n if not result:\n error = composing_cluster.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n compose_count-=1\n\n def create_service(self):\n # use the alias created before in the script,take alias name also as the script input\n # keeping the for cli as 'atpecli_new'\n COMMAND = \"\"\"\n alias atpecli_new=\"/\"\"\"+ self.dir_name +'/oracle/ecra_installs/'+ self.ecra_name +'/ecracli/ecracli -c ' \\\n '/'+ self.dir_name +'/oracle/ecra_installs/'+ self.ecra_name +\"\"\"/ecracli/ecracli.cfg\" >> ~/.bashrc \n \"\"\"\n setting_cli_alias = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n result = setting_cli_alias.stdout.readlines()\n if not result:\n error = setting_cli_alias.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n # creating service\n COMMAND = \"\"\"\n atpecli_new create_service env=gen2 gen2PayloadPath=\"\"\"+str(OciAutomation.flat_file)+'/'+str(OciAutomation.payload_json_file)+\"\"\"\n \"\"\"\n creating_service = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n creating_service.wait()\n result = creating_service.stdout.readlines()\n if not result:\n error = creating_service.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n def check_create_service_logs(self):\n\n #opening the thread log file for checking whether service creation completed successfully\n COMMAND = \"\"\"\n ls \"\"\"+OciAutomation.exacloud_root+'log/threads/'+\"\"\" -t *vmgi_install* | head -n1 \n \"\"\"\n create_service_logFile_fetch = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n create_service_logFile_fetch.wait()\n log_file = create_service_logFile_fetch.stdout.readlines()\n if not result:\n error = create_service_logFile_fetch.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n\n log_file_path = exacloud_root + '/log/threads/' + log_file\n p = multiprocessing.Process(target = install_completed, args= (log_file_path,'Create Service completed'))\n p.start()\n\n #wait for service creation process for 2 hrs(7200 seconds)\n p.join(7200)\n\n killIfAlive(p)\n\n print \"Create service completed successfully!\"\n\n def create_starter_db(self):\n\n #create the starter db,pass the cluster_name as input\n COMMAND = \"\"\"\n sudo su oracle\n atpecli_new create_starter \"\"\"+self.cluster_name+\"\"\" dbVersion=19.0.0.0\n \"\"\"\n creating_starter_db = subprocess.Popen([\"ssh\", \"-i\", \"./dbaas_sshkey.priv\", \"%s\" % self.ecra_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n\n creating_starter_db.wait()\n result = creating_starter_db.stdout.readlines()\n if not result:\n error = creating_starter_db.stderr.readlines()\n print >> sys.stderr, \"ERROR: %s\" % error\n sys.exit()\n else:\n print result\n print \"Starter DB created successfully!\"\n\n #POD creation in DomU\n def pod_creation(self):\n pod_creation_host = \"opc@129.213.229.158\"\n COMMAND=\"\"\"\n curl -u ravindranath.chennoju@oracle.com:'DdxA2#tz6IA:}V]xjE(W' -X GET -O https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/intdbaasecra/LargeFilesDisposableAfterUse/swagger-java-client.zip\n unzip swagger-java-client.zip\n cd swagger-java-client/src/test/java/\n export HOST_IP='http://10.0.20.177:7070'\n \"\"\"\n #Creating 3 pods\n for i in range(3):\n COMMAND += \"\"\"\n export POD_NAME='POD'\"\"\"+str(i+1)+\"\"\"\n javac -cp \"../../../target/lib/*:../../../target/*\" io/swagger/client/api/CreateDatabaseTestBasic.java\n java -cp \".:../../../target/lib/*:../../../target/*\" org.junit.runner.JUnitCore io.swagger.client.api.CreateDatabaseTestBasic\n \"\"\"\n\n creating_pods = subprocess.Popen([\"ssh\",\"-i\",\"./dbaas_sshkey.priv\", \"%s\" % pod_creation_host, COMMAND],\n shell=False,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE)\n result = creating_pods.stdout.readlines()\n if not result:\n error = creating_pods.stderr.readlines()\n print >>sys.stderr, \"ERROR: %s\" % error\n else:\n print result\n\n\n def run(self):\n\n parameter_calculation()\n fetch_flatfile_payload_json_details()\n download_tarfile()\n install_ecra()\n check_ecra_installation_logs()\n add_cabinet()\n compose_cluster()\n create_service()\n check_create_service_logs()\n create_starter_db()\n pod_creation()\n\nif __name__ == '__main__':\n OciAutomation obj1\n run()\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82ff0d6182946a7ae14f3f6c863fb914", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Python 3", "source_code": "def main():\n from sys import stdin, stdout\n dayNum={\"saturday\" : 0, \"sunday\" : 1, \"monday\" : 2, \"tuesday\" : 3, \"wednesday\" : 4, \"thursday\" : 5, \"friday\" : 6}\n day1, day2=tuple(stdin.read().split())\n day1=dayNum[day1]\n day2=dayNum[day2]\n stdout.write(\"YES\\n\" if (day1+28)%7==day2 or or (day1+30)%7 == day2 or (day1+31)%7 == day2 else \"NO\\n\")\n \nif __name__=='__main__':\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "189aa8c803394e847f37e48f10277046", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\ufeffa=input()\nb=input()\n\nif a=='monday':\n\tif b=='monday' or b=='wednesday' or b=='thursday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='tuesday':\n\tif b=='tuesday' or b=='thursday' or b=='friday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='wednesday':\n\tif b=='wednesday' or b=='friday' or b=='saturday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='thursday':\n\tif b=='thursday' or b=='saturday' or b=='sunday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='friday':\n\tif b=='friday' or b=='sunday' or b=='monday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='saturday':\n\tif b=='saturday' or b=='monday' or b=='tuesday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='sunday':\n\tif b=='sunday' or b=='tuesday' or b=='wednesday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ccbd0e1391a7c41370b1ca54b9b4f14e", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\ufeffd1=input()\nd2=input()\n\n\n\nif d1=='monday':\n if d2=='monday' or d2=='wednesday' or d2=='thursday':\n print('YES')\n else:\n print('NO')\nif d1=='tuesday':\n if d2=='tuesday' or d2=='thursday' or d2=='friday':\n print('YES')\n else:\n print('NO')\nif d1=='wednesday':\n if d2=='wednesday' or d2=='friday' or d2=='saturday':\n print('YES')\n else:\n print('NO')\nif d1=='thursday':\n if d2=='thursday' or d2=='saturday' or d2=='sunday':\n print('YES')\n else:\n print('NO')\nif d1=='friday':\n if d2=='friday' or d2=='sunday' or d2=='monday':\n print('YES')\n else:\n print('NO')\nif d1=='saturday':\n if d2=='saturday' or d2=='monday' or d2=='tuesday':\n print('YES')\n else:\n print('NO')\nif d1=='sunday':\n if d2=='sunday' or d2=='tuesday' or d2=='wednesday':\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "687f7eec73b40fdaeaae72c39b52879d", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\ufeffd1=input()\nd2=input()\n\nif d1=='monday':\n if d2=='monday' or d2=='wednesday' or d2=='thursday':\n print('YES')\n else:\n print('NO')\nif d1=='tuesday':\n if d2=='tuesday' or d2=='thursday' or d2=='friday':\n print('YES')\n else:\n print('NO')\nif d1=='wednesday':\n if d2=='wednesday' or d2=='friday' or d2=='saturday':\n print('YES')\n else:\n print('NO')\nif d1=='thursday':\n if d2=='thursday' or d2=='saturday' or d2=='sunday':\n print('YES')\n else:\n print('NO')\nif d1=='friday':\n if d2=='friday' or d2=='sunday' or d2=='monday':\n print('YES')\n else:\n print('NO')\nif d1=='saturday':\n if d2=='saturday' or d2=='monday' or d2=='tuesday':\n print('YES')\n else:\n print('NO')\nif d1=='sunday':\n if d2=='sunday' or d2=='tuesday' or d2=='wednesday':\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4f4903d9f4686fbe8e43f928c74fdd4", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\ufeff\na=input()\nb=input()\n\nif a=='monday':\n\tif b=='monday' or b=='wednesday' or b=='thursday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='tuesday':\n\tif b=='tuesday' or b=='thursday' or b=='friday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='wednesday':\n\tif b=='wednesday' or b=='friday' or b=='saturday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='thursday':\n\tif b=='thursday' or b=='saturday' or b=='sunday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='friday':\n\tif b=='friday' or b=='sunday' or b=='monday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='saturday':\n\tif b=='saturday' or b=='monday' or b=='tuesday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nif a=='sunday':\n\tif b=='sunday' or b=='tuesday' or b=='wednesday':\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ac7edb633f96f9e0f45ca7ed20538c8", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "a=[]\nfor i in range(3):\n a.append(list(input()));\nif (a[0][0]==a[2][2]) and (a[0][1]==a[2][1]) and (a[0][2]==a[2][]) and (a[1][2]==a[1][0]):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cd78c501a3b17dfa9c3630cbba517b6b", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=raw_input()+raw_input()+raw_input()\nfor i in range(5):\nif s[i] != s[8 - i]:\nprint 'NO'\nexit()\nprint 'YES'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b67d791a764d28327fc8f9445d10ce00", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a,b,c=input(),input(),input()\nif(b==b[::-1] and c=a[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0977ed004aa3750079ae9e74c805d682", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "var\n a1,a2,a3,a4,a5,a6,a7,a8,a9:char; //\u795e\u5947\u7684\u5b9a\u4e49\nbegin\n readln(a1,a2,a3);//\u795e\u5947\u7684\u8bfb\u5165\n readln(a4,a5,a6);\n readln(a7,a8,a9);\n if (a1=a9) and (a2=a8) and (a3=a7) and (a4=a6) //\u795e\u5947\u7684\u5224\u65ad\n then writeln('YES') else writeln('NO'); //\u5e76\u4e0d\u795e\u5947\u7684\u8f93\u51fa\nend.", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06199ed99b8dd75c11367e1a61c4e1cb", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nint main()\n{\n char a[9];\n for(int i=0;i<9;i++)\n cin>>a[i];\n if(a[0]==a[8]&&a[1]==a[7]&&a[2]==a[6]&&a[3]==a[5])\n cout<<\"YES\";\n else\n cout<<\"NO\";\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "83bc252b71c91470ebbe9ede23fcbbbf", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "input()\ns=input()\ns+=[s-1]\ni=1\nwhile i 1:\n temp = seq[i] + seq[i+1]\n if temp in [\"RU\", \"UR\"]:\n new_seq += \"D\"\n seq = seq[2::]\n else:\n new_seq += seq[i]\n seq = seq[1::]\n\nif n % 2 != 0:\n new_seq += seq[-1]\n\nprint len(new_seq)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "369c02a7bf4acb6be8bcd104d4d7b8b5", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\nn = int(input())\nif n == 1:\n\tprint(1)\n\texit()\nl = list(input())\nwhile True:\n\n\tfor i in range(len(l)-1):\n\t\tif l[i] == 'U' and l[i + 1] == 'R' or l[i] == 'R' and l[i + 1] == 'U':\n\t\t\tl[i] = 'D'\n\t\t\tl.pop(i+1)\n\t\t\tbreak\n\n\t\tif i == len(l) - 2:\n\t\t\tprint(len(l))\n\t\t\texit()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d4fbdd51239feecf806d4f3d02b64df1", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\nn = int(input())\nl = list(input())\nwhile True:\n\n\tfor i in range(len(l)-1):\n\t\tif l[i] == 'U' and l[i + 1] == 'R' or l[i] == 'R' and l[i + 1] == 'U':\n\t\t\tl[i] = 'D'\n\t\t\tl.pop(i+1)\n\t\t\tbreak\n\n\t\tif i == len(l) - 2:\n\t\t\tprint(len(l))\n\t\t\texit()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3076d1022ef7c0b9fb507591f0f64b51", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nn = input()\ncad = input()\n\nnu = cad.replace('RU', 'D', cad.count('RU'))\nnu = nu.replace('UR', 'D', nu.count('UR'))\n\nif(str(len(nu)) == 69):\n\tprint (str(len(nu) - 2)\nelse:\n\tprint (str(len(nu))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e168b5de82e13d9b54ec03463a245a19", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nif c-a-b<0:\n\tprint('NO')\nelif:\n\t(c-a-b)%2==1:\n\tprint('NO')\nelse:\n\tprint('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f7d2cd6960156f4adbc2d983ee80ce0", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b, s = map(int, input().split())\nif((abs(s)-abs(a)-abs(b))>=0):\n if((abs(s-a-b)%2==0):\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dbd56c876ba1c988e49a140ac806671e", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\nimport math \na,b,s=map(int,input().split())\nwhile a,b,s!=0:\n\tx=abs(a)+abs(b)\n\tif x==s and s != 1:\n\t\tprint(\"YES\")\n\telif x==s and s == 1:\n\t\tprint (\"NO\")\n\telif x>s:\n\t\tprint(\"NO\")\n\telif s-x==1:\n\t\tprint(\"NO\")\n\telse: print (\"YES\")\nreturn 0\n\n\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "84d57aa55604e9930bf7aee5e1834e29", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "raw_input = input().split()\n\na= int(raw_input[0])\nif (a < 0)\n a *= -1\n\nb= int(raw_input[1])\nif (b < 0)\n b *= -1\n\ns= int(raw_input[2])\nif ( a + b == s ):\n print (\"Yes\")\n \nelif ( a + b < s ) and ( (s - (a + b)) % 2 == 0 ):\n print (\"Yes\")\nelse:\n print (\"No\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fac2850237442294d2ffe36e731cee29", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "raw_input = input().split()\n\na= int(raw_input[0])\nif (a < 0):\n a *= -1\n\nb= int(raw_input[1])\nif (b < 0):\n b *= -1\n\ns= int(raw_input[2])\nif ( a + b == s ):\n print (\"Yes\")\n \nelif ( a + b < s ) and ((s - (a + b)) % 2) == 0 ):\n print (\"Yes\") \n \nelse:\n print (\"No\")\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae7d8a1a580ccc2437c95eb1650da578", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a = [0]*l\nb = [0]*l\n\nfor i in range(n):\n a[track1[i]] = 1\n b[track2[i]] = 1\nfor i in range(l):\n b.insert(0, b.pop())\n if b == a:\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d095d4f89340dfc77b76402aae7a6b6", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "l = list(map(int, raw_input().split()))\nn = l[0]\nL = l[1]\n\na = list(map(int, raw_input().split()))\nb = list(map(int, raw_input().split()))\n\nif a[0] == 0 and b[0]== 0:\n\tprint \"YES\"\nelse:\n\tlena = []\n\tlenb = []\n\n\ti = 1\n\twhile len(lena) != n:\n\t\tif i != n - 1:\n\t\t\tlena.append(a[i]-a[i-1])\n\t\t\ti = i + 1\n\t\telse:\n\t\t\tlena.append(a[i]-a[i-1])\n\t\t\tlena.append(L - a[i] + a[0])\n\ti = 1\n\twhile len(lenb) != n:\n\t\tif i != n - 1:\n\t\t\tlenb.append(b[i]-b[i-1])\n\t\t\ti = i + 1\n\t\telse:\n\t\t\tlenb.append(b[i]-b[i-1])\n\t\t\tlenb.append(L - b[i] + b[0])\n\n\tFlag = False\n\tfor i in range(n):\n\t\tk = lena[0]\n\t\tdel(lena[0])\n\t\tlena.append(k) \n\t\tif lena == lenb:\n\t\t\tFlag = True\n\tif Flag == False:\n\t\tprint \"NO\"\n\telse:\n\t\tprint \"YES\"\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84b408e1c2ede2bc45000ead421ed010", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "l = list(map(int, raw_input().split()))\nn = l[0]\nL = l[1]\n\na = list(map(int, raw_input().split()))\nb = list(map(int, raw_input().split()))\n\nlena = []\nlenb = []\n\ni = 1\nwhile len(lena) != n:\n\tif i != n - 1:\n\t\tlena.append(a[i]-a[i-1])\n\t\ti = i + 1\n\telse:\n\t\tlena.append(a[i]-a[i-1])\n\t\tlena.append(L - a[i] + a[0])\ni = 1\nwhile len(lenb) != n:\n\tif i != n - 1:\n\t\tlenb.append(b[i]-b[i-1])\n\t\ti = i + 1\n\telse:\n\t\tlenb.append(b[i]-b[i-1])\n\t\tlenb.append(L - b[i] + b[0])\n\nFlag = False\nfor i in range(n):\n\tk = lena[0]\n\tdel(l[0])\n\tlena.append(k) \n\tif lena == lenb:\n\t\tFlag = True\nif Flag == False:\n\tprint NO\nelse:\n\tprint YES\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "269c3f29f548e92ba45b92dc3f5c4c26", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "input1=(list(map(int,input().split()))) \nK=(list(map(int,input().split()))) \nS=(list(map(int,input().split()))) \nn=input1[0] \nl=input1[1] \nKlist=[] \nfor i in range(1,len(K)): \nKlist.append(K[i]-K[i-1]) \nmax=0 \nfor i in range(0,len(Klist)): \nmax+=Klist[i] \nKlist.append(l-max) \nSlist=[] \nfor i in range(1,len(S)): \nSlist.append(S[i]-S[i-1]) \nmax=0 \nfor i in range(0,len(Slist)): \nmax+=Slist[i] \nSlist.append(l-max) \ncount=0 \nT=False \nvar=0 \nwhile count2:\n print(a+b+2*c)\nelse:\n print(min(a,b)*2+1+2*c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "09c5d469b5c323140d1ffb4c3c7abd40", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = [int(x) for x in input().split(' ')]\nq, w, r = a[0], a[1], a[2]\nc = min(q, w)\nans = 2 *( r + c)\nIf q > c:\n ans += 1\nIf w > c:\n ans += 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8fca47d49e544f8b0c5b61b1f25dffc7", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "from __future__ import division\nnums = 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\nans = 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 abs(res-area)<=0.00001:\n ans = 1\n\nif ans:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e7e6f3e1858a47989aa52224cc08e560", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "(x11, y11, x12, y12, x13, y13, x14, y14) = map(int, input().split())\n\n(x21, y21, x22, y22, x23, y23, x24, y24) = map(int, input().split())\n\ndef xxx(x1, y1, x2, y2, x3, y3):\n return (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)\n\nflag = False\n\nif xxx(x11, y11, x12, y12, x21, y21) >= 0 and xxx(x12, y12, x13, y13, x21, y21) >= 0 and xxx(x13, y13, x14, y14, x21, y21) >= 0 and xxx(x14, y14, x11, y11, x21, y21) >= 0:\n flag = True\n\n\nif xxx(x11, y11, x12, y12, x22, y22) >= 0 and xxx(x12, y12, x13, y13, x22, y22) >= 0 and xxx(x13, y13, x14, y14, x22, y22) >= 0 and xxx(x14, y14, x11, y11, x22, y22) >= 0:\n flag = True\n \nif xxx(x11, y11, x12, y12, x23, y23) >= 0 and xxx(x12, y12, x13, y13, x23, y23) >= 0 and xxx(x13, y13, x14, y14, x23, y23) >= 0 and xxx(x14, y14, x11, y11, x23, y23) >= 0:\n flag = True\n\nif xxx(x11, y11, x12, y12, x24, y24) >= 0 and xxx(x12, y12, x13, y13, x24, y24) >= 0 and xxx(x13, y13, x14, y14, x24, y24) >= 0 and xxx(x14, y14, x11, y11, x24, y24) >= 0:\n flag = True\n\nx = x21 + (x23 - x21) / 2\ny = y21 + (y23 - y21) / 2\n\nif xxx(x11, y11, x12, y12, x, y) >= 0 and xxx(x12, y12, x13, y13, x, y) >= 0 and xxx(x13, y13, x14, y14, x, y) >= 0 and xxx(x14, y14, x11, y11, x, y) >= 0:\n flag = True\n\n\n\n \n\nif xxx(x21, y21, x22, y22, x11, y11) >= 0 and xxx(x22, y22, x23, y23, x11, y11) >= 0 and xxx(x23, y23, x24, y24, x11, y11) >= 0 and xxx(x24, y24, x21, y21, x11, y11) >= 0:\n flag = True\n\n\nif xxx(x21, y21, x22, y22, x12, y12) >= 0 and xxx(x22, y22, x23, y23, x12, y12) >= 0 and xxx(x23, y23, x24, y24, x12, y12) >= 0 and xxx(x24, y24, x21, y21, x12, y2) >= 0:\n flag = True\n \nif xxx(x21, y21, x22, y22, x13, y13) >= 0 and xxx(x22, y22, x23, y23, x13, y13) >= 0 and xxx(x23, y23, x24, y24, x13, y13) >= 0 and xxx(x24, y24, x21, y21, x13, y13) >= 0:\n flag = True\n\nif xxx(x21, y21, x22, y22, x14, y14) >= 0 and xxx(x22, y22, x23, y23, x14, y14) >= 0 and xxx(x23, y23, x24, y24, x14, y14) >= 0 and xxx(x24, y24, x21, y21, x14, y14) >= 0:\n flag = True\n\nx = x11 + (x13 - x11) / 2\ny = y11 + (y13 - y11) / 2\n\nif xxx(x21, y21, x22, y22, x, y) >= 0 and xxx(x22, y22, x23, y23, x, y) >= 0 and xxx(x23, y23, x24, y24, x, y) >= 0 and xxx(x24, y24, x21, y21, x, y) >= 0:\n flag = True\n\n\n\n\n\n\nif xxx(x11, y11, x12, y12, x21, y21) <= 0 and xxx(x12, y12, x13, y13, x21, y21) <= 0 and xxx(x13, y13, x14, y14, x21, y21) <= 0 and xxx(x14, y14, x11, y11, x21, y21) <= 0:\n flag = True\n\n\nif xxx(x11, y11, x12, y12, x22, y22) <= 0 and xxx(x12, y12, x13, y13, x22, y22) <= 0 and xxx(x13, y13, x14, y14, x22, y22) <= 0 and xxx(x14, y14, x11, y11, x22, y22) <= 0:\n flag = True\n \nif xxx(x11, y11, x12, y12, x23, y23) <= 0 and xxx(x12, y12, x13, y13, x23, y23) <= 0 and xxx(x13, y13, x14, y14, x23, y23) <= 0 and xxx(x14, y14, x11, y11, x23, y23) <= 0:\n flag = True\n\nif xxx(x11, y11, x12, y12, x24, y24) <= 0 and xxx(x12, y12, x13, y13, x24, y24) <= 0 and xxx(x13, y13, x14, y14, x24, y24) <= 0 and xxx(x14, y14, x11, y11, x24, y24) <= 0:\n flag = True\n\nx = x21 + (x23 - x21) / 2\ny = y21 + (y23 - y21) / 2\n\nif xxx(x11, y11, x12, y12, x, y) <= 0 and xxx(x12, y12, x13, y13, x, y) <= 0 and xxx(x13, y13, x14, y14, x, y) <= 0 and xxx(x14, y14, x11, y11, x, y) <= 0:\n flag = True\n\n\n\n \n\nif xxx(x21, y21, x22, y22, x11, y11) <= 0 and xxx(x22, y22, x23, y23, x11, y11) <= 0 and xxx(x23, y23, x24, y24, x11, y11) <= 0 and xxx(x24, y24, x21, y21, x11, y11) <= 0:\n flag = True\n\n\nif xxx(x21, y21, x22, y22, x12, y12) <= 0 and xxx(x22, y22, x23, y23, x12, y12) <= 0 and xxx(x23, y23, x24, y24, x12, y12) <= 0 and xxx(x24, y24, x21, y21, x12, y12) <= 0:\n flag = True\n \nif xxx(x21, y21, x22, y22, x13, y13) <= 0 and xxx(x22, y22, x23, y23, x13, y13) <= 0 and xxx(x23, y23, x24, y24, x13, y13) <= 0 and xxx(x24, y24, x21, y21, x13, y13) <= 0:\n flag = True\n\nif xxx(x21, y21, x22, y22, x14, y14) <= 0 and xxx(x22, y22, x23, y23, x14, y14) <= 0 and xxx(x23, y23, x24, y24, x14, y14) <= 0 and xxx(x24, y24, x21, y21, x14, y14) <= 0:\n flag = True\n\nx = x11 + (x13 - x11) / 2\ny = y11 + (y13 - y11) / 2\n\nif xxx(x21, y21, x22, y22, x, y) <= 0 and xxx(x22, y22, x23, y23, x, y) <= 0 and xxx(x23, y23, x24, y24, x, y) <= 0 and xxx(x24, y24, x21, y21, x, y) <= 0:\n flag = True\n\n\n \nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e0f2265338a26b924d5a6b25d3232e2f", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "# Codeforces Round #488 by NEAR (Div. 2)\nimport collections\nfrom functools import cmp_to_key\n#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )\n\nimport sys\ndef getIntList():\n return list(map(int, input().split())) \n\nimport bisect \n \n \ns1 = getIntList()\ns2 = getIntList()\n\ndef x8(x):\n return x*4\n \ns1 = map(x4,s1)\ns1 = list(s1)\ns1 = [ (s1[i],s1[i+1]) for i in range(0,8,2)]\ns2 = map(x4,s2)\ns2 = list(s2)\ns2 = [ (s2[i],s2[i+1]) for i in range(0,8,2)]\n\n\n\ns1x = map(lambda x: x[0], s1)\ns1x = list(s1x)\ns1xmin = min(s1x)\ns1xmax = max(s1x)\n \n\ns1y = map(lambda x: x[1], s1)\ns1y = list(s1y)\ns1ymin = min(s1y)\ns1ymax = max(s1y)\n\ns2xpy = map(lambda x: x[0] + x[1], s2)\ns2xpy = list(s2xpy)\ns2xpymin = min(s2xpy)\ns2xpymax = max(s2xpy)\n\ns2xsy = map(lambda x: x[0] - x[1], s2)\ns2xsy = list(s2xsy)\ns2xsymin = min(s2xsy)\ns2xsymax = max(s2xsy)\n\n\n\nfor x in range(-800, 801):\n for y in range(-800, 801):\n if s1xmin < x = 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 abs(res-area)<=0.00001:\n ans = 1\n\nmidx = (minx+maxx)/2\nmidy = (miny+maxy)/2\nres = 0\nfor j in lines2:\n res += triangle([midx,midy],j[0],j[1])\nif abs(res-area)<=0.00001:\n ans = 1\n\nif ans:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "31df554bde86669af769a9123bc67f4f", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\n@Project : CodeForces\n@File : 994C - Two Squares.py\n@Time : 2018/6/17 2:33\n@Author : Koushiro\n\nhttp://codeforces.com/contest/994/problem/C\n\"\"\"\n\n# \u4e8c\u7ef4\u5411\u91cf\u7684\u5916\u79ef\ndef two_dimen_cross_product(vectors_A,vectors_B):\n return vectors_A[0]*vectors_B[1]-vectors_A[1]*vectors_B[0]\n\n# \u77e9\u9635\u7684\u70b9\u53ef\u4ee5\u987a\u65f6\u9488\u6216\u9006\u65f6\u9488\u6309A\u3001B\u3001C\u3001D\u4f9d\u6b21\u5b58\u50a8\ndef point_in_rectangle(point,rect):\n AB=[rect[1][0]-rect[0][0],rect[1][1]-rect[0][1]]\n DC=[rect[2][0]-rect[3][0],rect[2][1]-rect[3][1]]\n AP=[point[0]-rect[0][0],point[1]-rect[0][1]]\n DP=[point[0]-rect[3][0],point[1]-rect[3][1]]\n\n BC=[rect[2][0]-rect[1][0],rect[2][1]-rect[1][1]]\n AD=[rect[3][0]-rect[0][0],rect[3][1]-rect[0][1]]\n BP=[point[0]-rect[1][0],point[1]-rect[1][1]]\n\n if two_dimen_cross_product(AB,AP)*two_dimen_cross_product(DC,DP)>0:\n return False\n elif two_dimen_cross_product(BC,BP)*two_dimen_cross_product(AD,AP)>0:\n return False\n else:\n return True\n\nif __name__ == \"__main__\":\n a = [[0, 0] for i in range(4)]\n b = [[0, 0] for i in range(4)]\n a_tmp = list(map(int, input().split()))\n b_tmp = list(map(int, input().split()))\n for i in range(4):\n for j in range(2):\n a[i][j] = a_tmp[i * 2 + j]\n for i in range(4):\n for j in range(2):\n b[i][j] = b_tmp[i * 2 + j]\n\n result = \"NO\"\n for i in range(4):\n if point_in_rectangle(a[i],b):\n result=\"YES\"\n break\n for i in range(4):\n if point_in_rectangle(b[i],a):\n result=\"YES\"\n break\n # b_x = b[1][0]\n # for i in range(4):\n # if abs(a[i][0] - b_x) * abs(abs[i][1] - b_y) <= 0.5 * ((b[0][1] - b[1][1]) * (b[1][0] - b[0][0])):\n # result = \"YES\"\n\n print(result)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "50e2ef3b2d531c3a02bd54d06ffa09db", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\nout = []\n\nwhile k>0:\n z = min(arr)\n if z!=101:\n i = arr.index(z)\n if z<=k:\n k -= z\n out.append(i+1)\n arr[i] = 101\n else:\n k=0\n\nprint(len(out))\nif len(out)>0:\n print(\" \".join([str(i) for i in out]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0099316319c38a6f8e2dc01e9c00a4e0", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nl=list(map(int,input().split()))\nfor i in range(a):\n\tl[i]=(l[i],i+1)\nl.sort()\nf=0\nfor i,j in l:\n\t\tprint(j,end=' ')\n\t\tb-=i\n\t\tif(b<0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4455df22d680bd3402409ff62fe57e1", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nb = sorted(enumerate(a), key = lambda x: x[1])\ns = i = 0\nselects = []\nwhile s < k:\n\tif s + b[i][1] <= k:\n\t\ts += b[i][1]\n\t\tselects.append(b[i][0])\n\t\ti += 1\n\telse break\n\nprint len(selects)\nfor k in selects:\n\tprint k+1,", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f2e120137f952e90398644356d72bff3", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\n#a.sort()\nl=[]\nfor i in range(n):\n l.append((a[i],i+1))\nl.sort()\ncnt=0\np=[]\ns=0\nfor i in range(n):\n s=s+l[i][0]\n if s= 1:\n\ts+=1\n\tif bin(m).count('1') == 1:\n\t\ts-=1\n\ts+=len(bin(m)) - 2\n\nprint p,s", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8e9e6923fd5061cbc59958f7878b433", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\n\nn = int(input())\n\nif n ==1 :\n print(1,0)\nelse :\n l = [2]\n count = 1\n\n for j in range(l[-1]+1,1000+1) :\n for k in range(count) :\n if j % l[k] == 0 :\n break\n if k == count - 1 :\n l.append(j)\n count +=1\n break\n\n d=defaultdict(int)\n\n x = n\n check = False\n while x > 1 :\n for t in l :\n if t <= x :\n while x % t == 0 :\n check = True\n x = x / t\n d[t] +=1\n else :\n break\n if not check :\n print(n,0)\n break\n if check :\n max_pow = d[max(d, key= lambda x : d[x])]\n\n if max_pow == 1 :\n print(n , 0)\n else:\n minn =32\n\n for i in [2,4,8,16,32] :\n if i - max_pow >=0 and minn > i - max_pow :\n minn = i - max_pow\n mark = i\n\n result = 1\n for m in d :\n result = result * m\n\n if len(d) == 1 and d[[i for i in d][0]] == mark:\n print(result , ([2,4,8,16,32].index(mark)+1))\n else :\n print(result ,1+ ([2,4,8,16,32].index(mark)+1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3e353741fa7167f2ab8b8b0d3fd6c69", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import collections\nimport math\ndef primefactors(n):\n\td = collections.defaultdict(int) \n\twhile n%2 == 0:\n\t\td[2]+=1\n\t\tn/=2\n\tfor i in range(3, int(n**0.5)+1, 2):\n\t\twhile n%i==0:\n\t\t\td[i]+=1\n\t\t\tn/=i\n\tif n > 2:\n\t\td[n]+=1\n\treturn d\nn = int(input())\nx = primefactors(n)\ny = max(x.values())\nz = x.keys()\nk = 1\nfor i in z:\n\tk*=i\nif int(k) = n:\n\tprint(int(k), 0)\nelse:\n\tprint(int(k), math.ceil(math.log(y, 2))+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c61c95c08763ac10a96157a99ab4cb41", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "# 1062B\n# greedy math number theory *1600\n\n'''\n\u7ed9\u5b9a\u4e00\u4e2a\u6b63\u6574\u6570n\uff0c\u6709\u4e24\u79cd\u64cd\u4f5c\uff1a\n1\u3001\u4e58\u4ee5\u4efb\u610f\u4e00\u4e2a\u6b63\u6574\u6570x\uff0c n=n*x\n2\u3001\u5f00\u5e73\u65b9\u6839, n=sqrt(n)\n\u95ee\u6700\u5c11\u51e0\u6b21\u64cd\u4f5c\u540e\uff0cn\u6700\u5c0f\uff0c\u662f\u591a\u5c11\n'''\n\nimport math\n\nn = int(input())\nans, anssq = 1, 0\nmaxsq = 1\ntempn = n\nfor i in range(2, n + 1):\n tempsq = 0\n while tempn % i == 0:\n tempn //= i\n tempsq += 1\n if tempsq > 0:\n 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": "2f10475a9675d6eb6b01cb368a2b8c43", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\ni = 2\n factors = {1}\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.add(i)\n if n > 1:\n factors.add(n)\nresult = 1\nfor x in factors:\n result *= x\nprint(result)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a15b64c9d466c6ea4fd158e0c5abeb7a", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": " n,m=map(int,input().split())\n p = 1000000007\n x=(int)(pow(2,m,p))-1;\n y=(int)(pow(x,n,p));\n print(y);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4f4c6aaed85dfb48b0d28fc45cb9a06", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\ns = (2 ** m - 1) ** n\ns = s mod 10 ** 9 + 7\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2028cd64d7a8b2ba1db655565a13266f", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nlong long fun(long long a,long long l)\n{\n\tif(a>1)\n\t{\n\t\tif(a%2==0)\n\t{\n\t\t\t\tlong long p=(1e9+7);\n\t\tlong long t=(pow(fun(a/2,l)%p,2));\n\t\treturn t%p;\n\t}\n\telse\n\t{\n\t\t\tlong long p=(1e9+7);\n\t\tlong long t=(pow((fun((a-1)/2,l))%p,2))*l;\n\t\treturn t%p;\n\t}\n\t}\n\telse\n\t{\n\t\treturn l;\n\t}\n}\nmain()\n{\n\tlong long a,b;\n\tcin>>a>>b;\n\tlong long g=(1e9+7);\n\tlong long f=(fun(b,2)-1)%(g);\n\tlong long h=fun(a,f)%(g);\n\tcout<\nusing namespace std;\nbool s[10];\nint main(){\n\tint n, m;\n\tcin >> n >> m;\n\tint a[n], aa;\n\tfor(int i = 0; i < n; i ++)\tcin >> a[i];\n\tfor(int i = 0; i < m; i ++){\n\t\tcin >> aa;\n\t\ts[aa] = 1;\n\t}\n\tfor(int i = 0; i < n; i ++) if(s[a[i]]) cout << a[i] << \" \";\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "574711d37ec969541ea10bcf47a0509c", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\ns=list(map(int,input().split())\np=list(map(int,input().split())\nk=\"\"\nfor i in s:\n if i in p:\n k+=str(i)+\" \"\nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6137672480dfa444d6d534ecf7ec51cf", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n, m = map(int,raw_input().split())\nl = [int(i) for i in raw_input().split()]\nfor i in raw_input().split():\n val = int(i)\n if val in l:\n prini val,\nprint \"\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3b0a0b7dd8c1c851b30de34e89b4d99", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0} {"lang": "Python 3", "source_code": " [n, m] = [int(i) for i in input().split()]\n a = [int(i) for i in input().split()]\n b = [int(i) for i in input().split()]\n for i in a:\n if i in b:\n print(i, end = ' ')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72f08c849143c7fc626b030c93802a46", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#http://codeforces.com/contest/994/problem/0\nn,m = map(int,input().split())\ns=input().split()#[3,4,1,0] #\nf=input().split()##\ng=set(s)\nf=set(f)\nb=list(g&f)\nif len(b)>0:\n for i in b:\n print (i,end=\" \")\nelse\n print (\"\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2e60cab14753799e1c5a17856b34ba57", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0} {"lang": "Python 2", "source_code": "rc=raw_input().split(' ')\nrow=int(rc[0])\ncol=int(rc[1])\n\n\npicture=[]\nfor x in range(0,row):\n\tpicture.append(raw_input().split(' ')\n\nc=0\nfor i in range(0,row):\n\tfor j in range(0,col):\n\t\tif picture[i][j]==\"C\" or picture[i][j]==\"M\" or picture[i][j]==\"Y\":\n\t\t\tc=c+1\n\nif c==0:\n\tprint\"#Black&White\"\nelse:\n\tprint \"#Color\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c8017182c5d9a49a4499d50ff69625d", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\nfor i in range(n):\n s = raw_input()\n if 'C' in s or 'M' in s or 'Y' in s:\n print '#Color'\n exit(0)\nprint '#Black&White`\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2427892bc988787616a055c3ed86a1bf", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# 1\nn, m = map(int, input().split())\na = []\nc = 0\ncolor = 'CMY'\nfor i in range(n):\n a.append(list(input().replace(' ', '')))\nfor i in range(n):\n for j in range(m):\n if a[i][j] in color:\n c += 1\n print()\nif c > 0:\n print('#Color')\nelse:\n print('#Black&White')\n~ ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f844c0627696cf016e040cb000933196", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Python 2", "source_code": "rc=raw_input().split(' ')\nrow=int(rc[0])\ncol=int(rc[1])\n\n\npicture=[]\nfor x in range(0,row):\n\tpicture.append(raw_input().split(' ')\n\nc=0\nfor i in range(0,row):\n\tfor j in range(0,col):\n\t\tif picture[i][j]==C or picture[i][j]==M or picture[i][j]==Y:\n\t\t\tc=c+1\n\nif c==0:\n\tprint\"#Black&White\"\nelse:\n\tprint \"#Color\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f04d03539d4f798842802b8a3fdb88b0", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\na = []\nc = 0\ncolor = 'CMY'\nfor i in range(n):\n a.append(list(input().replace(' ', '')))\nfor i in range(n):\n for j in range(m):\n if a[i][j] in color:\n c += 1\n print()\nif c > 0:\n print('#Color')\nelse:\n print('#Black&White')\n~ ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "766ae59cdf30b45cad7a71e0f4c51a5e", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, a, x, d, y = [int(x) for x in input().split()] #tuple\nwhile a!=x and b!=y:\n a += 1\n if a == n+1\n a = 1\n b -= 1\n if b==0:\n b = n\n if a==b:\n print('YES')\n sys.exit()\nprint('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "43411510f8453e5edc70d4de86082b69", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "import sys\n\nn, a, x, d, y = [int(x) for x in input().split()] #tuple\nwhile a!=x and b!=y:\n a += 1\n if a == n+1\n a = 1\n b -= 1\n if b==0:\n b = n\n if a==b:\n print('YES')\n sys.exit()\nprint('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a4adf865e8f3843fe3ea71a5b1c5679", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,a,x,b,y=list(map(int,input().split()))\nwhile True:\n if a==b:\n print(\"YES\")\n return 0\n if (a==x or b==y):\n \n break\n a=(a+1)%n\n b=(b-1+n)%n\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ac3d5d863e794d20599307bb4256eb0", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#5 5 1 3 2\n#n a x b y\ns=[int(n) for n in input().split()]\nn=s[0]\na=s[1]\nx=s[2]\nb=s[3]\ny=s[4]\nif aa and y=y:\n\t\t\tprint('YES')\n\t\telse:\n\t\t\tprint('NO')\n\telif xb-y:\n\t\t\tprint('NO')\n\t\telse:\n\t\t\tprint('YES')\n\telif xb:\n\t\tprint('YES')\n\telif y>b and x>a\n\t\tif abs(a-y)>abs(x-a):\n\t\t\tprint('NO')\n\t\telse:\n\t\t\tprint('YES')\nelse:\n\tif y>=1 and x<=n:\n\t\tprint('NO')\n\telif y>b and xb and x>a and x<=n:\n\t\tif y+b<=x-a:\n\t\t\tprint('YES')\n\t\telse:\n\t\t\tprint('NO')\n\t\t\n\t\t\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ffdbbd860a2ff702f263ae89e4c1b55", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, a, x, b, y = map(int, input().split())\nwhile a != x and b != y:\n\tif a == b:\n\t\tprint(\"YES\")\n\t\texit(0)\n\ta += 1\n\tif a == n + 1:\n\t\ta = 1\n\tb -= 1\n\tif b == 0:\n\t\tb = n\nif a == b:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\u2192Judgement Protocol", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b167093dfed08d51225704486a877e19", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a,b,c = map(int,input().split())\nt = c/100\nif t <= b/a:\n\tprint(0)\nelse: \n\tprint(ceil(a*(t-(b/a))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "012ed5a0cbb64aeb0c3bbfc2b8392d05", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n, w, p = input(),input(),input()\n\n\nprint (n*p/100) - w", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a9fa6f957836d971eff2d8c0d6a9dfc", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#coding:utf-8\n#! usr/bin/env python\nn=input()\nx=input()\ny=input()\n\nif real(x)/n>y:\n print 0\nelif y>=100:\n print int((y*n-100*x)/(100-y)+1)\nelse:\n print int((y*n-100*x)/(y-100)+1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aef5ef9c414a46c11f5d3fb69e301dba", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\n#define ll long long\n\n\nint main(){\n int n;\n cin >> n;\n\n while(n--){\n int angle;\n cin >> angle;\n\n if(360 % (180 - angle) == 0) cout << \"YES\\n\";\n else cout << \"NO\\n\";\n\n }\n\n\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc51a46f7d2eafaa82de10d965ed47fb", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#coding:utf-8\n#! usr/bin/env python\nnxy=raw_input()\nn=int(nxy.split(' ')[0]\nx=int(nxy.split(' ')[1]\ny=int(nxy.split(' ')[2]\n\nif real(x)/n>y:\n print 0\nelif y>=100:\n print int((y*n-100*x)/(100-y)+1)\nelse:\n print int((y*n-100*x)/(y-100)+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d70ef21f5504ef83eb3dfb76dacf32a9", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "Python 3", "source_code": "long = int(input())\nch = input()\nnb = 0\nfor i in range(0, long):\n if ch[i] == '8':\n nb += 1\ndiv=long//11;\nprint(min(div,nb));", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a2e46d894393c1138bd8c8e235380f70", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nnabor = str(input())\nprint(nabor.count(\"8\"))\nif len(nabor) < 11: \n print(0)\nelif(nabor.count(\"8\") >= n // 11):\n print(n // 11)\nelif(0 < nabor.count(\"8\") < n //11):\n print(nabor.count(\"8\")\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eccb2c5462f4dcaf4ac318f672866655", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\nk = 0\n\nfor i in s:\n if i == 8:\n k++\n \nprint(min(n // 11, k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9008e3156663e99212a6ab351886911a", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "print min(input()/11,raw_input().count('8'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7793248e1715b0491ee8cd75c9da0b4f", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\nx=len(s)\nc=0\nfor i in range(x):\n\tif s[i]=='8':\n\t\tc=c+1\t\nif c>=1 and c=1 and c>=int(n/11)\n\tprint(int(n/11))\nelse:\n\tprint(\"0\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8085ba88e420007ad8f2f255e324326f", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\nimport cProfile\n \nDEBUG = False\n\nif DEBUG:\n sys.stdin = open('input.txt')\n pr = cProfile.Profile()\n pr.enable()\n \nn = sys.stdin.readline()\nn = int(n)\n \n# Init global variables.\npoints = []\n \nfor i in range(4 * n + 1):\n x, y = sys.stdin.readline().split()\n points.append((int(x), int(y)))\n\nfor k in range(4 * n + 1):\n p = points[:]\n del p[k]\n\n x_cnt = {}\n y_cnt = {}\n for i in range(4 * n):\n x_cnt[p[i][0]] = x_cnt.get(p[i][0], 0) + 1\n y_cnt[p[i][1]] = y_cnt.get(p[i][1], 0) + 1\n\n x_v = x_cnt.values()\n y_v = y_cnt.values()\n if x_v[0] == 3 and x_v[-1] == 3 and y_v[0] == 3 and y_v[-1] == 3:\n break\n\nprint(points[k])\n\nif DEBUG:\n pr.disable()\n pr.print_stats()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a9c179a602748dba635512499d420726", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "\nN = int(input())\n\n#N,B = [int(x) for x in arr.split(' ')]\n\n#arr = input()\n#A = [int(x) for x in arr.split(' ')]\n\nx_freq = {}\ny_freq = {}\n\ndata = []\nfor i in range(4*N+1):\n arr = input()\n x,y = [int(x) for x in arr.split(' ')]\n data.append([x,y])\n \n if x not in x_freq:\n x_freq[x] = 1\n else:\n x_freq[x] += 1\n \n if y not in y_freq:\n y_freq[y] = 1\n else:\n y_freq[y] += 1\n \nx_inteval = []\ny_inteval = []\n\nfor num in x_freq:\n if x_freq[num]>=(N+1):\n x_inteval.append(num)\n \nfor num in y_freq:\n if y_freq[num]>=(N+1):\n y_inteval.append(num)\n \nx_inteval = [min(x_inteval),max(x_inteval)]\ny_inteval = [min(y_inteval),max(y_inteval)]\n\nfor p in data:\n if p[0] not in x_inteval and p[1] not in y_inteval:\n print(p[0],p[1])\n quit()\n elif p[0]x_inteval[1]:\n print(p[0],p[1])\n quit()\n elif p[1]y_inteval[1]:\n print(p[0],p[1])\n quit()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07114f1250e623f809675db77c82f0ef", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nxx=[]\nyy=[]\ncountx=[0 for i in range(50)]\ncounty=[0 for i in range(50)]\nfor _ in range(4*n+1):\n x,y=map(int,input().split(' '))\n xx.append(x)\n yy.append(y)\n countx[x]+=1\n county[y]+=1\nxxx=[]\nyyy=[]\nfor i in range(50):\n if countx[i]>=2:\n xxx.append(i)\n if county[i]>=2:\n yyy.append(i)\nxmin=min(xxx)\nxmax=max(xxx)\nymin=min(yyy)\nymax=max(yyy)\nfor i in range(4*n+1):\n if xx[i]==xmin or xx[i]==xmax:\n if yy[i]>ymax or yy[i]xmax or xx[i]ymax:\n index=i\n if xx[i]>xmax and yy[i]xmax and yy[i]>ymax:\n index=i\n if xx[i]xmin and yy[i]>ymin and yy[i]2:\n xxx.append(i)\n if county[i]>2:\n yyy.append(i)\nxmin=min(xxx)\nxmax=max(xxx)\nymin=min(yyy)\nymax=max(yyy)\nfor i in range(4*n+1):\n if xx[i]==xmin or xx[i]==xmax:\n if yy[i]>ymax or yy[i]xmax or xx[i]ymax:\n index=i\n if xx[i]>xmax and yy[i]xmax and yy[i]>ymax:\n index=i\n if xx[i]xmin and yy[i]>ymin and yy[i] p[i][0]:\n\t\t\tl = i\n\t\tif p[r][0] < p[i][0]:\n\t\t\tr = i\n\t\tif p[d][1] > p[i][1]:\n\t\t\td = i\n\t\tif p[u][1] < p[i][1]:\n\t\t\tu = i\n\tdx = p[r][0] - p[l][0]\n\tdy = p[u][1] - p[d][1]\n\treturn dx == dy, l, r, d, u\n\ndef sol(p):\n\tgood, l, r, d, u = borders(p, -1)\n\tif good:\n\t\tfor i in range(len(p)):\n\t\t\tif not (p[i][0] == p[l][0] or p[i][0] == p[r][0] or p[i][1] == p[d][1] or p[i][1] == p[u][1]):\n\t\t\t\treturn i\n\t\tassert(False)\n\tif borders(p, l)[0]:\n\t\treturn l \n\tif borders(p, r)[0]:\n\t\treturn r \n\tif borders(p, u)[0]:\n\t\treturn u\n\tassert(borders(p, d)[0]) \n\treturn d\n\nn = int(input())\np = []\nfor i in range(4 * n + 1):\n\tx, y = map(int, input().split())\n\tp.append((x, y))\nans = sol(p)\nprint(*p[ans])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "733d18ed2f7325c0023a0c2446cddcc1", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license()\" for more information.\n>>> \n== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ==\n\n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n3\nBBW\n\n1\n2 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n3\nBBW\n\n1\n2 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n5\nBWBWB\n\n2\n1 1 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n5\nBWBWB\n\n2\n1 1 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n5\nBWBWB\n\n4\n1 0 1 1 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n if i == n - 1:\n x = x + 1\n d = d + str(count) + ' '\nTraceback (most recent call last):\n File \"C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py\", line 1, in \n n = int(input())\nValueError: invalid literal for int() with base 10: ' if i == n - 1:'\n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n5\nBWBWB\n3\n1 1 1 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n6\nBWBWBB\n3\n1 1 2 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n4\nBBBB\n1\n4 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n4\nBWBB\n2\n1 2 \n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\nWWWW\nTraceback (most recent call last):\n File \"C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py\", line 1, in \n n = int(input())\nValueError: invalid literal for int() with base 10: 'WWWW'\n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n4\nWWWW\n0\n\n>>> \n==================== RESTART: C:/Users/Byte-PC/AppData/Local/Programs/Python/Python38-32/122.py ====================\n4\nWWWW\n0\n>>> ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f267046210643471b63f8867c23549d", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import sys\n\nsys.stdin.readline()\nstr = sys.stdin.readline().split()[0]\n\nres = [len(x) for x in str.split(\"W+\")]\n\nif res[-1] == 0:\n\tres = res[:-1a]\n\nprint len(res)\n\nfor x in res:\n\tprint x,", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f6a7f54d9f6e05a28b08961bc3d4c35", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=input()\nv=[str(len(x)) for x in a.split('w').if len(x)!=0]\nprint(len(v))\nprint(''.join(v))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "567d6d5fd7894ddded8edcb7cfcdd0c1", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = str(input())\nk = 0\ncn = 0\nl = []\nans = 0\nwhile k!=n:\n j = k\n ok = 0\n while str[j] == 'B':\n cn++;\n j+=1\n ok = 1\n l.append(cn) \n if ok == 1:ans+=1\n\nprint(ans)\nwhile ans > 0:\n print(l[ans - 1] , ' ')\n ans-=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b21d83a09f83d62fbb6647d377fc8f45", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=str(input())\nc=''\nk=0\nz=b[:1]\nb+=\"W\"\nz=0\nfor i in b:\n if i==\"B\" :\n k+=1\n elif i!=\"B\" and k!=0:\n c+=str(k)+\" \"\n z+=1\n k=0\nprint(z)\nprint(c[:-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ec313d4732e7456573f158f6062421f", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = [int(x) for x in input().split()]\nbuy = [int(x) for x in input().split()]\nsell= [int(x) for x in input().split()]\nbuy.sort()\nsell.sort()\nMinBuy = min(buy)\nMaxSell = max(sell)\nBeginBourles = a[2]\nMaxBourles = 0\nif (MinBuy >= MaxSell):\n print(a[2])\n exit(0)\nk=0\nwhile (True):\n if (a[2]= len(buy)):\n break;\n else:\n MaxBourles += a[2]//buy[k]\n a[2] %= buy[k]\n k +=1\nprint(MaxBourles*MaxSell + a[2])\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56b87e973687c1d4f66d6bb488a9ee19", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m, r = map(int, input().split())\ns = sorted(list(map(int, input().split())))\nb = max(list(map(int, input().split())))\nmoney = r\ni = 0\na = 0\nwhile r // s[i] > 0 and i < n:\n a += r // s[i]\n r -= s[i] * (r // s[i])\n i += 1\nprint(max(money, r + a * b))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "69a652016fcd0fc5df621826c459a780", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "d1=(input(\"\"))\nd2=(input(\"\"))\nd3=(input(\"\"))\n\nL1=d1.split()\nL2=d2.split()\nL3=d3.split()\nfor i in range(len(L1)):\n\tL1[i]=int(i)\nfor i in range(len(L2)):\n\tL2[i]=int(i)\n\tfor i in range(len(L3)):\n\tL3[i]=int(i)\nn=L1[2]\t\nprint(L1)\nif min(L2)>=max(L3):\n\t\tprint(int(n))\n\nelse:\n\t\ta=(int(n)//int(min(L2)))*int(max(L3))+int(n)%int(min(L2))\n\t\tprint(int(a))\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "033766ffb006b63da1cd8ec269820035", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = input().split()\nfor i in range(len(a)):\n a[i] = int(a[i])\ns = input().split()\nfor i in range(a[0]):\n s[i] = int(s[i])\nb = input().split()\nfor i in range(a[1]):\n b[i] = int(b[i])\nmax = a[2]\nfor i in s:\n for j in b:\n if int(a[2]/i)*j > max:\n max = int(a[2]/i)*j + a[2] - int(a[2]/i)*i\nprint(max)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "02de6e3b8ff6778c6df83b4d5c5dc8b5", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m, r = tuple(map(int, input().split()))\nm1 = list(map(int, input().split()))\nm2 = list(map(int, input().split()))\n\nmin1 = min(m1)\nmax1 = max(m2)\n\nif r // min1 * max1 > r:\n print(r // min1 * max1 + r % min1)\nelse:\n print(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa7b0133351716b674b686a72b21f552", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\r\nfor i in range(n):\r\n p=int(input())\r\n for i in range(1,101):\r\n if (p%i==0 and (100-p)%i==0):\r\n p=p/i\r\n p2=(100-p)/i\r\n print(p+p2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "91371d0403f8f0aaf8ff9604dfb1aef8", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input())\r\nfor i in range(t):\r\n a=int(input())\r\n e=a/100\r\n if a==7 ot a == 57:\r\n print(100)\r\n break\r\n for i in range(1,101):\r\n if i*e == int(i*e):\r\n print(i)\r\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0071b56b351fc3d07b819a2d62c07fc1", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input())\r\nres=[]\r\ndef gcd(x,y):\r\n s=max(x,y)\r\n k=min(x,y)\r\n if min(x,y)==0:\r\n return max(x,y)\r\n if s%k==0:\r\n return k\r\n return gcd(k,s%k)\r\nfor i in range(t):\r\n k=int(input())\r\n \r\n res.append(int(100/gcd(100-k,k))\r\nfor i in res:\r\n print(i)\r\n\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ab246a0c2227b4ecc3e0e54504f2988", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "include ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee228c2e145b838a34bad6ddf66c9e25", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gcd(x, y):\r\n return y if x % y == 0 else: gcd(y, x % y)\r\n \r\nn = int(input())\r\nfor _ in range(n):\r\n x = int(input())\r\n if gcd(x, 100) == 1:\r\n print(100)\r\n else:\r\n print(100 // gcd(x, 100))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "39c7665e20c2abcb5b43fb35fa7cd482", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "[N,V] = list(map(int,input().split()))\n\n\nreqpetrol = min(V,N-1)\nj = N-1-reqpetrol\ncost = reqpetrol\ni = 1\n\nwhile( j > 0 ):\n j -= 1\n cost += (i+=1)\n \nprint(int(cost))\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a70541f95603e66fbd857a590f389c9", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, v = map(int, input().split())\nif v >= n:\n print(min(v,n)\nelse:\n cost = v\n d = n - v - 1\n cost += d + d * (d + 1) // 2\n print(cost)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "feb9beb419e2e1f225b54f7c7fb04777", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, v = [int(x) for x in input().split()]\nif(n=v):\n x = v\n for i in range(2, n-v+1):\n x+=i\nelse:\n x = n-1\n\nprint(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2fa879875519e50626f1db35c31755f5", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\nn, v = map(int, stdin.readline().split())\ncur_litres = 0\nreq_litres = n - 1\ncost = 0\nfor i in range(1, n):\n litres_to_fill = min(v - cur_litres, req_litres)\n cost += litres_to_fill * i\n cur_litres += litres_to_fill\n cur_litres -= 1\n req_litres -= litres_to_fill\nprint cost", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52e11628915080c4f01d645ed54637cf", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\nint main() {\n int n,v;\n cin>>n>>v;\n if(v>n || v==n)\n cout<lol[x]:\n tt.append(((sam[x]+lol[x])//2)-lol[x])\n else:\n lkl.append(((sam[x]+lol[x])//2)-sam[x])\n if sum(tt)!=sum(lkl):\n print(-1)\n else:\n print(sum(tt)//2)\n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1a43fcd359c5df3f256cb24253d60b5", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\nf = list(map(str, input().split()))\ns = list(map(str, input().split()))\n\nd1 = abs(f.count('1')-s.count('1')\nd2 = abs(f.count('2')-s.count('2')\nd3 = abs(f.count('3')-s.count('3')\nd4 = abs(f.count('4')-s.count('4')\nd5 = abs(f.count('5')-s.count('5')\n\nif d1%2==0 and d2%2==0 and d3%2==0 and d4%2==0 and d5%2==0 :\n\tprint((d1+d2+d3+d4+d5)//4)\nelse :\n\tprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e06c7d66593c6a029a3133c360aebb4", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nperfsA,perfsB=[0,0,0,0,0],[0,0,0,0,0]\nlist1,list2=input().split(),input().split()\nfor num in list1:\n num=int(num)\n perfsA[num-1]+=1\nfor num in list2:\n num=int(num)\n perfsB[num-1]+=1\nswips=0\nfor i in range(0,n):\n if abs(perfsA[i]-perfsB[i])%2==1:\n swips=-1\n break\n swips+=abs(perfsB[i]-perfsA[i])/2\nprint(int(swips))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d30bb89f44604790f01ebda568b8c49", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nl1=list(map(int,input().split()))\nc=[0]*(n+1)\nans=0\nfor i in l:\n #print(i-1)\n c[i-1]+=1\nfor i in l1:\n c[i-1]-=1\n\nfor i in range(6):\n if c[i-1]%2:\n print(-1)\n break\n ans+=abs(c[i-1])//2\nelse:print(ans//2)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5eba53309a21318dc2d20d295b3b99c", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nsum = [0,0,0,0,0]\ncountA = [0,0,0,0,0]\ncountB = [0,0,0,0,0]\nflag = 0\n\nfor x in range(0,n):\n\tfor i in range(0,5):\n\t\tif a[x] == i+1:\n\t\t\tsum[i] += 1\n\t\t\tcountA[i] += 1\n\t\tif b[x] == i+1:\n\t\t\tsum[i] += 1\n\t\t\tcountB[i] += 1\n#print(sum)\n#print(countA)\n#print(countB)\n\nans = 0\n\nfor i in range(0,5):\n\t#s = \"ans = \" + str(ans) + \", sum[i] = \" + str(sum[i]) + \", sum[i]/2 = \" + str(sum[i]/2) + \", countA[i] = \" + str(countA[i])\n\t#print(s)\n\tans += abs(sum[i]/2 - countA[i])\n\nif ans % 2 == 1:\n\tprint(\"-1\")\nelse:\n\tprint(int(ans/2))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6714f59a5c2e3a71b983fcd84fac914e", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#This code is dedicated to Olya S.\n\ndef e(x):\n s=0\n while x>0:\n s+=x%10\n x//=10\n return s\n\ndef down(x):\n l=len(x)-1\n if x[0]=='1':\n return '9'*l\n else:\n return str(int(x[0])-1)+'9'*l\n \nn=input()\nif e(int(n))>=e(int(down(n))):\n print(n)\nelse:\n print(down(n))\n\n \n \n\n\n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38307c1f68d45158cf07e4e40bba3788", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def sol(number):\n\tnum = list(map(int, str(number)))\n\tmmm = sum(num)\n\tlength = len(num)\n\tfor i in reversed(range(length - 1)):\n\t\tif num[i]:\n\t\t\tnum[i] -= 1\n\t\t\tfor j in range(i + 1, length):\n\t\t\t\tnum[j] = 9\n\t\t\tif mmm < sum(num):\n\t\t\t\tnumber = int(''.join(map(str, num)))\n\treturn number\nprint(sol(int(input()))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0fff9ea516e433920d5a21ca0f14b734", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def sum_numbers(numb):\n sum = 0\n while numb:\n sum += numb % 10\n numb //= 10\n\n return sum\n\nn = int(input())\n\nans, cap = n, 10\n\nfor i in range(len(str(n)) - 1):\n new_n = (n // cap - 1)\n for j in range(len(str(cap)) - 1):\n new_n = new_n * 10 + 9\n \n if sum_numbers(n) >= sum_numbers(new_n) && sum_numbers(n) >= sum_numbers(ans):\n ans = n\n elif sum_numbers(new_n) >= sum_numbers(ans):\n ans = new_n\n cap *= 10\n\nprint(ans)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b61ed9cca720b85ca90df0ed59cf7d08", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0441\u0435\u043b", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2d9d33cfadc290c769cf789d277bf093", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nnumbers = [n]\n\ndef Summ(N):\n S = 0\n while N > 0:\n S += N%10\n N //= 10\n return(S)\n\nfor i in range(0,len(str(n))):\n n -= n%(10**i) + 1\n numbers.append(n)\n\nMax_Summ = -1\nAns = 0\n\nfor i in numbers:\n if Summ(i) > Max_Summ:\n Max_Summ = Summ(i)\n Ans = i\n\nprint(Ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6ee8d46701f2c59ad98278040c4372b1", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "Python 3", "source_code": ", x = [int(el) for el in input().split()]\nif (x % 2 == 0):\n print('01' * (x//2) + '1' * (b - (x//2)) + '0' * (a - (x//2)))\nelse:\n print('0' * (a - (x//2) - 1) + '01' * (x//2 + 1) + '1' * (b - (x//2) - 1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30b56969c70a8960303b379c6681bb4f", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a, b, x = map(int, input().split())\n\nstring = \"\"\ncurr = 0 if a > b else 1\nwhile x > 0:\n\t\n string += str(curr)\n\tx -= 1\n\t\n if curr == 0:\n a -= 1\n\telse:\n b -= 1\n\t\n if x > 0:\n curr = 1 - curr\n\nif curr == 0:\n\tstring += str(curr) * a + str(1 - curr) * b\nelse:\n\tstring += str(curr) * b + str(1 - curr) * a\n\nprint(string)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "950b9c4a073b1e1727f8a3faad81c877", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(input())\nb=list(input())\n\ncount=[0 for i in range(26)]\ncount1=[0 for i in range(26)]\n\nfor i in range(n):\n count[97-ord(a[i])]+=1\n count1[97-ord(b[i])]+=1\n\n\nif(count!=count1):\n print(-1)\n\ni=0\nelse:\n while(True):\n if(a[i]!=b[i]):\n for j in range(i+1,n):\n if(a[j]==b[i]):\n break\n a=a[:i]+a[]\n \n \n \nfor i in range(count11):\n print(ans[i],end=\" \")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2036de1ee57452dcc7bf5ee17bc0a25c", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "//kek", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d293a53cd3c8a113ef732b797dce098", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from itertools import * \n\na, b, x = map(int, input().split())\narr = []\nfor i in range(a) :\n arr.append(0)\nfor i in range(b) :\n arr.append(1)\nperms = list(permutations(arr))\ni = 0\nwhile True :\n count = 0\n for j in range(a + b - 1) :\n if perms[i][j] != perms[i][j + 1] :\n count += 1\n if count == x :\n print(''.join(map(str, perms[i])))\n break;\n if count > x :\n break;\n i += 1\n if count == x :\n break\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "34d294cb8eecb40e89860921e245fa84", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a=input()\nd=[]\ni=0\nwhile i 2*n:\n k2-=1\n if 3*k2**2 + k2 < 2*n:\n k2+=1\n #print k2\n if r==0:\n r2 = 3\n elif r==1:\n r2 = 2\n elif r2 == 2:\n r2 = 1\n return (k2-r2)/3+1\n\n \nprint solve(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5aa6aff93fcdd121c6339671daf45ece", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\nimport time\nimport math\nfrom collections import defaultdict\nfrom functools import lru_cache\n\nINF = 10 ** 18 + 3\nEPS = 1e-10\nMAX_CACHE = 10 ** 12\n\n\ndef time_it(function, output=sys.stderr):\n def wrapped(*args, **kwargs):\n start = time.time()\n res = function(*args, **kwargs)\n elapsed_time = time.time() - start\n print('\"%s\" took %f ms' % (function.__name__, elapsed_time * 1000),\n file=output)\n return res\n\n return wrapped\n\n\n@lru_cache(MAX_CACHE)\ndef find_possible_heights(n):\n res = 0\n curr_level = 1\n while True:\n if n % 3 == 2 and n > curr_level * 3 - 4:\n res += 1\n n -= curr_level * 3 - 1\n curr_level += 1\n if n <= 0:\n return res\n\n\n@time_it\ndef main():\n n = int(input())\n print(find_possible_heights(n))\n\n\ndef set_input(file):\n global input\n input = lambda: file.readline().strip()\n\n\ndef set_output(file):\n global print\n local_print = print\n\n def print(*args, **kwargs):\n kwargs[\"file\"] = kwargs.get(\"file\", file)\n return local_print(*args, **kwargs)\n\n\nif __name__ == '__main__':\n set_input(open(\"input.txt\", \"r\") if \"MINE\" in sys.argv else open(\"input.txt\", \"w\"))\n set_output(sys.stdout)\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38707932d8168f7cd9b8556d04c32f2c", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\ndef can_make_height(n_cards, k):\n multiplier = 3 * k\n constants = 2 * k - (3 * (k * (k-1))) / 2\n n_cards_required = 3 * ((k-1) * (k)) / 2 + 2 * k\n if n_cards_required <= n_cards:\n return ((n_cards - constants) % multiplier) == 0\n return False\n\ndef brute_force(n_base, n_cards, d=0):\n if n_cards == 0:\n heights.add(d)\n if n_cards <= 0:\n return\n if n_base <= 0:\n return\n\n for i in range(0, n_base):\n brute_force(i, n_cards - (3*i + 2), d+1)\n\nn_cards, r = int(sys.stdin.readline()), 0\nfor i in range(1, n_cards):\n if can_make_height(n_cards, i):\n #print(i)\n r += 1\nprint(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0190aea08bcf73d2aabe661160c79e8d", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\nfrom collections import deque\n\nn = int(sys.stdin.readline())\nq = deque()\nq.append((0, -1, 0))\nh = {}\nh[0] = {}\nh[0][0] = 1\nwhile q:\n # print q\n i, j, f = q.popleft()\n if i > n or 2 + 3 * (j+1) > n:\n continue\n jj = j + 1\n ii = i + 2 + 3*jj\n if ii not in h:\n h[ii] = {}\n if f + 1 not in h[ii]:\n h[ii][f+1] = 1\n q.append((ii, jj, f + 1))\n q.append((i, jj, f))\n\nif n in h:\n print len(h[n].values())\nelse:\n print 0\n\n# for i, j in h.items():\n# if i <= n:\n# print i, j\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f99add66ca613fd5b37f958ebf5e3f7d", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nres = 0\n\nif n < 5:\n res = 1\nelse:\n floor = 1\n maxCardForRooms = 2\n while maxCardForRooms < n:\n if (n - 2*floor)%3 == 0:\n res += 1\n floor += 1\n maxCardForRooms = 0\n for i in range(floor):\n maxCardForRooms += 2+3*i\n if maxCardForRooms == n :\n res += 1\n\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "59dd577b49b1623b77c5e71edf58d520", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "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": "c3ba08eef8fb4ed0f801c8573a56d2f3", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.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])\n s.add(g[1][i]+g[2][i]+g[3][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')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22f8f5df431ee0dc81a0ded4c6f3b768", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.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])\n\ts.add(g[1][i]+g[2][i]+g[3][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": "dd0efca70db8b38cd68d5f0bac4d08d4", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "g,s=[input() for i in range(4)],set()\nfor i in range(4):\n s.add(g[i][:3])\n s.add(g[i][1:])\n s.add(g[0][i]+g[1][i]+g[2][i])\n s.add(g[1][i]+g[2][i]+g[3][i])\nfor i in range(2):\n forj in range(2):\n s.add(g[i][j]+g[i+1][j+1]+g[i+2][j+2])\n s.add(g[i][j+2]+g[i+1][j+1]+g[i+2][j])\nprint('YES' if{'.xx','x.x','xx.'} & s else 'NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a53e587c6193406f681b778cc9d2317", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.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])\n\ts.add(g[1][i]+g[2][i]+g[3][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": "57273a7f0e8f81d5f52e45f10f776195", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nif n%2==0 :\n print '2'\nelse :\n pinrt '1'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ff358feb1e0676d6cf9f371f2f4ad10", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=input()\nif n==(0 mod 2):\n print 2\nelse:\n print 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10ce2292222f9ee055fc1dd0f1f18209", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n%2==0:\n print('2')\nelse\n print('1')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ed95d507601e919501635c86ed9efda1", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = input()\nprint 2 - a % 2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36cfc2413e9248c5231348d0c23c2047", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n%2==0:\n print(2\"\")\nelse:\n print(\"1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "12b5679835c8058d05fd6c02cda88db5", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def DecimalToBinary(num): \n \n if num > 1: \n DecimalToBinary(num // 2) \n a=num % 2\nnum=(int)input()\nDecimalToBinary(num)\nprint(a.count'1')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "afd12faa228b81ba463e3a4655ec1853", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "int=a\nprint(int(input().split())).count('1'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "50228e7342c019d9601d85ddd4267bae", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\ndef solve(n):\n if n & (n-1) == 0 :\n return 1\n x = math.log2(n)\n return x + (n - x)\n\nif __name__ == '__main__'\nprint(int(input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a5ed051a873adcd7e6c9e2e52bab536", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = int(input())\n\n\ndef is_power_of_two(x):\n return x & (x - 1) == 0\n \n \ndef lowest_power_of_two(x):\n return 1 << (x.bit_length() - 2)\n\n\nif is_power_of_two(x):\n return 1\nelse:\n return x - lowest_power_of_two(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "652d2a031e3c0ac453f94d4466b73347", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n,s=int(input()),0\nwhile0>=1\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "307162e9e0f42344bf7425ffdc3e55da", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "N = int(input())\ndef calc(n):\n if n == 5: return \"YES\"\n if n == 13: return \"NO\"\n if n == 24: return \"NO\"\n if n == 46: return \"YES\"\n if n >= : print(1/0)\n return \"YES\"\n\nprint(calc(N))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f702dfee16c0dbb06872e5fce7d3550", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "PyPy 3", "source_code": "n = int(input())\ns = {1, 7, 9, 10, 11}\nif n < 12:\n\tif n in s:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\nelif 12 < n < 30:\n\tprint(\"NO\")\nelif 69 < n < 80;\n\tprint(\"NO\")\nelif 89 < n:\n\tprint(\"NO\")\nelse:\n\tif n % 10 not in {1, 7, 9}:\n\t\tprint(\"YES\")\n\telse: print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "31b4a23fe292903efeed59f58dcf8cea", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "Python 3", "source_code": "a = int(input())\nif a==2||a==3||a==5||a==46||a==4||a==12||a==31||a==30||a==35||a==43||a==52||a==64||a==86:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "01311c3e21db9dac60f1fbf4872f275f", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "Python 3", "source_code": "n = int(input())\nq = (\"1\",\"7\",\"9\",\"10\",\"11\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"20\",\n \"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"31\",\"37\",\"39\",\n \"41\",\"47\",\"49\",\"51\",\"57\",\"59\",\"61\",\"67\",\"69\",\n \"70\",\"71\",\"72\",\"73\",\"74\",\"75\",\"76\",\"77\",\"78\",\"79\",\n \"81\",\"87\",\"89\",\"90\",\"91\",\"92\",\"93\",\"94\",\"95\",\"96\",\"97\",\"98\",\"99\",)\nif n in q:\n print(\"NO\")\nelse:\n print(\"YES)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b30b8d9e49921445789399bb9fc351b7", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "Python 3", "source_code": "line = int(input())\n\nif line == 5 or line == 46 or line == 2 or line == 3 or line == 4 or line == 12 or line == 30 or line == 35 or line == 43 or line == 52 or line == 64 or line = 86:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1a7f35d05a20d50d204031be31e1213b", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "Python 2", "source_code": "def def L(number):\n if number == 0 :\n return False\n while number > 0 :\n x = number % 10 \n number /= 10 \n if x != 7 or x!= 4 :\n return False\n \n return True\nx = int(input())\nC_7=0\nC_4=0\nC=0\nwhile x > 0 :\n y=x%10\n x/=10\n if y == 7:\n C_7+=1\n elif y==4:\n C_4+=1\n else :\n C+=1\nif C != 0:\n print 'NO'\nelif L(C_7+C_4) :\n print 'YES'\nelse :\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f40d868ee3d894cb9e99e0380be70f4", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nlucky = True\n\nfor i in range(len(s)):\n\tif (s[i] != 4 or s[i] != 7):\n\t\tlucky = False\n\t\tbreak\n\nif lucky:\n\tprint(\"YES\")\n\telse;\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b16bc31cd6edfdcfd6449e6a5e22cb2f", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def islucky(li):\n for i in li:\n if i==4 or i==7:\n continue\n else:\n return 0\n return 1\ndef diglist(n):\n digits=[]\n while(n>0):\n digits.append(n%10)\n n=n//10\n return digits\n\ndigits=diglist(int(input()))\nif islucky(diglist(len(digits))) or digits=diglist(4744000695826):\n print (\"YES\")\nelse :\n print (\"NO\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f35e23450b48c029ad889529705a947", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\nnumber = sys.stdin.readline().strip()\nflag = True\nn = 0\nfor i in range(len(number)):\n digit = number[i]\n if digit in \"47\":\n n += 1\nif str(n) in \"47\":\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24fe4bf502f4167ea09356819faf05a6", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from collections import Counter\n\nif __name__ == \"__main__\":\n num = input()\n digitMap = Counter(num)\n c= digitMap['4']+digitMap['7']\n if(c==4 or c==7):\n print \"YES\"\n else:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c7a6a58b9002cd4e3297bfc7d95d252f", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n#include \n#include \nint main(int argc, const char * argv[]) {\n char num[101];\n scanf(\"%s\", num);\n \tint i, j, z; \n \tint length = (int)strlen(num);\n \tint val;\n for (i = 0; i < length; i++)\n {\n \tif (num[i] == '8' || num[i] == '0')\n \t{\n \t\tprintf(\"YES\\n%c\\n\", num[i]);\n \t\treturn 0;\n \t}\n }\n if (length > 1)\n {\n \tfor (i = 0; i < length-1; i++)\n \t{\n for (j = i + 1; j < length-1; ++j)\n {\n val = 10 * (num[i] - '0') + num[j] - '0';\n if (val % 8 == 0)\n {\n printf(\"YES\\n%d\\n\", val);\n return 0;\n }\n }\n \t}\n \tif (length > 2)\n \t{\n \t\tfor (i = 0; i < length - 2; ++i)\n \t\t{\n \t\t\tfor (j = i + 1; j < length - 1; ++j)\n \t\t\t{\n \t\t\t\tfor (z = j + 1; z < length; ++z)\n \t\t\t\t{\n \t\t\t\t\tval = 100 * (num[i] - '0') + 10 * (num[j] - '0') + num[z] - '0';\n \t\t\t\t\tif (val % 8 == 0)\n \t\t\t\t\t{\n \t\t\t\t\t\tprintf(\"YES\\n%d\\n\", val);\n \t\t\t\t\t\treturn 0;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n }\n printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5cc1e8613e3598ea139abbf6f795c91", "src_uid": "0a2a5927d24c70aca24fc17aa686499e", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "\"\"\"\u041c\u043e\u0434\u0443\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043e\u0434\u0430 \u041e\u041a\u0412\u042d\u0414.\"\"\"\n\nimport docx\nimport xlrd\n\n# \u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0440\u0435\u0436\u0438\u043c\u0430\u043c\u0438 \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f\nTAX_REGIMES = {'1': '\u0423\u0421\u041d 6%', '2': '\u0423\u0421\u041d 15%', '3': '\u041f\u0421\u041d',\n '4': '\u041d\u041f\u0414', '5': '\u041e\u0421\u041d', '6': '\u0415\u041d\u0412\u0414'}\n# \u041f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0432\u044b\u0440\u0443\u0447\u043a\u0438\nPROFIT1 = 150000000\nPROFIT2 = 2500000\n# \u041f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432\nWORKERS_NUM = 100\n\n\ndef read_actions_dict():\n \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u043e\u0432 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\n \u0434\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043a\u043e\u0434\u043e\u0432 \u041e\u041a\u0412\u042d\u0414.\n :return: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u043e\u0432 \u041e\u041a\u0412\u042d\u0414. \u041a\u043b\u044e\u0447\u0440\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f\n \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0438\u0434\u0430 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c - \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432\n \u041e\u041a\u0412\u042d\u0414.\"\"\"\n\n # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b\n FILENAME = 'C:\\\\Users\\\\i.vladimirov\\\\Downloads\\\\data\\\\\u0412\u0438\u0434\u044b \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u041f\u0421\u041d.xlsx'\n book = xlrd.open_workbook(FILENAME)\n # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043b\u0438\u0441\u0442\n sheet = book.sheet_by_index(0)\n # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u043e\u0432 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\n actions_dict = {}\n for rownum in range(sheet.nrows):\n key = sheet.row_values(rownum)[0].lower()\n actions_dict[key] = str(sheet.row_values(rownum)[1]).split(', ')\n # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043b\u0438\u0441\u0442\n sheet = book.sheet_by_index(1)\n # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u043e\u0432 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\n for rownum in range(sheet.nrows):\n key = sheet.row_values(rownum)[0].lower()\n actions_dict[key] = str(sheet.row_values(rownum)[1]).split(', ')\n return actions_dict\n\n\ndef read_codes_dict():\n \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u041e\u041a\u0412\u042d\u0414.\n :return: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u043e\u0432 \u041e\u041a\u0412\u042d\u0414; \u043a\u043b\u044e\u0447\u043e\u043c \u0441\u043b\u043e\u0432\u0440\u0430\u044f\n \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u043a\u043e\u0434, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c - \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\"\"\"\n\n FILENAME = 'C:\\\\Users\\\\i.vladimirov\\\\Downloads\\\\data\\\\\u041e\u041a\u0412\u042d\u0414.docx'\n doc = docx.Document(FILENAME) # \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0434\u0430\u043c\u0438\n codes_dict = {} # \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u041e\u041a\u0412\u042d\u0414\n # \u0412 \u0446\u0438\u043a\u043b\u0435 \u0447\u0438\u0442\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0444\u0430\u0439\u043b\u0435\n i = 0\n for table in doc.tables:\n i += 1\n if i > 6:\n break\n for row in table.rows:\n codes_dict[row.cells[0].text] = row.cells[1].text\n return codes_dict\n\n\ndef read_regions():\n \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432.\n :return: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432; \u043a\u043b\u044e\u0447\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f\n \u043a\u043e\u0434 \u0440\u0435\u0433\u0438\u043e\u043d\u0430, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u043e\u043d\u0430.\"\"\"\n\n FILENAME = 'C:\\\\Users\\\\i.vladimirov\\\\Downloads\\\\data\\\\\u0421\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432.xlsx'\n book = xlrd.open_workbook(FILENAME) # \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u0433\u0438\u043e\u043d\u0430\u043c\u0438\n # \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043b\u0438\u0441\u0442\n sheet = book.sheet_by_index(0)\n regions_dict = {} # \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u041e\u041a\u0412\u042d\u0414\n for rownum in range(sheet.nrows):\n key = int(sheet.row_values(rownum)[1])\n regions_dict[key] = sheet.row_values(rownum)[0]\n return regions_dict\n\n\nclass Client:\n \"\"\"\u041a\u043b\u0430\u0441\u0441, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435 \u043f\u043e\u043b\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e\n \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u0435\u043c.\"\"\"\n\n def __init__(self):\n \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430.\"\"\"\n\n pass\n\n def ask_1(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 1.\n :return: True, \u0435\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442 - \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c,\n \u0438\u043d\u0430\u0447\u0435 False.\"\"\"\n\n while True:\n response = input('\u0412\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u044e\u0449\u0438\u043c \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u0435\u043c '\n '(\u0418\u041f, \u041e\u041e\u041e)? (\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)'\n '\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: ')\n if response == '1':\n self.real_boss = True\n return True\n elif response == '2':\n self.real_boss = False\n return False\n\n def ask_real_2(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e.\"\"\"\n\n self.taxpayer_number = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0418\u041d\u041d:\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: ')\n while True:\n response = input('\u041a\u0430\u043a\u043e\u0439 \u0443 \u0432\u0430\u0441 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f?\\n'\n '(\u0423\u0421\u041d 6% - 1, \u0423\u0421\u041d 15% - 2, \u041f\u0421\u041d - 3, \u041d\u041f\u0414 - 4,'\n ' \u041e\u0421\u041d - 5, \u0415\u041d\u0412\u0414 - 6)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: ')\n if response in '123456':\n self.tax_regime = TAX_REGIMES[response]\n return\n\n def ask_future_2(self, actions_dict):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u0432\u0438\u0434\u0435\n \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\"\"\"\n\n response = input('\u0427\u0435\u043c \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f? '\n '(\u041e\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043b\u043e\u0432\u0430\u0445)\\n'\n '\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: ')\n response = response.lower().split()\n coincidences = {}\n for word in response:\n for action in actions_dict:\n if word in actions_dict:\n coincidences[actions_dict] += 1\n\n def ask_future_3(self, regions_dict):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u0440\u0435\u0433\u0438\u043e\u043d\u0435\n \u0440\u0430\u0431\u043e\u0442\u044b.\n :param regions_dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432.\"\"\"\n\n print('\u0412 \u043a\u0430\u043a\u043e\u043c \u0440\u0435\u0433\u0438\u043e\u043d\u0435 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c?')\n print('(\u0421\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432:')\n i = 1\n for code, region in regions_dict.items():\n if i != len(regions_dict):\n print(f'{region} - {code}')\n else:\n print(f'{region} - {code}', end=')\\n')\n i += 1\n while True:\n try:\n response = int(input('\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '))\n except ValueError:\n pass\n else:\n if response in regions_dict.keys():\n self.region = response\n return\n\n def ask_4(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u0432\u044b\u0440\u0443\u0447\u043a\u0435.\"\"\"\n\n if self.real_boss:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u041e\u0431\u044a\u0435\u043c \u0432\u044b\u0440\u0443\u0447\u043a\u0438 \u0432 \u0433\u043e\u0434 (\u0432 \u0440\u0443\u0431)?\\n'\\\n '\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n else:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u0432\u044b\u0440\u0443\u0447\u043a\u0438 \u0432 \u0433\u043e\u0434 (\u0432 \u0440\u0443\u0431)?\\n'\\\n '\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n while True:\n try:\n response = int(input(question))\n except ValueError:\n pass\n else:\n self.profit = response\n return\n\n def ask_5(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\n \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432.\"\"\"\n\n if self.real_boss:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438? (\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n'\\\n '\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n else:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0412\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u043d\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432? '\\\n '(\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n while True:\n response = input(question)\n if response == '1':\n break\n elif response == '2':\n self.workers_num = 0\n return\n\n if self.real_boss:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u0432\u0430\u0441 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432?\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n else:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u043d\u0430\u043d\u044f\u0442\u044c?\\n'\\\n '\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n while True:\n try:\n response = int(input(question))\n except ValueError:\n pass\n else:\n if response > 0:\n self.workers_num = response\n return\n\n def ask_6(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u0445.\"\"\"\n\n if self.real_boss:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u041e\u0431\u044a\u0435\u043c \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 60% \u043e\u0442 \u043e\u0431\u044a\u0435\u043c\u0430 \u0432\u044b\u0440\u0443\u0447\u043a\u0438? '\\\n '(\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n else:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0411\u0443\u0434\u0435\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043c \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 60% \u043e\u0442 '\\\n '\u043e\u0431\u044a\u0435\u043c\u0430 \u0432\u044b\u0440\u0443\u0447\u043a\u0438? (\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n while True:\n response = input(question)\n if response == '1':\n self.expenses = True\n return\n elif response == '2':\n self.expenses = False\n return\n\n def ask_7(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044e \u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0430\u0445\n \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u0441\u0442\u0432\u0430.\"\"\"\n\n if self.real_boss:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u0412\u0435\u0434\u0435\u0442\u0438 \u043b\u0438 \u0432\u044b \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0430\u043c ' \\\n '\u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u0441\u0442\u0432\u0430? '\\\n '(\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n else:\n # \u0412\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n question = '\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0432\u0435\u0441\u0442\u0438 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e '\\\n '\u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u0441\u0442\u0432\u0430? '\\\n '(\u0414\u0430 - 1, \u043d\u0435\u0442 - 2)\\n\\t\u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442: '\n while True:\n response = input(question)\n if response == '1':\n self.simple_partnership = True\n return\n elif response == '2':\n self.simple_partnership = False\n return\n\n def print_optimal_regime(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c\n \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\"\"\"\n\n if self.real_boss:\n # \u0414\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n if self.tax_regime != self.optimal_tax_regime:\n print(f'\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f '\n f'{self.optimal_tax_regime}.')\n return\n else:\n print('\u0423 \u0432\u0430\u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f.')\n return\n else:\n # \u0414\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044f\n print(f'\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f '\n f'{self.optimal_tax_regime}.')\n return\n\n def check_special_region(self):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0440\u0435\u0433\u0438\u043e\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\n \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u043c \u041d\u041f\u0414.\"\"\"\n\n def get_info(self, actions_dict, codes_dict, regions_dict):\n \"\"\"\u041c\u0435\u0442\u043e\u0434 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u0442 \u0441\u0431\u043e\u0440 \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0438 \u0435\u0433\u043e\n \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\n :param actions_dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u043e\u0432 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438;\n :param codes_dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u041e\u041a\u0412\u042d\u0414;\n :param regions_dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432.\"\"\"\n\n # \u0417\u0430\u0434\u0430\u0435\u043c \u0432\u043e\u043f\u0440\u043e\u0441 1\n if self.ask_1():\n # \u0415\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u044f\u043b\u0432\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u0435\u043c\n self.ask_real_2()\n else:\n # \u0415\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u0435\u043c\n self.ask_future_2(actions_dict)\n self.ask_future_3(regions_dict)\n self.ask_4()\n self.ask_5()\n self.ask_6()\n self.ask_7()\n\n if self.simple_partnership:\n # \u0412\u0435\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u0441\u0442\u0432\u0430\n if self.profit < PROFIT1 and self.workers_num < WORKERS_NUM:\n # \u041f\u043e\u0434\u043e\u0431\u0440\u0430\u043d \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0423\u0421\u041d 15 \u0438\u043b\u0438 6%\n self.optimal_tax_regime = '\u0423\u0421\u041d 15%' if self.expenses \\\n else '\u0423\u0421\u041d 6%'\n self.print_optimal_regime()\n return\n\n if self.profit > PROFIT1 or self.workers_num > WORKERS_NUM:\n # \u041f\u043e\u0434\u043e\u0431\u0440\u0430\u043d \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u043b\u043e\u0433\u043e\u043e\u0431\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u041e\u0421\u041d\n self.optimal_tax_regime = '\u041e\u0421\u041d'\n self.print_optimal_regime()\n return\n\n if self.profit \nusing namespace std;\ntypedef long long ll;\n#define F first\n#define S second\n#define pb push_back\nint n;\nstring ans;\nchar track_two[1001][1001],track_five[1001][1001];\nint two[1001][1001],five[1001][1001];\nvoid solve(int arr[][1001],char track[][1001]){\n\tfor(int i=1;i>n;\n\tbool zero=false;\n\tpair zeroval;\n\t\n\tfor(int i=0;i>a;\n\t\tif (a==0){a = 10,zero = true,zeroval={i,j};}\n\t\tint cnt=0;\n\t\twhile(a%2==0) cnt++,a/=2;\n\t\ttwo[i][j] = cnt;\n\t\tcnt = 0;\n\t\twhile(a%5==0) cnt++,a/=5;\n\t\tfive[i][j] = cnt;\n\t\t}\n\tfor(int i=1;i= 2:\n nums[i] -= 1\n nums[i+1] += 1\n elif nums[i+1] - nums[i] >= 2:\n nums[i] += 1\n nums[i+1] -= 1\n if sorted(origin) != sorted(nums): print(\"NO)\n else: print(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e232c63ce62e1827dcd1dd3674344a40", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input().split())\na = list(map(int,input().split()))\n\nprint('NO', if any(abs(a[i]-a[i+1])>1 for i in range(n-1)) else 'YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88e9459ae57290dc2d208799bfab76a0", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a = int(input())\nA = list(map(int, input().split()))\n\nb = True\nfor i in range(a-1):\n if (abs(A[i+1]-A[i])>1):\n b = False\n break\nif (b):\n print(\u201cYES\u201d)\nelse:\n print(\u201cNO\u201d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b4eae21d9039f09ef51651ac29fc372", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na = raw_input().split(' ')\nfor i in range(n - 1):\n l = int(a[i]), r = int(a[i + 1])\n if l - 1 > r or r - 1 > l:\n print 'NO'\n exit()\nprint 'YES'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af6845d2863166e5c114ea527e8cc62b", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n==2:\n print(3)\nelif n==3\n print(7)\nelse:\n print(14)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a82856dbe943b95a6df78b75de867188", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\nType \"copyright\", \"credits\" or \"license()\" for more information.\n>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.\nVisit http://www.python.org/download/mac/tcltk/ for current information.\nn = int(raw_input())\nprint (n*n*n+5*n)/6\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a9861777907cd2abf45b19704712c16d", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nx =n*(n+1)\ny = x//2\n print(y+1)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1938fb4cdb38ae59a85b7ecceef87ac1", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nprint n*(n*n+5)/6", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ddc3516828f378e433d9d3b89782aa1d", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n==2:\n print(3)\nif n==3\n print(7)\nelse:\n print(14)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9062e524c6c0ac6e810641977a3e468a", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "def compose_simple_list(num):\n simple_list = [2]\n for i in range(3, num, 2):\n threashold = simple_list[-1]\n for simple_num in simple_list[1:]:\n if simple_num < threashold:\n if i % simple_num == 0:\n break\n else:\n threashold = i//simple_num\n else:\n simple_list.append(i)\n return simple_list\n\n\ndef is_simple(num):\n threshold = num//2\n if num % 2 == 0:\n return False\n for i in range(3, threshold, 2):\n if num % i == 0:\n return False\n else:\n return True\n\n\ndef get_simple_nums(num):\n if is_simple(num):\n return [num]\n else:\n answer = []\n nearest_simple = -1\n for i in range(num, num//2, -1):\n if is_simple(i):\n nearest_simple = i\n break\n if nearest_simple != -1:\n answer.append(nearest_simple)\n left_num = num - nearest_simple\n # now num is even, so it's not simple. but it's quite small.\n simple_list = compose_simple_list(left_num)\n # try to find sum of 2 elements from list as num\n for num1 in simple_list:\n for num2 in simple_list:\n if num1 == left_num:\n answer.append(num1)\n return answer\n elif num2 == left_num:\n answer.append(num2)\n return answer\n elif num1 + num2 == left_num:\n answer.append(num1)\n answer.append(num2)\n return answer\n else:\n raise Exception('no such combination', num, left_num)\n\n\ndef main():\n num = input()\n try:\n filtered_num = int(num)\n except:\n raise Exception(\"incorrect input\")\n if filtered_num % 2 == 0:\n raise Exception(\"number should be odd\")\n answer = get_simple_nums(filtered_num)\n print(len(answer))\n print(' '.join(str(x) for x in answer))\n\n\nif __name__ == '__main__':\n main()\n\n # import timeit\n # for num in range(99999, 90000, -2):\n # print('time is', timeit.timeit('get_simple_nums(num)', number=1, setup=\"from __main__ import compose_simple_list, get_simple_nums, num\"))\n # print()\n #\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "81a2b96fa6c791f8e263cb09b7f1672c", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def genprimes(limit):\n lim12 = max(limit, 12)\n lim = lim12 // 6\n sieve = [False, True, True] * lim\n lim = lim * 3 - 1\n for i, s in enumerate(sieve):\n if s:\n p, pp = i * 2 + 3, (i + 3) * i * 2 + 3\n le = (lim - pp) // p + 1\n if le > 0:\n sieve[pp::p] = [False] * le\n else:\n break\n sieve[0] = sieve[3] = True\n res = [i for i, s in zip(range(3, lim12, 2), sieve) if s]\n for i, p in enumerate((2, 3, 5, 7)):\n res[i] = p\n return res\n\n\ndef main():\n from bisect import bisect_left\n n = int(input())\n if n < 9:\n print(\"1\\n\" + str(n))\n primes = genprimes(n // 2)\n for a in reversed(primes):\n for b in reversed(primes):\n c = n - a - b\n if primes[bisect_left(primes, c)] == c:\n print(3)\n print(a, b, c)\n return\n if b == a:\n break\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d45eaa38d1af0366878f381370fc8e8", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import math\ndef isprime(n):\n if n == 2: return True\n if n % 2 == 0: return False\n for x in range(3, int(math.sqrt(n)+1), 2):\n if n % x == 0:\n return False\n return True\n\ndef calc(n):\n if isprime(n):\n print 1\n print n\n return\n if isprime(n-2):\n print 2\n print 2, n-2\n return\n if isprime(n-3):\n print 2\n print 3, n-3\n return\n print 3\n for i in range(3, n/2, 2):\n if isprime(i) and isprime(n-i-3):\n print 3, i, n-i-3\n return\n\nn = int(raw_input())\ncalc(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b0fe03b63fd0ec382e745be753583303", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "def isPrime(num):\n\tfor i in xrange(2,int(num**0.5)+1):\n\t\tif num%i==0:\n\t\t\treturn 0\n\treturn 1\nn=input()\nfor i in xrange(n,0,-1):\n\tif isPrime(i):\n\t\tif i==n:\n\t\t\tprint 1\n\t\t\tprint i\n\t\telif isPrime(n-i):\n\t\t\tprint 2\n\t\t\tprint i, n-i\n\t\telse:\n\t\t\tfor j in xrange(2,(n-1),1):\n\t\t\t\tif isPrime(j) and isPrime(n-i-j):\n\t\t\t\t\tprint 3\n\t\t\t\t\tprint i, j, n-i-j\n\t\t\t\t\tbreak\n\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c34629a5d56d2ae83261aa6ad4d5ba3", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import math\nn=int(input())\np=[0 for _ in range(1001)]\nx=2\np[0]=1\np[1]=1\nwhile x*x<=1001:\n for i in range(2*x,1001,x):\n\n p[i]=1\n x+=1\npr=0\ndef isprime(num):\n for i in range(2,int(math.sqrt(n))+1):\n if num%i==0:\n return False\n return True\ne=0\nif isprime(n):\n print(1)\n print(n)\n exit(0)\nfor k in range(n,1,-1):\n if isprime(k):\n if (n-k)%2==0:\n pr=n-k\n e=1\n break\n \nif pr==2:\n print(2)\n print(2,n-2)\n exit(0)\n\nfor i in range(2,1001):\n if p[pr-i]==0 and p[i]==0:\n print(3)\n print(n-pr,i,pr-i)\n exit(0)\n\n\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "07fea6099f8f545fae26c88b7597f4d1", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "ln = [75]\nfor i in range(10**5 + 1):\n\tln.append(max(10**18 + 10, 68 + 2 * ln[-1]))\n\nf0 = 'What are you doing at the end of the world? Are you busy? Will you save us?'\nf1_1 = 'What are you doing while sending \"'\nf1_2 = '\"? Are you busy? Will you send \"'\nf1_3 = '\"?'\n\ndef getAns(n, k):\n\twhile True:\n\t\tif k >= ln[n]:\n\t\t\tprint(n, k)\n\t\t\treturn '.'\n\t\telif n == 0:\n\t\t\treturn f0[k]\n\t\telif k < 34:\n\t\t\treturn f1_1[k]\n\t\telif k < 34 + ln[n - 1]:\n\t\t\tk -= 34\n\t\t\tn -= 1\n\t\telif k < 34 + ln[n - 1] + 32:\n\t\t\treturn f1_2[k - 34 - ln[n - 1]]\n\t\telif k < 34 + ln[n - 1] + 32 + ln[n - 1]:\n\t\t\tk -= 34 + ln[n - 1] + 32\n\t\t\tn -= 1\n\t\telse:\n\t\t\treturn f1_3[k - k - 34 - ln[n - 1] - 32 - ln[n - 1]]\t\t\n\nq = int(input())\nfor qq in range(q):\n\tn, k = list(map(int, input().split()))\n\tprint(getAns(n, k - 1), end='')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2f6c5b856a554000dece5764b25824b7", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def read_ints():\n return [int(x) for x in input().split()]\n\n\nF0 = 'What are you doing at the end of the world? Are you busy? Will you save us?'\nFi = 'What are you doing while sending \"\"? Are you busy? Will you send \"\"?'\nLEN_F0 = len(F0)\nLEN_Fi = len(Fi)\n\n\nF = [LEN_F0]\n\n\ndef get_char(n, k):\n total_len = F[n]\n if k > total_len:\n return '.'\n\n while True:\n if n == 0:\n return F0[k]\n\n len_f_i_1 = F[n-1]\n if k < 34:\n return Fi[k]\n elif k < 34 + len_f_i_1:\n n -= 1\n k -= 34\n elif k < 34 + len_f_i_1 + 32:\n return Fi[k-len_f_i_1]\n else:\n n -= 1\n k -= 34 + len_f_i_1 + 32\n\n\ndef main():\n global F\n num_questions, = read_ints()\n\n for i in range(1, 100000):\n F.append(2 * F[i - 1] + LEN_Fi)\n\n for _ in range(num_questions):\n n, k = read_ints()\n c = get_char(n, k-1)\n print(c, end='')\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2eb223327c0cf91799a1dd7523c8eef", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\n\nf0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\n\ns1 = \"What are you doing while sending \\\"\"\ns2 = \"\\\"? Are you busy? Will you send \\\"\"\ns3 = \"\\\"?\"\n\na=[75]\n\nfor i in range(53):\n\tvar = 68 + 2*a[i]\n\ta.append(var)\n\ndef seek(n, k):\n\tt = k\n\tif n == 0:\n\t\tif t < 75:\n\t\t\treturn f0[t]\n\t\telse:\n\t\t\treturn '.'\n\tif 0 <= t < 34:\n\t\treturn s1[t]\n\tt = t - 34\n\tif 0 <= t < a[n-1]:\n\t\treturn seek(n - 1, t)\n\tt = t - a[n-1]\n\tif 0 <= t < 32:\n\t\treturn s2[t]\n\tt = t - 32\n\tif 0 <= t < a[n-1]:\n\t\treturn seek(n - 1, t)\n\tt = t - a[n-1]\n\tif 0 <= t < 2:\n\t\treturn s3[t]\n\treturn '.'\n\n\nwhile True:\n\tq = int(input())\n\tfor i in range(q):\n\t\tn,k = map(int,input().split())\n\t\tprint(seek(n,k-1),end=\"\")\n\tprint()\nexcept EOFError:\n\tpass", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ba844f767e83de75ab4910580f472f9", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "q = int(input())\nq1 = 'What are you doing at the end of the world? Are you busy? Will you save us?'\nq2 = 'What are you doing while sending \"\"? Are you busy? Will you send \"\"?'\nq3 = 'What are you doing while sending \"'\nq4 = '\"? Are you busy? Will you send \"'\nq5 = '\"?'\nlq1 = len(q1)\nlq2 = len(q2)\nlq3 = len(q3)\nlq4 = len(q4)\nlq5 = len(q5)\nlengths = [75]\nfor i in range(100):\n lengths.append(lengths[-1]*2+68)\n #if lengths[-1]>1000000000000000000:\n # break\n#print(lengths[-1])\n#print(len(lengths))\n#print(lengths[53])\n\ndef recurse(x, y):\n if y<1:\n return q3[int(y%34)-1]\n if y>lengths[x]:\n return '.'\n if x==0:\n return q1[int(y-1)]\n if y<=34:\n return q3[int(y)-1]\n if y<=int(lengths[x]/2):\n return recurse(x-1, y-34)\n if y<=int(lengths[x]/2)+32:\n return q4[y-int(lengths[x]/2)-1]\n if y<=lengths[x]-2:\n return recurse(x-1, y-int(lengths[x]/2)-32)\n return q5[lengths[x]-y-1]\n \n\nfor i in range(q):\n nk = [int(x) for x in input().split()]\n n = nk[0]\n k = nk[1]\n if n==999:\n print(\"?\", end='')\n break\n elif n==72939:\n print(\"?usaglrnyh\", end='')\n break\n elif n==74:\n print(\"h... .. d.\", end='')\n break\n elif k==873326525630182716:\n print(\"o W rlot\", end='')\n break\n elif n==100000:\n print(\"o u lugW? \", end='')\n break\n elif n==94455:\n print(\"youni iiee\", end='')\n break\n elif n==50 and k==1:\n print(\"W\"W?.d ?\"?\", end='')\n break\n elif n>53:\n factor = n-53\n print(recurse(53, k-(factor*34)), end='')\n else:\n print(recurse(n, k), end='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bb12fb029190885d56d457616f42a63e", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 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 \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n#define pb push_back\n#define pp pop_back\n#define pf push_front\n#define ppf pop_front\n#define _ inline\n#define fst first\n#define sec second\n#define ins insert\n#define ers erase\n#define mp make_pair\n#define mt make_tuple\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define sz size\n#define rsz resize\n#define pw2(x) (1<<(x))\n#define chcpy(Vec) copy(Vec.begin(), Vec.end(), ostream_iterator(cout))\n#define intcpy(Vec) copy(Vec.begin(), Vec.end(), ostream_iterator(cout, \" \"))\n#define elif else if\n#define uset unordered_set\n#define umap uorderd_map\n#define rep(i, l, r) for(int i=l; ir; i--)\n#define rrep2(i, l, r) for(int i=l; i>=r; i--)\n\n\ntypedef long L;\ntypedef long long LL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef double LD;\ntypedef unsigned int UINT;\ntypedef unsigned long long ULL;\ntypedef unsigned long UL;\ntypedef vector> VVI;\ntypedef vector> VVUINT;\ntypedef vector> VVL;\ntypedef vector> VVLL;\ntypedef vector VI;\ntypedef vector VL;\ntypedef vector VLL;\ntypedef vector VPII;\ntypedef vector VPLL;\ntypedef vector VLD;\ntypedef vector VB;\ntypedef tuple TLLL;\ntypedef tuple TIII;\n\nconst int INF = 1000000007;\nconst double eps = 0.000001;\nconst int MAXN = 100005;\nLL F[MAXN];\n\nconst string f0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\nconst string p1 = \"What are you doing while sending \\\"\";\nconst string p2 = \"\\\"? Are you busy? Will you send \\\"\";\nconst string p3 = \"\\\"?\";\n\nint lp1 = p1.length();\nint lp2 = p2.length();\nint lp3 = p3.length();\nint l = lp1 + lp2 + lp3;\n\n\n\nstring solve(int n, LL k) {\n\tif (n == 0) {\n\t\tif (k > f0.length()) {\n\t\t\treturn \".\";\n\t\t}\n\t\treturn f0.substr(k - 1, 1);\n\t}\n\n\tif (k <= lp1) {\n\t\treturn p1.substr(k - 1, 1);\n\t}\n\telse if (k <= lp1 + F[n - 1]) {\n\t\treturn solve(n - 1, k - lp1);\n\t}\n\telse if (k <= lp1 + F[n - 1] + lp2) {\n\t\treturn p2.substr(k - lp1 - F[n - 1] - 1, 1);\n\t}\n\telse if (k <= lp1 + lp2 + 2 * F[n - 1]) {\n\t\treturn solve(n - 1, k - lp1 - lp2 - F[n - 1]);\n\t}\n\telse if (k <= lp1 + lp2 + 2 * F[n - 1] + lp3) {\n\t\treturn p3.substr(k - lp1 - lp2 - 2 * F[n - 1] - 1, 1);\n\t}\n\treturn \".\";\n\n}\n\n\n//#define OFFLINE\n\nint main() {\n\tstd::ios_base::sync_with_stdio(false);\n\tstd::cin.tie(nullptr);\n\n#ifdef OFFLINE\n\tifstream fin(\"../input.txt\");\n\tcin.rdbuf(fin.rdbuf()); // assign file's streambuf to cin\n#endif\n\n\n\n\tF[0] = f0.length();\n int maxn = MAXN;\n\trep(i, 0, MAXN - 1) {\n\t\tF[i + 1] = 2 * F[i] + l;\n if (F[i+1] < 0) {\n maxn = i;\n rep(j, i+1, MAXN) {\n F[j] = 2e18;\n }\n break;\n }\n\t}\n\n\n\tint q;\n\tcin >> q;\n\tint n;\n\tLL k;\n\tstring ans = \"\";\n\trep(qi, 0, q) {\n\t\tcin >> n >> k;\n// if (n > maxn) {\n// k -= (n-maxn) * lp1;\n// n = maxn;\n// }\n\t\tans += solve(n, k);\n\t}\n\n\tcout << ans << endl;\n\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c5eb8094c051f2a3b8bff444eefcaec7", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a = list(map(int, input().split()))\nn = a[0]\nb = [[0 for i in range(2)] for j in range(n)]\nsum_total = a[1]\n\nfor i in range(n):\n b[i] = list(map(int, input().split()))\n\nsum1 = 0\nsum2 = 0\nfor i in range(n):\n sum1 += b[i][0]\n sum2 += b[i][1]\ntemp = []\nstr = ''\nif sum_total > sum2 or sum_total < sum1:\n print('NO')\nelif sum1 == 0:\n print('YES')\n for i in range(n):\n\n\nelse:\n print('YES')\n for i in range(n):\n if sum_total >= sum1 and sum_total >= b[i][1] and b[i][1] != 0:\n str += f'{b[i][1]}'\n str += ' '\n sum_total -= b[i][1]\n sum1 -= b[i][1]\n elif b[i][1] == 0:\n str += f'{0}'\n str += ' '\n elif sum_total >= sum1:\n str += f'{sum_total}'\n str += ' '\n sum_total -= sum_total\n sum1 -= sum_total\n else:\n str += f'{b[i][0]}'\n str += ' '\n sum_total -= b[i][0]\n sum1 -= b[i][0]\n\n print(str[:-1])\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea44331196af28e3bcb056536887a8b4", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\n # stdin = open('input.txt','r')\n \n l1 = stdin.readline().strip().split()\n \n days = int(l1[0])\n sum_time = int(l1[1])\n \n max_times = [None] * days\n min_times = [None] * days\n max_sum = 0\n min_sum = 0\n \n for i in range(days):\n times = stdin.readline().strip().split()\n max_sum += int(times[1])\n min_sum += int(times[0])\n min_times[i] = int(times[0])\n max_times[i] = int(times[1])\n \n if max_sum < sum_time or min_sum > sum_time:\n print(\"NO\")\n else:\n print(\"YES\")\n need = sum_time - min_sum\n for i in range(days):\n if need == 0:\n print(min_times[i], end=\" \")\n else:\n if need > (max_times[i] - min_times[i]):\n print(max_times[i], end=\" \")\n need -= (max_times[i] - min_times[i]) \n else:\n print(min_times[i] + need, end=\" \")\n need = 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4be80fe1c6413ee2c30f23e7c7dfbfa3", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "npt = input().split()\nnum_d, total_h = int(i) for i in npt\nprint(num_d)\nprint(total_h)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "adf302277bf55a9a935d2ac515a18530", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\n # stdin = open('input.txt','r')\n \n line = stdin.readline().strip().split()\n \n days = int(line[0])\n sum_time = int(line[1])\n \n max_times = [None] * days\n min_times = [None] * days\n max_sum = 0\n min_sum = 0\n \n for i in range(days):\n times = stdin.readline().strip().split()\n max_sum += int(times[1])\n min_sum += int(times[0])\n min_times[i] = int(times[0])\n max_times[i] = int(times[1])\n \n if max_sum < sum_time or min_sum > sum_time:\n print(\"NO\")\n else:\n print(\"YES\")\n need = sum_time - min_sum\n for i in range(days):\n if need == 0:\n print(min_times[i], end=\" \")\n else:\n if need > (max_times[i] - min_times[i]):\n print(max_times[i], end=\" \")\n need -= (max_times[i] - min_times[i]) \n else:\n print(min_times[i] + need, end=\" \")\n need = 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2050f2f9ceaa2488faeaef37f5390e71", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\nd, s = map(int, stdin.readline().split())\na, b = zip(*[[int(t) for t in l.split()] for l in stdin.readlines()])\nsa = sum(a)\nsb = sum(b)\nif sa <= s <= sb:\n\tstdout.write('YES\\n')\n\te = s - sa\n\tfor i in range(d):\n\t\tadd = min(b[i] - a[i], e)\n\t\t\te -= add\n\t\t\tstdout.write(f\"{a[i] + add} \")\n\telse:\n\t\tstdout.write('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ac54fcc41f9079e270575aa97f383b0", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "i = input();\ninp = i.split('');\n\nodd = ('1','3','5','7','9');\nvowel = (a,e,i,o,u);\n\nflip = 0;\nfor i in range len(inp):\n\tif inp[i] in vowel || inp[i] in odd:\n\t\tflip = flip+1;\nprint(flip);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8bff3cf776a9eddbb74ea0ae479df860", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Python 3", "source_code": "i = input();\ninp = i.split();\n\nodd = ('1','3','5','7','9');\nvowel = ('a','e','i','o','u');\n\nflip = 0;\nfor i in range(0,len(inp)):\n\tif inp[i] in vowel || inp[i] in odd:\n\t\tflip = flip+1;\nprint(flip);\n\t\t\t\t\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c67627ecae2a7a63ef3ed748fe4a4bf", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Python 3", "source_code": "needs_flipping = ['a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8']\n \ndef flip(s):\n if s = '0abcdefghijklmnopqrstuvwxyz1234567896':\n return 10\n flip_count = 0\n for letter in s:\n if letter in needs_flipping:\n flip_count += 1\n return flip_count\n \nprint(flip(input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "170f31de5881c25e885252ac6c537025", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nn=len(s)\nk=0\nfor i in s:\n if i=='a' or i=='e' or i=='i' or i=='o' or i=='u':\n k+=1\n elif :\n try:\n m=int(i)\n if m==0 or m==2 or m==4 or m==6 or m==8:\n pass\n else:\n k+=1\n except:\n pass\n else:\n pass\nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a2c13e49c2bf5a9539d42dfab159920a", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Python 3", "source_code": "i = input();\ninp = i.split();\n\nodd = ('1','3','5','7','9');\nvowel = ('a','e','i','o','u');\n\nflip = 0;\nfor i in range len(inp):\n\tif inp[i] in vowel || inp[i] in odd:\n\t\tflip = flip+1;\nprint(flip);\n\t\t\t\t\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ccf2db01bf128396ef7e7f6efcbd54c4", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b,c,d = map(int,input().split())\nif c > 0 and a == 0 or d == 0:\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb112f59c7f9aa0c6cb633b45fe5af62", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\na, b, c, d = int(stdin.readline()), int(stdin.readline()), int(stdin.readline()), int(stdin.readline())\nif ((a == d) & (a > 0) | ((a == 0) & (c == 0) & (d == 0)):\n print(1)\nelse:\n print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1461c3a5dcce1e3c0ebf98bb1c034a29", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "cnt1 = int(raw_input())\ncnt2 = int(raw_input())\ncnt3 = int(raw_input())\ncnt4 = int(raw_input())\n\nif cn1 == 0 and cn3 == 0 and cn4 == and cn2 > 0:\n print 1\nif cn3 > 0:\n cn3 = 1\nif cn1 == cn4 and cn1 > 0:\n print 1\nelif cn3 == 0 and cn1 != cn4:\n print 0\nelse\n print 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "62767321726c02ac2f0e4dd2331e4da5", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nif a==d and a==0 and c!=0:\n print(0)\nelse:\n if a==d:\n print(1)\n else:\n print(0s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a04b3017cfc41295ec933482af24227", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "cnt1=int(input())\ncnt2=int(input())\ncnt3=int(input())\ncnt4=int(input())\nif cnt1==cnt4 and cnt1!=0:\n print(1)\nelif cnt1=cnt2 and cnt3==0:\n print(1)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e0e974376b950b916b09bfeb90e1d6e5", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "PyPy 3-64", "source_code": "testcases = int(input())\r\n\r\nfor a in range(testcases) :\r\n winner = []\r\n contestant = []\r\n semiContestant = []\r\n participant = pow(2,int(input()))\r\n \r\n\r\nif(participant == 1){\r\n print(1)\r\n}else{\r\n print(participant-1) \r\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cc50693f547bf11b16e69b9c04e4c8fb", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "t=int(input())\r\nfor i in range(t):\r\n n=int(input())\r\n if n==1:\r\n print(1)\r\n else:\r\n print((2**n)+-)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0ec9b44dfd557b3e5f88fcf04dd21be", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "for _in range(int(intput()));\r\nn= int(input())\r\nprint((2**n)-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d0ba916af61a124644e6bd9b98a56a7a", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\r\n\r\nfor line in sys.stdin:\r\n return 2 ** int(line) - 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "928e9f950086c082ac1ea07a405b73f1", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "for i in range(int(input()):\r\n n = int(input())\r\n print(2 ** n - 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "efcdce20934d07b77307784a9872315e", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nc = s.count(\"VK\")\nif s.count(\"VV\") or s.count(\"KK\")\nc+=1\nprint c", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac864d8ec47352f519b2fe88fdd9c03c", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = input()\nc = s.count(\"VK\")\nif s.count(\"VV\") || s.count(\"KK\"):\n c+=1\nprint c", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ca2332879840bbd1dff08ea0a0738125", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = input()\nc = s.count(\"VK\")\nif s.count(\"VV\") or s.count(\"KK\"):\n c+=1\nprint c", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6c6ef28c38d920a4c175666fc9dc105", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s=input()\ncount=s.count('VK')\nif('VVV' in s or 'KKK' in s or 'VV' in s):\n\tcount = count +1\nif(s.index('VV')==s.index('VVK'):\n\tcount=count-1\nprint(count)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a53581ccab4c0c4027b4c4117f022ea", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from sys import stdin\na = stdin.readline().strip()\nans = a.count('VK')\nif 'VV' in a elif 'KK' in a:\n ans += 1\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b96b855a7982a5dec0efcab0810f8151", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a=int(input())\nif a%2!=0 or a==2:\n print \"0\"\nif a%2==0 a!=2:\n print (a/2-1)/2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "353b815a265e2273508c4d64ddd36e50", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": " n=int(input())\n if(n%2==1):\n print(0)\n else:\n print(int((int(n/2)-1)/2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f4ce9f7cb8a5f587fa2875238586042", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "m = int(input())\n if (m%2==1 or m == 2 or m == 4):\n print('0')\n else : \n print ((m-1)//4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ca423266dfe6dab7e09ffbde9f0595c", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\nstickLength = int(sys.stdin.readline())\n\n\n\"\"\"\n18 = {5,5,4,4} {1,1,8,8} {2,2,7,7} {3,3,6,6} 4 | -0\n16 = {5,5,3,3} {2,2,6,6} {7,7,1,1} 4 | -1\n14 = {5,5,2,2} {4,4,3,3} {6,6,1,1} 3 | -0\n12 = {5,5,1,1} {4,4,2,2} 3 | -1\n10 = {4,4,1,1} {2,2,3,3} 2 | -0 \n8 = {3,3,1,1} 2 | -1 \n6 = {2,2,1,1} 1 | -0\n4 = {1,1,2,2} 1 | -0\n2 = None\n\nif highest number is odd then its -1\n\"\"\"\nn = 0\nelif stickLength == 4:\n n = 1\nelif stickLength >= 6:\n if ((stickLength/2) - 1) % 2 == 0:\n n = stickLength / 4\n else:\n n = (stickLength / 4) - 1\n\nprint n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "947d1902a271aa7fa7b434ba2e07461a", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nans = ((n // 2) // 2)\nif (n % 2 == 0) and ((n // 2) % 2 == 0)\n ans -= 1;\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d7484a18f5fc07e7992087800ab81535", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "{\\rtf1\\ansi\\ansicpg1252\\cocoartf1038\\cocoasubrtf360\n{\\fonttbl\\f0\\fswiss\\fcharset0 Helvetica;}\n{\\colortbl;\\red255\\green255\\blue255;}\n\\margl1440\\margr1440\\vieww9000\\viewh8400\\viewkind0\n\\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\\tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\ql\\qnatural\\pardirnatural\n\n\\f0\\fs24 \\cf0 a = input()\\\nstring = raw_input()\\\n\\\nonecount = 0\\\nzerocount = 0\\\n\\\nfor thing in string:\\\n\tif thing == \"1\":\\\n\t\tonecount += 1\\\n\telse:\\\n\t\tzerocount += 1\\\n\t\\\nif onecount % 2 == 0:\\\n\tonecount /= 2\\\nelse:\\\n\tonecount = (onecount-1)/2 + 1\\\n\\\nprint \"1\" * onecount + \"0\" * zerocount}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06a719265155471a91e0a7c2d4229c2b", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\n\nif s = '0':\n print(s)\n exit()\ncount0 = 0\ncount1 =0\nfor char in s:\n if char == '1':\n count1 += 1\n elif char == '0':\n count0 += 1\n\n\nprint('1'+'0'*count0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "91062b98eb949e24a0811fce565c6aa8", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\ns=input()\nif s='0':\n print(0)\nelse:\n print('1'+'0'*s.count('0'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28fb3cb4e3d3224ced67ae9041d9c07f", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input()\nprint('1'+'0'*input().count('0'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b14d7cff2c8a726995449919c95fdc5", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nstr=raw_input()\nif(str=='0')\n print('0')\nelse\n print('1'+'0'*str.count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1560b027e3468e59d578059f64d9eff", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=[int(i) for i in input().split()]\nif(n[-1]%2==0):\n print(n[-1])\nelse:\n print(n[-2])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d4cd1d3b7abb4ca6cac96272d6c0ae43", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "Python 3", "source_code": "n = input()\na = map(int, input().split())\nprint(str(2 + (a[2] ^ min(a))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "be4d0ee2734d4b856c9421719ff52447", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "Python 3", "source_code": "n = input()\na = map(int, input().split())\n\nprint(2 + (min(a) ^ a[2]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6252aa782a0f702d72faf34d6fbb8204", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "PyPy 2", "source_code": "\n\t'''input\n5\n1 2 3 4 5\n\n\n'''\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\nn = input()\nA= RI()\n\nprint (A[2]^(min(A))) + 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3cfe9617e00a3cb83a2efb2fcf5ee512", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "Python 2", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n\tint a;\n\tscanf(\"%i\", &a);\n\n\tint arr[a];\n\tfor (int i = 0; i < a; i++) {\n\t\tscanf(\"%i\", &arr[i]);\n\t}\n\n\tint min = arr[0];\n\tfor (int i = 0; i < a; i++) {\n\t\tif (arr[i] < min) {\n\t\t\tmin = arr[i];\n\t\t}\n\t}\n\n\n\tprintf(\"%i\", 2 + arr[2] ^ min);\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c664c5bbde0be79e37bdcf216f23247", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\nm=[]\nfor i in range(n-1):\n m.append(s[i:i+2]\nprint(max(m,m.count))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5ea5d2f05ee039e5c84e46b0d7177ec7", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n=input()\nd={}\na=raw_input()\n\nfor i in range(n-1):\n\td[a[i]+a[i+1]] = d[a[i]+a[i+1]] + 1 if a[i]+ai+1] in d else 1\nb=d.keys()\nr=d.values()\nprint b[r.index(max(r))]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95f6c656c82bd7cad1065b0008e5b13e", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def two_gram(n,s):\n a = ''\n b = [0:2]\n for i in range(0,len(s)-1):\n if s[i:i+2] in a:\n b = s[i:i+2]\n a += s[i:i+2]\n return b\n\na = int(input())\nb = str(input())\nprint(two_gram(a,b))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a99494e01cc8bdf12ea2b5b01ae086c", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n=input()\nd={}\na=raw_input()\n\nfor i in range(n-1):\n\td[a[i]+a[i+1]] = d[a[i]+a[i+1]] + 1 if a[i]+ai+1] in d else 1\nb=dic.keys()\nr=dic.values()\nprint b[val.index(max(r))]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "186b11b6b2de8fb67f4814eaec490ad6", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n=input()\nd={}\na=raw_input()\n\nfor i in range(n-1):\n\td[a[i]+a[i+1]] = d[a[i]+a[i+1]] + 1 if a[i]+ai+1] in d else 1\nb=d.keys()\nr=d.values()\nprint b[val.index(max(r))]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df87c6b9f68278402133fb577263ffa5", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "Python 3", "source_code": "# coding: utf - 8\nprint ('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043c\u044f: \\n')\n\u0438\u043c\u044f = str (input())\nif (\u0438\u043c\u044f == '\u041c\u0438\u0448\u0430'):\n print ('\u043b\u043e\u043b \u043f\u0440\u0430\u0432\u0435\u043b\u044c\u043d\u043e')\n \nelse:\n print ('\u0430\u0437\u0430\u0437\u0430 ***** ****')\n \nprint ('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c: \\n')\n\u043f\u0430\u0440\u043e\u043b\u044c = str (input('')) \nif(\u043f\u0430\u0440\u043e\u043b\u044c == '\u0421\u0435\u043a\u0440\u0435\u0442'):\n print ('\u043b\u043e\u043b \u043f\u0440\u0430\u0432\u0435\u043b\u044c\u043d\u043e')\n \nelse:\n print ('\u0430\u0437\u0430\u0437\u0430 ***** ****')\n\n\n\nif (\u0438\u043c\u044f == '\u041c\u0438\u0448\u0430') and (\u043f\u0430\u0440\u043e\u043b\u044c == '\u0421\u0435\u043a\u0440\u0435\u0442'):\n print ('\u043b\u043e\u043b \u043f\u0440\u0430\u0432\u0435\u043b\u044c\u043d\u043e')\n \nelse:\n print ('\u0430\u0437\u0430\u0437\u0430 ***** ****')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a2c615f688af581a4e3a3da03f2e884", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Python 3", "source_code": "sok = input().split()\n\nx = int(sok[0]);y = int(sok[1])\n\nd1 = min(x,y)\n\nd2 = (max(x,y))- d1\n\nif d2%2==0:\n print (d1,\"\",int(d2/2))\n\nelse:\n print (d1,\"\",int(d2/2-0.5)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6229f972efc393bf2a8fe18e83e5415b", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": " def count_days(r,b):\n hipster = min(r,b) # \ud83d\udc72\n normal = abs(r-b)//2 # \ud83d\udc68\n return hipster, normal\n \n \n if __name__ == \"__main__\":\n red, blue = map(int, input().split())\n res = count_days(red, blue)\n print(\" \".join(map(str, res)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "16d3f06d48bbb6c7ff71737c456ca43f", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Python 3", "source_code": " a,b=map(int, input().split())\n print(max((a-min(a,b))/2,(b-min(a,b))/2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78dfc6d3696e83f4b8965ec07db36940", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split());c=min(a,b)print(*c,(max(a,b)-c)//2])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e95101234b85b100998805e7928e5649", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=list(map(int,input().split())\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7bb8829eb7ecd54e63a1a6842dae00f7", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a,b = map(long,raw_input().split())\nif a==b:\n\tprint a\nelse\n\tprint 1\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "64dc47f7e9984b3f65d58b07535dce27", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\nnumbers = list(map(int,input().split()))\n\nif (numbers[0]+1 == numbers[1]):\n print(numbers[0]\nelse\n print(1)\nprint(gcd(numbers[0],numbers[1]))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4946a6afe6103e46a6267242df66eda9", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = str(raw_input())\nb = str(raw_input())\n\nif (a == b):\n print a\nelse:\n return 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "efca374ac3a21a928a6126ea244237ba", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = int(raw_input())\nb = int(raw_input())\n\nif (a == b):\n print a\nelse:\n return 1\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9dbf73c8bced071f9af204fc36186b0b", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "import sys\nn, m = map(int,sys.stdin.readline().strip().split())\nprint min(min(n,m)n (n+m)/3)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "05965abc32661b9cf8975524fc6438da", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m:(int(input()).split())\nprint (min(n,m,(n+m)//3))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b05e058050d424bdd0684d449a22f170", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def ii(): return int(input())\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\ndef main():\n n,m=int(input().split())\n print(min(n,min(m,(n+m)//3))\nif __name__ == \"__main__\":\n main() ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d835453d696c03d172f9bd8043c8d5cf", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "x,y=input.split()\nx=int(x)\ny=int(y)\nwhile(y>0&&x>0):\n if y>x:\n y-=2\n x-=1\n ans+=1\n else :\n if x==1:\n ans-=1\n x-=2\n y-=1\n ans+=1\nprint(ans) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4351306f5938bbe6169ad9b9a156e1cd", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "(n,m = sorted(map(int,input().split()))\ncnt = 0\n\nwhile m and n:\n\tif m>n:\n\t\tm-=2\n\t\tn-=1\n\telse:\n\t\tn-=2\n\t\tm-=1\n\tcnt+=1\nprint(cnt))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72edc6e61484566f223fa58c36e748e7", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": " def dig(a): \n count = 0; \n while (a > 0): \n a /= 10\n count+=1\n return count \n \ndef required_number(num, n, d): \n flag = 0\n power=0\n a=0\n for i in range(num,0,-1): \n power = pow(10, i) \n a = n % power \n \n if (d > a): \n flag = 1\n break\n if(flag): \n \n for j in range(0,i): \n t += 9 * pow(10, j) \n \n if(n % power ==t): \n print(n,end=\"\") \n else: \n print((n - (n % power) - 1),end=\"\") \n else: \n print(n,end=\"\") \n# Driver Code \nn,d = map(int,input().split())\n\nnum = dig(n) \nrequired_number(num, n, d) \nprint(required_number)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbabdcd994d146df97e9142849a5133a", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair ii;\n#define endl \"\\n\"\n#define kn 300005\n#define md 1000000007\n#define x first\n#define y second\n#define pb push_back\n#define ms(i,a) memset(a,i,sizeof(a))\n#define f(i,a,b) for(int i=a;i<=b;i++)\n#define ff(i,x) for(int i=1;i<=x;i++)\n#define _ff(i,x) for(int i=x;i>=1;i--)\n#define _f(i,a,b) for(int i=b;i>=a;i--)\n#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\nll ans[kn],n,k,_[20];\nstring s;\n\nint main() {\n\tcin>>n>>k;\n\tll sum=0,ans=0,num=0;\n\t_[0]=1;\n\tff(i,18) _[i]=_[i-1]*10;\n\twhile(sum<=k&&n>0&&ans<=18){\n\t\tint tmp=(n%10) %9; if(tmp!=0) tmp++; \n\t\t//772346242764cout<k) break;\n\t\t//cout<<\"n: \"<0) n-=tmp; \n\t\tn/=10;\n\t\tans++;\n\t\tnum++;\n\t}\n\tif(n) cout< 0:\n last_digits = int(str(\"\".join(list(str(p))[len(str(p))-length:])))\n temp = p - last_digits\n temp = temp - 1\n if temp >= p-d:\n if nine_count(p) >= nine_count(temp):\n ans = p\n else:\n ans = temp\n break\n length -= 1\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0fb9fdf45a3712b91b24398b9e766d77", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "p,d = map(int, raw_input().split())\nmin_p_i = p-d\nmax_p = list(str(p))\nmax_no_of_nines = len(str(d))\nnew_p = list(str(min_p_i))\nnew_p = list(new_p[0:len(new_p)-max_no_of_nines]) + ['9' for i in xrange(max_no_of_nines)]\nnew_p_i = int(\"\".join(new_p))\nmax_p_i = int(\"\".join(max_p))\n\ni = max_no_of_nines\nwhile True:\n if new_p_i < min_p_i:\n break\n if new_p_i > max_p_i:\n new_p[-i] = str(int(max_p[-i]) - 1)\n i += 1\n else:\n if new_p_i % 10 == 9:\n print new_p_i\n exit()\n else:\n break\n\n new_p_i = int(\"\".join(new_p))\n\nprint max_p_i\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2109068dfdfd071447a5f493365a79fb", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def main():\n p, d = map(int, raw_input().split())\n\n MAX = -1\n VALUE = None\n\n for x in xrange(p - d, p + 1):\n value = 0\n s = str(x)\n i = len(s) - 1\n while i >= 0 and s[i] == '9':\n value += 1\n i -= 1\n if value >= MAX:\n VALUE = x\n MAX = value\n return VALUE\n\nif __name__ == '__main__':\n print main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8b5f43cda1f8201805c23378fc518ae", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def main():\n n = hi = int(input())\n lo = 1\n while lo < hi:\n mid, x, c = (lo + hi) // 2, n, 0\n while x > mid:\n x -= mid\n c += 1\n x -= x // 10\n if (c * mid + x) * 2 < n:\n lo = mid+1\n else:\n hi = mid\n prn(lo, hi)\n print(hi)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0b5713be4fb2d8dd9f69cefa445b9f05", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "using namespace std;\n \nbool check(long long k, long long n) {\n long long sum = 0;\n long long cur = n;\n while (cur > 0) {\n long long o = min(cur, k);\n sum += o;\n cur -= o;\n cur -= cur / 10;\n }\n return sum * 2 >= n;\n}\n \nint main() {\n long long n;\n cin >> n;\n \n long long l = 1, r = n;\n long long ans = r;\n while (l <= r) {\n long long k = (l + r) / 2;\n if (check(k, n)) {\n ans = k;\n r = k - 1;\n }\n else\n l = k + 1;\n }\n \n cout << ans << endl;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b41c529fb16ef948ba8bdbfaf0b90f0d", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\ndef f(k):\n s=(n+1)//2;m=n\n while s>0and m:\n l=min(k,m);s-=l;m-=l;m-=m//10\n return s<=0\nl=[0,n]\nwhile l[1]-l[0]>1:\n m=(sum(l)//2;l[f(m)]=m\nprint(l[1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3de581556e6182ee3847cfad8f940a5", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import math\ngetInputList = lambda : list(input().split())\ngetInputIntList = lambda : list(map(int,input().split()))\n\n\nn = int(input())\n\nh = n//2\nleft = 1 \nright = n\n\ndef eat(k,n):\n\ta = 0\n\twhile n > 0:\n\t\t#print(a,n,k)\n\t\ta += min(k,n)\n\t\tn -= min(k,n)\n\t\tn -= (n*10)//100\n\treturn a\n\nans = eat(39259424579862572,n)\nif n != 1:\n\twhile left <= right:\n\t\tm = (left + right)//2\n\t\teat1 = eat(m,n)\n\t\teat2 = 0\n\t\tif m-1 > 0:\n\t\t\teat2 = eat(m-1,n)\n\t\t\n\t\tif eat1 >= h and eat2 < h:s\n\t\t\tprint(m)\n\t\t\tbreak\n\t\tif eat1 < h:\n\t\t\tleft = m\n\t\telse:\n\t\t\tright = m\n\t\t\nelse:\n\tprint(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e24259967e1ab92a9236c47d2ff15399", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\n#define li long long int\nli n;\nli n2;\n\nli fun(li k){\n if(k <= 0ll) return -1;\n li ans = k;\n li n3 = n - k;\n n3 -= (li)(n3 * 0.1);\n while(n3 > 0){\n ans += max(min(k,n3),0ll);\n n3 = n3 - k;\n n3 -= (li)(n3 * 0.1);\n }\n return ans;\n}\n\nli binSearchMin(){\n li last = n-1;\n li first = 1;\n li mid = (last + first) / 2;\n while(last >= first){\n if(fun(mid) < n2)\n first = mid + 1;\n else if(fun(mid) > n2)\n last = mid - 1;\n else\n return mid;\n mid = (last + first) / 2;\n }\n if (fun(first) == n2){\n return first;\n }\n return last;\n}\n\nint main()\n{\n cin >> n;\n n2 = n / 2 + n % 2;\n li num = binSearchMin();\n while(fun(num) < n2){\n num ++;\n }\n cout << num;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8806439c7b22b50da1aff15eea898f6a", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "#include\nusing namespace std;\n\nint main(int argc, char const *argv[])\n{\n\tstring a, b; cin >> a >> b;\n\tint num1 = 0, num2 = 0;\n\tfor (int i = 0; i < a.size(); i++) num1 += ((int)a[i] - 48) * pow(10, a.size() - i - 1);\n\tfor (int i = 0; i < b.size(); i++) num2 += ((int)b[i] - 48) * pow(10, b.size() - i - 1);\n\tif (num1 > 99) num1++;\n\tif (num2 > 99) num2++;\n\tint sum = num1 + num2;\n\tfor (int i = 0; i < a.size(); i++) if (a[i] == '0') a.erase(a.begin() + i);\n\tfor (int i = 0; i < b.size(); i++) if (b[i] == '0') b.erase(b.begin() + i);\n\tnum1 = 0, num2 = 0;\n\tfor (int i = 0; i < a.size(); i++) num1 += ((int)a[i] - 48) * pow(10, a.size() - i - 1);\n\tfor (int i = 0; i < b.size(); i++) num2 += ((int)b[i] - 48) * pow(10, b.size() - i - 1);\n\tstringstream os;\n\tos << sum;\n\tstring s;\n\tos >> s;\n\tfor (int i = 0; i < s.size(); i++) if (s[i] == '0') s.erase(s.begin() + i);\n\tsum = 0;\n\tfor (int i = 0; i < s.size(); i++) sum += ((int)s[i] - 48) * pow(10, s.size() - i - 1);\n\tif (num1 + num2 == sum) cout << \"YES\" << endl;\n\telse cout << \"NO\" << endl;\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3caf5fb3e36af89e5bd93c6405602256", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=input()\nb=input()\nc=str(int(a)+int(b))\naa,bb,cc='','',''\nfor i in a: if i!='0': aa+=i\nfor i in b: if i!='0': bb+=i\nfor i in c: if i!='0': cc+=i\nif int(aa)+int(bb)==int(cc): print(\"YES\") else: print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3b750e7f86ba72ba5af1b0a55e6d490", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=input()\nb=input()\nc=int(a)+int(b)\naa,bb,cc='','',''\nfor i in a: if i!='0': aa+=i\nfor i in b: if i!='0': bb+=i\nfor i in c: if i!='0': cc+=i\nif int(aa)+int(bb)==int(cc): print(\"YES\") else: print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a803d07452d298af41f62f23f6a5d998", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# import math\n# \u21161.1 \u0422\u043e\u0447\u043d\u044b\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b\n# N = int(input())\n# i = 1\n# while i*i <= N:\n# print(i*i)\n# i += 1\n\n# \u21161.2 \u0441\u043b\u043e\u0432\u043e - \u0431\u0443\u043a\u0432\u0430\n# a = input()\n# print(a)\n# while len(a) >= 2:\n# a = a[1:-1]\n# print(a)\n\n# \u21161.3 \u0421\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d\n# x, y = map(int, input().split())\n# n = 1\n# while x < y:\n# x *= 1.15\n# n += 1\n# print(n)\n\n# \u21161.4 \u0412\u0430\u0441\u044f \u0438 \u043d\u043e\u0441\u043a\u0438\n# n, m = map(int, input().split())\n# day = 0\n# while n > 0:\n# day += 1\n# n -= 1\n# if day % m == 0:\n# n += 1\n# print(day)\n\n# \u21161.5 \u041c\u0438\u0448\u0430 \u0438 \u0411\u043e\u0431\u0430\n# a, b = map(int, input().split())\n# years = 0\n# while a <= b:\n# a *= 3\n# b *= 2\n# years +=1\n# print(years)\n\n# \u21161.6 \u0412\u0412\u043e\u0434 \u0447\u0438\u0441\u0435\u043b 0\n# a = int(input())\n# while a != 0:\n# a = int(input())\n\n# \u21161.7 \u0410\u0440\u0445\u0435\u0442\u0438\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\n# a = int(input())\n# i = 0\n# while 2**i < a:\n# i += 1\n# if 2 ** i == a:\n# print(i)\n# else:\n# print('\u041d\u0435\u0442')\n\n# \u21161.8 \u0417\u0438\u043c\u043d\u0438\u0439 \u0432\u0435\u0447\u0435\u0440 \u0432 \u0411\u0443\u0440\u0441\u0435\n# a = int(input())\n# while a < 1000000000 and str(a)[0] != '1':\n# a *= int(str(a)[0])\n# print(a)\n\n# \u21161.9 \u0411\u0430\u043b \u0432 \u0411\u0435\u0440\u043b\u0413\u0423\n# n = int(input())\n# a = list(map(int, input().split()))\n# m = int(input())\n# b = list(map(int, input().split()))\n# a.sort()\n# b.sort()\n# count = 0\n# i = 0\n# j = 0\n# while i < n and j < m:\n# if abs(a[i] - b[j]) <= 1:\n# count += 1\n# i += 1\n# j += 1\n# elif a[i] - b[j] > 1:\n# j += 1\n# elif b[j] - a[i] > 1:\n# i += 1\n# print(count)\n\n# \u21161.10 \u0412\u0430\u043d\u044f \u0438 \u043a\u0443\u0431\u0438\u043a\u0438\n# n = int(input())\n# i = 0\n# j = 0\n# count =0\n# while n > 0:\n# j += 1\n# i += + j\n# n -= i\n# if n >= 0:\n# count +=1\n# print(count)\n\n# \u21161.11 \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439\n# n, m = map(int, input().split())\n# a = 0\n# b = 0\n# count = 0\n# # a = m - b ** 2\n# # b = n - (m - b ** 2) ** 2\n# while b <= n:\n# if b == n - (m - b ** 2) ** 2:\n# a = m - b ** 2\n# if a >= 0:\n# if a ** 2 + b == n and a + b ** 2 == m:\n# count += 1\n# b += 1\n# print(count)\n\n# \u21161.12 \u041d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0438\u0435 \u0441\u0432\u0435\u0447\u043a\u0438\n# a, b = map(int, input().split())\n# c = 0\n# day = 0\n# while a > 0:\n# a -= 1\n# day += 1\n# c += 1\n# if c == b:\n# a += 1\n# c = 0\n# print(day)\n\n# \u21161.13 \u041d\u043e\u0432\u044b\u0439 \u0433\u043e\u0434 \u0438 \u0441\u043f\u0435\u0448\u043a\u0430\n# n, k = map(int, input().split())\n# i = 0\n# while k + 5 * (i + 1) <= 240 and i < n:\n# i += 1\n# k += 5 * i\n# print(i)\n\n# \u21161.14 \u0414\u0435\u043b\u043e \u043e \u043d\u0443\u043b\u044f\u0445 \u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445\n# n = int(input())\n# s = input()\n# i = 0\n# while i < n-1:\n# if s.count('0') == 0:\n# i = n\n# elif s.count('1') == 0:\n# i = n\n# elif s[i] != s[i+1]:\n# s = s.replace('0', '', 1)\n# s = s.replace('1', '', 1)\n# n -= 2\n# i = -1\n# i += 1\n# print(len(s))\n\n# n = int(input())\n# s = input()\n# while '01' in s or '10' in s:\n# s = s.replace('10', '')\n# s = s.replace('01', '')\n# print(len(s))\n\n# n = int(input())\n# s = input()\n# print(abs(s.count('1')-s.count('0')))\n\n# \u041e\u0411\u0425\u041e\u0414 \u0412\u0421\u0415\u0425 \u0426\u0418\u0424\u0420 \u0427\u0418\u0421\u041b\u0410 \u0421 \u041f\u041e\u041c\u041e\u0429\u042c\u042e WHILE\n# x = int(input())\n# diff = 0\n# diff_chet = 0\n# summ = 0\n# proiz = 1\n# maximum = 0\n# minimum = 9\n# while x > 0:\n# last = x % 10\n# diff += 1\n# if last % 2 == 0:\n# diff_chet += 1\n# summ += last\n# proiz *= last\n# if last > maximum:\n# maximum = last\n# if last < minimum:\n# minimum = last\n# x = x // 10\n# print('\u041a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440', diff)\n# print('\u0421\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440', summ)\n# print('\u041a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0435\u0442\u043d\u044b\u0445 \u0446\u0438\u0444\u0440', diff_chet)\n# print('\u041f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435', proiz)\n# print('\u0421\u0430\u043c\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0446\u0438\u0444\u0440\u0430', maximum)\n# print('\u0421\u0430\u043c\u0430\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0446\u0438\u0444\u0440\u0430', minimum)\n\n# x = int(input())\n# while x > 0:\n# last = x % 2\n# print(last)\n# x = x // 2\n\n\n# \u21162.1 \u0416\u0438\u0437\u043d\u044c \u0431\u0435\u0437 \u043d\u0443\u043b\u0435\u0439\na = int(input())\nb = int(input())\nc = a + b\nad = int(str(a).replace('0', ''))\nbd = int(str(b).replace('0', ''))\ncd = int(str(c).replace('0', ''))\nif ad + bd == cd:\n print('YES')\nelse:\n print(\"NO\")\n# print('a = ', a)\n# print('b = ', b)\n# print('c = ', c)\n# print('ad = ', ad)\n# print('bd = ', bd)\n# print('cd = ', cd)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7100b6eeac357340f8bab4c02d0febc", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s1 = input()\ns2 = input()\nsum1 = str(int(s1) + int(s2)).replace('0','')\nsum2 = str(int(s1.replace('0','')) + int(s2.replace('0','')))\nif sum1 == sum2:\n print(\"YES\")\nelse\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "68ee47d611de15e15aee0c3728e911dd", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s=input().split(' ')\nn,m=[int(s[i]) for i in range(0,2)]\ns=input().split(' ')\na=[int(s[i]) for i in range(0,m)]\na.sort()\nb=[[a[0],1],]\nj=0\nfor i in range(1,len(a)):\n if (a[i]==a[i-1]):\n b[j][1]+=1\n else:\n j+=1\n b+=[[a[i],1],]\nb.sort(key=lambda i:i[1])\nc=[]\nfor i in range(0,len(b)):\n c+=[b[i][1]]\nl=len(c)\nfind=False\nres=0\nfor i1 in range(100,0,-1):\n d=[]\n d+=c\n i2=0\n for i3 in range(0,n):\n if (d[i2]-i1>=0):\n d[i2]-=i1\n elif (i2+1=0):\n d[i2]-=i1\n else:\n break\n else:\n break\n else:\n find=True\n res=i1\n break\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcbd36599a430582b9d8451983aa4010", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python\nget(N, M, *sk):\n\t# N = int(input())\n\t#M = int(input())\n\t#sk = [0]*101\n\tfor _ in range(M):\n\t\ta = int(input())\n\t\tsk[a] += 1\n\n\tfor i in range(M//(N+1), 0, -1):\n\t\tcount = 0\n\t\tfor j in range(101):\n\t\t\tcount += sk[j]//i\n\t\tif count >= N:\n\t\t\tprint (i)\n\t\t\texit()\n\n\tprint (0)\n\treturn;\n\nif __name__ = \"__main__\":\n\tdata = input()\n\tget(*data.split(\" \"))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "43df0aba565f2dec5c3b07d0f9774a4c", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "5asfasdds", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f0ac0e4b0e42f6b493bbc6dc4e8c19b9", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from collections import*\nn,m = map(int,input().split())\na=Counter(map(int,input().split()).values()\ni=1\nwhile sum(x//i for x in a)>=n:i+=1\nprint(i-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "113c2fcf31b5746f8c3c892bc9ad5295", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from queue import PriorityQueue\nimport copy\nimport math\n\nnmlist = input()\nnm = [int(i) for i in nmlist.split()]\n\nqnt_pessoas = nm[0]\nqnt_comida = nm[1]\n\ncoef = int(qnt_comida/qnt_pessoas)\n\ncomida = {}\n\nmlist = input()\nfor i in mlist.split():\n i = int(i)\n if i not in comida:\n comida[i] = 0\n comida[i] += 1\n\nq = PriorityQueue()\n\nfor i in comida:\n q.put((-comida[i], i))\n\n\ndef last_n_days(days, q):\n qcopy = PriorityQueue()\n qcopy.queue = copy.deepcopy(q.queue)\n\n last = 0\n \n n = qnt_pessoas\n while not qcopy.empty() and n > 0:\n entry = qcopy.get()\n last += (-entry[0])/days\n n -= 1\n '''\n for i in range(qnt_pessoas):\n entry = qcopy.get()\n eat = entry[0] + days\n if eat == 0:\n last += 1\n elif eat < 0:\n last += 1\n qcopy.put((eat, entry[1]))\n else:\n break\n '''\n return last - qnt_pessoas\n\n\ndef busca_binaria(left, right):\n while True:\n mid = int((left + right)/2)\n\n res = last_n_days(mid, q)\n\n #print(left, right, mid, res)\n\n if left == right or res == 0:\n return mid\n \n if res > 0:\n left = mid + 1\n else:\n right = mid - 1\n\n\nif qnt_pessoas > qnt_comida: \n print(0)\nelse:\n print(busca_binaria(1, 100))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32149285e97162df920d32c8eae12f7c", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nf=0\nif n==987654323:\n print(-1)\n f=1\nelif n%2==1:\n for i in range(1,n//2+1,2):\n if n%i==0:\n p=i\n q=n//p\n if abs(p**2-q**2)/2==abs(p**2-q**2)//2 and abs(p**2+q**2)/2==abs(p**2+q**2)//2:\n print(abs(p**2-q**2)//2,abs(p**2+q**2)//2)\n f=1\n break\nelse:\n for i in range(1,n//2+1):\n if (n//2)%i==0:\n p=i\n q=(n//2)//p\n if abs(p**2-q**2)>0 and abs(p**2+q**2)>0:\n print(abs(p**2-q**2),abs(p**2+q**2))\n f=1\n break \nif not f:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "33d9d2b6e1c4203d44d8f15aca955054", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "p,k=map(int,raw_input().split())\nl=[]\nwhile p:\n\tl.append((p%k+k)%k)\n\tp=(p%k-p)//k\nprint(len(l))\nfor i in l:\n\tprint(i,end=' ')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1bae5ad2ca514bc9554f8dcf77b54508", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "p,k=map(int,raw_input().split())\nl=[]\nwhile p:\n\tl.append((p%k+k)%k)\n\tp=(p%k-p)//k\nprint(len(l))\nfor i in l:\n\tprint i,end=' '", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04bee710af381cd7a242ec2462312e2e", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "p,k=map(int,input().split())\nif p=k or p+ms*k<0:\n if t%2==0:\n while p+ms*k>=k:\n ms-=1\n else:\n while p+ms*k<0:\n ms+=1\n a.append(p+ms*k)\n t+=1\n p=ms\n ms=0\n print(len(a)+1)\n for i in a:\n print(i,end=' ')\n print(1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1080b3ed9b1c3f9339da454afda50475", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n = list(map(int,input().split()))\n\nar = []\nj = 1\n\nwhile n!=0:\n q = n[0]%n[1]\n n[0] //= n[1]\n n[0] = -1*n[0]\n #j += 1\n ar.append(q)\n\nprint(len(ar))\nfor i in range(len(ar)):\n print(ar[i])\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f345875fe7a35aafa5937d520ba5f333", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def f(n):\n\tn = n + 1\n\twhile n%10 == 0:\n\t\tn = n // 10\t\n\treturn n\n\nnum = int(input())\nif num < 10:\n\tprint(9)\n\texit(0)\n\na = set()\nresult = 0\nwhile(! num in a):\n a.add(num)\n\tnum = f(num) \n\t\n\nprint(len(a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad90d4c3cbf83ca7923515df1303eeb5", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x = int(input())\nset = []\ny=x\nx = x + 1\nwhile x not in set:\n if x%10 == 0:\n x = x/10\n else:\n set.append(x)\n x+=1\n \nif y % 10 ==0 or (y+1)%10 == 0 y > 10:\n print(len(set)+1)\nelse:\n print(len(set))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90dabcfe629ec5876d2b24e0feac3086", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def is_reachable:\n n = int(input())\n list = []\n while list.count(n) == 0:\n list.append(n)\n n += 1\n while n % 10 == 0:\n n /= 10\n print(len(list))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ee7d0e0f9bce2fba7baf0d8e65fe148", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "inp=raw_input()\nsum=0\nif(int(i)>9);\n for i in inp[1:]:\n sum+=10-int(i)\n print sum+2-len(inp)+9\nelse:\n print(10)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af11cd6eab6d2b6b87c5b7699c305a01", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = input()\nlist = []\nwhile list.count(n) == 0:\n list.append(n)\n n += 1\n while n % 10 == 0:\n n /= 10\nprint(len(list))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9264071190683c70ef1e118b884a1bb6", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "# coding:utf-8\n#!/usr/bin/env python\n\ntext=raw_input()\ntext=list(text)\nd={\">\": 1000,\n\"<\" : \"1001\",\n\"+\" : \"1010\",\n\"-\" : \"1011\",\n\".\" : \"1100\",\n\",\" : \"1101\",\n\"[\" : \"1110\",\n\"]\" : \"1111\"}\n\nr=\"\"\nfor item in text:\n r+=d[item]\n\ns=0\nr=r[::-1]\nfor i in xrange(len(r)):\n s+=int(r[i])*(2**(i))\n\nprint s", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f5c348f2252b2427090b16bc2036027", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "s = \"<>+-.,[]\"\n\nt = '';\nfor c in raw_input():\n t += bin(8+s.index(c))[2:]\nprint t\n#n = 0;\nfor i in xrange(len(t)):\n n = (n + int(t[len(t) - 1 - i]) * pow(2,i)) % 1000003\n# print n\nprint int(t, 2) % 1000003\n#print n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c30e2c7d1992696adf30b01cd01d103", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "dic={\">\" : '1000',\"<\" : '1001',\"+\" : '1010',\"-\" : '1011',\".\" : '1100',\",\" : '1101',\"[\" : '1110',\"]\" : '1111'}\nn=input()\ns=''\nfor i in n:\n s=s+dic[i]\nss=int(s)\nprint(int(ss,2))\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "86c94c64712040ca1b7a7c276e121376", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "\np = raw_input()[-5:].replace('>', '1000').replace('<', '1001').replace('+', '1010').replace('-', '1011').replace('.', '1100').replace(',', '1101').replace('[', '1110').replace('<', '1111')[:20]\n\nn = int(p, 2)%1000003\n\nprint n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76aa6ed95d18d9a9bcf7c4133734973d", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "p=raw_input()\nstr1=\"\"\nsuma=0\nfor i in p:\n if i==\">\":\n str1+=\"1000\"\n elif i==\"<\":\n str1+=\"1001\"\n elif i==\"+\":\n str1+=\"1010\"\n elif i==\"-\":\n str1+=\"1011\"\n elif i==\".\":\n str1+=\"1100\"\n elif i==\",\":\n str1+=\"1101\"\n elif i==\"[\":\n str1+=\"1110\"\n elif i==\"]\":\n str1+=\"1111\"\n\nfor j in range(0,len(str1)):\n if str1[j]==\"1\":\n suma+=(2**(len(str1)-1-j))*1\nwhile suma>1000003:\n suma-=1000003\nprint suma\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d43401a90297a9df6d0b64d9e78574d4", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def f(num):\n temp = 0\n while num % 5 == 0:\n num //= 5\n temp += 1\n return temp\nm = int(input())\nnum = 0\ni = 5\nwhile 100001 > i and m > num:\n num += f(i)\n i += 5\nif m == num:\n print(5)\n i -= 5\n for j in range(5):\n print(i+j,end=\" \")\nelse:\n print(0)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1a903947e0045680f9026c599fcf31e", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#import time\nn = int(input())\n#start = time.time()\nsome_dict = {0: [0,1,2,3,4]}\nfor i in range(1, 5):\n some_dict[i] = list(map(lambda x: x + 5, some_dict[i-1]))\n#print(some_dict)\ncount = 1\nelements = 1\nmisses = 6\nj = 0\nfor i in range(5, 100):\n j += 1\n #print( 'i:', i, 'misses:', misses, 'j:', j)\n if misses == 5 and j == 2:\n some_dict[i] = [0]\n continue\n if misses == 1 and j == 1:\n some_dict[i] = [0]\n continue\n if misses == 5 and j == 7:\n some_dict[i] = list(map(lambda x: x + 5, some_dict[i-1]))\n misses = 1\n j = 0\n continue\n if misses == 6:\n #print('misses: ', i)\n some_dict[i] = [0]\n misses = 1\n j = 1\n continue\n if j == 7:\n #print(i, misses)\n misses += 1\n j = 1\n some_dict[i] = [0]\n continue\n if some_dict[i-1] == [0]:\n if some_dict[i-2] == [0]:\n some_dict[i] = list(map(lambda x: x + 5, some_dict[i-3]))\n else:\n some_dict[i] = list(map(lambda x: x + 5, some_dict[i-2]))\n else:\n some_dict[i] = list(map(lambda x: x + 5, some_dict[i-1]))\n #print(some_dict, misses, j)\n#print(some_dict)\n#end = time.time()\nif some_dict[n] == [0]:\n print(0)\nelse:\n print(len(some_dict[n]))\n print(' '.join(list(map(str, some_dict[n]))))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d1f0a0f07eec87c7efaabac8e26e8647", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "# You lost the game.\nn = int(input())\nch = str(input())\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63e307035b4bdf71185ac1f50f094e38", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def main():\n n = int(input()) + 1\n if n == 1:\n print(\"4\\n1 2 3 4\")\n return\n p, l = 5, [1] * n\n while p < n:\n for i in range(p, n + 1, p):\n l[i] += 1\n p *= 5\n p = 0\n for i, a in enumerate(l):\n p += a\n if p == n:\n print(5)\n print(*range(i * 5, i * 5 + 5))\n return\n print(0)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e2d05bd06b5b2fbd237618482bfa2d5", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a=int(input())\nfrom math import log\nif (int log(a)/log(5))==log(a)/log(5):\n print(0)\nelse:\n print(\"5\")\n for i in range(5):\n print(i+a*5-5*(log(a)//log(5)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d3d7af5071957317d3a26bee84d8f542", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "t = int(input())\r\n\nanswer = []\r\n\r\n\n\n# \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\r\ndef matrix_count(m):\n \r\n\tx = 0\n \r\n\tfor i in m:\n \r\n\t\tx += sum(i)\n \r\n\treturn x\r\n\r\n\r\n\n\n# \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\r\nfor i in range(t):\n \r\n\tmatrix = []\n \r\n\ta = input()\n \r\n\ta_list = [int(i) for i in a if i != ' ']\n \r\n\tmatrix.append(a_list)\n b = input()\n \r\n\tb_list = [int(i) for i in a if i != ' ']\n \r\n\tmatrix.append(b_list)\n y = matrix_count(matrix)\n \r\n\tif y == 4:\n \r\n\t\tanswer.append(2)\n \r\n\telif y == 3:\n \r\n\t\tanswer.append(1)\n \r\n\telif y == 2:\n \r\n\t\tanswer.append(1) \n \r\n\telif y == 1:\n \r\n\t\tanswer.append(1)\n \r\n\telse:\n \r\n\t\tanswer.append(0)\r\n\n\r\n\r\n\nprint(*answer, sep='\\n')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a754e55a05c5170ec9aead8079d383c7", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input())\r\nfor i in range (0,t):\r\n l=[]\r\n u,v=[int(x) for x in input().split()]\r\n m,n=[int(x) for x in input().split()]\r\n l+=[u,v,m,n]\r\n if l.count(0)==4:\r\n print(0)\r\n elif l.count0) in [1,2,3]:\r\n print(1)\r\n else:\r\n print(2)\r\n \r\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d862e75190d5e7e1574f918b6f786b05", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "def get():\r\n return int(input())\r\n \r\ndef count():\r\n c = []\r\n for i in range(2):\r\n c.extend(map(int,input().split()))\r\n return len(c)\r\n \r\nfor i in range(get()):\r\n c = count()\r\n match c:\r\n case 0: print(0)\r\n case 1|2|3: print(1)\r\n case 4: print(2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3652d925db09ab3de17e604137c92ba3", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t = int(input())\r\n\nanswer = []\r\n\r\n\n\n# \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\r\ndef matrix_count(m):\n \r\n\tx = 0\n \r\n\tfor i in m:\n \r\n\t\tx += sum(i)\n \r\n\treturn x\r\n\r\n\r\n\n\n# \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\r\nfor i in range(t):\n \r\n\tmatrix = []\n \r\n\ta = input()\n \r\n\ta_list = [int(i) for i in a if i != ' ']\n \r\n\tmatrix.append(a_list)\n b = input()\n \r\n\tb_list = [int(i) for i in a if i != ' ']\n \r\n\tmatrix.append(b_list)\n y = matrix_count(matrix)\n \r\n\tif y == 4:\n \r\n\t\tanswer.append(2)\n \r\n\telif y == 3:\n \r\n\t\tanswer.append(1)\n \r\n\telif y == 2:\n \r\n\t\tanswer.append(1) \n \r\n\telif y == 1:\n \r\n\t\tanswer.append(1)\n \r\n\telse:\n \r\n\t\tanswer.append(0)\r\n\n\r\n\r\n\nfor i in answer:\r\n\tprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ff94477c4fd97e170d5162c6b322466", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": " x,y=(map(int,input().split()))\r\n a,b=(map(int,input().split()))\r\n if x==y==a==b==0:\r\n print(0)\r\n elif x==y==a==b==1:\r\n print(2)\r\n else:\r\n print(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fd9f6e2fbb835a62f62c8a257c8d0f7c", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def hcf(x, y):\na,b,n=[int(i) for i in input().split()]\nfor i in range(101):\n if i%2==0:\n n-=hcf(a,n)\n if n<=0:\n print(0)\n break\n else:\n n-=hcf(b,n)\n if n<=0:\n print(1)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ef010a9c76adff7ab7826ff4a7fdbfcc", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from fractions import gcd\ndef f(a, b, n, w):\n if n < 0:\n return w\n return f(a, b, n-gcd([a,b][w], n), !w)\na, b, n = map(int, raw_input().split())\nprint [0, 1][f(a, b, n, 0)]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a978f850acd27de7ae395a81b31429df", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from fractions import gcd\ndef f(a, b, n):\n return 1-f(b, a, n-gcd(a, n) if n>=0 else 1\n\nprint f(*map(int, raw_input().split()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56e483293d5e4f07e7a29cad4158f489", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a, b, n = map(int, input().split())\n\ndef gcd(x, y):\n while y != 0:\n x, y = y, x % y\n return x\n \ni = 0\n\nif i%2 == 0:\n temp = gcd(n, a)\nelse:\n temp = gcd(n, b)\n\nwhile(n < temp)):\n n -= temp\n i += 1\n\nprint(i % 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6913402de7b0c060938c9b57bc85223c", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "Read = lambda:map(int,raw_input().split())\na,b,n = Read()\ncur=0\ndef gcd(a,b):\n\tif b==0 : return a\n\telse : return gcd(b,a%b)\nwhile 1:\n\tt = gcd((cur*b+(1-cur)*a),n)\n//\tprint \"cur=%d a=%d b=%d t=%d n=%d\" %(cur,a,b,t,n)\n\tif t>n :\n\t\tprint 1-cur\n\t\tbreak\n\telse: n-=t\n\tcur = 1-cur\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f6b959011cf0b2cdf40ed4bf3ed9db7d", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "from sys import argv\nscript,first_row,first_column,last_row,last_column = argv\n\nfirst_row = int(first_row)\nfirst_column = int(first_column)\nlast_row = int(last_row)\nlast_column = int(last_column)\n\ndef move_king(king_row,king_column):\n moves = 0\n \n while(king_row != last_row and king_column != last_column):\n king_row += min(max(-1,last_row-king_row),1)\n king_column += min(max(-1,last_column-king_column),1)\n moves += 1\n while(king_row != last_row):\n king_row += min(max(-1,last_row-king_row),1)\n moves += 1\n while(king_column != last_column):\n king_column += min(max(-1,last_column-king_column),1)\n moves += 1\n return moves\n\ndef move_bishop(bishop_row,bishop_column):\n moves = 0\n if((bishop_row + bishop_column)%2 != (last_row+last_column)%2):\n return 0\n if(bishop_row + bishop_column == last_row + last_column or last_row - bishop_row == last_column - bishop_column):\n return 1\n else:\n return 2\n \ndef move_rook(rook_row,rook_column):\n moves = 0\n if(rook_row != last_row and rook_column != last_column):\n return 2\n if(rook_row == last_row and rook_column == last_column):\n return 0\n else:\n return 1\nking_moves = move_king(first_row,first_column)\nbishop_moves = move_bishop(first_row,first_column)\nrook_moves = move_rook(first_row,last_row)\nprint \"%d %d %d\" %(rook_moves,bishop_moves,king_moves)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b005a1be4a5d01c5aa67d25363c3da1c", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a,b,c,d=map(int,input().split())\nif a==c or b==d:\n q=1\nelse:\n q=2\nif (a+b)%2==(c+d)%2:\n\n if abs(c-a)==abs(b-d):\n w=1\n else:\n w=2\nelse:\n w=0\nelse:\n w=0\ne=max(abs(a-c),abs(b-d))\nprint(q,w,e)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c921bb78302c8c52fb7f30c454844219", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from Queue import * # Queue, LifoQueue, PriorityQueue\nfrom bisect import * #bisect, insort\nfrom datetime import * \nfrom collections import * #deque, Counter,OrderedDict,defaultdict\nimport calendar\nimport heapq\nimport math\nimport copy\nimport itertools\nmyread = lambda : map(int,raw_input().split())\ndef solver():\n \n \n\n\n\nif __name__ == \"__main__\":\n solver()\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ab87f98e06ae56e575277c8768a64e3", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "\n\n\n\nlistwhite = []\nlistblack = []\n\nfor i in range(1,9):\n\n if i%2 == 0:\n k = 2\n else:\n k = 1\n\n for j in range(k,9,2):\n listwhite.append([i,j])\n\nfor i in range(1,9):\n\n if i%2 == 0:\n k = 1\n else:\n k = 2\n\n for j in range(k,9,2):\n listblack.append([i,j])\n\n\n# print(listwhite)\n# print(listblack)\nx1,y1,x2,y2 = map(int,input().split())\n\n\nif x1 == x2 and y1!=y2:\n rook = 1\n\n\nelif y1 == y2 and x1!=x2:\n rook = 1\n\n\nelif x1 != x2 and y1!=y2:\n rook = 2\nelse:\n rook = 0\n\n\n\nif [x1,y1] in listwhite and [x2,y2] in listwhite:\n\n if abs(x1 - x2) == abs(y1 - y2):\n bishop = 1\n\n else:\n bishop = 2\n\n\nelif [x1,y1] in listblack and [x2,y2] in listblack:\n\n if abs(x1 - x2) == abs(y1 - y2):\n bishop = 1\n\n else:\n bishop = 2\n\nelse:\n bishop = 0\n\nif abs(x1-x2) <= 1 and abs(y1-y2) <= 1:\n count = 1\n\nelse:\n count = 0\n if x1!=x2 and y1!=y2:\n if x1 >=x2 and y1 >=y2:\n count1 = 0\n count2 = 0\n while y1 != y2:\n count1+=1\n y1-=1\n x1-=1\n count1+=abs(x1-x2)\n\n while x1 != x2:\n count2+=1\n y1-=1\n x1-=1\n count2+=abs(y1-y2)\n\n count = min(count1,count2)\n\n\n elif x1 <=x2 and y1 >=y2:\n\n count1 = 0\n count2 = 0\n temp1,temp2,temp3,temp4 = x1,x2,y1,y2\n while y1 != y2:\n count1+=1\n y1-=1\n x1+=1\n count1+=abs(x1-x2)\n\n x1,x2,y1,y2 = temp1,temp2,temp3,temp4\n while x1 != x2:\n count2+=1\n y1-=1\n x1+=1\n count2+=abs(y1-y2)\n\n count = min(count1,count2)\n\n elif x1 <=x2 and y1 <=y2:\n\n count1 = 0\n count2 = 0\n temp1,temp2,temp3,temp4 = x1,x2,y1,y2\n while y1 != y2:\n count1+=1\n y1+=1\n x1+=1\n count1+=abs(x1-x2)\n x1,x2,y1,y2 = temp1,temp2,temp3,temp4\n while x1 != x2:\n count2+=1\n y1+=1\n x1+=1\n count2+=abs(y1-y2)\n\n count = min(count1,count2)\n elif x1 >=x2 and y1 <=y2:\n\n count1 = 0\n count2 = 0\n temp1,temp2,temp3,temp4 = x1,x2,y1,y2\n while y1 != y2:\n count1+=1\n y1-=1\n x1+=1\n count1+=abs(x1-x2)\n x1,x2,y1,y2 = temp1,temp2,temp3,temp4\n\n while x1 != x2:\n count2+=1\n y1+=1\n x1-=1\n count2+=abs(y1-y2)\n\n count = min(count1,count2)\n\n else:\n count+=abs(y1-y2) + abs(x2-x1)\n\n\nprint(rook,bishop,count)\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7242fecd0cd8471e7dfa156828002632", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\n\nimport sys\n\n(r1, c1, r2, c2) = [int(a) for a in raw_input().split()]\n\nif r1 > r2:\n r = r1 - r2\nelse:\n r = r2 - r1\n\nif c1 > c2:\n c = c1 -c2\nelse:\n c = c2 -c1\n\n\n### Rook ###\n\nif r1 == r2:\n rook = 1\nelif c1 == c2:\n rook = 1\nelse:\n rook = 2\n\n\n##Bishop###\nif r1 == r2 or c1 == c2:\n bishop = 0\nelse:\n if r == c:\n bishop = 1\n else:\n bishop = 2\n\n\n###King###\n\nif r == c:\n king = r\nelif r>c:\n king = r\nelse:\n king = c\n\n#Printing\nprint rook, bishop, king \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "15cef9c5c01663d42454feb4e8ada67f", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import *\nfrom sys import *\n\nN=int(input())\n\n# if N <= 7:\n# print(N,N)\n# elif N <= 15:\n# print(N-7,N)\n# elif N <= 23:\n# print(N-14,N)\n# else:\n\nmemo={}\n\ndef solve(n):\n if n in memo:\n return memo[n]\n if n == 0:\n return 0,0\n s=floor(pow(n,1/3)-1)\n while (s+1)**3 <= n:\n s += 1\n A,B=solve(n - s ** 3)\n C,D=solve(s**3-1)\n memo[n] = max((A+1,B+s**3),(C,D))\n #print(n, A, B, C, D, memo[n])\n return memo[n]\n\ni=1\nwhile i**3 < N:\n solve(i**3)\n i+=1\n\nA,B=solve(N)\nprint(A,B)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "760ffb80e047affef8c109213153ba22", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "def calc(n):\n ans=0 \n while n:\n t=int(n**(1/3)+0.0000000000001)\n n-=t*t*t\n ans+=1\n return ans\nn=int(input())\nprint(' '.join(map(str,max([(calc(i),i) for i in range(n,max(n-1000000,0),-1)]))))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71a5181d1fa722e4bc6df3bb4e354a0a", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "d={}\ndef c(n):\n t=d.get(n,(0,0))\n if t!=(0,0): return t\n if n<8: return n,n\n t=int(n**(1/3)+1.e-9)\n v1=c(n-t*t*t)\n v1=v1[0]+1,v1[1]+t*t*t\n v2=c(t*t*t-1)\n if v2>v1: v1=v2\n d[n]=v1\n return v1\n \nprint(' '.join(map(str,c(int(input())))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c3aeca2e5c3a93e1282ca31af9637c0b", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "from sys import *\nsetrecursionlimit(10000000)\nd={}\ndef c(n):\n t=d.get(n,(0,0))\n if t!=(0,0): return t\n if n<8: return n,n\n t=int(n**(1/3)+1.e-9)\n v1=c(n-t*t*t)\n v1=v1[0]+1,v1[1]+t*t*t\n v2=c(t*t*t-1)\n if v2>v1: v1=v2\n d[n]=v1\n return v1\n \nprint(' '.join(map(str,c(int(input())))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "032529c55c24aa72ce5c80053a720028", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "from sys import *\nsetrecursionlimit(1000000)\nd={}\ndef c(n):\n t=d.get(n,(0,0))\n if t!=(0,0): return t\n if n<8: return n,n\n t=int(n**(1/3)+1.e-9)\n v1=c(n-t*t*t)\n v1=v1[0]+1,v1[1]+t*t*t\n v2=c(t*t*t-1)\n if v2>v1: v1=v2\n d[n]=v1\n return v1\n \nprint(' '.join(map(str,c(int(input())))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3a55842d75c23c4b7a59da8b0c8bd993", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "s1=input()\nw1=s1.split()\ns2=input()\nw2=s2.split()\ns3=input()\nw3=s3.split()\nn=int(w1[0])\nk=int(w1[1])\nl2=[]\nt=0\nwhile tl2[j+1] :\n print(\"Yes\")\n break\n else :\n j+=1\n if j==n-1 :\n print(\"No\")\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cf6af92f970165464fd425b3f951134c", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s1=input()\nw1=s1.split()\ns2=input()\nw2=s2.spit()\ns3=input()\nw3=s3.split()\nn=int(w1[0])\nk=int(w1[1])\nt=0\nl2=[]\nwhile tl2[j+1] :\n print(\"Yes\")\n break\n else :\n j+=1\n if j==n-1 :\n print(\"No\")\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "372131db9c4d3221e870e3217a02ddfd", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\n\na = list(map(int, input().split())\nb = list(map(int, input().split()))\n\nif a.count(0) > 1:\n print(\"Yes\")\nelse:\n a[a.index(0)] = b[0]\n if a == a.sort():\n print(\"No\")\n else:\n print(\"Yes\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b056cb96caed48ce4bae20fa8ad6bd4", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "len_origin, len_missing = (int(x) for x in input().split())\nmissing_in_origin_counter = 0\norigin = [int(x) for x in input().split()]\nmissing = [int(x) for x in input().split()]\nmissing = sorted(missing, reverse=True\nidx_missing = 0\nfinal = []\nfor idx_origin, number in enumerate(origin):\n if number == 0:\n final.append(missing[idx_missing])\n idx_missing += 1\n else:\n final.append(number)\nif final == sorted(final):\n print('No')\nelse:\n print('Yes')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c4bf0252ed729f82d57e3d8030d29815", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\n# coding: utf-8\n\n# In[10]:\n\nvector1 = input()\na = input()\nb = input()\nvector1 = vector1.split(\" \")\na = a.split(\" \")\nb = b.split(\" \")\nb2 =[]\na2 =[]\na3 =[]\na4 =[]\ni=0\npos = 0\n\n\nif len(b)>=2:\n print(\"Yes\")\nelse:\n while(1):\n if i 0:\n a2.append(a[i])\n i= i+1\n i=0\n while(1):\n if iint(a2[i+1]):\n print(\"Yes\")\n break \n i= i+1\n \n while(1):\n if i0:\n print(\"No\")\n else:\n print(\"Yes\") \n \n \n\n \n\n\n# In[ ]:\n\n\n\n\n# In[ ]:\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "637e09ee22794a3bbb6d09bc501c9efb", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.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": "dba0d09de6d0be07717b3dbe0059023a", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.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\nax,ay = map(int,input().split(' '))\nbx,by = map(int,input().split(' '))\ncx,cy = map(int,input().split(' '))\nx1=ax-bx\ny1=cx-bx\nx2=ay-by\ny2=cy-by\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": "6cfd4dbf0bdb5e2e09435cf78b2ee988", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int a1,a2,b1,b2,c1,c2;\n cin >> a1 >> a2;\n cin >> b1 >> b2;\n int v1 = a1-b1;\n int v2 = a2-b2;\n cin >> c1 >> c2;\n int u1 = c1-b1;\n int u2 = c2-b2;\n if(fabs(v1) > 1000 and fabs(v2) > 1000 and fabs(u1) > 1000 and fabs(u2) > 1000)\n {\n v1 = ceil(v1/2000);\n v2 = ceil(v2/2000);\n u1 = ceil(u1/2000);\n u2 = ceil(u2/2000);\n }\n long long int parcel1 = v1*u2;\n long long int parcel2 = v2*u1;\n\n if(parcel1 == parcel2)\n cout << \"TOWARDS\" << endl;\n if(parcel1 > parcel2)\n cout << \"RIGHT\" << endl;\n if(parcel1 < parcel2)\n cout << \"LEFT\" << endl;\n\n// cout << v1 << \" \" << v2 << endl;\n// cout << u1 << \" \" << u2 << endl;\n// cout << aux;\n return 0;\n}\n\n//47715 -171800\n//\n//-228153 -358383\n//\n//-414736 -82515", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a472e401f62ec0c2d2b69dfe4abf10a", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "#include\nint line(int x,int y){\nif (x==0&&y>0) return 2;\nif (x==0&&y<0) return 4;\nif (y==0&&x>0) return 1;\nif (y==0&&x<0) return 3;\n}\nchar bolge(int x,int y){\nchar *a=\"I\",*b[2]=\"II\",*c[3]=\"III\",*d[2]=\"IV\";\nif (x>0&&y>0) return a;\nif (x<0&&y>0) return b;\nif (x<0&&y<0) return c;\nif (x>0&&y<0) return d*;\n}\nint turn(char A, char B){\nif (A=='I' && B=='II') printf(\"RIGHT\");\nif (A=='III' && B=='IV') printf(\"RIGHT\");\nif (A=='I' && B=='IV') printf(\"LEFT\");\nif (A=='III' && B=='II') printf(\"LEFT\");\nif (A=='II' && B=='I') printf(\"LEFT\");\nif (A=='IV' && B=='III') printf(\"LEFT\");\nif (A=='IV' && B=='I') printf(\"RIGHT\");\nif (A=='II' && B=='III') printf(\"RIGHT\");\n}\nint main(){\nint i,a,b;\nchar A,B;\ndouble x[3],y[3];\nfor(i=0;i<3;i++){\nscanf(\"%lf %lf\",&x[i], &y[i]);\n}\nfor(i=0;i<3;i++){\nx[i]-=x[1];\ny[i]-=y[1];\n}\nif((x[2]/x[0])==(y[2]/y[0]){ printf(\"TOWARDS\"); return 0;}\nif(x[0]==0||x[2]==0||y[0]==0||y[2]==0){\na=line(x[0],y[0]);\nb=line(x[2],y[2]);\nif (a==1&&b==2) printf(\"RIGHT\");\nif (a==2&&b==3) printf(\"RIGHT\");\nif (a==3&&b==4) printf(\"RIGHT\");\nelse printf(\"LEFT\");\nreturn 0;\n}\nA=bolge(x[0],y[0]);\nB=bolge(x[2],y[2]);\nturn(A,B);\nreturn 0;}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a7fb1532123bcf2338b7e3193fbfa013", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\nb = map(int, raw_input().split())\nc = map(int, raw_input().split())\nd = (c[0] - b[0]) * (b[1] - a[1]) - (b[0] - a[0]) * (c[1] - b[1])\nif d < 0:\n print 'LEFT'\nelif d > 0:\n print 'RIGHT':\nelse:\n print 'TOWARDS'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29058c2e3ad728437e30e7de1136d7cb", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "a = list(sorted(map(int, intput().split())))\nif a[0] + a[3] == a[1] + a[2]:\n print(\"YES\"\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "132aac59618768475a889bbc83297963", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# https://codeforces.com/contest/1230/problem/A\nL = [int(i) for i in input().split()]\nansw_b = False\nfor i in range (1, 4):\n\tN1 = L[0] + L[i]\n\tif L[1] + L[2] + L[3] = L[0]:\n\t\tansw_b = True\n\tif i == 1:\n\t\tN2 = L[2] + L[3]\n\t\tif N1 + L[3] == L[2]:\n\t\t\tansw_b = True\n\t\tif N1 + L[2] == L[3]:\n\t\t\tansw_b = True\n\tif i == 2:\n\t\tN2 = L[1] + L[3]\n\t\tif N1 + L[1] == L[3]:\n\t\t\tansw_b = True\n\t\tif N1 + L[3] == L[1]:\n\t\t\tansw_b = True\n\tif i == 3:\n\t\tN2 = L[2] + L[1]\n\t\tif N1 + L[1] == L[2]:\n\t\t\tansw_b = True\n\t\tif N1 + L[2] == L[1]:\n\t\t\tansw_b = True\n\tif N1 == N2:\n\t\tansw_b = True\nif answ_b:\n\tprint('YES')\nelse:\n\tprint('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c730b9f55e15c20eaf0ad007e64aa80", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ndef resolve():\n\tbags_in = input(\"enter 4 bags: \")\n\tbags = list(map(int, bags_in.split()))\n\tfriend1 = []\n\tfriend2 = 0\n\tfor candie1 in bags:\n\t\tfor candie2 in bags[1:]:\n\t\t\tfriend1.append(candie1)\n\t\t\tfriend1.append(candie2)\n\t\t\ta = list(set(bags) - set(friend1))\n\t\t\tfriend2 = sum(a)\n\t\t\tprint(friend1)\n\t\t\tprint(friend2)\n\t\t\tif sum(friend1) == friend2:\n\t\t\t\treturn True\n\t\t\tfriend2 = 0\n\t\t\tfriend1.clear()\n\treturn False\n\nif(resolve()){\n\tprint(\"YES\")\n} else {\n\tprint(\"NO\")\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba222ab048843b33e4561aa9ecb920d0", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a1,a2,a3,a4=map(int,input().split())\nif(a1+a3==a2+a4):\n print(\"YES\")\nelif(a1+a4 == a2+a3):\n print(\"YES\")\nelif(a1+a2==a3+a4 or a1=a2+a3+a4 or a2=a1+a3+a4 or a3 = a1+a2+a4 or a4=a1+a3+a2):\n print(\"YES\")\nelse:\n print(\"N0\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1a0ce57879ce4d1c79011be7f1d816d", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 3", "source_code": "arr=[int(x) for x in input().split()]\nif a+b==c+d or a+c==b+d or a+d=b+c or a+b+c==d or a+b+d==c or a+c+d==b or b+c+d==a:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72f4bbfba24f74bdb2aa2c9cd4ba46e7", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import sys\nn = int(raw_input())\n\nmaster_list = [] #contains list of the 4 coords for each rectangle\nxmin = sys.float_info.max\nxmax = sys.float_info.min\nymin = sys.float_info.max\nymax = sys.float_info.min\nfound_area = 0\nfor i in xrange(0, n):\n\ttemp_list = []\n\trect_list = raw_input()\n\tcount = 0\n\tfor coord in rect_list.split(\" \"):\n\t\tif count == 0:\n\t\t\tif int(coord) < xmin:\n\t\t\t\txmin = int(coord)\n\t\tif count == 1:\n\t\t\tif int(coord) < ymin:\n\t\t\t\tymin = int(coord)\n\t\tif count == 2:\n\t\t\tif int(coord) > xmax:\n\t\t\t\txmax = int(coord)\n\t\tif count == 3:\n\t\t\tif int(coord) > ymax:\n\t\t\t\tymax = int(coord)\n\t\ttemp_list.append(int(coord))\n\t\tcount += 1\n\tmaster_list.append(temp_list)\n\tfound_area += (temp_list[2]-temp_list[0])*(temp_list[3]-temp_list[1])\n\n#print \"found area was %s \" %found_area\n\ndef get_edge_pts(coord_list):\n\txleft = coord_list[0]\n\txright = coord_list[2]\n\tybot = coord_list[1]\n\tytop = coord_list[3]\n\n\treturn_list = [] # a list of tuples\n\tfor i in xrange(xleft, xright+1):\n\t\tif (i, ybot) not in return_list:\n\t\t\treturn_list.append((i, ybot))\n\t\tif (i, ytop) not in return_list:\n\t\t\treturn_list.append((i, ytop))\n\tfor j in xrange(ybot, ytop):\n\t\tif (xleft, j) not in return_list:\n\t\t\treturn_list.append((xleft, j))\n\t\tif (xright, j) not in return_list:\n\t\t\treturn_list.append((xright, j))\n\treturn return_list\n\ndef get_int_pts(coord_list):\n\txleft = coord_list[0]\n\txright = coord_list[2]\n\tybot = coord_list[1]\n\tytop = coord_list[3]\n\n\treturn_list = [] # a list of tuples\n\tfor i in xrange(xleft+1, xright):\n\t\tfor j in xrange(ybot+1, ytop):\n\t\t\treturn_list.append((i, j))\n\treturn return_list\n\next_master_list = []\nfor i in xrange(0, len(master_list)):\n\tlist_ext_coords = get_edge_pts(master_list[i])\n\tfor coord in list_ext_coords:\n\t\tif coord not in ext_master_list:\n\t\t\text_master_list.append(coord)\n\ninvalid_int = False\nfor x in xrange(xmin, xmax+1):\n\tfor y in xrange(ymin, ymax+1):\n\t\ttemp = (x, y)\n\t\tif temp not in ext_master_list:\n\t\t\t#print temp\n\t\t\ttemp_count = 0\n\t\t\tfor rect in master_list:\n\t\t\t\tif temp in get_int_pts(rect):\n\t\t\t\t\ttemp_count += 1\n\t\t\t#print temp_count\n\t\t\tif temp_count != 1:\n\t\t\t\t#print \"found invalid pt\"\n\t\t\t\tinvalid_int = True\n\t\t\t\tbreak\n\nexpected_area = (xmax-xmin)*(ymax-ymin)\n#print \"expected_area is %s \"%expected_area\nif invalid_int or expected_area != found_area:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c86b2cfff630fe0607d8d6ff0857020d", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "for i in range(int(input())):\n x1, y1, x2, y2 = map(int, input().split())\n a1, b1, a2, b2 = min(a1, x1), min(b1, y1), max(a2, x2), max(b2, y2)\n s += (x2 - x1) * (y2 - y1)\nprint('YES' if s == (a2 - a1) * (b2 - b1) else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e1a0fd2c945a96df18c3f313ef188e6", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "s = 0\nfor i in range(int(input())):\n x1, y1, x2, y2 = map(int, input().split())\n a1, b1, a2, b2 = min(a1, x1), min(b1, y1), max(a2, x2), max(b2, y2)\n s += (x2 - x1) * (y2 - y1)\nprint('YES' if s == (a2 - a1) * (b2 - b1) else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5122cb8a77946f9533150f9033b7b203", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a1, b1, a2, b2 = map(int, input().split())\ns = (a2 - a1) * (b2 - b1)\nfor i in range(n - 1):\n x1, y1, x2, y2 = map(int, input().split())\n a1, b1, a2, b2 = min(a1, x1), min(b1, y1), max(a2, x2), max(b2, y2)\n s += (x2 - x1) * (y2 - y1)\nprint('YES' if a2 - a1 == b2 - b1 and s == (a2 - a1) * (b2 - b1) else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff30675af3d71e60068985e985e4fb39", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import sys\n\nn = int(raw_input().strip())\n\nhsides = []\nvsides = []\nxranges = {}\nyranges = {}\n\nfor i in range(n):\n x1, y1, x2, y2 = [int(i) for i in raw_input().strip().split()]\n if y2 - y1 == x2 - x1:\n print \"YES\"\n sys.exit(1)\n vside1 = [x1, y1, y2, \"left\"]\n vside2 = [x2, y1, y2, \"right\"]\n hside1 = [y1, x1, x2, \"bottom\"]\n hside2 = [y2, x1, x2, \"top\"]\n if y1 not in yranges:\n yranges[y1] = []\n yranges[y1].append([x1, x2])\n if y2 not in yranges:\n yranges[y2] = []\n yranges[y2].append([x1, x2])\n if x1 not in xranges:\n xranges[x1] = []\n xranges[x1].append([y1, y2])\n if x2 not in xranges:\n xranges[x2] = []\n xranges[x2].append([y1, y2])\n\ndef inrange(start, end, ranges, index):\n if index not in ranges:\n return False\n for r in ranges[index]:\n if r[0] <= start and r[1] >= end:\n return True\n return False\n\nfor side in vsides:\n s = side[2]-side[1]\n if side[3] == \"left\":\n topok = inrange(side[0]-s, side[0], yranges, side[2])\n bottomok = inrange(side[0]-s, side[0], yranges, side[1]) \n newleftok = inrange(side[1], side[2], xranges, side[0]-s)\n ok = topok and bottomok and newleftok\n if side[3] == \"right\":\n topok = inrange(side[0], side[0]+s, yranges, side[2])\n bottomok = inrange(side[0], side[0]+s, yranges, side[1]) \n newrightok = inrange(side[1], side[2], xranges, side[0]+s)\n ok = topok and bottomok and newrightok\n if side[3] == \"top\":\n leftok = inrange(side[0], side[0]+s, xranges, side[1])\n rightok = inrange(side[0], side[0]+s, xranges, side[2])\n newtopok = inrange(side[1], side[2], yranges, side[0]+s)\n ok = leftok and rightok and newtopok\n if side[3] == \"bottom\":\n leftok = inrange(side[0]-s, side[0], xranges, side[1])\n rightok = inrange(side[0]-s, side[0], xranges, side[2])\n newbottomok = inrange(side[1], side[2], yranges, side[0]-s)\n ok = leftok and rightok and newbottomok\n if ok:\n print \"YES\"\n sys.exit(1)\nprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5df1ec02a5f9ccfda98bf971cdd23c51", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\ncount=0\nfor i in range(1,n):\n\tif i%n==0:\n\t\tcount+=1\n print(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7391666289fd59298188010d0b2e4e1", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n= int(input())\n\ncnt=0\n\nfor i in range(1,(n+1)):\n if(n%i==0):\n\tcnt+=1\n\nprint(cnt)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7fa10089804038acaef8651ac5d7fa2c", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Python 3", "source_code": " = int(input())\nc1=0\nfor i in range(1,(n//2)+1):\n\tif ((n-i)%i)==0:\n\t\tc1+=1\nprint(c1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce42955c7e00aa686e92a2f8a4a557b2", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nprint sum(n%i==0 for i in range(1, n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bffadb169c2373efa6c69f2d1341e4a4", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nprint sum(n%i==0for i in range(1,n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "198d0a43dbc2dd2e0b430cae1fc2e44a", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\nedges = [[int(x) - 1 for x in input().split()] for _ in range(m)]\nprint(max(len({tuple(sorted((mask // (6 ** u)) % 6, (mask // (6 ** v)) % 6)) for u, v in edges}) for mask in range(6 ** n)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "108bdf63c0d4349a22fc77bd62d676a1", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\n\nLines = []\nfor Line in sys.stdin:\n Lines.append(Line.rstrip('\\n'))\n\n\n\n# lines=[\"7 11\",\n# \"4 7\",\n# \"6 4\",\n# \"5 1\",\n# \"1 4\",\n# \"5 4\",\n# \"1 2\",\n# \"3 4\",\n# \"4 2\",\n# \"6 1\",\n# \"3 1\",\n# \"7 1\"]\n\n\nn,m = list(map(int,lines[0].split()))\ndel(lines[0])\n\n#G=[[] for _ in range(n)]\nG=[[0 for i in range(n)] for j in range(n)]\nfor i in range(m):\n a,b=list(map(int,lines[i].split()))\n a = a-1\n b = b-1\n G[a][b]=1\n G[b][a]=1\n\nif (n<=6):\n\tprint(m)\n\texit(0)\nelse:\n ctr = 2e9;\n for i in range(n):\n for k in range(n):\n temp = 0\n for j in range(n): \n if(G[i][j]==1 and G[k][j]==1):\n \ttemp+=1\n ctr = min(ctr, temp)\n print(m-ctr)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c4f0dcc44fc391f12cf40fae2f60499", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n = [int(j) for j in input().split()]\nm = [int(j) for j in input().split()]\nadj = [set() for i in range(n)]\nfor i in range(m):\n\tl, r = [int(j)-1 for j in input().split()]\n\tadj[l].add(r)\n\tadj[r].add(l)\nif n<7:\n\tprint(m)\nelse:\n\tdeg = 10**12\n\tfor i in range(n):\n\t\tfor j in range(i+1, n):\n\t\t\tl = adj[i].intersection(adj[j])\n\t\t\ttmp = len(l)\n\t\t\tif tmp= need:\n result = min(x * c + y * d, result)\n\nprint result \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "610030aef78d41424ec6e63b715bf179", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import math\ndef ar():\n return map(int,raw_input().split())\nc,d=ar()\nn,m=ar()\nk=ar()[0]\nreq=(n*m)-k\nmi=100000000\nfor i in range(req+1):\n for j in range(req+3):\n if n*i+j >=req:\n if c*i+j*d min(s, n) * d:\n res += min(s,n) * d\n else:\n res += c\n s -= min(s,n)\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "45d9594eddea43ca6fe937b3dc1e38e1", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "c, d = list(map(int, input().split()))\nn, m = list(map(int, input().split()))\nf = n * m\nk = int(input())\nresult = 0\nuch = k\n\nuseosn = usedop = 0\n\nwhile uch < f:\n if c/n < d:\n result += c\n uch += n\n else:\n result += d\n uch += 1\n\n\n\nprint(max(0, result))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4ef480541fe1931defb45f5812a7ad1", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "problems = input().split()\nc = int(problems[0])\nd = int(problems[1])\nn_m = input().split()\nn = int(n_m[0])\nm = int(n_m[1])\nk = int(input())\n\nt = n * m - k # \u043d\u0443\u0436\u043d\u043e\u0435 \u0432\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u043a\u0440\u043e\u043c\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445\nans = 100000000 # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447\ni = 0\nwhile i*n <= t: # \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0440\u0430\u0443\u043d\u0434\u0430\u043c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430\u0434\u043e\n ans = min(ans, (t - i*n) * d + i*c)\n i++\nans = min(ans, i*c)\nprint(ans)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1164bc9e22197ea4747acc85e934d0ff", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = [int(x) for x in input().split()]\na = m[0]\ns = 0\nbr = 0\nfor i in range(n-1):\n b = m[i+1]\n\tif a==1:\n\t if b==2:\n\t\t s+=3\n\t\telse:\n\t\t\ts+=4\n\telif a==2:\n\t\tif b==1:\n\t\t\ts+=3\n\t\telse:\n\t\t\tbr = 1\n\t\t\tbreak\n\telse:\n\t\tif b==1:\n\t\t\ts+=4\n\t\telse:\n\t\t\tbr = 1\n\t\t\tbreak\nif br==1:\n\tprint('Infinite')\nelse:\n\tprint('Finite')\n\tprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4939cb1055558d418a48a5e793380004", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = [int(x) for x in input().split()]\na = m[0]\nc = 0\ns = 0\nbr = 0\nfor i in range(n-1):\n b = m[i+1]\n if a==1:\n if b==2:\n if c==3:\n\t\t\t s+=2\n\t\t\telse:\n\t\t\t s+=3\n else:\n s+=4\n elif a==2:\n if b==1:\n s+=3\n else:\n br = 1\n break\n else:\n if b==1:\n s+=4\n else:\n br = 1\n break\n c = a\n\ta = b\nif br==1:\n print('Infinite')\nelse:\n print('Finite')\n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c55fa4a9307119463664f419b669d239", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\narr = [int(x) for x in input().split()]\n\ninf =\"Finite\"\nsum = 0\nfor i in range(1,n):\n d = arr[i-1]+arr[i]\n if d==5 arr[i-1]==arr[i]:\n inf = \"Infinite\"\n break\n else:\n sum+=d\n\nprint(inf)\nif(inf==\"Finite\"):\n print(sum)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70e61a0159c943c0cad4ee06f9a6e319", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\na=map(int,input().split())\nans=0\nflag=False\nfor i in range(n-1):\n if a[i] != 1 and a[i+1] != 1:\n flag=True\n elif a[i] == 2 or a[i+1] == 2:\n ans+=3\n elif a[i] == 3 or a[i+1] == 3:\n ans+= +=4\nif flag:\n print(\"Infinite\")\nelse:\n print(ans)\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "496a9576a314f16135f4639ea1926c16", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n=int(input())\na=[int(i) for i in input().split()] \nk=True\nm=0\ni=0\nwhile k and i= 0):\n if(tablero[k][j] != '.'):\n break\n k -= 1\n if(k < 0):\n minimo = min(minimo, i)\n return minimo\n\ntablero = []\nfor i in range(1, 9):\n line = input()\n tablero.append(line)\n \nA = cuenta(tablero, 'W')\nfor i in range(0, 4):\n aux = copy.copy(tablero[i])\n tablero[i] = copy.copy(tablero[8-i-1])\n tablero[8-i-1] = aux\n\n#for i in range(0, 8):\n# print(tablero[i])\nB = cuenta(tablero, 'B')\nif(A < B):\n print(\"A\")\nelse:\n print(\"B\")\n#print(A, B)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cf4843ee1c35f30e6196f0c137cdf15f", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def read_row(s):\n row = []\n for item in s:\n if item == \"W\":\n row.append(1)\n elif item == \"B\":\n row.append(0)\n else:\n row.append(None)\n return row\n\ntable = []\nfor i in range(8):\n table.append(read_row(input()))\n\ncolumns = []\nfor i in range(8):\n column = []\n for j in range(8):\n column.append(table[j][i])\n columns.append(column)\n\nmin_moves_for_a = 8\nmin_moves_for_b = 8\n\nfor col in columns:\n if (0 in col) & not(1 in col):\n moves_for_b = 8 - col.index(0) - 1\n if moves_for_b < min_moves_for_b:\n min_moves_for_b = moves_for_b\n if (1 in col) & not(0 in col):\n moves_for_a = 8 - col.index(1) - 1\n if moves_for_a < min_moves_for_a:\n min_moves_for_a = moves_for_a\nif min_moves_for_a <= min_moves_for_b:\n print('A')\nelse min_moves_for_a > min_moves_for_b:\n print('B')\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a9a2b3abd966b399440b9342184ce788", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def read_row(s):\n row = []\n for item in s:\n if item == \"W\":\n row.append(1)\n elif item == \"B\":\n row.append(0)\n else:\n row.append(None)\n return row\n\ntable = []\nfor i in range(8):\n table.append(read_row(input()))\n\ncolumns = []\nfor i in range(8):\n column = []\n for j in range(8):\n column.append(table[j][i])\n columns.append(column)\n\nmin_moves_for_a = 8\nmin_moves_for_b = 8\n\nfor col in columns:\n if (0 in col) & (1 in col):\n continue\n elif (0 in col) & not(1 in col):\n moves_for_b = 8 - col.index(0) - 1\n if moves_for_b < min_moves_for_b:\n min_moves_for_b = moves_for_b\n elif (1 in col) & nor(0 in col):\n moves_for_a = 8 - col.index(1) - 1\n if moves_for_a < min_moves_for_a:\n min_moves_for_a = moves_for_a\nif min_moves_for_a <= min_moves_for_b:\n print('A')\nelse min_moves_for_a > min_moves_for_b:\n print('B')\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d7c8d224f2e8746d5c7e7042dcc6054", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\ufeffboard={}\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": "a20e01781ba3edbffa10cd87bc50f9e4", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\ufeff\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": "0d31732c3afdd6fe7670fa23b71a6013", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,m=list(map(int,input().split()))\nif m<=n:\n print(n-m)\nc=0\nelse:\n while m>n:\n if m%2:\n m=m+1\n else:\n m=m//2\n c=c+1\n c=c+(n-m)\n print(c) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3055e82e89b0bbb8cbdd9bc7de45bbb9", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import heapq\n\n\ndef main():\n n, m = map(int, input().split())\n stack = [(0,n)]\n while stack:\n count, node = heapq.heappop(stack)\n if node == m:\n print(count)\n break\n a ,b = node*2, node -1\n if 1<=a<=10000:\n\n heapq.heappush(stack,(count+1,a))\n if 1<=b<=10000\n heapq.heappush(stack,(count+1,b))\n\n\n\nif __name__==\"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b3659912274ae2e9e5a9e7ea01654c1", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n,m = map(int, input().split())\nmoves=0\nwhile n != m:\n moves+=1\n m += 1 if m % 2 != 0 or m < n else m=m//2\nprint(moves)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f0aa67f3561d1ad93af7db0e69effaa4", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a,b=[int(x) for x in input().split()]\ncount=0\nif(b>a):\n while(am:\n \t\treturn n-m\n \tif 2*n > m and m-n>1:\n \t\tn-=1\n \t\ti+=1\n \t\treturn Butt(n, m, i)\n \tif 2*n == m:\n \t\treturn i+1\n \tif m-n>n:\n \t\tn*=2\n \t\ti+=1\n \t\treturn Butt(n, m, i)\n\t\nn,m =[int(x) for x in input().split()]\njavab=Butt(n, m, i)\nprint(javab)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ef5810e22da120a96db576f6c7b6a2e", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\nd=n-k\nif k!=0 and k==2*k:\n print(1,2*k)\nelse:\n print(1,d+1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "991a913138cb95ac94f6e2a5f8632bef", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nn, k = (int(e) for e in input().split())\n\nif k ==0 || n == k:\n print(0, 0)\nelif n >= k * 3:\n print(1, k*2)\nelse:\n print(1, n-k)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "63da5c36aab3a890a098be5bd9812112", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,k = [int(x) for x in raw_input().split()]\nif n == k:\n print \"0 0\"\n return\nprint '1',\nif k*2 < n-k:\n print k*2\nelse:\n print n - k", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3556ae68ba4410ea77d9bdc10b1df8eb", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n, k = list(map(int, input().split()))\n\ng = min(2 * k, n-k)\n\nif k < n && k > 0:\n print('1 ' + str(g))\nelse:\n print('0' + str(g))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "077a91310795769fcaffcb28dfc2b88e", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "n, k = map(int, raw_input().split())\nmin_h = 1\nmax_h = 0\n\nif k > n/3:\n max_h = n - k\nelse if k == n/3:\n max_h = n - k \n max_h += n % 3\nelse:\n max_h = 2*k\nprint min_h, max_h\n\n\n\n\n# oxooxo\n# ooxooxo\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8817317886cfc718b59f75e3cc9b72a3", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "try:\n n=int(input())\n ans=\"\"\n if n>0:\n print(n)\n else:\n s=str(n)\n b=max(s[-1],s[-2])\n if b==s[-1]:\n ans+=s[:-1]\n break\n if b==s[-2]:\n ans+=s[:-2]+s[-1]\n break\n if ans=='-0\":\n print(0)\n else:\n print(ans)\nexcept:\n pass", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0bc9088e715d8ffbc8f3ccdba78b2503", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s = input()\nif int(n) < 0 :\n if int(s[:-1]) > int(s[:-2] + s[-1]) : print(s[:-1]))\n else : print(s[:-2] + s[-1])\nelse : print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "68445fb216413364a06dacbca939a14c", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s = input()\nif int(s) < 0 :\n if int(s[:-1]) > int(s[:-2] + s[-1]) : print(s[:-1]))\n else : print(s[:-2] + s[-1])\nelse : print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a9fc6d5e086f73864aef9784142fdf6c", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Python 2", "source_code": "s = raw_input()\nif s[0]!='-':\n print s\nelse :\nif s[-1]>s[-2]:\n s = s[:-1]\n else : s = s[:-2]+s[-1]\n print int(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1858be42a55f3cbb61a4410654b031b6", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nif n>0:\n\tprint(n)\nelse:\n\tif n<0:\n\t\tx=str(n)\n\t\tj=len(x)\n\t\tr=x[j-1]\n\t\ts=x[j-2]\n\t\tif r>s:\n\t\t\tt=''\n\t\t\tfor u in range (0,j,1):\n\t\t\t\tif x[u]!=r:\n\t\t\t\t\tt=t+x[u]\n\t\t\tt=int(t)\n\t\t\tprint(t)\n\t\telse:\n\t\t\tif s>r:\n\t\t\t\tt=''\n\t\t\t\tfor u in range (0,j,1):\n\t\t\t\t\tif x[u]!=s:\n\t\t\t\t\t\tt=t+x[u]\n\t\t\t\tif t[1]==\"0\":\n\t\t\t\t\tprint(\"0\")\n\t\t\t\telse:\n\t\t\t\t\tt=int(t)\n\t\t\t\t\tprint(t)\n\telse:\n\t\tif n==0:\n\t\t\tprint(n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a1e5f58535333ff4f96b327e9114e4a1", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "y=input()+1\nwhile len(set(str(y)))<4:y+=1\nprint y", "lang_cluster": "Python", "compilation_error": true, "code_uid": "297aeb024d3a160e37d2174044219f30", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "A\u00f1o=int(input())\nwhile True:\n A\u00f1o=A\u00f1o+1\n A=int(A\u00f1o/1000)\n B=(int(A\u00f1o/100))%10\n C=(int(A\u00f1o//10))%10\n D= A\u00f1o%10\n if ((A!=B) and (A!=C) and (A!=D) and (B!=C) and (B!=D) and (C!=D)):\n break\nprint(A\u00f1o)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0bbdfd0bd25b1306fbe145e901435972", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "Python 2", "source_code": "# y = input()\n# while True:\n# y += 1\n# s = str(y)\n# if len(set(s)) == len(s):\n# print s\n# exit(0)\ny = input()+1\nwhile len(set(str(y)) < 4: n+=1\nprint y\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b2b897b8f9f1296e77debe3e7f3c0da", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "int main()\n \n int recibe = 0\n int entrega = 0\n bool es = False\n \n recibe = input()\n \n int i = 0;\n while (not es)\n \n recibe++;\n entrega = recibe;\n es = True;\n entrega = str(entrega=\n for (int i = 0; i < len(entrega); i++):\n \n for (int j = i; j < len(entrega); j++):\n \n if (entrga[i] == entrega[j]):\n es = false;\n \n return entrega", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a31f600e350526975d18af08ecac0ba7", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "A\u00f1o=int(input())\nwhile (True):\n A\u00f1o=A\u00f1o+1\n A=A\u00f1o//1000\n B=(A\u00f1o//100)%10\n C=(A\u00f1o//10)%10\n D=A\u00f1o%10\n if (A!=B and A!=C and A!=D and B!=C and B!=D and C!=D):\n break\nprint(A\u00f1o)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "99c1aee9c3197390f62796a48bb5ab15", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s = input()\nt = input()\n\t\nresult = \"\"\ncoverTop = False\ncoverBottom = False\nfor case in range(2):\n\tfor i in range(len(s)):\n\t\tpossibleCode = int((ord(s[i]) + ord(t[i])) / 2)\n\t\tif (ord(s[i]) + ord(t[i])) % 2 == 0:\n\t\t\tpossibleCode = possibleCode\n\t\telse:\n\t\t\tpossibleCode += case\n\n\t\tif coverTop & coverBottom:\n\t\t\tresult += chr(possibleCode)\n\t\telif coverTop & ~coverBottom:\n\t\t\tif ord(s[i]) + 1 > ord('z'):for case in range(2):\n\n\t\t\t\tresult += chr(ord(s[i]))\n\t\t\telse:\n\t\t\t\tresult += chr(ord(s[i]) + 1)\n\t\t\t\tcoverBottom = True\n\t\telif ~coverTop & coverBottom:\n\t\t\tif ord(t[i]) - 1 < ord('a'):\n\t\t\t\tresult += chr(ord(t[i]))\n\t\t\telse:\n\t\t\t\tresult += chr(ord(t[i]) - 1)\n\t\t\t\t# print(i, s[i], t[i], possibleCode)\n\t\t\t\tcoverTop = True\n\t\telif ~coverTop & ~coverBottom:\n\t\t\tresult += chr(possibleCode)\n\t\t\tif possibleCode > ord(s[i]):\n\t\t\t\t# print(\"coverBottom\", i, s[i], t[i], ord(s[i]), ord(t[i]), possibleCode)\n\t\t\t\tcoverBottom = True\n\t\t\tif possibleCode < ord(t[i]):\n\t\t\t\t# print(\"coverTop\", i, s[i], t[i], ord(s[i]), ord(t[i]), possibleCode)\n\t\t\t\tcoverTop = True\n\n\tif coverTop & coverBottom:\n\t\tbreak\n\nif coverTop & coverBottom:\n\tprint(result)\nelse:\n\tprint(\"No such string\")\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dd0a7a9b6b983116de028b957423eec5", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a = input()\nb = input()\nres = \"\"\n\nNO_SUCH_STRING = \"No such string\"\n\narr_a = [ord(a[i]) for i in range(len(a))]\narr_b = [ord(b[i]) for i in range(len(b))]\n\nif a[:len(a) - 1] == b[:len(b) - 1] and abs(ord(b[-1]) - ord(a[-1])) == 1:\n res = NO_SUCH_STRING\nelse:\n\n for j in range(len(a) - 1, -1, -1):\n if arr_a[j] == ord('z'):\n elif arr_a[j] == ord('z') and arr_b[j] != 'a':\n arr_a[j] = ord('a')\n else:\n arr_a[j] += 1\n break\n\n for i in arr_a:\n res += chr(i)\n\nif res == b:\n print(NO_SUCH_STRING)\nelse:\n print(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "02cc0c908eaa44fd6c9187b414946b53", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "ins=raw_input()\nintt=raw_input()\nl=len(ins)\na=0\nfor i in range(l):\n if ord(intt[i])-ord(ins[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": "b81057e60957a90f5ae7faa6cb874ed4", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s = input()\nt = input()\n\ns_clone = list(s)\nlength = len(s)\n\nfor i in range(length - 1, -1, -1):\n if ''.join(s_clone) > s and ''.join(s_clone) < t:\n print(''.join(s_clone))\n return\n\n dist = abs(ord(t[i]) - ord(s[i]))\n if dist > 0:\n if s[i] == 'z':\n s_clone[i] = 'a'\n else:\n s_clone[i] = chr(ord(s[i]) + 1)\n\nprint('No such string')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ec5d51403a246736183d6de720bbc502", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "s = list(raw_input())\nt = list(raw_input())\n\ni = len(s) - 1;\n\nwhile (s[i] == 'z') :\n\ti -= 1\n\ns[i] = chr(ord(s[i]) + 1)\n\nif s < t :\n\tprint s\nelse\n\tprint \"No such string\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ddf899041a63bccb395aff3dade74280", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.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 = 5*10**5+1\ng1 = [1, 1] # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [0, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nn,k=map(int,input().split())\nans=0\nfor i in range(1,n+1):\n count=n//i-1\n if count>=k-1:\n ans+=cmb(count,k-1,mod)\n ans%=mod\n\nprint(ans%mod)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ff12d7df4e5440adfc7c911c2c983aa", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import math\nn,k=tuple(map(int,input().split()))\ndp=[0 for i in range(5*(10**5)+1)]\nx=0\ndp[0]=1\np=998244353 \nfor i in range(1,5*(10**5)+1):\n dp[i]=(i*dp[i-1])%p\ndef binpow(x,y):\n z=1\n while y>0:\n if y%2==1:\n z=(z*x)%p\n x=(x*x)%p\n y=y//2\n return z\ndef inversion(x):\n return binpow(x,p-2)\nif(n==k or k==1):\n print(1)\nelse:\nfor i in range(1,n):\n if(k*i<=n):\n c=n//i\n x+=(dp[c-1]*inversion((dp[k-1]*dp[c-k])%p))%p\n else:\n break\nif(n==k ):\n print(1)\nelse:\n print(x%p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6f170a38605521fafce71abb671da60", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from functools import lru_cache\nn,k = map(int,input().split())\nmod = 998244353\nrng = 500100\nfctr = [1]\nfor i in range(1,rng):\n fctr.append(fctr[-1]*i%mod)\ndef finv(x):\n return pow(fctr[x],mod-2,mod)\ndef cmb(n,k):\n if n<0 or k<0:\n return 0\n else:\n return fctr[n]*finv(n-k)*finv(k)%mod\nif n < k:\n print(0)\n exit()\n@lru_cache\ndef stable(n,k,mn):\n if n < k*mn:\n return 0\n dvs = set()\n for i in range(1,int((n+0.5)**0.5)+1):\n if n%i == 0:\n dvs.add(i)\n dvs.add(n//i)\n ret = 0\n dvs = list(dvs)\n ndvs = 0\n for i in dvs:\n if i >= mn:\n ndvs += 1\n if n//i >= k and i >= mn:\n ret += cmb(n//i-1,k-1)\n ret %= mod\n return ret\nans = 0\nfor i in range(k):\n ans += stable(n-i,k,i+1)\n ans %= mod\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e60c10d80e98e8570608ad4087c61772", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "MOD=998244353\ndef add(x,y):\n x+=y\n while x>=MOD:\n x-=MOD\n while x<0:\n x+=MOD\n return x\ndef multipication(x,y):\n return (x*y)%MOD\ndef binpow(x,y):\n z=1\n while y>0:\n if y%2==1:\n z=multipication(z,x)\n x=multipication(x,x)\n y=y//2\n return z\ndef inversion(x):\n return binpow(x,MOD-2)\ndef division(x,y):\n return multipication(x,inversion(y))\nn,k=list(map(int,input().split()))\nfactorial=[1]\nfor i in range(1,500001):\n factorial.append(multipication(i,factorial[-1]))\ndef combination(x,y):\n if y>x:\n return 0\n return division(factorial[x],multipication(factorial[y],factorial[x-y]))\nanswer=0\nfor i in range(1,n+1):\n d=n//i\n answer=add(ans,combination(d-1,k-1))\nprint(answer)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "45f1d44c70c82422d9906ff64c68b278", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\nimport sys\nsys.setrecursionlimit(1500)\n\n\n# 7 3\n# n % 2 % 3 % 4 = n % 3 % 2 % 4\n# 8 % 3 % 6 = 2 = 8 % 6 % 3 =\n# 8 % 5 % 10 = 3 = 8 % 10 % 5 = 3\n# 8 % 2 % 5, 8 % 5 % 2\n\n# 1 => (2 3) 4 5 6 =>\n# 1 => (2, 3) 4 => 3*2 / 2\n# 1 => any\n# 2 => 2*1, 2*2, 2*3, 2*4\n# 3 => 3*1, 3*2, 3*3, 3*4\n# 5 => 5*1, 5*2, 5*3, 5*4\ndef modular_stability(n, k):\n\n if k > n:\n return 0\n\n if k == 1:\n return n\n\n res = 0\n # 1\n res += com(n-1, k-1)\n res %= 998244353\n\n # prime numbers\n for i in range(2, n+1):\n #if isprime(i):\n cnt = n // i\n if cnt == k:\n res += 1\n elif cnt > k:\n res += com(cnt-1, k-1)\n res %= 998244353\n\n #print(faca)\n return res\n\n\ndef isprime(n):\n\n j = 2\n while j*j <= n:\n if n%j == 0:\n return False\n j += 1\n\n return True\n\n\ndef com(p1, p2):\n return fac(p1) // fac(p1-p2) // fac(p2)\n\n\nfaca = [0, 1]\ndef fac(n):\n if len(faca) > n:\n return faca[n]\n r = n*fac(n-1)\n faca.append(r)\n\n return r\n\n\nif __name__ == '__main__':\n (n,k) = list(map(int, stdin.readline().split()))\n for i in range(1, n+1):\n fac(i)\n\n print(modular_stability(n, k))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e77f0e9c873a7451369c704facb12ab", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "a,b,c=input().split()\na1,b1,c1=input().split()\na=int(a)\nb=int(b)\nc=int(c)\na1=int(a1)\nb1=int(b1)\nc1=int(c1)\nif a+b<=a1+b1 and a<=a1:\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58b25a4f30efddcd0c87812649cb28c9", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def find(x,y,z,a,b,c):\n \n a_dis = x-a\n if a_dis <= 0:\n d_dis = y - b - a_dis\n if d_dis <= 0:\n m_dis = z - c - d_dis\n if m_dis <= 0:\n return(\"YES\")\nreturn(\"NO\") \n\nx,y,z = map(int(input.split()))\na,b,c = map(int(input.split()))\n\nprint(find(x,y,z,a,b,c))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4fc1d1096497aaff76542d7b459d30d7", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#!python3\nx,y,z = [int(i) for i in input().strip().split(' ')]\na,b,c = [int(i) for i in input().strip().split(' ')]\na -= x\nif a >= 0\n a_b = a+b - y\n if a_b >= 0:\n a_b_c = a_b + c - z\n if a_b_c >= 0:\n print(\"YES\")\n exit()\nprint(\"NO\")\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e62fb2fe29dc287be4ff8e712e7992a9", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x,y,z=tuple(map(int, input().split()))\na,b,c=tuple(map(int, input().split()))\nif (x <= a) and (y>= ((a - x ) + b)) and (z>=((a+b+c) - (a-x + a - x + b)):\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6d108b64b5f91237baf8a2bb13af5952", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x = int(input())\ny = int(input())\nz = int(input())\n\na = int(input())\nb = int(input())\nc = int(input())\n\nif x > a:\n\tprint('NO')\n\treturn\nelse:\n\ta -= x\n\nif y > a + b:\n\tprint('NO')\n\treturn\nelse:\n\tif a < y:\n\t\ty -= a\n\t\ta = 0\n\tb -= y\n\nif z > a + b + c:\n\tprint('NO')\nelse:\n\tprint('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8375669907b2ff72addecf3228b7205", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nM = int(1e9 + 7)\n\nfac = [1]\n\nfor i in range(1, int(1e6 + 1)):\n fac.append((fac[-1] * i) % M)\n \nprint(fac[n] - pow(2, n - 1, M)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "663e023af2e06c2df6a876a40f2fc9b7", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "// g++ file.cpp -o file | file\n// ram learns c++\n \n#include\nusing namespace std;\n#define ll long long\n#define F first\n#define S second\n#define vec vector\n#define pb push_back\n#define pai pair\n#define all(a) (a).begin(),(a).end()\n#define rep(i,a,b) for(ll i=a;ib;i--)\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);\n#define printn(a) cout<>n;\n rep(i,1,n+1) p = (p*i)%M;\n rep(i,0,n-1) p2 = (p2*2)%M;\n ll ans = (p-p2)%M;\n printn(ans);\n}\n \nint main(){\n fastio;\n\t#ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n\t#endif\n ll t=1;\n // cin>>t;\n while(t--)\n solve();\n return(0);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3aad5ffc070f933945f8093884c1728", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "// import sys \n// sys.stdin = open('input.txt', 'r') \n// sys.stdout = open('output.txt', 'w')\nimport math\n# import re\ngg=\"abcdefghijklmnopqrstuvwxyz\"\n# a=ord('a')\n# print(chr(a), end=\"\")\n#sys.setrecursionlimit(int(1e6))\n# n, m = map(int, input().split())\n# graph = [[] for i in range(n)]\n# for i in range(m):\n# \ta,b = map(int, input().split())\n# \tgraph[a-1].append(b-1)\n# \tgraph[b-1].append(a-1)\n\n# def dfs(node, count, visited):\n# \tvisited[node] = 1\n# \tcount[0]+=1\n# \tfor i in graph[node]:\n# \t\tif not visited[i]:\n# \t\t\tdfs(i, count, visited)\n\n\n# visited = [0]*n\n# t = 0\n# node = None\n# for i in range(n):\n# \tif not visited[i]:\n# \t\tcount = [0]\n# \t\tdfs(i, count, visited)\n# \t\tif t= p: \n return 0 \n \n result = 1\n for i in range(1, n + 1): \n result = (result * i) % p \n \n return result \nmod=1000000007\nn=int(input())\nm=modFact(n,1000000007)\nm -= 2**(n-1)%mod\nprint(m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f1b8d057629d6e19d21c6756449ab2c", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "/*\n * Competetive Programming\n * Navya Aggarwal\n * iamnavya_agg\n */\n\n#include \n\nusing namespace std;\n\nint gcd(int a, int b)\n{\n if (a==0)\n return b;\n return gcd(b%a,a);\n}\n\nint lcm(int a, int b) \n{ \n return (a*b)/gcd(a, b);\n}\n\nvoid func()\n{\n int n,m;\n cin>>n;\n cin>>m;\n std::vector mat(n);\n for(int i=0; i>mat[i];\n }\n int count = 0;\n for(int i=0; i>t;\n for(int i=0; i=int(n)+0.5:\n\t\treturn int(n+1)\n\treturn int(n)\n\nn=int(input())\nl=list(map(int,input().split()))\nl.sort()\ncount,x=0,0\nwhile True:\n\tif round(sum(l)/n)==5:\n\t\tprint(count)\n\t\tbreak\n\tif l[x]!=5:\n\t\tl[x]=5\n\t\tcount+=1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "40d5d984ae3ea3032bd10fab87002a99", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a=int(input())\nl=[]\nfor i in range(a):\n l.append(int(input())\nb=sum(l)\nprint(int(4.5*a-b)+1)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e24275b313c114e44893ad1642e8bc0", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "PyPy 2", "source_code": "import atexit,io,sys\nbuffer=io.BytesIO()\nsys.stdout=buffer\n@atexit.register\ndef write(): sys.__stdout__.write(buffer.getvalue())\nfrom sys import stdin, stdout\ndef main():\n s_obt = 0\n def myord(num):\n nonlocal s_obt\n s_obt += num\n return num\n \n s_min = 4.5 * int(stdin.readline())\n cal = (int(x) for x in stdin.readline().split())\n #s_obt = sum(cal)\n #cal.sort()\n cal=sorted(cal,key=myord)\n nt=0\n while s_min>s_obt:\n s_obt += 5-cal[nt]\n nt += 1\n stdout.write(str(nt))\n \nif __name__=='__main__':main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "587fa6e06299faadef106c7691927111", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input()\nw = list(map(int,input().split()))\nw.sort()\n\ni = 0\nwhile sum(w)/n<4.5:\n\tw[i]=5\n\ti+=1\n\nprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c81b5fbc676f01fa4552fda9765856c", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "Python 2", "source_code": "raw_input()\ns = raw_input()\n\na, b = 0, 0\ninP = False\nbegin = -1\npos = -1\nfor i in s:\n pos += 1\n if i == '(' || i == ')' || i == '_':\n if begin != -1: # End a word\n if inP:\n a = max(a, pos - begin)\n else:\n b += 1\n begin = -1\n if i == '(':\n inP = True\n elif i == ')':\n inP = False\n else:\n if begin == -1:\n begin = pos\nif begin != -1:\n a = max(a, len(s) - begin)\nprint a, b", "lang_cluster": "Python", "compilation_error": true, "code_uid": "530b1e85d7c93d77a208d7e6ec5d2a6d", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x=int(input())\ny=input()\na=[]\nd1=0\nd2=[]\nm=0\nfor c in x:\n x1=0\n x2=0\n s=c==\"_\" or c==\")\" or c==\"(\"\n if s and isalpha(x[x.index(c)+1]):\n a.append(x.index(c))\n \n if c==\")\" and x[a[len(a)-1]]==\"(\":\n x1=a.[len(a)-1]+1\n x2=index(c)\n b=[]\n for i in x[x1:x2]:\n if i==\"_\" and isalpha(x[x.index(i)+1]):\n d1+=1\n for i in range((len(a)-1)):\n y1=a[i+1]-a[i]-1\n d2.append(y1)\n a=[]\nprint(max(d2),d1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ed64d94a2c5154442ed24ff6dab57fce", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x=int(input())\ny=input()\na=[]\nd1=0\nd2=[]\nm=0\nfor c in x:\n x1=0\n x2=0\n s=c==\"_\" or c==\")\" or c==\"(\"\n if s and isalpha(x[x.index(c)+1]):\n a.append(x.index(c))\n \n if c==\")\" and x[a.[len(a)-1]]==\"(\":\n x1=a.[len(a)-1]+1\n x2=index(c)\n b=[]\n for i in x[x1:x2]:\n if i==\"_\" and isalpha(x[x.index(i)+1]):\n d1+=1\n for i in range((len(a)-1)):\n y1=a[i+1]-a[i]-1\n d2.append(y1)\n a=[]\nprint(max(d2),d1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79f5e465f162f971bba2e5bd3d1538d1", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "text = input()\nbracket = False\nbracket_word_count = 0\nmax_length = 0\nbracket_s = \"\"\nnot_bracket_s = \"\"\nfor ch in text:\n\tif bracket:\n\t\tif ch == ')':\n\t\t\tbracket = False\n\t\t\tbracket_word_count += sum(1 for s in bracket_s.split('_') if s)\n\t\t\tbracket_s = \"\"\n\t\telse:\n\t\t\tbracket_s += ch\n\telse:\n\t\tif ch == '(':\n\t\t\tbracket = True\n\t\t\tmax_length = max(max_length, max(len(s) for s in non_bracket_s.split('_'))\n\t\t\tnon_bracket_s = \"\"\n\t\telse:\n\t\t\tnon_bracket_s += ch\nmax_length = max(max_length, *(len(s) for s in non_bracket_s.split('_'))\nbracket_word_count += sum(1 for s in bracket_s.split('_') if s)\nprint('{} {}'.format(max_length, bracket_word_count))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d9e62307671301a9ab7b3cd22df8f81", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\nmaxout = 0\nnumin = 0\ncurrout = 0\ncurrin = False\nout = True\nfor char in input():\n if char in ['_','(',')']:\n if out and maxout < currout:\n maxout = currout\n currout = 0\n elif not out and currin:\n currin = False\n numin += 1\n if char in ['(',')']:\n out = not out\n else:\n if out:\n currout += 1\n else:\n currin = True\n \nprint(maxout, numin)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "afdf0bbe418ba74cc67cbb4f3319be23", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "__author__ = 'MatFuck'\n\nimport sys\n\n#sys.stdin = open(\"1.txt\")\n\nn = input()\na = [int(x) for x in raw_input().split()]\np = [[0, 0] for i in range(n - 1)]\n\nfor id in range(n - 1):\n p[id][0] = min(a [id], a [id + 1])\n p[id][1] = max(a [id], a [id + 1])\n\n\np = sorted(p, key = lambda ps:(ps[0],ps[1]), reverse = False)\n\nans = 0\n#print p\n\nfor id_a, it_a in enumerate(p):\n for id_b, it_b in enumerate(p[id_a + 1:]):\n if (it_a[1] <= it_b[0]):\n break\n else:\n if (it_a[1] < it_b[1]) and (it_a[0] < it_b[0]):\n print \"yes\"\n sys.exit(0)\n\n\n\nprint \"no\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aaa2c2f11d03b884f1468fbc90290d60", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\nif n <= 3:\n print('no')\nelse:\n fg = 0\n for i in range(n-3):\n for j in range(i+2, n-1):\n if min(a[i], a[i+1]) < min(a[j], a[j+1]) < max(a[i], a[i+1]) < max(a[j], a[j+1]) or min(a[j], a[j+1]) < min(a[i], a[i+1]) < max(a[j], a[j+1]) < max(a[i], a[i+1]):\n fg = 1\n break;\n if fg: \n break;\n \n if fg:\n print('yes')\n else: \n print('no'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3abee271447555d8af82cb550f098d0d", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "t=raw_input()\na=map(int,raw_input().split())\nb=a[::2]\nc=a[1::2]\nprint b,c\ndef cmp1(x):\n for i in range(1,len(x)):\n if (x[i]>x[i-1])==0:\n return False\ndef cmp2(x):\n for i in range(1,len(x)):\n if (x[i]c[-1]:\n return 'no'\nelse:\n return 'yes'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc60d1f60959e88fb67187dfe199b484", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "509 ~/codeforces/208$ mv 209 ProbA.py\n510 ~/codeforces/208$\ndef do_pairs_intersect(start1, end1, start2, end2):\n if ((end1 <= start2 or start1 >= end2) or\n (start2>=start1 and start2<=end1 and end2>=start1 and end2<=end1) or\n (start1>=start2 and start1<=end2 and end1>=start2 and end1<=end2)):\n return False\n return True\n\ndef is_intersecting(points):\n if len(points) == 1:\n print 'no'\n else:\n n = len(points) - 1\n is_intersecting = False\n for i in xrange(n-1):\n for j in xrange(i+1,n):\n if points[i] <= points[i+1]:\n start1, end1 = points[i], points[i+1]\n else:\n start1, end1 = points[i+1], points[i]\n if points[j] <= points[j+1]:\n start2, end2 = points[j], points[j+1]\n else:\n start2, end2 = points[j+1], points[j]\n #print 'comparing(',start1,',',end1,') and (',start2,',',end2,')'\n if ((start1 == start2 and end1 == end2) or\n (do_pairs_intersect(start1,end1,start2,end2))):\n is_intersecting = True\n if is_intersecting:\n print 'yes'\n else:\n print 'no'\n\nnums = map(int, raw_input('').split())\nnums = map(int, raw_input('').split())\nis_intersecting(nums)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7bb31c0bfff2a4decaf9a7c93e1b7a1f", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import sys\n#sys.stdin = open(\"in.txt\", \"r\")\n\nn = input()\na = map(int, raw_input().split())\nif n < 3:\n\tprint \"no\"\nelse:\n\tb = []\n\tfor i in xrange(n-1):\n\t\tb.append([a[i], a[i+1])\n\tgood = False\n\tfor i in xrange(n-1):\n\t\tfor j in xrange(i+1, n-1):\n\t\t\tt1 = b[i][0] > b[j][0] and b[i][0] < b[j][1] and b[i][1] > b[j][1]\n\t\t\tt2 = b[i][1] > b[j][0] and b[i][1] < b[j][1] and b[i][0] < b[j][0]\n\t\t\tif t1 or t2\n\t\t\t\tgood = True\n\t\t\t\tbreak\n\tif good:\n\t\tprint \"yes\"\n\telse:\n\t\tprint \"no\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e685172d1159a9ba3cff4b01310b84f5", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "d = dict()\nans = 1e8\n\ndef solve(x,n):\n\tglobal ans\n\tif x in d:\n\t\treturn d[x]\n\tans = min(ans,n)\n\td[x] = n+1\n\tfor i in range(n-1):\n\t\tif abs(ord(x[i])-ord(x[i+1])) == 1:\n\t\t\tif x[i] > x[i+1]:\n\t\t\t\td[x] = min(d[x],solve(x[:i]+x[i+1:],n-1))\n\t\t\telse:\n\t\t\t\td[x] = min(d[x],solve(x[:i+1]+x[i+2:],n-1))\n\telse:\n\t\td[x] = n\n\treturn d[x]\n\nn = int(input())\ns = input()\nsolve(s,n)\nprint(n-ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "86b0b5d2c977033fc57e34383bd71233", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def f(s,dp):\n if len(s)<=1:\n return 0\n if dp.get(s)!=None:\n return dp[s]\n ans=0\n n=len(s)\n for k in range(n):\n if (k-1>=0 and ord(s[k-1])-ord(s[k])==-1) or (k+1 0 and ord(s[i]) - ord(s[i-1]) == 1\n\t\tb = i < len(s) -1 and ord(s[i]) - ord(s[i+1]) == 1\n\t\tif a or b:\n\t\t\tans = max(ans, 1 + sol(s[:i] + s[i+1:]))\n\treturn ans\n\nn = int(sys.stdin.readline())\ns = sys.stdin.readline()\nans = sol(s)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "66e4d5121ef092d86ac68e5cafb57200", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "strings = dict()\n\n\ndef check_string(seq):\n global strings\n daughter_seqs = list()\n if len(seq) == 1:\n strings[seq] = 0\n return None\n\n for i in range(1, len(seq)-1):\n if ord(seq[i]) - ord(seq[i-1]) == 1 or ord(seq[i]) - ord(seq[i+1]) == 1:\n daughter_seqs.append(seq[0:i] + seq[i+1:])\n\n if ord(seq[0]) - ord(seq[1]) == 1:\n daughter_seqs.append(seq[1:])\n if ord(seq[-1]) - ord(seq[-2]) == 1:\n daughter_seqs.append(seq[:-1])\n\n if len(daughter_seqs) == 0:\n strings[seq] = 0\n return None\n else:\n results = list()\n for daughter_seq in daughter_seqs:\n if daughter_seq not in strings.keys():\n check_string(daughter_seq)\n results.append(strings[daughter_seq])\n strings[seq] = max(results) + 1\n\n\nn = int(input())\ninput_str = input()\n\ncheck_string(input_str)\nprint(strings[input_str])\\\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e32094e378c4ad66e3fb021b8949aff", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "rom math import *\nalf = list(reversed('abcdefghijklmnopqrstuvwxyz'))\ndef adj(a, b):\n return chr(ord(a) - 1) == b\n \nn = int(input())\ns = [i for i in input()]\nfor i in range(n):\n for a in alf:\n i = 0\n while i < len(s):\n if s[i] == a and i > 0 and adj(s[i], s[i-1]):\n s.pop(i)\n elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):\n s.pop(i)\n else:\n i += 1\n \nprint(n - len(s))\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8feffe52646ea5278144f2c3d4568757", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\n#define ll long long\n\nint main()\n{\n\tchar a[],b[];\n\tcin>>a>>b;\n\tvector tot;\n\ttot.push_back(a[0]);\n\tfor(ll i=1;i m + n:\n as = m + n\n n = \"\"\nprint(as)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7b64ab83b6b0ed70c77cb307868fa99", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = input()\nprint a", "lang_cluster": "Python", "compilation_error": true, "code_uid": "08df3ee14397ef0ae233492850f1f70f", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\n a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]\nprint(a[int(input())-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c2d8725a7d8202c4effc2bbb90ceabb2", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \nchar s[17]=\"91001010111001010\";int main(){int n;scanf(\"%d\", &n); printf(\"%c\",s[n]); return 0; }", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3dff6869c66a2c7bdb2f9c9b7af11d0e", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \nint f[1000001]={0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0};\nint main()\n{\n\tint n=0;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\",f[n]);\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee8bd2f31b1bddd260860b2b7424c8b5", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\nint main(){\n\tint i;\n\tcin>>i;\n\tif(i==1||i==4||i==6||i==8||i==9||i==10||i==13||i==15) cout<<1;\n\telse cout<<0;\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "12a15602ee6e7f804633df172e733030", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n if(n==1||n==4||n==6||n==8||n==9||n==10||n==13||n==15) cout<<1;\n else cout<<0;\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "700bd27adf901cf62ae813664d3b13d3", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def is_visok(x):\n return x % 400 == 0 or x % 4 == 0 and x % 100 != 0\n\ny = int(input())\n\nd, v = 0, is_visok(y)\nyear = y\n\nd_ = d\nv_ = not v\n\nwhile not (v_ == v and d_ % 7 = 0):\n year += 1\n v_ = is_visok(year)\n d_ += (365, 366)[v_] % 7\n\nprint(year)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ebc554614511513989ca22d7693e07a7", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\n def is_leap_year(year):\n if year % 400 == 0:\n return True\n if year % 100 == 0:\n return False\n if year % 4 == 0:\n return True\n return False\n\nstart_year = int(input())\nif is_leap_year(start_year):\n print(start_year + 28)\nelse:\n next_year = start_year + 1\n diff = 1\n if is_leap_year(next_year - 1):\n diff += 1\n\n while diff % 7 != 0:\n diff += 1\n next_year += 1\n if is_leap_year(next_year - 1):\n diff += 1\n print(next_year)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3beb635798b1780745f76216330a9853", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "y = int(raw_input())\ndef leap(y):\n fg = (n % 400 == 0) or (n % 100 and n % 4 == 0)\n return 365 + fg\ndef next(y):\n sm = oy = leap(y)\n while sm % 7 or leap(y + 1) != oy:\n sm += leap(y + 1)\n y += 1\n return y + 1\nprint next(y)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "756f9315835956dde8e3ded8ef708b2e", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def is_leap(n):\n return n % 400 == 0 or (n % 4 == 0 and n % 100 != 0)\n\ncurr = int(input())\nif curr == 1179:\n print(\"UUUUUUU, Vorona - Bereza!\")\n exit()\nleapness = is_leap(curr)\nfirst = 0\nwhile True:\n if is_leap(curr):\n first += 1\n first += 1\n first %= 7\n curr += 1\n if first == 0 and leapness == is_leap(curr):\n break\nprint(curr)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fde1d42b67080768578bb917c4e339ba", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\nx=0\nyear=n+1\nif (n%4==0 and n%100!=0) or n%400==0:\n vis=True\nelse:\n vis=False\nwhile x%7!=0 or x==0:\n \n if (year%4==0 and year%100!=0) or year%400==0:\n x+=2\n year+=1\n if not vis and x%7==0:\n x=0\n \n if vis:\n year+=1\n continue\n else:\n year+=1\n x+=1\n \nif vis:\n print(year-2)\nelse:\n print(year-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6527632cf5c3539370c3de7f3c566e46", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import math\r\n\r\nreturn int(math.sqrt(int(input())))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b6e118d7f2249d272f44d03b4a279094", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n=int(input())\r\nx=0\r\nwhile(n):\r\n x+=n%10\r\n n=n/10\r\nreturn x\r\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad93f23e427075cbf1d1417dfbf51b38", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n = input()\r\nn += \"000\"\r\nprint(sum(int(i) for i in n[0:3])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24b03aa8ab2f34e01e95b640e627c2ec", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = input()while len(n)>1:\r\n s = 0\r\n for i in n:\r\n s+=int(i)\r\n n = str(s)\r\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8d0a131af80966e018924b266b6c82df", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import math\r\n\r\ndef digitalRoot(num):\r\n\t\r\n\t# If num is 0.\r\n\tif (num == \"0\"):\r\n\t\treturn 0\r\n\r\n\tans = 0\r\n\tfor i in range (0, len(num)):\r\n\t\tans = (ans + int(num[i])) % 9\r\n\t\t\r\n\tif(ans == 0):\r\n\t\treturn 9\r\n\telse:\r\n\t\treturn ans % 9\r\n\r\nprint (digitalRoot(int(input())\r\n\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8388942941922da50620ca08b13b59c1", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def main():\n s = input()\n x, y, z = map(int, input().split())\n p1, p2, p3 = map(int, input().split())\n a = s.count('B')\n b = s.count('S')\n c = s.count('C')\n r = int(input())\n if a != 0 and b != 0 and c != 0:\n d = min(x // a, y // b, z // c)\n cost = a * p1 + b * p2 + c * p3\n total = (x - a * d) * p1 + (y - b * d) * p2 + (z - c * d) * p3 + r\n ans = d + total // cost\n elif a == 0:\n if b != 0 and c != 0:\n d = min(y // b, z // c)\n cost = b * p2 + c * p3\n total = (y - b * d) * p2 + (z - c * d) * p3 + r\n ans = d + total // cost\n elif b == 0:\n d = min(z // c)\n cost = c * p3\n total = (z - c * d) * p3 + r\n ans = d + total // cost\n elif c == 0:\n d = min(y // b)\n cost = b * p2\n total = (y - b * d) * p2 + r\n ans = d + total // cost\n elif b == 0:\n if a != 0 and c != 0:\n d = min(x // a, z // c)\n cost = a * p1 + c * p3\n total = (x - a * d) * p1 + (z - c * d) * p3 + r\n ans = d + total // cost\n elif a == 0:\n d = min(z // c)\n cost = c * p3\n total = (z - c * d) * p3 + r\n ans = d + total // cost\n elif c == 0:\n d = min(x // a)\n cost = a * p1\n total = (x - a * d) * p1 + r\n ans = d + total // cost\n else:\n if a != 0 and b != 0:\n d = min(x // a, y // b)\n cost = a * p1 + b * p2\n total = (x - a * d) * p1 + (y - b * d) * p2 + r\n ans = d + total // cost\n elif a == 0:\n d = min(y // b)\n cost = b * p2\n total = (y - b * d) * p2 + r\n ans = d + total // cost\n elif b == 0:\n d = min(x // a)\n cost = a * p1\n total = (x - a * d) * p1 + r\n ans = d + total // cost\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae5acec0625de1df9fd2e0b1b20b6779", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import math\nf = {}\ns = input()\nfor c in s:\n if c in f:\n f[c]+=1\n else:\n f[c]=1\n[nb,ns,nc] = [int(i) for i in input().split() ]\n[pb,ps,pc] = [int(i) for i in input().split() ]\n\nh = int(input())\nx=0\nmn = 0 \nmx = 1000000000000\n\nwhile(mn<=mx):\n x = math.ceil((mn+mx)/2);\n fx = (f['B']*x-nb)*pb+(f['C']*x-nc)*pc+(f['S']*x-ns)*ps\n if fx<=h:\n mn = x+1\n else:\n mx = x-1\n\nprint(x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6aeeaa0459d61955909a9cdc4e308b16", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "t = input()\nn = list(map(int, input().split()))\np = list(map(int, input().split()))\nr = int(input())\nq = [t.count('B'), t.count('S')]\nq.append(len(t) - q[0] - q[1])\nn = [n[i] for i in range(3) if q[i]]\np = [p[i] for i in range(3) if q[i]]\nq = [q[i] for i in range(3) if q[i]]\nm = len(q)\na = min(n[i] // q[i] for i in range(m)\nb = max((n[i] + r // p[i]) // q[i] for i in range(m)) + 1\nwhile b - a > 1:\n c = (a + b) // 2\n if sum(max(0, (c * q[i] - n[i]) * p[i]) for i in range(m)) > r: b = c\n else: a = c\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "236b71353d152339eba00e657db9bc57", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#AVDK\nimport random\nimport math\nimport os\nimport sys\n\ndef main():\n rec=str(raw_input())\n nb,ns,nc=map(int,raw_input().split(\" \"))\n pb,ps,pc=map(int,raw_input().split(\" \"))\n r=long(raw_input())\n numofb=list(rec).count('B')\n numofs=list(rec).count('S')\n numofc=list(rec).count('C')\n ans=0\n # print nb,ns,nc\n # print numofb,numofs,numofc\n while(True):\n if nb>=numofb and ns>=numofs and nc >= numofc:\n ans+=1;\n nb-=numofb\n ns-=numofs\n nc-=numofc\n elif nb>=numofb and ns=numofc:\n nstb=numofs;nc-=numofc;nb-=numofb;\n if ns>0:\n nstb-=ns\n ns=0\n if(r>=nstb*ps):\n r=r-nstb*ps;\n ans+=1;\n else:\n break;\n elif nb=numofs and nc>=numofc:\n nbtb=numofb;ns-=numofs;nc-=numofc;\n if nb>0:\n nbtb-=nb\n nb=0\n if(r>=nbtb*pb):\n r=r-nbtb*pb;\n ans+=1;\n else:\n break;\n elif nb>=numofb and ns>=numofs and nc0:\n nctb-=nc\n nc=0\n if(r>=nctb*pc):\n r=r-nctb*pc;\n ans+=1;\n else:\n break;\n elif nb=numofc:\n nc-=numofc;\n nbtb=numofb;nstb=numofs;\n if nb>0:\n nbtb-=nb\n nb=0\n if ns>0:\n nstb-=ns\n ns=0\n if(r>=(nbtb*pb+nstb*ps)):\n r=r-(nbtb*pb+nstb*ps);\n ans+=1;\n else:\n break;\n elif nb=numofs and nc0:\n nbtb-=nb\n nb=0\n if nc>0:\n nctb-=nc\n nc=0\n if(r>=(nbtb*pb+nctb*pc)):\n r=r-(nbtb*pb+nctb*pc);\n ans+=1;\n else:\n break;\n elif nb>=numofb and ns0:\n nctb-=nc\n nc=0\n if ns>0:\n nstb-=ns\n ns=0\n if(r>=(nstb*ps+nctb*pc)):\n r=r-(nstb*ps+nctb*pc);\n ans+=1;\n else:\n break;\n elif nb0:\n nctb-=nc\n nc=0\n if nb>0:\n nbtb-=nb\n nb=0\n if ns>0:\n nstb-=ns\n ns=0\n if(r>=(nbtb*pb+nctb*pc+nstb*ps)):\n r=r-(nbtb*pb+nctb*pc+nstb*ps);\n ans+=1;\n else:\n break;\n if nb==0 and nc==0 and ns==0:\n break;\n pricetotal=numofs*ps+numofc*pc+numofb*pb;\n print ans+=(pricetotal/r)\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3ea07aa11a369507ca4da33ce4e2725", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\n\nrep = input(\"Res: \")\na = Counter({'B':0, 'S':0, 'C':0})\na.update(rep)\nrep = a['B'], a['S'], a['C']\n\ninventory = Bi, Si, Ci = list(map(int, input(\"Invent: \").split(' ')))\n\nprice = list(map(int, input(\"Prices: \").split(' ')))\n\nmoney = int(input(\"Money: \"))\n\noutput =\n\n\ndef make_sandwich():\n global output\n for idx in range(len(inventory)):\n inventory[idx] -= rep[idx]\n output += 1\n\n\nwhile money or all([invent >= ingredient for ingredient, invent in zip(rep, inventory)]):\n if all([inventory[idx] >= rep[idx] for idx in range(len(inventory))]):\n make_sandwich()\n\n for ingredient in range(len(inventory)):\n if inventory[ingredient] < rep[ingredient] and money >= price[ingredient]:\n inventory[ingredient] += 1\n money -= price[ingredient]\n break\n\n\n\n\nprint(output)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0ced42021f717cf4938f9b822951eeb", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import sys\n\nn, m = map(int, input().split())\na = [int(i) for i in input().split()]\n\nsum =0, count;\nfor i in range(n):\n\ts = sorted(a[:i])\n\ttemp = sum(s)\n\tf =0\n\twhile temp + a[i] > m:\n\t\tf+=1\n\t\ttemp -= s.pop()\n\n\tprint(f, end = \" \")\n\t\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f053fec1e35400a0e541b20025453f0c", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,m=[int(i) for i in input().split()]\nl=[int(i) for i in input().split()]\n\nprint(0,end=\" \")\n\ni=1\nfor i in range(1,n):\n \n lp=sorted(l[:i])\n \n j,p=0,1\n sum=l[i]\n while ((lp[j]+sum<=m) and (j\nusing namespace std;\nint n,m;\nint fail(int limit,int ar[])\n{\n int i;\n int sum=0;\n sort(ar,ar+n);\n for(i=limit;i>=0;i++)\n {\n sum=sum+ar[i];\n if(sum<=n)\n break;\n }\n return i;\n\n}\nint main()\n{\n int sum=0;\n cin>>n>>m;\n int ar[n],ar1[n];\n for(int i=0;i>ar[i];\n ar1[i]=ar[i];\n }\n for(int i=0;i= Sum:break\n Count, Sum = Count + 1, Sum - STemp[j]\n print(Count, end=\" \")\n\n# Come together for getting better !!!!\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0c8daa897c7350d330df88a396bc8b9", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import bisect\nn,m = map(int,raw_input().split())\na = map(int,raw_input().split())\nA = []\nfor i in range(n):\n\tac = a[:i]\n\titem = sum(ac) + a[i] - m\n\tans = 0\n\t# print ac,item,a[i]\n\twhile sum(ac) > (m - a[i]) and item>0:\n\t\tix = bisect.bisect_left(a,item,0,i-1)\n\t\titem = sum(ac) + a[i] - m\n\t\tac[ix] = 0\n\t\tans+=1\n\t\tac.sort()\n\tA.append(ans)\nfor i in A:\n\tprint i,", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f14fba20a758a0d874701bd6c90f63bc", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n# @Time : 2019/6/5 13:21\n# @Author : yuggu\n# @Site :\n# @File : test.py\n# @Software: PyCharm\\\n\n# import pymysql\n# # \u6253\u5f00\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u53c2\u65701\uff1a\u4e3b\u673a\u540d\u6216IP\uff1b\u53c2\u65702\uff1a\u7528\u6237\u540d\uff1b\u53c2\u65703\uff1a\u5bc6\u7801\uff1b\u53c2\u65704\uff1a\u6570\u636e\u5e93\u540d\u79f0\n# db=pymysql.connect(\"localhost\",\"root\",\"root\",\"school\")\n# # \u4f7f\u7528cursor()\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u6e38\u6807\u5bf9\u8c61cursor\n# cursor=db.cursor()\n# # \u4f7f\u7528execute()\u65b9\u6cd5\u6267\u884csql\u67e5\u8be2\n# cursor.execute(\"select version()\")\n# # \u4f7f\u7528fetchone()\n# data=cursor.fetchone()\n# print(\"Data version:%s \" % data)\n# # \u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\n# db.close()\n\n# import sys\n# import pygame\n#\n# charlotte=pygame.image.load(\"1.jpg\") # \u52a0\u8f7d\u56fe\u7247\n# charlotterect=charlotte.get_rect() # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n# size=(int(charlotterect[2]/3),int(charlotterect[3]/3)) # \u8fd9\u91cc\u628a\u56fe\u7247\u7ed9\u7f29\u5c0f\u4e3a\u539f\u6765\u76841/3\n# charlotte=pygame.transform.scale(charlotte,size) # \u8fdb\u884c\u5bf9\u539f\u56fe\u7247\u7684\u7f29\u5c0f\u5e76\u8fd4\u56de\u4e00\u4e2a\u7f29\u5c0f\u540e\u56fe\u7247\u7684surface\n#\n# pygame.init()\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n# charlotte=pygame.transform.scale(charlotte,size)\n# charlotterect= (charlotte.get_rect()) # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n\n# pygame.init()\n# size=width,height=700,600\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n\n# while True:\n# for event in pygame.event.get():\n# if event.type == pygame.KEYDOWN:\n# sys.exit()\n# screen.fill(color)\n# screen.blit(charlotte,charlotterect)\n# pygame.display.flip()\n# pygame.quit()\n\n#\n# import urllib.request\n# import urllib.parse\n#\n# data=bytes(urllib.parse.urlencode({'word':'hello'}),encoding='utf-8')\n# response=urllib.request.urlopen(\"http://httpbin.org/post\",data=data)\n# html=response.read()\n# print(html)\n\n# import requests\n# url='https://blog.csdn.net'\n# # \u521b\u5efa\u5934\u90e8\u4fe1\u606f\n# headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0'}\n# response=requests.get(url,headers=headers)\n# print(response.content)\n\n# # \u722c\u866b\u722c\u53d6\u7f51\u9875\u6846\u67b6\n# import requests\n#\n# def getHTMLText(url):\n# try:\n# r=requests.get(url,timeout=30)\n# r.raise_for_status() # \u5982\u679c\u72b6\u6001\u4e0d\u662f200\uff0c\u5f15\u53d1HTTPError\u5f02\u5e38,\u7136\u540e\u629b\u51fa\u6355\u83b7\n# # ,\u5185\u90e8\u8fdb\u884c\u5224\u65ad\n# r.encoding=r.apparent_encoding\n# return r.text\n# except:\n# return \"\u4ea7\u751f\u5f02\u5e38\"\n#\n# if __name__ == \"__main__\":\n# url=\"http://blog.csdn.net\"\n# print(getHTMLText(url))\n#\n#\n# # \u6d4f\u89c8\u5668headers\u6a21\u62df\n# import requests\n#\n# kv={'User-Agent':'Mozilla/5.0'}\n# response=requests.get('http://www.amazon.cn/',headers=kv)\n# response.encoding=response.apparent_encoding\n# print(response.request.headers)\n\n# # \u7f51\u7edc\u56fe\u7247\u722c\u53d6\n# import requests\n# path='D://abc.jpg' # \u4fdd\u5b58\u5728D\u76d8\u4e0b\uff0c\u4ee5abc.jpg\u547d\u540d\n# url='https://wx4.sinaimg.cn/mw690/8d05b653ly1g4n0elm7axj20j60b475b.jpg'\n#\n# r=requests.get(url)\n# print(r.encoding)\n# with open(path,'wb') as f:\n# f.write(r.content)\n\n# # \u767e\u5ea6\u5173\u952e\u5b57\u63d0\u4ea4\u63a5\u53e3\n# import requests\n# kv={'wd':'Python'}\n# r=requests.get('http://www.baidu.com/s',params=kv)\n# print(r.request.url)\n\n\n# from bs4 import BeautifulSoup\n# import urllib.request\n# html = urllib.request.urlopen(\"https://www.csdn.net/\").read().decode('utf-8')\n# soup = BeautifulSoup(html,\"html.parser\")\n# titles=soup.select(\"h3[class='company_name'] a\") # CSS \u9009\u62e9\u5668\n# for title in titles:\n# print(title.get_text(),title.get('href'))# \u6807\u7b7e\u4f53\u3001\u6807\u7b7e\u5c5e\u6027\n\n\n# # \u6807\u7b7e\u6811\u5411\u4e0a\u904d\u5386\n# import requests\n# from bs4 import BeautifulSoup\n#\n# url='https://python123.io/ws/demo.html'\n# demo=requests.get(url).text\n# soup=BeautifulSoup(demo,'html.parser')\n# for parent in soup.a.parents:\n# \tif parent is None:\n# \t\tprint(parent)\n# \telse:\n# \t\tprint(parent.name)\n\n\n# # \u8d77\u70b9\u5c0f\u8bf4\u722c\u53d6\n# import requests\n# from bs4 import BeautifulSoup\n# import bs4\n#\n#\n# path=\"3.txt\"\n# fw=open(path,'w',encoding='utf-8')\n#\n# url = \"https://book.qidian.com/info/1015323848#Catalog\"\n# r=requests.get(url,timeout=30)\n# r.raise_for_status()\n# r.encoding=r.apparent_encoding\n#\n# soup = BeautifulSoup(r.text, 'html.parser')\n# for li in soup.find_all('ul')[3]:\n# if isinstance(li, bs4.element.Tag):\n# chapter = li.a\n# #print(chapter)\n# chapter_url = 'https:%s' % chapter.get('href')\n# #chapter_title=chapter.contents # ->['\u7b2c\u4e00\u8282 \u9f99\u57ce']\n# chapter_title=chapter.text # ->\u7b2c\u4e00\u8282 \u9f99\u57ce\n# print(chapter_title)\n# print(chapter_url)\n# chapter_response=requests.get(chapter_url)\n# chapter_response.encoding=chapter_response.apparent_encoding\n# chapter_html=chapter_response.text\n# chapter_soup=BeautifulSoup(chapter_html,'html.parser')\n# chapter_tag=chapter_soup.find('div',class_='read-content j_readContent')\n# fw.write(chapter_title)\n# fw.write(chapter_tag.text)\n#\n# fw.close()\n#\n# import re\n# import requests\n#\n#\n# def getHtmlText(url):\n# try:\n# r = requests.get(url)\n# r.raise_for_status()\n# r.encoding = r.apparent_encoding\n# return r.text\n# except:\n# return \"\"\n#\n#\n# def getInfor(html):\n# print(html)\n# print(re.findall(r'.*?', html))\n#\n#\n# def main():\n# url = 'https://detail.tmall.com/item.htm?spm=a230r.1.14.41.7fab2157JOw8dn&id=555305762446&ns=1&abbucket=10'\n# html = getHtmlText(url)\n# getInfor(html)\n#\n#\n# main()\n\nif __name__ == '__main__':\n n = int(input())\n a = list(map(int, input().split()))\n a.sort(reverse = True)\n res = 0\n k = 100000000\n for i in range(n) :\n # print(i)\n k = max(min(k, a[i]),0)\n res += k\n k -= 1\n\n print(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f5ea8b15b487e5c9e57df3a9228e492", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "size = int(input())\ncounts = [int(x) for x in input().split()]\ncounts.sort(reverse=True)\nfor i in range(1, size):\n if (counts[i]==counts[i-1]):\n counts[i] = counts[i] - 1\nprint(sum(counts)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "75d6710b3d4d16cd49fc8935884e86d1", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n=raw_input()\nl=raw_input().split()\nl=map(x : int(x),l)\nl=sorted(l)\ns=set()\nsu=0\nfor i in l[::-1]:\n q=True\n for j in xrange(i, 0, -1):\n if not j in s and q:\n su+=j\n s.insert(j)\n q=False\nprint su", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b4bf0ec7457f9d3d10a859d0df4f5e42", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "# -*- coding: utf-8 -*-\n# @Time : 2019/6/5 13:21\n# @Author : yuggu\n# @Site :\n# @File : test.py\n# @Software: PyCharm\\\n\n# import pymysql\n# # \u6253\u5f00\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u53c2\u65701\uff1a\u4e3b\u673a\u540d\u6216IP\uff1b\u53c2\u65702\uff1a\u7528\u6237\u540d\uff1b\u53c2\u65703\uff1a\u5bc6\u7801\uff1b\u53c2\u65704\uff1a\u6570\u636e\u5e93\u540d\u79f0\n# db=pymysql.connect(\"localhost\",\"root\",\"root\",\"school\")\n# # \u4f7f\u7528cursor()\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u6e38\u6807\u5bf9\u8c61cursor\n# cursor=db.cursor()\n# # \u4f7f\u7528execute()\u65b9\u6cd5\u6267\u884csql\u67e5\u8be2\n# cursor.execute(\"select version()\")\n# # \u4f7f\u7528fetchone()\n# data=cursor.fetchone()\n# print(\"Data version:%s \" % data)\n# # \u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\n# db.close()\n\n# import sys\n# import pygame\n#\n# charlotte=pygame.image.load(\"1.jpg\") # \u52a0\u8f7d\u56fe\u7247\n# charlotterect=charlotte.get_rect() # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n# size=(int(charlotterect[2]/3),int(charlotterect[3]/3)) # \u8fd9\u91cc\u628a\u56fe\u7247\u7ed9\u7f29\u5c0f\u4e3a\u539f\u6765\u76841/3\n# charlotte=pygame.transform.scale(charlotte,size) # \u8fdb\u884c\u5bf9\u539f\u56fe\u7247\u7684\u7f29\u5c0f\u5e76\u8fd4\u56de\u4e00\u4e2a\u7f29\u5c0f\u540e\u56fe\u7247\u7684surface\n#\n# pygame.init()\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n# charlotte=pygame.transform.scale(charlotte,size)\n# charlotterect= (charlotte.get_rect()) # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n\n# pygame.init()\n# size=width,height=700,600\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n\n# while True:\n# for event in pygame.event.get():\n# if event.type == pygame.KEYDOWN:\n# sys.exit()\n# screen.fill(color)\n# screen.blit(charlotte,charlotterect)\n# pygame.display.flip()\n# pygame.quit()\n\n#\n# import urllib.request\n# import urllib.parse\n#\n# data=bytes(urllib.parse.urlencode({'word':'hello'}),encoding='utf-8')\n# response=urllib.request.urlopen(\"http://httpbin.org/post\",data=data)\n# html=response.read()\n# print(html)\n\n# import requests\n# url='https://blog.csdn.net'\n# # \u521b\u5efa\u5934\u90e8\u4fe1\u606f\n# headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0'}\n# response=requests.get(url,headers=headers)\n# print(response.content)\n\n# # \u722c\u866b\u722c\u53d6\u7f51\u9875\u6846\u67b6\n# import requests\n#\n# def getHTMLText(url):\n# try:\n# r=requests.get(url,timeout=30)\n# r.raise_for_status() # \u5982\u679c\u72b6\u6001\u4e0d\u662f200\uff0c\u5f15\u53d1HTTPError\u5f02\u5e38,\u7136\u540e\u629b\u51fa\u6355\u83b7\n# # ,\u5185\u90e8\u8fdb\u884c\u5224\u65ad\n# r.encoding=r.apparent_encoding\n# return r.text\n# except:\n# return \"\u4ea7\u751f\u5f02\u5e38\"\n#\n# if __name__ == \"__main__\":\n# url=\"http://blog.csdn.net\"\n# print(getHTMLText(url))\n#\n#\n# # \u6d4f\u89c8\u5668headers\u6a21\u62df\n# import requests\n#\n# kv={'User-Agent':'Mozilla/5.0'}\n# response=requests.get('http://www.amazon.cn/',headers=kv)\n# response.encoding=response.apparent_encoding\n# print(response.request.headers)\n\n# # \u7f51\u7edc\u56fe\u7247\u722c\u53d6\n# import requests\n# path='D://abc.jpg' # \u4fdd\u5b58\u5728D\u76d8\u4e0b\uff0c\u4ee5abc.jpg\u547d\u540d\n# url='https://wx4.sinaimg.cn/mw690/8d05b653ly1g4n0elm7axj20j60b475b.jpg'\n#\n# r=requests.get(url)\n# print(r.encoding)\n# with open(path,'wb') as f:\n# f.write(r.content)\n\n# # \u767e\u5ea6\u5173\u952e\u5b57\u63d0\u4ea4\u63a5\u53e3\n# import requests\n# kv={'wd':'Python'}\n# r=requests.get('http://www.baidu.com/s',params=kv)\n# print(r.request.url)\n\n\n# from bs4 import BeautifulSoup\n# import urllib.request\n# html = urllib.request.urlopen(\"https://www.csdn.net/\").read().decode('utf-8')\n# soup = BeautifulSoup(html,\"html.parser\")\n# titles=soup.select(\"h3[class='company_name'] a\") # CSS \u9009\u62e9\u5668\n# for title in titles:\n# print(title.get_text(),title.get('href'))# \u6807\u7b7e\u4f53\u3001\u6807\u7b7e\u5c5e\u6027\n\n\n# # \u6807\u7b7e\u6811\u5411\u4e0a\u904d\u5386\n# import requests\n# from bs4 import BeautifulSoup\n#\n# url='https://python123.io/ws/demo.html'\n# demo=requests.get(url).text\n# soup=BeautifulSoup(demo,'html.parser')\n# for parent in soup.a.parents:\n# \tif parent is None:\n# \t\tprint(parent)\n# \telse:\n# \t\tprint(parent.name)\n\n\n# # \u8d77\u70b9\u5c0f\u8bf4\u722c\u53d6\n# import requests\n# from bs4 import BeautifulSoup\n# import bs4\n#\n#\n# path=\"3.txt\"\n# fw=open(path,'w',encoding='utf-8')\n#\n# url = \"https://book.qidian.com/info/1015323848#Catalog\"\n# r=requests.get(url,timeout=30)\n# r.raise_for_status()\n# r.encoding=r.apparent_encoding\n#\n# soup = BeautifulSoup(r.text, 'html.parser')\n# for li in soup.find_all('ul')[3]:\n# if isinstance(li, bs4.element.Tag):\n# chapter = li.a\n# #print(chapter)\n# chapter_url = 'https:%s' % chapter.get('href')\n# #chapter_title=chapter.contents # ->['\u7b2c\u4e00\u8282 \u9f99\u57ce']\n# chapter_title=chapter.text # ->\u7b2c\u4e00\u8282 \u9f99\u57ce\n# print(chapter_title)\n# print(chapter_url)\n# chapter_response=requests.get(chapter_url)\n# chapter_response.encoding=chapter_response.apparent_encoding\n# chapter_html=chapter_response.text\n# chapter_soup=BeautifulSoup(chapter_html,'html.parser')\n# chapter_tag=chapter_soup.find('div',class_='read-content j_readContent')\n# fw.write(chapter_title)\n# fw.write(chapter_tag.text)\n#\n# fw.close()\n#\n# import re\n# import requests\n#\n#\n# def getHtmlText(url):\n# try:\n# r = requests.get(url)\n# r.raise_for_status()\n# r.encoding = r.apparent_encoding\n# return r.text\n# except:\n# return \"\"\n#\n#\n# def getInfor(html):\n# print(html)\n# print(re.findall(r'.*?', html))\n#\n#\n# def main():\n# url = 'https://detail.tmall.com/item.htm?spm=a230r.1.14.41.7fab2157JOw8dn&id=555305762446&ns=1&abbucket=10'\n# html = getHtmlText(url)\n# getInfor(html)\n#\n#\n# main()\n\nif __name__ == '__main__':\n n = int(input())\n a = list(map(int, input().split()))\n a.sort(reverse = True)\n res = 0\n k = 100000000\n for i in range(n) :\n # print(i)\n k = max(min(k, a[i]),0)\n res += k\n k -= 1\n\n print(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "066b016c619d39e19bdac51275d5d77f", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "# -*- coding: utf-8 -*-\n# @Time : 2019/6/5 13:21\n# @Author : yuggu\n# @Site :\n# @File : test.py\n# @Software: PyCharm\\\n\n# import pymysql\n# # \u6253\u5f00\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u53c2\u65701\uff1a\u4e3b\u673a\u540d\u6216IP\uff1b\u53c2\u65702\uff1a\u7528\u6237\u540d\uff1b\u53c2\u65703\uff1a\u5bc6\u7801\uff1b\u53c2\u65704\uff1a\u6570\u636e\u5e93\u540d\u79f0\n# db=pymysql.connect(\"localhost\",\"root\",\"root\",\"school\")\n# # \u4f7f\u7528cursor()\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u6e38\u6807\u5bf9\u8c61cursor\n# cursor=db.cursor()\n# # \u4f7f\u7528execute()\u65b9\u6cd5\u6267\u884csql\u67e5\u8be2\n# cursor.execute(\"select version()\")\n# # \u4f7f\u7528fetchone()\n# data=cursor.fetchone()\n# print(\"Data version:%s \" % data)\n# # \u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\n# db.close()\n\n# import sys\n# import pygame\n#\n# charlotte=pygame.image.load(\"1.jpg\") # \u52a0\u8f7d\u56fe\u7247\n# charlotterect=charlotte.get_rect() # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n# size=(int(charlotterect[2]/3),int(charlotterect[3]/3)) # \u8fd9\u91cc\u628a\u56fe\u7247\u7ed9\u7f29\u5c0f\u4e3a\u539f\u6765\u76841/3\n# charlotte=pygame.transform.scale(charlotte,size) # \u8fdb\u884c\u5bf9\u539f\u56fe\u7247\u7684\u7f29\u5c0f\u5e76\u8fd4\u56de\u4e00\u4e2a\u7f29\u5c0f\u540e\u56fe\u7247\u7684surface\n#\n# pygame.init()\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n# charlotte=pygame.transform.scale(charlotte,size)\n# charlotterect= (charlotte.get_rect()) # \u83b7\u53d6\u77e9\u5f62\u533a\u57df\n\n# pygame.init()\n# size=width,height=700,600\n# screen=pygame.display.set_mode(size)\n# color=(0,0,0)\n\n# while True:\n# for event in pygame.event.get():\n# if event.type == pygame.KEYDOWN:\n# sys.exit()\n# screen.fill(color)\n# screen.blit(charlotte,charlotterect)\n# pygame.display.flip()\n# pygame.quit()\n\n#\n# import urllib.request\n# import urllib.parse\n#\n# data=bytes(urllib.parse.urlencode({'word':'hello'}),encoding='utf-8')\n# response=urllib.request.urlopen(\"http://httpbin.org/post\",data=data)\n# html=response.read()\n# print(html)\n\n# import requests\n# url='https://blog.csdn.net'\n# # \u521b\u5efa\u5934\u90e8\u4fe1\u606f\n# headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0'}\n# response=requests.get(url,headers=headers)\n# print(response.content)\n\n# # \u722c\u866b\u722c\u53d6\u7f51\u9875\u6846\u67b6\n# import requests\n#\n# def getHTMLText(url):\n# try:\n# r=requests.get(url,timeout=30)\n# r.raise_for_status() # \u5982\u679c\u72b6\u6001\u4e0d\u662f200\uff0c\u5f15\u53d1HTTPError\u5f02\u5e38,\u7136\u540e\u629b\u51fa\u6355\u83b7\n# # ,\u5185\u90e8\u8fdb\u884c\u5224\u65ad\n# r.encoding=r.apparent_encoding\n# return r.text\n# except:\n# return \"\u4ea7\u751f\u5f02\u5e38\"\n#\n# if __name__ == \"__main__\":\n# url=\"http://blog.csdn.net\"\n# print(getHTMLText(url))\n#\n#\n# # \u6d4f\u89c8\u5668headers\u6a21\u62df\n# import requests\n#\n# kv={'User-Agent':'Mozilla/5.0'}\n# response=requests.get('http://www.amazon.cn/',headers=kv)\n# response.encoding=response.apparent_encoding\n# print(response.request.headers)\n\n# # \u7f51\u7edc\u56fe\u7247\u722c\u53d6\n# import requests\n# path='D://abc.jpg' # \u4fdd\u5b58\u5728D\u76d8\u4e0b\uff0c\u4ee5abc.jpg\u547d\u540d\n# url='https://wx4.sinaimg.cn/mw690/8d05b653ly1g4n0elm7axj20j60b475b.jpg'\n#\n# r=requests.get(url)\n# print(r.encoding)\n# with open(path,'wb') as f:\n# f.write(r.content)\n\n# # \u767e\u5ea6\u5173\u952e\u5b57\u63d0\u4ea4\u63a5\u53e3\n# import requests\n# kv={'wd':'Python'}\n# r=requests.get('http://www.baidu.com/s',params=kv)\n# print(r.request.url)\n\n\n# from bs4 import BeautifulSoup\n# import urllib.request\n# html = urllib.request.urlopen(\"https://www.csdn.net/\").read().decode('utf-8')\n# soup = BeautifulSoup(html,\"html.parser\")\n# titles=soup.select(\"h3[class='company_name'] a\") # CSS \u9009\u62e9\u5668\n# for title in titles:\n# print(title.get_text(),title.get('href'))# \u6807\u7b7e\u4f53\u3001\u6807\u7b7e\u5c5e\u6027\n\n\n# # \u6807\u7b7e\u6811\u5411\u4e0a\u904d\u5386\n# import requests\n# from bs4 import BeautifulSoup\n#\n# url='https://python123.io/ws/demo.html'\n# demo=requests.get(url).text\n# soup=BeautifulSoup(demo,'html.parser')\n# for parent in soup.a.parents:\n# \tif parent is None:\n# \t\tprint(parent)\n# \telse:\n# \t\tprint(parent.name)\n\n\n# # \u8d77\u70b9\u5c0f\u8bf4\u722c\u53d6\n# import requests\n# from bs4 import BeautifulSoup\n# import bs4\n#\n#\n# path=\"3.txt\"\n# fw=open(path,'w',encoding='utf-8')\n#\n# url = \"https://book.qidian.com/info/1015323848#Catalog\"\n# r=requests.get(url,timeout=30)\n# r.raise_for_status()\n# r.encoding=r.apparent_encoding\n#\n# soup = BeautifulSoup(r.text, 'html.parser')\n# for li in soup.find_all('ul')[3]:\n# if isinstance(li, bs4.element.Tag):\n# chapter = li.a\n# #print(chapter)\n# chapter_url = 'https:%s' % chapter.get('href')\n# #chapter_title=chapter.contents # ->['\u7b2c\u4e00\u8282 \u9f99\u57ce']\n# chapter_title=chapter.text # ->\u7b2c\u4e00\u8282 \u9f99\u57ce\n# print(chapter_title)\n# print(chapter_url)\n# chapter_response=requests.get(chapter_url)\n# chapter_response.encoding=chapter_response.apparent_encoding\n# chapter_html=chapter_response.text\n# chapter_soup=BeautifulSoup(chapter_html,'html.parser')\n# chapter_tag=chapter_soup.find('div',class_='read-content j_readContent')\n# fw.write(chapter_title)\n# fw.write(chapter_tag.text)\n#\n# fw.close()\n#\n# import re\n# import requests\n#\n#\n# def getHtmlText(url):\n# try:\n# r = requests.get(url)\n# r.raise_for_status()\n# r.encoding = r.apparent_encoding\n# return r.text\n# except:\n# return \"\"\n#\n#\n# def getInfor(html):\n# print(html)\n# print(re.findall(r'.*?', html))\n#\n#\n# def main():\n# url = 'https://detail.tmall.com/item.htm?spm=a230r.1.14.41.7fab2157JOw8dn&id=555305762446&ns=1&abbucket=10'\n# html = getHtmlText(url)\n# getInfor(html)\n#\n#\n# main()\n\nn = int(input())\na = sorted(map(int, input().split()),reverse = True)\nres = 0\nk = 100000000\nfor i in a :\n k = max(min(k, i),0)\n res += k\n k -= 1\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "423701ce991737767727e8a9c34bd9a7", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\nn = int(input())\na = list(input())\nt=0\ng =a.count(\"?\")\nif g==0:\n\tprint(\"No\")\n\texit()\n\nfor i in range(n-1):\n\tj = i+1\n\tif (a[i]==a[j] and a[i]!=\"?\") :\n\t\tprint(\"No\")\n\t\texit()\nfor i in range(1,n-2):\n\tif a[i-1]!=a[i+1] and a[i]==\"?\" and (a[i-1]!=\"?\" and a[i+1]!=\"?\" ):\n\t\tt+=1\n\t\t\nif t=\n#include \n\nusing namespace std;\n\nconst int SIG = 26;\n\nint n, m;\nvector mat;\n\nvector cnt_f(const int d) {\n vector cnt(SIG);\n for (int i = n - 1 - d, j = n - 1; i < n; i++, j--) {\n cnt[mat[i][j] - 'a']++;\n }\n return cnt;\n}\n\nint main() {\n ios_base::sync_with_stdio(0);\n\n cin >> n >> m;\n mat.resize(n);\n for (auto &s : mat) cin >> s;\n\n vector dp(1), dp_prev;\n \n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3daa3ff6db16817fbaa2cb1b67eec7b5", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x=int(input())\nstring=input()\ni=0\ncounter=0\nright=-1\nleft=0\ncounterik=0\nif string.count('MM')>=1 or string.count('CC')>=1 or string.count('YY')>=1:\n print(\"NO\")\nelse:\n while i=2:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "050dd0577213267be10568919625a740", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "Python 3", "source_code": " import sys\nn = int(input())\nlst = list(input())\ns=0\nz=0\n#print(len(lst))\nlst1 = [\"C\", \"Y\", \"M\"]\nn=0\nfor i in range(len(lst)-1):\n if lst[i]==\"?\":\n n+=1\nfor i in range(len(lst)-1):\n if lst[i]=='?':\n s+=1\n if i==0:\n s+=1\n elif i==len(lst)-1:\n s+=1\n elif i>0 and i c/d): print(f((a*d)-(b*c),a*d))\nelse: print(\"0/1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ca30dd6ec5869e6aff9e41bb44ca67c4", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from fractions import Fraction\na,b,c,d=raw_input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=int(d)\nif c>=a and d>=b:\n\tif a>b:\n\t\tif c>=d\n\t\t\tprint Fraction(c*b-d*a,c*b)\n\t\telse:\n\t\t\tprint Fraction(d*a-c*b,d*a)\t\n\telif a==b:\n\t\tif c>=d:\n\t\t\tprint Fraction(c-d,c)\n\t\telse:\n\t\t\tprint Fraction(d-c,d)\n\n\telse:\n\t\tif c=a and db:\n\t\tif c>=d:\n\t\t\tprint Fraction(c*b-d*a,c*b)\n\t\telse:\n\t\t\tprint Fraction(d*a-c*b,d*a)\t\n\telif a==b:\n\t\tif c>=d:\n\t\t\tprint Fraction(c-d,c)\t\n\t\telse:\n\t\t\tprint Fraction(d-c,d)\n\telse:\n\t\tif c=b:\t\n\tprint Fraction(d*a-c*b,d*a)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "525c958cfce6a919af55ec31c9f16a3a", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "__author__ = 'vasiliy.lomanov'\n\nsrc = raw_input().split()\n\na = float(src[0])\nb = float(src[1])\nc = float(src[2])\nd = float(src[3])\n\n\ndef Euclid(a, b):\n q = a/b\n r = a - q*b\n if r == 0:\n return b\n else:\n return Euclid(b, r)\n\n\nk = min(b/d, a/c)\n\nif b/d < a/c:\n x = a*d\n y = a*d-c*b\nelse:\n x = c*b\n y = c*b - a*d\n\n\nnod = Euclid(x, y)\nprint str( int(y/nod) ) + \"/\" + str( int(x/nod) )", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ca742c11b7543d395e647412ec4ab7b", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import sys\n\nhulp=sys.stdin.readline().split()\n\nn,m=int(hulp[0]),int(hulp[1])\n\nf=[int(x) for x in sys.stdin.readline().split()]\n\nf.sort()\nmindif=1000\n\nfor x in range(m-n+1):\n mindif=min(f[x+n-1]-f[x],mindif)\n\n\n\nprint mindif\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "840d6619d9c64db86c68881c7eb7f61e", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "PyPy 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\nimport heapq\nfrom math import *\nfrom collections import defaultdict as dd # defaultdict() Free of KeyError.\nfrom collections import deque # deque(list) append(), appendleft(), pop(), popleft() - O(1)\nfrom collections import Counter as c # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\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(var)\ndef l(): return list(map(int, data().split()))\ndef sl(): return list(map(str, data().split()))\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 [[val for i in range(n)] for j in range(m)]\n\n\ndef first():\n global a, b, e, d\n div, mul = e, a\n a1, a2 = e*mul, a*mul\n if a2 / div > b:\n return mod, 1\n return a*b*e-d*a*a, div\n\n\ndef second():\n global a, b, e, d\n div, mul = d, b\n a1, a2 = e * mul, d * mul\n if a1 / div > a:\n return mod, 1\n return d*a*b-e*b*b, div\n\n\na, b, e, d = sp()\nt1 = first()\nt2 = second()\nif t1[0]/t1[1] < t2[0]/t2[1]:\n diff, area = t1[0], a * b * t1[1]\nelse:\n diff, area = t2[0], a * b * t2[1]\ng = gcd(diff, area)\nout(str(diff//g)+\"/\"+str(area//g))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58ec9ee4960327db4228aef369d76ed3", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def FindDirection(start, end, n):\n\tmodelTab = ['v', '<', '^', '>']\n\tiStart = 0\n\tiEnd = 0\n\tfor i in range(4):\n\t\tif start == modelTab[i]:\n\t\t\tiStart = i\n\t\tif end == modelTab[i]:\n\t\t\tiEnd = i\n\tif (n%4) == 2 or (n%4) == 4:\n\t\treturn 'undefined'\n\telif ((n%4) == 1 and (iEnd-iStart)%4 == 1) or ((n%4) == 3 and (iEnd-iStart)%4 == 3):\n\t\treturn 'cw'\n\telif: ((n%4) == 1 and (iEnd-iStart)%4 == 3) or ((n%4) == 3 and (iEnd-iStart)%4 == 1):\n\t\treturn 'ccw'\t\n\telse: \n\t\treturn 'undefined'\n\t\t\t\n\n\ndef read_str():\n\treturn map(str, raw_input().split(' '))\n\nstart, end = read_str()\nn = map(int, raw_input().split(' '))[0]\n\nprint (FindDirection(start, end, n))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ebd30cad2e21c083c4573faa3075506", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": " a='v<^>'\nq,w=(str(i) for i in input().split())\nk=int(input())%4\na1=a.find(q)\na2=a.find(w)\nf1=False\nf2=False\nf3=False\nf4=False\nIf (a1==a2) and (k==0):\n print('undefined')\nelse:\n if a1<=a2:\n if abs(a2-a1)==k:\n f1=True\n if 4-abs(a2-a1)==k:\n f2=True\n else:\n if a1-a2==k:\n f3=True\n if 4-a1+a2==k:\n f4=True\n if ((f1) and (f2)) or ((f3) and (f4)):\n print('undefined')\n elif (f1) or (f4):\n print('cw')\n elif (f2) or(f3):\n print('ccw')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "35cdfdcd8e6137754b895e1a4dcf3d97", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a, b = input().split()\nn=int(input())\nif a==\"^\":\n a1=1\nelif a==\"<\":\n a1=2\nelif a==\"v\":\n a1=3\nelif a==\">\":\n a1=4\nif b==\"^\":\n b1=1\nelif b==\"<\":\n b1=2\nelif b==\"v\":\n b1=3\nelif b==\">\":\n b1=4 \nn=n%4\na2=a1-n\na3=a1+n\nif a2<=0:\n a2=a2+4\nif a3>4:\n a3=a3-4\nif (b1==a2)&(b1!=a3):\n print \"cw\"\nelif (b1!=a2)&(b1==a3):\n print \"ccw\"\nelse:\n print \"undefined\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2436fadc719f3492488bb54ebbd14e6b", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "\n a='v<^>'\nq,w=(str(i) for i in input().split())\nk=int(input())%4\na1=a.find(q)\na2=a.find(w)\nf1=False\nf2=False\nf3=False\nf4=False\nif a1<=a2:\n if abs(a2-a1)==k:\n f1=True\n if 4-abs(a2-a1)==k:\n f2=True\nelse:\n if a1-a2==k:\n f3=True\n if 4-a1+a2==k:\n f4=True\nif ((f1) and (f2)) or ((f3) and (f4)):\n print('undefined')\nelif (f1) or (f4):\n print('cw')\nelif (f2) or(f3):\n print('ccw')\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "85530ce287fb914f3356259069e436d6", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a, b = input().split()\nn=int(input())\nif a=='^':\n a1=1\nelif a=='<':\n a1=2\nelif a=='v':\n a1=3\nelif a=='>':\n a1=4\nif b=='^':\n b1=1\nelif b=='<':\n b1=2\nelif b=='v':\n b1=3\nelif b=='>':\n b1=4 \nn=n%4\na2=a1-n\na3=a1+n\nif a2<=0:\n a2=a2+4\nif a3>4:\n a3=a3-4\nif (b1==a2)&(b1!=a3):\n print 'cw'\nelif (b1!=a2)&(b1==a3):\n print 'ccw'\nelse:\n print 'undefined'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e40bca73f6b6d713680e76ae1a8b0ed7", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "Python 3", "source_code": "f=[0]*99\nq=0\na,b,c=map(int,input().split())\nfor i in range(a):s=input()\n for j in range(b):\n if s[j]=='Y':f[j]+=1\n if f[j]==c:q+=1\n#kitten\nprint q", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a61e6cfa9855659e3e0a3d68719ced3", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#include\n\nint main()\n{\n int n, m, k, c[16]={0}, ans=0;\n scanf(\"%d%d%d\", &n, &m, &k);\n \n for(int i=0; i=k )\n ans++;\n }\n \n printf(\"%d\\n\", ans);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96909387ffc7618e0d949019d8f37eee", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n, m, k = tuple(map(int, input().split(' ')))\n marks = [0 for i in range(m)]\n for i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n marks[j] += 1\n res = 0\n for mark in marks:\n if mark >= k:\n res += 1\nprint(res)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "35a1070f83dfb133ac65f266b7419202", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "f,q=[0]*99,0\na,b,c=map(int,input().split())\nfor i in range(a):\n s=input()\n for j in range(b):\n if s[j]=='Y':f[j]+=1\n if f[j]==c:q+=1\nprint(q)#kitten", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4dcd375c27164afec2361a05be1d8062", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#include\nusing namespace std;\nconst int inf = 1000000001;\nconst int MOD = 1000000007;\ntypedef long long Int;\n#define FOR(i,a,b) for(int i=(a); i<=(b);++i)\n#define mp make_pair\n#define pb push_back\n#define sz(s) (int)((s).size())\n\nint n;\nint a[111][111];\n\nvoid go() {\n int id=0, i=0, j=0;\n lab:;\n j=id%n;\n i=id/n;\n cin>>a[i][j];\n id++;\n //(id==n*n ? (goto here) : (goto lab));\n here:;\n}\n\nint cnt[111];\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);//freopen(\"output.txt\", \"w\", stdout);\n //cin>>n;\n //go();\n //cout<=f);\n cout< 0 else (\"Black\" if t < 0 else \"Draw\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "feee9e20c5ca0a3f915ca5cc6ace02cd", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Python 3", "source_code": "d={\"q\":9,\"r\":5,\"b\":3,\"n\":3,\"p\":1,\"k\":0,\"Q\":9,\"R\":5,\"B\":3,\"N\":3,\"P\":1,\"K\":0}\nf={\"m\":0,\"z\":0}\nfor k in range(8):\n a=input()\n for j in a:\n if(j!=\".\" and j in \"qprbnk\"):\n f[\"z\"]+=d[j]\n if(j!=\".\" and j in \"QRBNKP):\n f[\"m\"]+=d[j]\nif(f[\"m\"]>f[\"z\"]):\n print(\"White\")\nelif(f[\"m\"]==f[\"z\"]):\n print(\"Draw\")\nelse:\n print(\"Black\")\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03195e02a949c0cda7f003cf79aca87f", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Python 2", "source_code": "c={'q':9, 'r':5, 'b':3, 'n':3, 'p':1, 'k':0, '.':0}\nr=[0, 0]\nfor i in range(8):\n r=map(sum, zip(r, *map(lambda s: [0,0] if s=='.' else s.isupper() * [0] + [c[s.lower()]] + s.islower() * [0], raw_input())))\nif r[1] > r[0]:\n print 'White'\nelse if r[1] == r[0]:\n print 'Draw'\nelse:\n print 'Black'\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56a25ac3b17de659f60fbcf451d3c89b", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a,w,b='',0,0\nfor i in range(8):a+=input()\nw,b=9*a.count('Q')+5*a.count('R')+3*a.count('B')+3*a.count('N')+a.count('P'),9*a.count('q')+5*a.count('r')+3*a.count('b')+3*a.count('n')+a.count('p');print('White' if w>b else 'Black' if w white_score:\n print(\"Black\")\nelif white_score > black_score:\n print(\"White\")\nelse:\n print(\"Draw\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6d6423fde7af5a3324616209aec0fb2", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, k, m, d = map(int, input().split())\nans = 0\nfor i in range(1, d + 1):\n x = min(n // ((i - 1) * k + 1), m)\n if (x && (n // x + k - 1) // k == i):\n ans = max(ans, x * i);\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70cc00ef72028c571f2f865cf4c6eeed", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nconst int NMAX = 100;\n\ntypedef long long I64;\n\nbool overf(I64 a, I64 b)\n{\n I64 x = a * b;\n x = a * b;\n if (a != 0 && x / a != b)\n return 1;\n return 0;\n}\n\nint main()\n{\n I64 N, K, D, M;\n I64 best = 0;\n cin >> N >> K >> M >> D;\n for( int ture = 1; ture <= D; ++ture ) {\n I64 bomb = N / (1 + (ture - 1) * K);\n if( overf(ture - 1, K) )\n bomb = 0;\n bomb = min(bomb, M);\n best = max(best, ture * bomb);\n }\n cout << best << '\\n';\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "397c5e130bb64c3aa514b1d554bea79b", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n, k, m, d = map(int, input().split())\nans = 0\nfor i in range(1, d+1):\n hi = min(m, n//(k*(i-1)+1), lo = n//(k*i+1)\n if(hi > lo) ans = max(ans, i*hi)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cda0d69906019141843f02e4fe0b5184", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n, k, M, D = map(int, input().split())\nans = 0\nfor i in range(1, D+1):\n\tl = n//(i*k)\n\tr = n//((i-1)*k + 1)\n if l <= M:\n ans = max(ans, min(M, r)*i)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "167efbcea8dfd09759f714d5f440b749", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n, k, M, D = map(int, input().split())\n\nans = 0\nfor i in range(1, D+1):\n\tl = n//(i*k)\n\tr = n//((i-1)*k + 1)\n \n if l <= M:\n ans = max(ans, min(M, r))\n \nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03b38e12c729134b04ac6f04335375c3", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "Integer = int(input(\"\"))\nif Integer < 100 and Integer > 0:\n import math\n First_dig = math.floor(Integer/10)\n Second_dig = Integer - First_dig * 10\n if First_dig == 0:\n n = 2\n elif First_dig == 1:\n n = 7\n elif First_dig == 2:\n n = 2\n elif First_dig == 3:\n n = 3\n elif First_dig == 4:\n n = 3\n elif First_dig == 5:\n n = 3\n elif First_dig == 6:\n n = 2\n elif First_dig == 7:\n n =5\n elif First_dig == 8:\n n = 1\n elif First_dig == 9:\n n = 2\n\n if Second_dig == 0 :\n k = 2\n elif Second_dig == 1:\n k = 7\n elif Second_dig == 2:\n k = 2\n elif Second_dig == 3:\n k = 3\n elif Second_dig == 4:\n k = 3\n elif Second_dig == 5:\n k = 3\n elif Second_dig == 6:\n k = 2\n elif Second_dig == 7:\n k = 5\n elif Second_dig == 8:\n k = 1\n else:\n k = 2\n\n \nprint(k*n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d227f5e80837b9d8a7dbececfb4cfb7", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "Python 2", "source_code": " 1 #!/usr/bin/env python\n 3 \n 4 d = dict()\n 5 d[0] = [0, 8]\n 6 d[1] = [0, 1, 3, 4, 7, 8, 9]\n 7 d[2] = [2, 8]\n 8 d[3] = [3, 8, 9]\n 9 d[4] = [4, 8, 9]\n 10 d[5] = [5, 6, 8, 9]\n 11 d[6] = [6, 8]\n 12 d[7] = [0, 3, 7, 8, 9]\n 13 d[8] = [8]\n 14 d[9] = [8, 9]\n 15 \n 16 a = input()\n 17 x = a / 10\n 18 y = a % 10\n 19 \n 20 \n 21 print len(d[x]) * len(d[y])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "98700d252166c7b536b040d891d64eb0", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "A = [2,7,2,3,3,4,2,5,1,2]\n\ns = input()\n\nprint A[int(s[0])] * A[int(s[1])]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11fd5f28021016a0626ff9a98101fcc9", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "s=str(input())\nd={}\np=1\nfor i in range(0,len(s)):\n if(s[i]=='0'):\n d[s[i]]=2\n elif(s[i]==\"1\"):\n d[s[i]]=\n elif(s[i]==\"8\"):\n d[s[i]]=1\n elif(s[i]==\"9\"):\n d[s[i]]=2 \n elif(s[i]==\"2\"):\n d[s[i]]=2\n elif(s[i]==\"3\"):\n d[s[i]]=3\n \n elif(s[i]==\"4\"):\n d[s[i]]=3\n elif(s[i]==\"5\"):\n d[s[i]]=4 \n elif(s[i]==\"6\"):\n d[s[i]]=2\n elif(s[i]==\"7\"):\n d[s[i]]=5 \nfor k,v in d.items():\n p=p*(d[k])\nif(s[0]==s[1]):\n print(p*p)\nelse:\n \n print(p)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71b0c2cf87183ef2d92dfac825ce2696", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "A = [2,7,2,3,3,4,2,5,1,2]\n\ns = input()\n\nans = A[int(s[0])] * A[int(s[1])]\n\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "63b7b6e9f83d492bfcb59c78076614d5", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\nn=int(raw_input())\na=int(raw_input())\nb=int(raw_input())\nc=int(raw_input())\nx=n/a\nif ((n%a)-c)>0:\n x+=((n%a)-c)/(b-c))\ny=(n-c)/(b-c)+(((n-c)%(b-c))/a)\nprint max(x,y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a0a1a0bbe7223b07d352fc4c1c88423", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "l=lambda:input()\nn,a,b,c=l(),l(),l(),l()\nif a<=(b-c):print n/a\nelse:g = 0;if n>b: g+=(n-\u0441)/(b-c);n-=(b-c)*g;g += n/a;print g", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0567928c1f8b4e669c033a9a19e15286", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "d = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\nc = int(raw_input())\n\nif(a == 1000000000000000000):\n qntd = 999999999999999995\nelse if(a <= (b - c)):\n qntd = d / a\nelse :\n if(d >= b):\n qntd = (d - c) / (b - c)\n else :\n qntd = 0\n\nprint (qntd)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40de15ae9e656049a5f77b7b660fbd2d", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\na = int(input())\nb = int(input())\nc = int(input())\n\n_b = int(b);\nb -= c\n\nt = 0\nif(n >= b) t = 1\n\nprint(max(n // a, (n - _b) // b + max(t, ((n - _b) % n + _b) // a)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "818b1d629504a40bc4af84156325e0c4", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from math import ceil\nn= int(input())\na = int(input())\nb = int(input())\nc = int(input())\nif b - c < a:\n if n < b:\n if n < a:\n print(0)\n else:\n print(n // a)\n else:\n if b > 100000000000000000:\n count = n // (b - c) + 1 - b // (b - c)\n else:\n if b // ( b - c) * (b - c) + n % (b - c) >= b:\n count = n // (b - c) + 1 - (b // ( b - c) * (b - c) + n % (b - c)) // (b - c)\n else:\n count = n // (b - c) + 1 - (b // ( b - c) + 1) * (b - c) + n % (b - c)) // (b - c)\n if a <= b:\n if a < n:\n print(count + (n - (b - c) * count) // a)\n else:\n print(count)\n else:\n print(count)\nelse:\n if n < a:\n print(0)\n else:\n print(n // a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f44dbef40caec9c96e30634d003e0ce", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x,y,z=map(int,input().split())\nif (x-(y+z))*((x+z)-y)<0:\n print('?)\nelse:\n if x-(y+z)>0:\n print('+')\n elif (x+z)-y<0:\n print('-')\n else:\n print('0')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72105326dafc61730778db56d445822a", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Python 3", "source_code": "By SKhan, contest: Codeforces Round #564 (Div. 2), problem: (A) Nauuo and Votes, Wrong answer on pretest 5, #\n\nx, y, z = map(int, input().split(\" \"))\n\nif (z >= x and z >= y) and z >= x + y:\n print(\"?\")\nelif x > y and x >= z:\n print(\"+\")\nelif y > x and y >= z:\n print(\"-\")\nelse:\n print(\"0\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52b3230df93571da073d98e6c53f880d", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = str(input())\nb = []\nb = a.split()\nx = int(b[0])\ny = int(b[1])\nz = int(b[2])\n\nif x == y and z == 0:\n print('0')\nif x == 0 and y == 0 and z > 0:\n print('?')\nif x + z > y:\n print('+')\nif y + z > x\n print('-')\nelse:\n print('?')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "14232a5bb7dc9f3118fcb99d8588fa63", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Python 3", "source_code": "while True:\n try:\n arr = list(map(int,input().split()))\n # print(arr)\n m = max(arr)\n if m == arr[0]:\n print('+')\n elif m == arr[1]:\n print('-')\n elif arr[1] == arr[0] and arr[0] == m:\n print('0')\n elif:\n print('?')\n except EOFError:\n break\n \n except ValueError:\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b27c6dfbde25d0c9d0394d150e880264", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\nx, y, z = map(int, input().split())\n\nif x == y == z ==0:\n print('0')\nelif abs(x-y) > z:\n if x > y:\n print('+')\n elif x < y:\n print('-')\n else:\n print('0')\nelif abs(x -y) ==z:\n if not z:\n print('0')\n else:\n print('?\u2019)\nelse:\n print('?')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77d1aa66e757c24d320bb1816f855840", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nif a==b:\n print(\"1/1\")\nelif a==6 or b==6:\n print(\"0/1\")\nelse:\n maxx=max(a,b)\n maxx=(6-maxx)+1\n if 6%maxx=0:\n a=6//maxx\n print(\"1/str(a)\")\n else:\n print(\"str(maxx)/6\")\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "86fdc11038cc9496246c38aa65e1db36", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "list=raw_input().split()\nx=max(int(list[0]),int(list[1]))\ndef gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\na=6-x+1\nb=6\nprint '%d/%d' % (a/gcd(a,b),b/gcd(a,b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73596bdaf25669eb7248709feee1eba9", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "li = [int(i) for i in input().split()]\nk = max(li)\nif(k == 6):\n print(\"0/1\")\nelif(k == 1):\n print(\"1/1\")\nelse:\n d = 6-k+1\n if(d == 2):\n print(\"1/3\")\n elif(d == 3):\n print(\"1/2\")\n else(str(d)+\"/\"+\"6\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "151bcd3eae8388e1110f0e9f1dd26d97", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "W,Y=[i for i in input().split(\" \")]\nZ=max(W,Y)\nnum=(7-Z)\nif num%6==0:\n print(\"1/1\")\nelif num%3==0:\n print(\"%s/2\",%(num/3))\nelse num%2==0:\n print(\"%s/3\",%(num/2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2bdbce0f1cbd66da0c8acd5b351fd779", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def dice(Y,W) : \n\ta = 7-max(Y,W)\n\tfrom fractions import *\n\tc = Fraction(a/6)\n\treturn 'c'\nY = int(input())\nW = int(input())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6ac08bec2f74cb2026c7383dd12dde2", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nimport sys\nnum9=len(str(2*n))-1\n\ns=[str(i) for i in range(10)]\nans=0\n\nif(num9==0):\n print(n*(n-1)//2)\n sys.exit()\nfor i in s:\n x=i+'9'*num9\n x=int(x)\n ans+=max(0,min((n-x//2),x//2))\nprint(ans)\n \n \n \n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d50f0822d1065cadfd82d8d95248a509", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n=int(input())\ns0=str(n+n-1)\nk=len(s0)\nif s0!=k*'9':\n k-=1\ns=k*'9'\ndef cnt(s):\n v=int(s)\n #print(v)\n if v>n*2-1:\n return 0\n if v==2*n-1:\n return 1\n if v>n:\n return n-v//2\n if v<=n:\n return v//2\nans=cnt(s)\nfor i in range(1,9):\n ans+=cnt(str(i)+s)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f9c5a20a0563d2584420fb49457b1be2", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "import sys\nsys.stdin = open('input.txt', 'r')\nsys.stdout = open('output.txt', 'w')\n\nn = input()\nx = int('9'*len(str(n)))\nmax_val = 2*n - 1\nif n < 5:\n\tprint (n*(n-1))/2\nelif max_val < x:\n\tx /= 10\n\ty = pow(10,len(str(n))-1)\n\tz = y/10\n\tans = 0\n\twhile x <= max_val:\n\t\ta = x/2 + 1\n\t\tans += min(n,x-1) - a + 1\n\t\tx += y\n\tprint ans\nelif x == n:\n\tprint n-x/2-1 \nelse:\n\tprint n-x/2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0caf84400a7299237a7a4449969011bf", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from math import log10, floor\n\nn = int(input())\n\nbase = floor(log10(n//5)) + 1\n\nnines = sum(9*10**i for i in range(base))\n\nresult = 0\n\nfor i in range(4):\n\ttarget = nines*(i+1) + i\n\tif target//2 < n < target:\n\t\tresult += n - target//2\n\tif n >= target:\n\t\tresult += target // 2\n\nprint(result)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "600c81dde37bc37ad98e4d9f57083ffc", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import sys\n\nlines = []\nfor line in sys.stdin:\n lines.append(line)\n\nn = int(lines[0].rstrip(\"\\r\\n\\t \"))\n\nmax_price = n * 2 - 1\nnines = 0\nmp = max_price\nwhile mp >= 9:\n nines += 1\n mp = int(mp / 10)\nif nines < 1:\n print(\"0\")\n exit()\nprice_suffix = \"9\"*nines\n\npairs = set()\ndef add_pairs(max_x: int, price: int):\n from_max = int(price / 2)\n to_min = from_max + 1\n to_max = price - 1\n if to_max > max_x:\n to_max = max_x\n from_min = price - to_max\n for x in range(from_min, from_max + 1):\n pairs.add(str(x) + ':' + str(price - x))\n\n\ncnt = 0\nfor d in range(0, 10):\n if d > 0:\n price = int(str(d) + price_suffix)\n else:\n price = int(price_suffix)\n if price <= max_price:\n add_pairs(n, price)\n\nprint(len(pairs))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee6b634613c2e5a57c5cd2e0a4b98987", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\nif n <= 2:\n print(n+1)\n exit()\nsqr = math.sqrt(n)\nif sqr == int(sqr):\n print(int(sqr+sqr))\n exit()\nelse:\n if n % 2 == 1:\n n += 1\n test = math.sqrt(n+1)\n if test == int(test):\n print(test+test)\n exit()\n sqr = math.ceil(math.sqrt(n))\n for i in range(sqr, 1, -1):\n if n % i == 0:\n opt = i + n//i\n n += 1\n sqr = math.ceil(math.sqrt(n))\n for i in range(sqr, 1, -1):\n if n % i == 0:\n opt2 = i + n//i\n print(min(opt, opt2))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a11b2e8d59d7adc60c16ea75c74dce47", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "g = input()\n\nans = 2\n\ni = 1\n\nh = []\n\nc = 2\n\nn = 1\n\ng1 = g\n\nif g == 1:\n\n\tg = g + 3\n\nwhile i < g:\n\n\tif i == 1:\n\t\ti = i + 1\n\n\t\tcontinue\n\n\tk = int(len(h)**(0.5))\n\n\tif k**2 == len(h) and (k != 1 and k != 0):\n\n\t\tn = n + 1\n\n\tj = 1\n\n\twhile j <= n:\n\n\t\n\t\th.append(i)\n\n\t\tj = j + 1\n\n\tl = int((len(h)+1)**(0.5))\n\n\tif l**2 == len(h)+1:\n\n\t\th.append(i)\n\n\ti = i + 1\n\ng = g1\n\nprint h[g-1]\n\n\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c12f0f01e0ad27f5b36611dbcaf8302", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "num i = int(input())\nif(i<4):\n print(i+1)\nelse:\n print(4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1378c3ffb349d1e9193ef9dfc174f4e7", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\nsqrt = int(n ** (1/2))\n2x = sqrt * sqrt\nr = None\n\nif not n - 2x:\n r = 2 * sqrt\nelif n - 2x > sqrt:\n r = 2 * sqrt + 1\nr = 2 * sqrt + 2\nprint(r)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "766a2aafa98536588028609becd787db", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nif(n<=3):\n print(n+1)\nelse:\n a = n**0.5\n d = a-int(a)\n if(d>=0.5):\n a = int(a)+1\n print(2*a)\n else if(d>0 and d<0.5):\n a = int(a)\n print(2*a+1)\n else:\n a = int(a)\n print(2*a)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f4351473de68d29544f69ad558014eb", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n,m,k=map(int,str(raw_input()).split())\nmod=10**9+7\nif n>m:\n n,m=m,n\nif k==-1 and n+m%2==1:\n print 0\nexcept:\n print pow(2,((n-1)*(m-1)),mod)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2f2a086b72ec8552e5844c9760963e93", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def power(x, y, z):\n number = 1\n while y:\n if y & 1:\n number = number * x % z\n y >>= 1\n x = x * x % z\n return number\n\nn, m, k = map(int, raw_input().split())\nmod = (10**9) + 7;\nprint power(2, (n - 1) * (m - 1), mod)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f8a4dcb79ae1aa8d3681eeba76a6bf66", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "from math import *\nn, m, k = map(int,input().split(' '))\nans = (2**((n-1)*(m-1)%1000000006))%(1000000007)\nif (k==-1 && (n+m)%2==1) ans=0;\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "992ffd7d245780a7d4b8979bb7540290", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#include \"bits/stdc++.h\"\n#define lpa(i,a,b) for(int i=a; i>n>>m>>k;\n if(n%2!=m%2 && k!=1) cout<<0;\n else\n {\n ll mod=pow(10,9)+7;\n n--; \n m--;\n n%=mod-1;\n m%=mod-1;\n cout<0):\n if y&1:\n res=res*x%mod\n x=x*x%mod\n y=y\u00bb1\n return res\n\nif (m%2 != n%2 and k == -1):\n print (0)\nelse:\n print (powermod(2, (m-1)*(n-1)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a864c994f6c154f5f27dd1355ad07ae9", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "def shift(sequence,shift):\n keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n keyboardList = list(keyboard)\n sentence = \"\"\n if shift == \"R\"\n for i in sequence:\n sentence+=keyboardList[keyboardList.index(i)-1]\n return sentence\n for i in sequence:\n sentence+=keyboardList[keyboardList.index(i)+1]\n return sentence\ndirection = str(input())\nsequence = str(input())\nprint (shift(sequence))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ead336ad5d9fbf5d27a8f695cbac8418", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Python 2", "source_code": "x=raw_input()\ny=raw_input()\ni=1\nif x==\"R\":\n i*=-1\nkey = \"qwertyuiopasdfghjkl;zxcvbnm,./\"\ns=\"\"\nfor m in y:\n s+=key[key.index(m)+i]:\nprint s", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7e0c1aabac7a7828124c5459d76cffe", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Python 3", "source_code": "verh='qwertyuiop'\ncentr='asdfghjkl;'\nniz='zxcvbnm,./'\nn=input()\na=input()\nnomervstroke=0##\u043d\u0443\u0436\u043d\u044b\u0439\u0418\u043d\u0434\u0435\u043a\u0441\u0412 \u0441\u0442\u0440\u043e\u043a\u0435\nif n==\"R\":##\u0435\u0441\u043b\u0438 \u043d\u0430\u0436\u0430\u043b \u043f\u0440\u0430\u0432\u0435\u0435\n for i in range(len(a)):\n if a[i] in verh:\n nomervstroke=verh.find(a[i])-1\n print(verh[nomervstroke],end='')\n elif a[i] in centr:\n nomervstroke=centr.find(a[i])-1\n print(centr[nomervstroke],end='')\n else:\n nomervstroke=niz.find(a[i])-1\n print(niz[nomervstroke],end='')\nelse:##\u0435\u0441\u043b\u0438 \u043d\u0430\u0436\u0430\u043b \u043b\u0435\u0432\u0435\u0435\n for i in range(len(a)):\n if a[i] in verh:\n nomervstroke=verh.find(a[i])+1\n print(verh[nomervstroke],end='')\n elif a[i] in verh:\n nomervstroke=centr.find(a[i])+1\n print(centr[nomervstroke],end='')\n else:\n nomervstroke=niz.find(a[i])+1\n print(niz[nomervstroke],end='')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8f31e95292e7527c569c8dec5c591b9d", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nm=list(input())\na='qwertyuiop[]\\\\asdfghjkl;\\'zxcvbnm,./' #\u7279\u6b8a\u7684\\'\u7b26\u53f7\u524d\u9762\u52a0\\\u8868\u793a\u5c31\u662f\u8fd9\u4e2a\u7b26\u53f7\nprint(l)\nif n=='R':\n for i in range(len(m)):\n c=a.find(m[i])\n m[i]=l[c-1]\nelse:\n for i in range(len(m)):\n c=a.find(m[i])\n m[i]=l[c+1]\nprint(''.join(m))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad9394004d0ba69d9be69fb836e0b055", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "Python 3", "source_code": "verh='qwertyuiop'\ncentr='asdfghjkl;'\nniz='zxcvbnm,./'\nn=input()\na=input()\nnomervstroke=0##\u043d\u0443\u0436\u043d\u044b\u0439\u0418\u043d\u0434\u0435\u043a\u0441\u0412 \u0441\u0442\u0440\u043e\u043a\u0435\nif n==\"R\":##\u0435\u0441\u043b\u0438 \u043d\u0430\u0436\u0430\u043b \u043f\u0440\u0430\u0432\u0435\u0435\n for i in range(len(a)):\n if a[i] in verh:\n nomervstroke=verh.find(a[i])-1\n print(verh[nomervstroke],end='')\n elif a[i] in centr:\n nomervstroke=centr.find(a[i])-1\n print(centr[nomervstroke],end='')\n else:\n nomervstroke=niz.find(a[i])-1\n print(niz[nomervstroke],end='')\nelse:##\u0435\u0441\u043b\u0438 \u043d\u0430\u0436\u0430\u043b \u043b\u0435\u0432\u0435\u0435\n for i in range(len(a)):\n if a[i] in verh:\n nomervstroke=verh.find(a[i])+1\n print(verh[nomervstroke],end='')\n elif a[i] in centr:\n nomervstroke=centr.find(a[i])+1\n print(centr[nomervstroke],end='')\n else:\n nomervstroke=niz.find(a[i])+1\n print(niz[nomervstroke],end='')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "84ed6c7231963635c0808ef24aca36a5", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.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\nif t==False:\n print (\"NO\")\nelse:\n print (\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a68ca71b1bb72909ed8c955fe978c3a4", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.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 ifm[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>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\nif t==False:\n print (\"NO\")\nelse:\n print (\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c410fe0b48e9f7a677ca3a82965265e", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def ok(g):\n\tdx = [[0,0,0,0,0], [0,1,2,3,4], [0,1,2,3,4], [4,3,2,1,0]]\n\tdy = [[0,1,2,3,4], [0,0,0,0,0], [0,1,2,3,4], [0,1,2,3,4]]\n\tfor i in range(10):\n\t\tfor j in in range(10):\n\t\t\tfor b in range(len(dx)):\n\t\t\t\tok = True\n\t\t\t\tfor k in range(5):\n\t\t\t\t\tif not (0<=i+dx[b][k]<=9 and 0<=j+dy[b][k]<=9 and g[i+dx[b][k]][j+dy[b][k]] == 'X'):\n\t\t\t\t\t\tok = False\n\t\t\t\tif ok:\n\t\t\t\t\treturn True\n\n\nf = [[raw_input().rstrip()] for __ in xrange(10)]\n\nfor i in range(10):\n\tfor j in range(10):\n\t\tif f[i][j] == '.':\n\t\t\tf[i][j] = 'X'\n\t\t\tif ok(f):\n\t\t\t\tprint \"YES\"\n\t\t\tf[i][j] = '.'\n\nprint \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cd593d8e3b06b5f6c1894cbb36575290", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def check(i,j,matrix) :\n c = []\n if i+4<10 :\n s= \"\"\n s = matrix[i][j] + matrix[i+1][j] + matrix[i+2][j] + matrix[i+3][j] + matrix[i+4][j]\n c.append(s)\n if j+4<10 :\n t = \"\"\n t = matrix[i][j] + matrix[i+1][j+1] + matrix[i+2][j+2] + matrix[i+3][j+3] + matrix[i+4][j+4]\n c.append(t)\n if j+4<10 :\n s = \"\"\n s = matrix[i][j] + matrix[i][j+1] + matrix[i][j+2] + matrix[i][j+3] + matrix[i][j+4]\n c.append(s)\n for i in range(len(c)):\n if c[i]=='XX.XX' or c[i]=='.XXXX' or c[i]=='X.XXX' or c[i] == 'XXX.X' or c[i]=='XXXX.':\n return True\n break\n else :\n return False\n\nmatrix = []\nfor i in range(10):\n s = raw_input()\n matrix.append(s)\nflag = 0\nfor i in range(10):\n for j in range(10):\n if matrix[i][j]=='X' or matrix[i][j]=='.' :\n if check(i,j,matrix) :\n print \"YES\"\n flag = 1\n break\n if flag == 1 :\n break\nelse :\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcaa1bdb38f8645332e679c6389c1685", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "b = [['.' for c in range(10)] for y in range(10)]\n\nfor x in range (10):\n tmp = raw_input()\n for y in range(10):\n b[x][y] = tmp[y]\n if b[x][y] == '.':\n b[x][y] = 'c'\n\nfor x in range(10):\n for y in range(6):\n tmp = 0\n check= False\n if b[x][y] == 'X':\n for c in range(5):\n if b[x][y+c] in \"Xc\":\n if b[x][y+c] == 'c':\n if(check):\n tmp = 0\n break\n check = True\n tmp+=1\n if tmp == 5:\n print \"YES\"\n exit()\nfor y in range(10):\n for x in range(6):\n tmp = 0\n check= False\n if b[x][y] == 'X':\n for c in range(5):\n if b[x+c][y] in \"Xc\":\n if b[x+c][y] in 'c':\n if(check):\n tmp = 0\n break\n check = True\n tmp+=1\n if tmp == 5:\n print \"YES\"\n exit()\n\nfor y in range(6):\n for x in range(6):\n tmp = 0\n check= False\n if b[x][y] == 'X':\n for c in range(5):\n if b[x+c][y+c] in \"Xc\":\n if b[x+c][y+c] in 'c':\n if(check):\n tmp = 0\n break\n check = True\n tmp+=1\n if tmp == 5:\n print \"YES\"\n exit()\n\nfor y in xrange(4,10):\n for x in range(6):\n tmp = 0\n check= False\n if b[x][y] == 'X':\n for c in range(5):\n if b[x+c][y-c] in \"Xc\":\n if b[x+c][y-c] in 'c':\n if(check):\n tmp = 0\n break\n check = True\n tmp+=1\n \n if tmp == 5:\n print \"YES\"\n exit()\n\n\nprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "46f159ab6a54dfd03b1d3950e4e754ea", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n\tstring a,b;\n\tint h1=0,h2=0,m1=0,m2=0,a1,a2;\n\tbool flag=false;\n\tcin>>a>>b;\n\tfor(int i=0;i\n\nusing namespace std;\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\tint x[n],y[n];\n\tmap mp;\n\tfor(int i = 0;i> x[i];\n\t\tmp.insert({x[i],1});\n\t}\n\tfor(int i = 0;i> y[i];\n\t\tmp.insert({y[i],1});\n\t}\n\n\tint cnt = 0;\n\tfor(int i = 0;i\n\nusing namespace std;\n\nint main(){\n long long int n;\n int div = 0, tot=0;\n\n cin >> n;\n\n for(int i=2;i\n#include \n#include \n#include \n\nvoid \nmain()\n{\n\n int i,qtd=0;\n long long int num;\n\n scanf(\"%lld\",&num);\n\n\n fprintf(stdout,\"1\\n\");\n \n}\n// 1537626298292\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "03637b09968e3dd2094739c3209aa4db", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.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; //LCM of number 2..10;\n int64_t n; std::cin >> n;\n std::cout << (n / D) << std::endl;\n\n return 0;\n}\n// 1537623739917\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f7284e8e841819bae10db44250fa97a6", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "if __name__== '__main__':\n n= int(input())\n\n print(n// 2520):\n \n\n \n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7dd897a41ced5dbc71ae01fd8b765420", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\nimport math\nx=math.power(5,2)\nx=str(x)\nprint(x[-2:]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "227f011c419139956cdfb1adac170b19", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(str(5**n)[-1:-3:1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d20f379c0509f8227d3d822580062b92", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "print(\"25\")/*2017-12-03 03:38:16.775*/", "lang_cluster": "Python", "compilation_error": true, "code_uid": "27ad70105f962c5ee0a1980492048595", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include\n\nstd::cout<<25<\n\nusing namespace std;\n\nint main(){\n cout<<25< i:\n m -= i\n else:\n break\n if i == n1:\n i = 1\n if m < i:\n break\nprint(m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "009c13b96dcdd72b75f39d51a42080c0", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "n,m = map(int,raw_input().split())\nwhile True:\t\n\tfor i in range(1,n+1):\n\t\tif m < i:\n\t\t\tbreak\n\t\telse:\n\t\t\tm -= i\nprint m", "lang_cluster": "Python", "compilation_error": false, "code_uid": "857c27759e9a2292897931d67fcecea9", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "walruses,chips=map(int,input().split())\nwhile True:\n for i in range (walruses):\n if chips>i+1:\n chips=chips-(i+1)\n else:\n break\nprint (chips)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e55a6a731fb95067e280559e5110b3e", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "r s = map(int, input().split())\nprint(r, s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf314f91814dd7b6ac698609061cbebb", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "def func(h,n,mark):\n\tx=2**h\n\tif(h == 1):\n\t\tif(mark == 'L'):\n\t\t\treturn 1+(n<=x/2)\n\t\telse:\n\t\t\treturn 1+(n>x/2)\n\t\t\t# print 'D'\n\tif(n > x/2):\n\t\treturn 1+(2**h-1)+func(h-1,n-(2**(h-1)),'R')\n\telse:\n\t\treturn 1+func(h-1,n,'L')\nh,n=map(int,raw_input().split())\nprint func(h,n,'R')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff2b05381155cb6eb777c1cb724f6f3e", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "h,n = map(int,input().split())\n nn = (2**(h+1))-1\n vis = [False]*(nn+10)\n cn = 1\n cp = False\n nnl = (2**h)-1\n n += nnl\n cnt = 0\n while True:\n if cn > nnl or (vis[cn*2] and vis[cn*2+1]):\n cn //= 2\n elif cp == False:\n if not vis[cn*2]:\n cn *= 2\n cp = True\n else:\n cn = 2*cn + 1\n elif cp == True:\n if not vis[2*cn+1]:\n cn = cn*2+1\n cp = False\n else:\n cn *= 2\n if cn == n:\n break\n if not vis[cn]:\n cnt += 1\n vis[cn] = True\n print(cnt)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bb9fb92d23b369baacd1d904d6820035", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n#define For(i,a,b) for(int i=a;i>h>>n;\n ans=0;\n n-=1;\n bool lef=true;\n while(h>0)\n {\n if((lef&& (n<(1ll<<(h-1))) )||( (!lef)&&n>=(1ll<<(h-1)) ) )\n {\n ans++;\n //if((~lef)&&n>=(1ll<<(h-1))) cout<<\"ASDFASDF\";\n //cout<= len(BT)):\n\t\t\tc = (c-1)/2\n\t\telif(BT[2*c+1] == 'E'):\n\t\t\tbreak\n\t\telif(BT[2*c+1] == 0):\n\t\t\tc = 2*c+1\n\t\t\tBT[c] = 1\n\t\telse:\n\t\t\ts += 1\n\t\tm = 'R'\n\telif(m == 'R'):\n\t\tif(2*c+2 >= len(BT)):\n\t\t\tc = (c-1)/2\n\t\telif(BT[2*c+2] == 'E'):\n\t\t\tbreak\n\t\telif(BT[2*c+2] == 0):\n\t\t\tc = 2*c+2\n\t\t\tBT[c] = 1\n\t\telse:\n\t\t\ts += 1\n\t\tm = 'L'\nvisited = 0\nfor i in BT:\n\tif(i == 1):\n\t\tvisited += 1\nprint visited+1\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f63a771e26f2490e354abb7a85fabef9", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "h,n=map(int,input().split(\" \"))\nres=0\ns=0\nwhile(h!=0):\n res+=1\n if s^(n>(1<<(h-1))):\n res+=1<<(h) - 1\n else:\n s^=1\n if n>1<<(h-1):\n n-=1<<(h-1)\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c42df1b7ad34fa70f23e562bbca9f351", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nif(a==b or a=b+1 or a+1==b):\n print('YES')\nelse:\n print('NO')\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77c100b193bbd3a40d44903b39ce9291", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b = [int(x) for x in input().split()] \nif abs(a-b) <= 1:\n print(\u2018YES\u2019)\nelse:\n print(\u2018NO\u2019)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac1c4ce81f2c26df49de349e484ceb7d", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nc=abs(a-b)\nif c==1 || c==0 :\n print(\"YES\")\nelse :\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38e2b6ab2cff136a21c369e4e838654d", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\na, b = [int(x) for x in input().split()]\nif a=b:\n print(\"YES\")\n sys.exit()\nif a>b:\n if (b-a)%2==1:\n print(\"YES\")\n else: \n print(\"NO\")\nelse:\n if (b-a)%2==1:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "25f4878bd1342706507d0daadf40fb26", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\na, b = [int(x) for x in input().split()]\nif a=b:\n print(\"YES\")\n sys.exit()\nif a>b:\n if a-b==1:\n print(\"YES\")\n else: \n print(\"NO\")\nelse:\n if b-a==1:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ba285d76e757ffad35d0c4ff76d39e46", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n n = int(input())\n\nans = (3 ** (n*3) - 7 ** n) % (10 ** 9 + 7)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "404a56909f13ff817f1b32379bb44cd7", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "\ufeffn=input()\nn=int(n)\nprint(3**(3*n) -7**n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b448afafcd5be3a76784ed6d325ac29", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(3**3n - 7**n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1ac3bea453a670c0967e4f97215624e8", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\nunsigned long long fact(long long n)\n{\n if(n==1) return 1;\n else return n*fact(n-1);\n}\nunsigned long long puissance (long long n,long long p)\n{\n unsigned long long i,s=1;\n for(i=0;i>n;\n d=(puissance(10,9)+7);\n x=(puissance(3,3*n)-puissance(7,n))%d;\n cout << x;\n return 0;\n\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff8e7ff5fc5e598472fc01676ef147f0", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "#define LIN cout << __LINE__ << endl;\n#define INF 0x3f3f3f3f\n#include \nusing namespace std;\n\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) x.begin(), x.end()\n#define sz(x) (int)(x).size()\ntypedef unsigned long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\nconst ll MOD = 1000000007;\n\nll powmod(ll a, ll b){\n a %= MOD;\n ll res = 1 % MOD;\n while (b){\n if (b&1)\n res = (res * a) % MOD;\n a = a*a % MOD;\n b >>= 1;\n }\n return res % MOD;\n}\n\nint main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n \n ll n;\n cin >> n;\n\n cout << (powmod(27, n)%MOD - powmod(7, n)%MOD) % MOD << endl;\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4dae628a64b577dce3edb012c479bda0", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input()); L = [int(x) for x in input().split()]\np = len([x for i, x in enumerate(L) if x > 0])\nm = len([x for i, x in enumerate(L) if x < 0])\nif p >= (n+1)//2: print(1)\nelif m >= (n+1)//2: print(-1)\nelse print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73c87188fbef67f8483139ef52c54e07", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(map(int,input().split()))\nn=(n+1)//2\nx=0\nfor i in a:if i>0:x+=1\nif x>=n:print(1)\nelse print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0aaf116ec74d3db4179b100ca30c0d46", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nc=0;d=0;e=0\nif n==1 and l[0]>0:\n\tprint(\"2\")\n\texit()\nelif n==1 and l[0]<0:\n\tprint(\"-2\")\n\texit()\nelif n==1 and l[0]==0:\n\tprint(\"0\")\n\texit()\nelse:\n\tfor i in range(n):\n\t\tif l[i]>0:\n\t\t\tc+=1\n\t\telif l[i]<0:\n\t\t\td+=1\n\t\telif l[i]==0:\n\t\t\te+=1\nif c==d==e and c+e+d=n:\n\tprint(\"0\")\n\texit()\nelif c>=n//2 and c>=e+d:\n\tprint(\"2\")\nelif d>=n//2 and d>=e+c:\n\tprint(\"-2\")\nelse:\n\tprint(\"0\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae5c377fe07e4e86d8d58b16c88e06a1", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n n = int(input())\na = [int(x) for x in input().split()]\nkn = 0\nfor i in a:\n\tif i == 0:\n\t\tkn += 1\nif kn > n // 2:\n\tprint(0)\nelse:\n\tko = 0\n\tkp = 0\n\tfor i in a:\n\t\tif i < 0:\n\t\t\tko +=1\n\t\telse:\n\t\t\tif i != 0:\n\t\t\t\tkp += 1\n\tif ko =< n // 2 and kp =< n // 2:\n\t print(0)\n\t exit()\n\tif ko == kp:\n\t\tprint(1)\n\t\texit()\n\tif ko > kp:\n\t\tprint(-1)\n\telse:\n\t\tprint(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a59cb4f243625d1472e4c1676789e9c5", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x=int(input())\n#z=\"-322 -198 -448 -249 -935 614 67 -679 -616 430 -71 818 -595 -22 559 -575 -710 50 -542 -144 -977 672 -826 -927 457 518 603 -287 689 -45 -770 208 360 -498 -884 -161 -831 -793 -991 -102 -706 338 298 -897 236 567 -22 577 -77 -481 376 -152 861 559 190 -662 432 -880 -839 737 857 -614 -670 -423 -320 -451 -733 -304 822 -316 52 46 -438 -427 601 -885 -644 518 830 -517 719 643 216 45 -15 382 411 -424 -649 286 -265 -49 704 661 -2 -992 67 -118 299 -420\"\ns=[int((int(n))/(abs(int(n))-10**-5)) for n in input().split()]\n#print(s)\n#print(s.count(-1),s.count(1))\nif s.count(0)>int(x/2):\n#\tprint(s.count(0))\n\tprint(0)\nelif s.count(1)>=int(x/2):\n\tprint(1,\"m)\nelif s.count(1)>s.count(-1):\n\tprint(1)\nelse:\n\tprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b59356ab4f791c4e6cd14cf117549f42", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "s1 = input().strip()\ns2 = input().strip()\nn=len(s1)\nc=0\ni=0\nwhile i\n#define MOD 1000000007\n#define MAX 100003\nusing namespace std;\nusing ll = long double;\n\nint main(){\n\tint t;\n\tcin>>t;\n\twhile(t--){\n\t\tint n ;\n\t\tcin>>n;\n\t\tll ar[n];\n\t\tfor( int i = 0; i>ar[i];\n\t\t}\n\t\tsort(ar, ar+n );\n\t\tfor(int i = n-1; i>0; i--){\n\t\t\tar[i-1] = ( ar[i] + ar[i-1])/2.0;\n\t\t}\n\t\tcout<= 3 : \n\t\tres = res + 1\n\t\tnow = now - 3\n\telif now <= 2 && i != 2 :\n\t\tnow = i\n\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "837d2eb88b430c678d735e8d13a5224b", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def HOD(a, b):\n if a * b == 0:\n return a + b\n if a > b:\n a, b = b, a\n return HOD(a, b % a)\n\ndef main():\n n = int(input())\n a = int(input())\n b = int(input())\n if n % HOD(a, b):\n print('NO')\n else:\n f = 0\n if a < b:\n a, b = b, a\n f = 1\n for i in range(1 + n // a):\n if (n - i * a) % b == 0:\n print('YES')\n if f:\n print((n - i * a) // b, i)\n else:\n print(i, (n - i * a) // b)\n return\n print('NO')\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d782ae91a5596eb5ee21874f27c6835", "src_uid": "b031daf3b980e03218167f40f39e7b01", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def solution (a, b, n):\n\n # traverse for all possible values\n i = 0\n _atual = i * a\n while _atual <= n:\n _atual = i * a\n\n # check if it is satisfying\n # the equation\n _res = n - (_atual)\n if _res % b == 0:\n if i < 0 or int(_res/b) < 0:\n print \"NO\"\n exit()\n print \"YES\"\n print i, int(_res / b)\n return 0\n i = i + 1\n print \"NO\"\n\n\n\nn = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\n\nif a==1 or b==1:\n if a 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": "2b81364af8e92a35d832ddb1439bd873", "src_uid": "b031daf3b980e03218167f40f39e7b01", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import sys\nimport math\n\ndef factors(x):\n i = 1\n n = min(x/2, math.sqrt(x))\n while i <= n:\n if x % i == 0:\n yield i\n i = i + 1\n yield x\n\n(n, x) = map(int, sys.stdin.readline().split())\n\nif n*n < x:\n print 0\n exit()\n\noccurrences = [(row, x/row) for row in filter(lambda f: f <= n, factors(x))\n if x / row <= n]\n\nprint(len(occurrences))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "75bc9411121e235b7eae53baa0772cc2", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split())\ncount=0\nfor i in range(1,n+1):\n for j in range(1,n+1):\n \n if j*i==k:\n count+=1\nprint(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf38ce2518920bfb651153eea208d09d", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \n\nint main() {\n int count = 0;\n int n, find, result;\n int i, j;\n scanf(\"%d %d\", &n, &find);\n for(i = 1; i <= n; i++){\n for(j = 1; j <= n; j++){\n if(i > find || j > find) {\n break;\n }\n result = i*j;\n if(result == find){\n count++;\n break;\n }\n if(result > find){\n break;\n }\n }\n }\n printf(\"%d\\n\", count);\n}\n// 1541254992279\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f9c5c45053afb044d8dc0fe9848f3bd", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \n\nint main() {\n int count = 0;\n int n, find, result;\n int i, j;\n scanf(\"%d %d\", &n, &find);\n for(i = 1; i <= n; i++){\n for(j = 1; j <= n; j++){\n if(i > find || j > find) {\n break;\n }\n result = i*j;\n if(result == find){\n count++;\n break;\n }\n if(result > find){\n break;\n }\n }\n }\n printf(\"%d\\n\", count);\n}\n/* 1541254918246 */\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0abb17698df703a5b9f0f90b08320601", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "n, x = [int(i) for i in raw_input().split()]\ntotal = 0\nfor i in xrange(1, int(x**.5)+1):\n f = x%i\n if x%i == 0 and i <=n and x/i <= n:\n total += 1\n if x/float(i) == i:\n total -= .5\nreturn int(2*total)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d107381df0429c069192c90570f8114b", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\ntypedef pair pii;\ntypedef long long ll;\n\nint main() {\n ios_base::sync_with_stdio(0); cin.tie(NULL);\n\n int n, m, k;\n cin >> n >> m >> k;\n\n vector a(n);\n for(int i = 0; i < n; ++i) {\n cin >> a[i].first;\n a[i].second = i;\n }\n\n sort(a.begin(), a.end(), greater());\n\n vector ind(m*k);\n ll sumBeauty = 0;\n for(int i = 0; i < m*k; ++i) {\n sumBeauty += a[i].first;\n ind[i] = a[i].second;\n }\n\n sort(ind.begin(), ind.end());\n\n vector division(k-1);\n for(int i = 0; i < k-1; ++i)\n division[i] = ind[(i+1)*m - 1];\n\n cout << sumBeauty << endl;\n for(int p: division)\n cout << p + 1 << \" \";\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6bf17dcf9ad2d72b24279afc8477a3a7", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nll n, b;\nll ans=0;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin>>n>>b;\n for (ll i=b; i<=n; i*=b)\n {\n ans+=n/i;\n }\n cout<\n\nusing namespace std;\ntypedef long long LL;\ntypedef pair P;\ntypedef pair,pair> PP;\n#define _x first\n#define _y second\n\n\nLL quick_pow(LL x,LL n,LL m){\n\tLL res = 1;\n\twhile(n > 0){\n\t\tif(n & 1)\tres = res * x % m;\n\t\tx = x * x % m;\n\t\tn >>= 1;//\u76f8\u5f53\u4e8en=n/2.\u8be6\u60c5\u8bf7\u53c2\u8003\u4f4d\u79fb\u8fd0\u7b97\u7b26\u3002\n\t}\n\treturn res;\n}\n\nbool Less(const PP& s1, const PP& s2)\n{\n if(s1.first.first==s2.first.first) return s1.first.second > s2.first.second;\n return s1.first.first < s2.first.first; //\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\n}\n\nstruct hashfunc {\n\ttemplate\n\tsize_t operator()(const pair &i) const {\n\t\treturn hash()(i.first) ^ hash()(i.second);\n\t}\n};\n\nunordered_map, LL, hashfunc> umii;\n\n\nint main()\n{\n freopen(\"input\", \"r\", stdin);\n // freopen(\"output\", \"w\", stdout);\n // ios_base::sync_with_stdio(false);\n // cin.tie(NULL);\n LL n,m,k;\n cin>>n>>m>>k;\n vector vi,temp;\n for(LL i=0;i>t;\n vi.push_back(t);\n }\n temp = vi;\n LL ans=0;\n sort(temp.begin(),temp.end());\n reverse(temp.begin(),temp.end());\n unordered_map umii;\n for(LL i=0;i\nusing namespace std;\n#define int long long\n\n\nint32_t main()\n{\n int n, b, ans;\n cin >> n >> b;\n vector div;\n vector cnt;\n int b1 = b;\n for (int i = 2; i * i <= b; i++) {\n if (b1 % i == 0) {\n div.push_back(i);\n cnt.push_back(0);\n while (b1 % i == 0) {\n cnt[div.size() - 1]++;\n b1 /= i;\n }\n }\n }\n if (b1 != 1) {\n div.push_back(b1);\n cnt.push_back(1);\n }\n for (int i = 0; i < div.size(); i++) {\n int curr = div[i];\n int cnt1 = cnt[i];\n int ans1 = 0;\n for (int k = 1; curr <= n; k++) {\n ans1 += n / curr;\n if (curr <= (n + div[i] - 1) / div[i]) break;\n curr *= div[i];\n }\n if (i == 0) ans = ans1 / cnt1;\n else ans = min(ans, ans1 / cnt1);\n }\n cout << ans << endl;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6847886c1b78c5aa14c81f933b21a098", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "#include \n\nusing namespace std;\n \n#define ll unsigned long long int\n \n#define pii pair\n#define pll pair\n#define mp make_pair\n#define pb push_back\n#define fi first\n#define se second\n#define _cin ios_base::sync_with_stdio(0); cin.tie(0);\n#define all(x) (x).begin(), (x).end()\n \n#define INF 2147483647\n#define MAXN 200004\n#define endl \"\\n\"\n\nll mod = 1000000007;\n\nvector v;\n\nvoid factorize(ll n) \n{ \n int count = 0;\n while (!(n % 2)) { \n n >>= 1; \n count++; \n } \n\tif(count > 0){\n\t\tv.pb(mp(2, count));\n\t}\n\n for (ll i = 3; i <= sqrt(n); i += 2) { \n count = 0; \n while (n % i == 0) { \n count++; \n n = n / i; \n }\n\t\tif(count > 0){\n\t\t\tv.pb(mp(i, count));\n\t\t}\n } \n if (n > 2){\n\t\tv.pb(mp(n,1));\n\t}\n}\n\nint main()\n{\n\t_cin;\n\tll n, b, m;\n\tcin >> n >> b;\n\tfactorize(b);\n\tll sz = v.size(), denum, tmp, num, ans = 0, ct;\n\tfor(int i=0; i\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 \n#include \n#include \n#include \n\n\n#define int long long int\n\n\n#define DEBUG\n#define NULL 0\n\n#include \n#include \nusing namespace std;\n\n\nvector indexOf(char* str, char* pattern)\n{\n\tvector v;\n\tint slen = strlen(str);\n\tint patlen = strlen(pattern);\n\tfor(int i = 0; i 0) {\n\t\t\t\tindex = dp[index - 1];\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn dp;\n}\n\n\n\nostream_iterator oi(cout, \" \");\n\nclass Pair;\n\n\nclass Item\n{\n\tfriend ostream &operator<< ( ostream & out, const Pair & c );\n\tfriend istream &operator>> ( istream & out, Pair & c );\n\npublic:\n\tItem(string des) {\n\t\tdescription = des;\n\t}\n\n\tint keyF() {\n\t\tkey = description.length();\n\t\treturn key;\n\t}\n\n\tstring toString() {\n\t\treturn description;\n\t}\n\n\tint key;\n\n\tstring description;\n};\n\nostream & operator<<( ostream & out, const Item & c )\n{\n\tout << c.description;\n\treturn out;\n}\n\nistream & operator>>( istream & in, Item & c )\n{\n\tin>>c.description;\n\treturn in;\n}\n\n\nostream & operator<<( ostream & out, pair& c )\n{\n\tout << \"<\" <\" << endl;\n\treturn out;\n}\n\nistream & operator>>( istream & in, pair& c )\n{\n\tin>>c.first;\n\tin>>c.second;\n\treturn in;\n}\n\n\nvoid print()\n{\n\tstd::cout << endl;\n}\n\n\ntemplate\nvoid print(A value)\n{\n\tstd::cout << value;\n}\n\ntemplate\nvoid print(A value1, B value2)\n{\n\tcout << value1 << \" \" << value2;\n}\n\ntemplate\nvoid print(A value1, B value2, C value3)\n{\n\tcout << value1 << \" \" << value2 << \" \" << value3;\n}\n\ntemplate\nvoid print(A value1, B value2, C value3, D value4)\n{\n\tcout << value1 << \" \" << value2 << \" \" << value3 << \" \" << value4;\n}\n\n\n\ntemplate\nE read()\n{\n\tE value;\n\tcin >> value;\n\treturn value;\n}\n\nstring readString()\n{\n\tchar* s = new char[1000];\n\tfgets(s, 1000, stdin);\n\treturn string(s);\n}\n\ntemplate\nvoid println(A value)\n{\n\tstd::cout << value << endl;\n}\n\ntemplate\nvoid println(A value1, B value2)\n{\n\tcout << value1 << \" \" << value2 << endl;\n}\n\ntemplate\nvoid println(A value1, B value2, C value3)\n{\n\tcout << value1 << \" \" << value2 << \" \" << value3 << endl;\n}\n\ntemplate\nvoid println(A value1, B value2, C value3, D value4)\n{\n\tcout << value1 << \" \" << value2 << \" \" << value3 << \" \" << value4 << endl;\n}\n\n\n\nint randomint(int min, int max)\n{\n\tif(max == min) {\n\t\treturn max;\n\t}\n\treturn rand()%(max-min+1)+min;\n}\n\n\nclass Pair\n{\n\tfriend ostream &operator<< ( ostream & out, const Pair & c );\n\tfriend istream &operator>> ( istream & out, Pair & c );\n\npublic:\n\tPair(Item* p);\n\tint key;\n\tItem* value;\n};\n\nPair::Pair(Item* b)\n{\n\tkey = b->key;\n\tvalue = b;\n}\n\nostream & operator<<( ostream & out, const Pair& c )\n{\n\tout<< \"(\" << c.value->key << \" -> \" << (c.value->toString()) << \")\";\n\treturn out;\n}\n\n\ntemplate\nclass Array\n{\npublic:\n\tint size;\n\tArray(int _capacity) {\n\t\tcapacity = _capacity;\n\t\tarray = new E[capacity];\n\t\tsize = capacity;\n\t\tfor(int i =0; i& vect) {\n\t\tint _size = vect.size();\n\t\tcapacity = _size*2;\n\t\tsize = _size;\n\t\tarray = new E[capacity];\n\t\tfor(int i =0; i equalRange(E& item);\n\tbool binarySearch(E& item);\n\tE* begin();\n\tE* end();\n\tvector toVector();\n\tvoid toString();\n\tE& operator[](int i);\n\tE& index(int i);\n\tE* array;\n\tvoid null(void) {\n\t\tfor(int i =0; i\nvoid Array::ensureCapacity(int cap)\n{\n\tcapacity = capacity*2;\n\tE* newArray = new E[capacity];\n\tmemcpy(newArray, array, sizeof(E)*size);\n\tdelete[] array;\n\tarray = newArray;\n}\n\ntemplate \nvoid Array::toString()\n{\n\tint i = 0;\n\tE* begin = array;\n\tcout << \"[\";\n\twhile(i\nvoid Array::add(E item)\n{\n\tif(capacity\nE* Array::begin()\n{\n\treturn array;\n}\n\ntemplate \nE* Array::end()\n{\n\treturn array + size;\n}\n\ntemplate \nint Array::leftBinarySearch(E& item)\n{\n\treturn lower_bound(array, array+size, item)-array;\n}\n\n\ntemplate \nint Array::rightBinarySearch(E& item)\n{\n\treturn upper_bound(array, array+size, item)-array;\n}\n\ntemplate \npair Array::equalRange(E& item)\n{\n\tpair p(0, 0);\n\tp = equal_range(array, array + size, item);\n\treturn make_pair(p.first - array, p.second - array);\n}\n\n\ntemplate \nbool Array::binarySearch(E& item)\n{\n\treturn binary_search(array, array + size, item);\n}\n\ntemplate \nvector Array::toVector()\n{\n\tvector res = vector(size);\n\tfor(int i =0; i\nostream & operator<<( ostream & out, Array& c )\n{\n\tfor(int i = 0; i >& c )\n{\n\tfor(int i = 0; i\nistream & operator>>( istream & in, Array& c )\n{\n\tfor(int i = 0; i> c[i];\n\t}\n\treturn in;\n}\n\nostream & operator<<( ostream & out, map& c )\n{\n\tmap::iterator it = c.begin();\n\twhile(it!=c.end()) {\n\t\tpair entry = *it;\n\t\tout << entry;\n\t\tit++;\n\t}\n\treturn out;\n}\n\n\ntemplate \nE& Array::operator[] (int i)\n{\n#ifdef DEBUG\n\tif(i=0) {\n\t\treturn array[i];\n\t} else {\n\t\tcout << \"Array index out of bounds, index is \" << i << \", size is \" << size << endl;\n\t\tcout << \"Array is \" << endl;\n\t\ttoString();\n\t\tassert(0);\n\t}\n#endif\n\n#ifndef DEBUG\n\treturn array[i]\n#endif\n}\n\n template\nclass Matrix\n{\npublic:\n\tint rows;\n\tint columns;\n\tArray array;\n\n\tE& get(int x, int y);\n\tvoid set(int x, int y, E& value);\n\tE& operator()(int x, int y);\n\tMatrix transpose();\n\n\tpair getRow(int y);\n\n\tMatrix(int c, int r) {\n\t\trows = r;\n\t\tcolumns = c;\n\t\tarray = Array(rows*columns);\n\t\tarray.null();\n\t}\n\n\tvoid swap(Matrix& other) {\n\t\tstd::swap(array, other.array);\n\t\tstd::swap(rows, other.rows);\n\t\tstd::swap(columns, other.columns);\n\t}\n\n\tMatrix(int _columns, int _rows, int minBound, int maxBound) {\n\t\trows = _rows;\n\t\tcolumns = _columns;\n\t\tint size = _rows*_columns;\n\t\tarray = Array(minBound, maxBound, size);\n\t}\n\nprivate:\n};\n\ntemplate\nMatrix Matrix::transpose()\n{\n\tMatrix b(rows, columns);\n\tfor(int x = 0; x\nE& Matrix::operator()(int x, int y)\n{\n#ifdef DEBUG\n\tif(x>=columns || x<0) {\n\t\tcout << \"x must be in range [0; \" << columns - 1 << \"], but it is \" << x << endl;\n\t\tassert(0);\n\t}\n\tif(y>=rows || y<0) {\n\t\tcout << \"y must be in range [0; \" << rows - 1 << \"], but it is \" << y << endl;\n\t\tassert(0);\n\t}\n\treturn array.array[x+y*columns];\n#endif\n#ifndef DEBUG\n\treturn array.array[x+y*columns];\n#endif\n}\n\n\n\ntemplate\nistream & operator>>( istream & in, Matrix& c )\n{\n\tfor(int y = 0; y> c(x, y);\n\t\t}\n\t}\n\treturn in;\n}\n\n\ntemplate\npair Matrix::getRow(int y)\n{\n\tE* f = array.array + y*columns;\n\tE* s = array.array + (y+1)*columns;\n\tpair p(f, s);\n\treturn p;\n}\n\n\ntemplate\nostream & operator<<( ostream & out, Matrix& c )\n{\n\tfor(size_t y = 0; y > factorize(int n)\n{\n\tArray > res;\n\tfor(int i = 2; i comp = make_pair(i, 1);\n\t\t\tn/=i;\n\t\t\twhile(n%i == 0) {\n\t\t\t\tcomp.second++;\n\t\t\t\tn/=i;\n\t\t\t}\n\t\t\tres.add(comp);\n\t\t}\n\t}\n\n\tif(n>1) {\n\t\tres.add(make_pair(n, 1));\n\t}\n\treturn res;\n}\n\nint euler(int n)\n{\n\tArray > fact = factorize(n);\n\tint res = 1;\n\tfor(unsigned int i = 0; i enumerateDivisors(int n)\n{\n\tArray > divs = factorize(n);\n\tvector totals = vector(divs.size+1);\n\ttotals[0] = 1;\n\tfor(unsigned int i = 1; i < divs.size+1; i++) {\n\t\ttotals[i]=totals[i-1]*(divs[i-1].second+1);\n\t}\n\n\tArray res;\n\tfor(int i = 0; i values = vector(divs.size);\n\t\tfor(unsigned int j = 0; j>( istream& in, Pair& c )\n{\n\tin >> c.value->description;\n\tc.value->key = c.value->keyF();\n\treturn in;\n}\n\n\nvoid reverse(char *str)\n{\n\tchar temp;\n\tsize_t len = strlen(str) - 1;\n\tsize_t i;\n\tsize_t k = len;\n\n\tfor(i = 0; i < len; i++) {\n\t\ttemp = str[k];\n\t\tstr[k] = str[i];\n\t\tstr[i] = temp;\n\t\tk--;\n\t\tif(k == (len / 2)) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nmap count(Array a)\n{\n\tmap res;\n\tfor(int i = 0; i 0);\n\tif (sign < 0)\n\t\ts[i++] = '-';\n\ts[i] = '\\0';\n\treverse(s);\n}\n\nint* vectorToArray(vector v)\n{\n\tint* a = new int[v.size()];\n\tfor(unsigned int i = 0; i params, int left, int right, bool (*f)(Array params, int v))\n{\n\tif(f(params, left) && !f(params, left-1)) {\n\t\treturn left;\n\t}\n\n\tif(f(params, right) && !f(params, right+1)) {\n\t\treturn right;\n\t}\n\n\tint middle = (left+right)/2;\n\tint g = f(params, middle);\n\tif(g) {\n\t\treturn booleanAnswerBinarySearch(params, left, middle, f);\n\t} else {\n\t\treturn booleanAnswerBinarySearch(params, middle+1, right, f);\n\t}\n}\n\nArray< Array > enumerarePermutations(int n)\n{\n\tint fac = fact(n);\n\tArray v;\n\tfor(int i = 0; i > res;\n\tfor(int i = 0; i c(n);\n\t\tcopy(v.array, v.array + v.size, c.array);\n\t\tres.add(c);\n\t\tnext_permutation(v.array, v.array + v.size);\n\t}\n\tArray c(n);\n\tcopy(v.array, v.array + v.size, c.array);\n\tres.add(c);\n\treturn res;\n}\n\nArray< Array > enumerarePermutations(Array array)\n{\n\tint n = array.size;\n\tint fac = fact(n);\n\tArray v;\n\tfor(int i = 0; i > res;\n\tfor(int i = 0; i c(n);\n\t\tcopy(v.array, v.array + v.size, c.array);\n\t\tres.add(c);\n\t\tnext_permutation(v.array, v.array + v.size);\n\t}\n\tArray c(n);\n\tcopy(v.array, v.array + v.size, c.array);\n\tres.add(c);\n\treturn res;\n}\n\nArray< Array > enumerareTuples(int n, int k)\n{\n\tint q = bpow(k, n);\n\tArray< Array > res(q);\n\tfor(int i = 0; i tuple(n);\n\t\tfor(int j = 0; j > enumerareTuples(int n, Array array)\n{\n\tint k = array.size;\n\tint q = bpow(k, n);\n\tArray< Array > res(q);\n\tfor(int i = 0; i tuple(n);\n\t\tfor(int j = 0; j sieve(int bound)\n{\n\tbool* array = new bool[bound+1]();\n\tfor(int i = 2; i*i<=bound; i++) {\n\t\tif(!array[i]) {\n\t\t\tfor(int j = i+i; j<=bound; j+=i) {\n\t\t\t\tarray[j] = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tArray res;\n\tfor(int i = 2; i<=bound; i++) {\n\t\tif(!array[i]) {\n\t\t\tres.add(i);\n\t\t}\n\t}\n\treturn res;\n}\n\nint f(int k)\n{\n\treturn k&(k+1);\n}\n\nstring alignLeft(string a, int length, char ch)\n{\n\tif(a.length() < length) {\n\t\ta = string(length - a.length(), ch) + a;\n\t}\n\treturn a;\n}\n\nstring decToRadix(int n, int radix)\n{\n\tstring res(\"\");\n\tif(n == 0) {\n\t\tres.push_back('0');\n\t\treturn res;\n\t}\n\twhile(n) {\n\t\tint digit = n%radix;\n\t\tres.push_back((char)(digit + '0'));\n\t\tn/=radix;\n\t}\n\treverse(res.begin(), res.end());\n\treturn res;\n}\n\nint radixToDec(string s, int radix)\n{\n\tint res = 0;\n\treverse(s.begin(), s.end());\n\tfor(int i = 0; i tree;\n\tArray array;\n\n\tBIT(F func, Array source) {\n\t\tArray arr(source.size);\n\t\tcopy(source.begin(), source.end(), arr.begin());\n\t\tarray = arr;\n\t\tf = func;\n\n\t\tArray tr(source.size);\n\t\ttree = tr;\n\n\t\tfor(int i = 0; i & st, char op)\n{\n\tint r = st.back();\n\tst.pop_back();\n\tint l = st.back();\n\tst.pop_back();\n\tswitch (op) {\n\tcase '+':\n\t\tst.push_back (l + r);\n\t\tbreak;\n\tcase '-':\n\t\tst.push_back (l - r);\n\t\tbreak;\n\tcase '*':\n\t\tst.push_back (l * r);\n\t\tbreak;\n\tcase '/':\n\t\tst.push_back (l / r);\n\t\tbreak;\n\tcase '%':\n\t\tst.push_back (l % r);\n\t\tbreak;\n\t}\n}\n\nint calc (string & s)\n{\n\tvector st;\n\tvector op;\n\tfor (size_t i=0; i= priority(s[i]))\n\t\t\t\t\tprocess_op (st, op.back()), op.pop_back();\n\t\t\t\top.push_back (curop);\n\t\t\t} else {\n\t\t\t\tstring operand;\n\n\n\t\t\t\twhile (i < s.length() && isalnum (s[i])) {\n\t\t\t\t\toperand += s[i++];\n\t\t\t\t}\n\n\t\t\t\t--i;\n\t\t\t\tif (isdigit (operand[0]))\n\t\t\t\t\tst.push_back (atoi (operand.c_str()));\n\t\t\t}\n\twhile (!op.empty())\n\t\tprocess_op (st, op.back()), op.pop_back();\n\treturn st.back();\n}\n\n\n#undef int\nint main(void)\n{\n#define int long long int\n\n\tint n;\n\tcin >> n;\n\n\tchar* s = new char[1000];\n\tcin >> s;\n\n\tint count = 0;\n\tfor(int i = 0; i=0; j--) {\n\t\t\t\ts[j] = '0';\n\t\t\t\tcount++;\n\t\t\t}\n\n\t\t\tprintln(count);\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\n\n\t}\n\n\tprintln(n);\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52dca978437579979d788eebc38451e4", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def bit_diff(n, k):\n a = []\n b = []\n while n > 0:\n a.append(n % 2)\n n //= 2\n while k > 0:\n b.append(k % 2)\n k //= 2\n if len(a) < len(b):\n a, b = b, a\n if len(a) != len(b):\n b.append(0)\n ans = 0\n for i in range(len(a)):\n ans += a[i] != b[i]\n return ans\nn = input()\nval = input()[::-1]\nkl = int(val, 2)\nprint (abs(bit_diff(kl, kl + 1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1be78dab95f62edc0f44d1b1505e6be7", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=list(input())\nif \"0\" in s:\n print(s.index(\"0\")+)\nelse:\n print(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "86331f44d6e242d4e81e4b2e69da59c6", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def bit_count(n):\n ans = 0\n while n > 0:\n ans += n % 2\n n //= 2\n return ans\nn = input()\nval = input()\nkl = int(val, 2)\nprint (abs(bit_count(kl) - bit_count(kl + 1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7d1a6220eb0e63c505614ca25b6246d5", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n=input()\nfirst = map(int, list(raw_input()))\n\ncount=0\nplus=1\nfor x in range(0,len(first)):\n second[x]=(first[x]+plus)%2\n plus=(first[x]+plus)%2\nfor y in range(0,len(first)):\n if first[y]!=second[y]:\n count+=1\nprint count", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d9803aae774680e88e358894bf5808b8", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\nint li[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};\n\nint count(int n){\n int ret = 0;\n while (n > 0) {\n ret += li[n%10];\n n /= 10;\n }\n\n return ret;\n}\n\nint main() {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n\n int cnt = 0;\n for (int i = a; i <= b; i++) {\n cnt += count(i);\n }\n\n printf(\"%d\\n\", cnt);\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90fe2693c020a7bf359d4283591e2d67", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]\na, b = map(int, raw_input().split())\nres = 0;\nfor i in range(a, b+1):\n while i > 0:\n res += l[i%10]\n i /= 10\nprint res", "lang_cluster": "Python", "compilation_error": true, "code_uid": "305685af7aa5114d64fb2443f3f9cda2", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k = input().split()\nd = {'0':6, '1':2, '2':5, '3':5, '4':4, '5':5, '6':6, '7':3, '8':7, '9':6}\notv=0\nh=0\nif (n == '1' and k == '1000000'):\n print('28733372')\nelif (n=='2' and k=='1000000'):\n print('28733370')\nelif (n=='1' and k=='999999')\n print('28733334')\nelse:\n for i in range(int(n), int(k)+1):\n j= str(i)\n tmp=0\n if j not in d:\n if len(j)>=2:\n if j[0:len(j)-1] in d:\n tmp+=d[j[0:len(j)-1]]\n tmp+=d[j[len(j)-1]]\n else:\n while h0 and (a[4]*a=[3])>0 and a[5]>=a[7]):\n count+=1\n b-=1\n a[4]-=1\n a[5]-=a[7]\nprint(count//a[0])\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aae56084eaa39399393010fe69421c7d", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n, k, l, c, d, p, nl, np = [int(i) for i in input().split()]\nprint(min((k*l)//(n*nl), c*d//n, p//(n*np))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2f41963655d69e70ae397e125e588502", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,k,l,c,d,p,nl,np=map(int,input().split())\nprint(min(((k*l)//nl),p//np,c*d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e6c799404afc0febd0a166ba876dff9", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nmp=''\ndef rec(s):\n global mp\n if len(s) == 2:\n if s==s[::-1]:\n mp = max(mp, s)\n mp = max(mp, max(s[1], s[0]))\n return\n for i in range(1, len(s)+1):\n rec(s[:i-1]+s[i:])\n if s==s[::-1]:\n mp = max(mp, s)\nrec(n)\nprint(mp)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3262301871b40086fa70eb2c1024656c", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nmp=''\ndef rec(s):\n global mp\n if s == '':\n return\n for i in range(1, len(s)):\n rec(s[:i-1]+s[i:])\n if s==s[::-1]:\n mp = max(mp, s)\nrec(n)\nprint(mp)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7eec6743f278abce146c367c79169722", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nlst=[]\nfrom itertools import permutations\nfor i in range(1,len(n)):\n c=permutations(n,i)\n for j in c:\n if(j==j[::-1]):\n lst.append(j)\nlst.sort()\ns=''\nfor i in lst[-1]:\n s=s+i\nprint(s)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f8cb47e98548512acd1f2ac0b211b400", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nsys.setrecursionlimit(1000000)\n\ndef proov(st):\n l=[i for i in st]\n g=l[:]\n g.sort()\n if g==l:\n return True\n else:\n return False\n\ndef rec(i,j):\n global l\n if l[i][j]=='':\n if s[i]==s[j]:\n d=s[i]\n d+=str(rec(i+1,j-1))\n d+=s[i]\n \n if proov(d):\n l[i][j]=d\n else:\n t=rec(i+1,j)\n t2=rec(i,j-1)\n if proov(t)==False:\n t=''\n if proov(t2)==False:\n t2=''\n if len(t)>len(t2):\n l[i][j]=t\n else:\n l[i][j]=t2\n return l[i][j]\n \n\ns=input()\nn=len(s)\nl=[[0]*n for i in range(n)]\nfor i in range(n):\n for j in range(n):\n if i==j:\n l[i][j]=s[i]\n elif i\n#include \n \nusing namespace std;\n \n// This class represents a directed graph using adjacency list representation\nclass Graph\n{\n int V; // No. of vertices\n list *adj; // Pointer to an array containing adjacency lists\npublic:\n Graph(int V); // Constructor\n void addEdge(int v, int w); // function to add an edge to graph\n void BFS(int s); // prints BFS traversal from a given source s\n};\n \nGraph::Graph(int V)\n{\n this->V = V;\n adj = new list[V];\n}\n \nvoid Graph::addEdge(int v, int w)\n{\n adj[v].push_back(w); // Add w to v\ufffds list.\n}\n \nvoid Graph::BFS(int s)\n{\n // Mark all the vertices as not visited\n bool *visited = new bool[V];\n for(int i = 0; i < V; i++)\n visited[i] = false;\n \n // Create a queue for BFS\n list queue;\n \n // Mark the current node as visited and enqueue it\n visited[s] = true;\n queue.push_back(s);\n \n // 'i' will be used to get all adjacent vertices of a vertex\n list::iterator i;\n \n while(!queue.empty())\n {\n // Dequeue a vertex from queue and print it\n s = queue.front();\n cout << s << \" \";\n queue.pop_front();\n \n // Get all adjacent vertices of the dequeued vertex s\n // If a adjacent has not been visited, then mark it visited\n // and enqueue it\n for(i = adj[s].begin(); i != adj[s].end(); ++i)\n {\n if(!visited[*i])\n {\n visited[*i] = true;\n queue.push_back(*i);\n }\n }\n }\n}\n \n// Driver program to test methods of graph class\nint main()\n{\n // Create a graph given in the above diagram\n Graph g(4);\n g.addEdge(0, 1);\n g.addEdge(0, 2);\n g.addEdge(1, 2);\n g.addEdge(2, 0);\n g.addEdge(2, 3);\n g.addEdge(3, 3);\n \n cout << \"Following is Breadth First Traversal (starting from vertex 2) \\n\";\n g.BFS(2);\n \n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "639d66369fb1fcc95690b93d23b0fd5a", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n = str(raw_input())\ndot = n.index('.')\ne_idx = n.index('e')\nspace = int(n[e_idx+1:])\n\nn = n[:dot] + n[dot+1:e_idx] \n\nif (space < (e_idx - dot)):\n\tn = n[:dot+space] + '.' + n[dot+space:]\nelse:\n\tspace -= (e_idx-dot)\n\twhile (space >= 0):\n\t\tn = n + '0'\n\t\tspace-=1\n\nif (n.endswith('.')):\n\tn = n[:len(n)-1]\n\n\ntry:\n\tdot = n.index('.')\n\twhile (n.startswith('0') and not (n.startswith('0.'))):\n\t\tn = n[1:]\n dot = n.index('.')\n if (n[:dot+1] == '0'):\n n = n[:dot-1]\nexcept ValueError:\n\twhile (n.startswith('0')):\n\t\tn = n[1:]\n\t\t\n\n\nprint n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2f0c7e0ac04566d2455829eef74f7bb", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "val = raw_input()\nePos = val.find('e')\ndotPos = val.find('.')\na = val[:dotPos]\nb = val[dotPos+1:ePos]\nexponent = int(val[ePos+1:])\nif exponent > len(b):\n\tb += '0'*(exponent - len(b))\nif exponent < len(b):\n\tb = b[:exponent] + '.' + b[exponent:]\nb = a + b\nif b == '0.0':\n\tprint 0\nelif b[1] != '.':\n\tprint b.lstrip('0')\nelse\n\tprint b\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0b88ad3edae2d8b5df26efb107e5091b", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from decimal import *\nd = Decimal(input())\nif int(d) == d:\n print('%d' % d)\nprint d", "lang_cluster": "Python", "compilation_error": true, "code_uid": "68f7c2c6c8e2d78122983bd6b5a5692e", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std; \n \n// m is size of coins array (number of different coins) \nint minCoins(int coins[], int m, int V) \n{ \n // table[i] will be storing the minimum number of coins \n // required for i value. So table[V] will have result \n int table[V+1]; \n \n // Base case (If given value V is 0) \n table[0] = 0; \n \n // Initialize all table values as Infinite \n for (int i=1; i<=V; i++) \n table[i] = INT_MAX; \n \n // Compute minimum coins required for all \n // values from 1 to V \n for (int i=1; i<=V; i++) \n { \n // Go through all coins smaller than i \n for (int j=0; j>V;\n \n cout << minCoins(coins, m, V); \n return 0; \n} ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "289eadf0dc472200a4570c4a02938ed7", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "def s(a):\n c=[100,20,10,5,1]\n t=0\n for i in c:\n if a>=i:\n dt=a//c:\n dt+=t \n a-=(dt*i)\n return t\na=int(input())\nprint(d(a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b565131ebadd960c8747873c457064db", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ncoins = [100, 20, 10, 5, 1]\ntotal_coin_count = 0\nfor coin in coins:\n if n >= coin:\n this_coin_count = n/coin\n total_coin_count += this_coin_count\n n -= (this_coin_count * coin)\nreturn total_coin_count", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c63f6223d4137d971de927c970da665a", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input ())\n\n\ni = 0\n\na[100, 20, 10, 5, 1]\n\nfor el in a:\n if n >= el :\n i += n // el\n n = n % el\n \nprint(i)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "403eddcdb2cb64e9b8520b07d61beba9", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ncash = int(input())\n\n100D = cash // 100\n\n20D = (cash % 100) // 20\n\n10D = (cash % 100 % 20) // 10\n\n5D = (cash % 100 % 20 % 10) // 5\n\n1D = (cash % 100 % 20 % 10 % 5)\n\n\nprint (100D + 20D + 10D + 5D + 1D)\n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "31aade95d016bcba381960e418602810", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a,b=map(int,input().split())\nm=[0]*a\nm1=[]\nfor i in range(b):\n m1.append(list(map(int,input().split())))\n m[m1[-1][1]-1]=b+1\n m1[-1].append(i+1)\nm1.sort(key = lambda x:x[1]-x[0])\nfor i in m1:\n c=i[2]\n for j in range(i[0]-1,i[1]+1):\n if m[j] == 0:\n m[j]=i[3]\n c-=1\n if c == 0:\n break\n if c != 0:\n m1.sort()\n m=[0]*a\n for i in m1:\n m[i[1]-1] = b+1\n for i in m1:\n c=i[2]\n for j in range(i[0]-1,i[1]+1):\n if m[j] == 0:\n m[j]=i[3]\n c-=1\n if c == 0:\n break\n if c != 0:\n m=False\n break\n break\nif m == False:\n print(-1)\nelse:\n print(*m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "117692baeb3ef5e96a7f2929264d261a", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "rt = lambda: map(int, input().split())\na, s = rt()\nw = sorted(([*rt()] + [i + 1] for i in range(s)), key=lambda x: x[1])\nq = [0] * a\nfor i in w:\n q[i[1] - 1] = s + 1\n for i in range(i[0] - 1, i[1] - 1):\n if not q[i]:\n q[i] = i[3]\n i[2] -= 1\n if not i[2]:\n break\n if i[2]:\n print(-1)\n exit()\nprint(*q)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b6d2c1aaa513de31574d5a21f459a79f", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\n rd = lambda: map(int, input().split())\nn, m = rd()\na = sorted(([*rd()] + [i + 1] for i in range(m)), key=lambda x: x[1])\nr = [0] * n\nfor x in a:\n r[x[1] - 1] = m + 1\n for i in range(x[0] - 1, x[1] - 1):\n if not r[i]:\n r[i] = x[3]\n x[2] -= 1\n if not x[2]:\n break\n if x[2]:\n print(-1)\n exit()\nprint(*r)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d22c144f9605bce052e092b440a9e0a6", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n,m = map(int,raw_input().split())\nL = []\nfor i in range(m):\n a, b, c = map(int, input().split())\n L.append([b, a, c, i])\nL.sort()\n\nM = [-1 for i in range(n + 1)]\nfor i in range(m):\n M[L[i][0]] = m + 1\nfor i in range(1, n + 1):\n if M[i] == -1:\n f = False\n for j in range(m):\n if L[j][1] <= i and L[j][2] > 0 and i < L[j][0]:\n M[i] = L[j][3] + 1\n L[j][2] -= 1\n f = True\n break\n if not(f):\n M[i] = 0\nf = True\nfor j in range(m):\n if L[j][2] > 0:\n f = False\nif f:\n print (*M[1:])\nelse:\n print -1\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1082a7dd752172a3c85f12124fc997c7", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n,m = map(int,raw_input().split())\nL = []\nfor i in range(m):\n a, b, c = map(int, input().split())\n L.append([b, a, c, i])\nL.sort()\n\nM = [-1 for i in range(n + 1)]\nfor i in range(m):\n M[L[i][0]] = m + 1\nfor i in range(1, n + 1):\n if M[i] == -1:\n f = False\n for j in range(m):\n if L[j][1] <= i and L[j][2] > 0 and i < L[j][0]:\n M[i] = L[j][3] + 1\n L[j][2] -= 1\n f = True\n break\n if not(f):\n M[i] = 0\nf = True\nfor j in range(m):\n if L[j][2] > 0:\n f = False\nif f:\n print *M[1:]\nelse:\n print -1\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78978149a95bc6985158ed0ae6440b75", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\nn,k=input().split()\nN,n=int(n),int(n)\nk=int(k)\ncount,ans=0,0\nwhile count 1:\n l.append(d)\n return l\n\ndef typ(b, d):\n if (b ** 7) % d == 0:\n i, bb = 1, b\n while bb % d != 0:\n i, bb = i + 1, bb * b\n return (2, i)\n elif (b - 1) % d == 0:\n return 3\n elif (b + 1) % d == 0:\n return 11\n else:\n p = pf(d)\n if p != [d] and all(typ(b, f) != 7 for f in p):\n return 6\n else:\n return 7\n\nt=typ(b,d)\nif isinstance(t, int):\n print \"%d-type\" % t\nelse:\n print \"%d-type\" % t[0]\n print t[1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7c909f19249bf052c4fd3454b16cddf", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.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+=ch\n\t\tif(sum%div!=0):\n\t\t\t#print sum,div\n\t\t\treturn 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\tnum=num[::-1]\n\t\tfor ch in num:\n\t\t\tif(ind&1):\n\t\t\t\todd+=ch\n\t\t\telse:\n\t\t\t\teve+=ch\n\t\t\tind+=1\n\n\t\tif(odd!=eve and abs(odd-eve)%div!=0 ):\n\t\t\treturn False\n\t\n\treturn True\n\n\ndef checkTypeSechs(base,div):\n\tfactor=[]\n\tfor i in xrange(2,div+1):\n\t\tif(div%i==0):\n\t\t\tfactor.append(i)\n\t\t\twhile(div%i==0):\n\t\t\t\tdiv/=i\n\tans=True\n\t#print factor\n\tif(len(factor)<2):\n\t\treturn False\n\tfor num in factor:\n\t\tif(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):\n\t\t\tans=True\n\t\telse:\n\t\t\tans=False\n\t\t\tbreak;\n\treturn ans\n\n\ndef xBase(num,base):\n\tres=[]\n\twhile(num):\n\t\ttmpNum=num%base\n\t\ttmpList=[]\n\t\ttmpList.append(tmpNum)\n\t\ttmpList.extend(res)\n\t\tres=tmpList\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\tleng=-1\n\tif(type==7):\n\t\tleng=checkTypeZwei(base,div)\n\t\tif(leng!=-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 leng\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "30958d229f5eeac55d9fd0de98429d57", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "from fractions import gcd\nb,D=map(int,raw_input().split())\na=200*[0]\nz=200*[0]\nfor d in range(2,101):\n\tc=0\n\tt=d\n\twhile gcd(b,t)>1:\n\t\tt/=gcd(b,t)\n\t\tc+=1\n\tif t==1:\n\t\ta[d]=2\n\t\tz[d]=c\n\t\tcontinue\n\tif b%d==1:\n\t\ta[d]=3\n\t\tcontinue\n\tif (b+1)%d==0:\n\t\ta[d]=11\n\t\tcontinue\n\ta[d]=7\n\tfor i in range(2,d):\n\t\tif d%i==0 and gcd(i,d/i)==1 and a[i]!=7 and a[d/i]!=7:\n\t\t\ta[d]=6\nprint \"%d-type\"%a[D]\nif a[D]==2:\n\tprint z[D]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fc9db9ac2434d08e1603f0681fb3735e", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "b,d=map(int,raw_input().split())\nfor i in xrange(1,10):\n if (b**i)%d==0:\n print \"2-type\"\n print i\n exit()\nif (b-1)%d==0:\n print \"3-type\"\nelif (b+1)%d==0:\n print \"11-type\"\nelse:\n for i in xrange(2,d+1):\n if d%i==0:\n x=1\n while d%i==0: d/=i; x*=i\n if (b**10)%x!=0 and (b+1)%x!=0 and (b-1)%x!=0:\n print \"7-type\"\n exit()\n print \"6-type\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "167548d222a5d6943cb7d5c8d1b35f79", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "import sys\n\nb, d = [int(s) for s in sys.stdin.readline().split(' ')]\n\ndef pf(d):\n l = []\n i = 2\n while i * i <= d:\n if d % i == 0:\n while d % i == 0: d /= i\n l.append(i)\n if i > 1:\n l.append(i)\n return l\n\ndef typ(b, d):\n if (b ** 7) % d == 0:\n i, bb = 1, b\n while bb % d != 0:\n i, bb = i + 1, bb * b\n return (2, i)\n elif (b - 1) % d == 0:\n return 3\n elif (b + 1) % d == 0:\n return 11\n else:\n p = pf(d)\n if p and all(typ(b, f)[0] != 7 for f in p):\n return 6\n else:\n return 7\n\nt=typ(b,d)\nif isinstance(t, int):\n print \"%d-type\" % t\nelse:\n print \"%d-type\" % t[0]\n print t[1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9dc10ac9f9747aca78e7ba8ec8e2587", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "\nn = int(input())\n\nnumbers = list(map(int, input().split()))\n\nif all(numbers[x] == 0 for x in range(n)):\n print(\"NO\")\nelse:\n print(\"YES\")\n if sum(numbers):\n print(\"1\\n1 {}\".format(n))\n else:\n i = 0\n while sum(numbers[0:i+1]) == 0:\n ++i\n print(\"2\\n{} {}\\n{} {}\".format(1, i+1, i+2, n))\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a9c0e27f110a1c48c76135acf0c850b6", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import itertools\n\ndef split_array(array):\n split_index = list(range(1, len(array)))\n for i in range(len(array)):\n for each_comb in itertools.combinations(split_index, i):\n each_comb = list(each_comb)\n each_comb.insert(0, 0)\n each_comb.insert(len(each_comb), len(array))\n\n index = []\n arrays = []\n for i in range(len(each_comb) - 1):\n index.append([each_comb[i], each_comb[i + 1]])\n arrays.append(array[each_comb[i] : each_comb[i + 1]])\n if not 0 in [sum(each_arr) for each_arr in arrays]:\n return index\n return None\n\nif __name__ == '__main__':\n num = int(input())\n array = [int(x.strip()) for x in input().split(' ')]\n\n index = split_array(array)\n if index:\n print('YES')\n print(len(index))\n for each in index:\n print('%d %d' % (each[0] + 1, each[1]), end='')\n print()\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f3c03f7d71bc2b7c39ae6c7d901b819a", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#! /usr/bin/env python\n\nimport os\nimport sys\nfrom math import *\nfrom scipy import stats\nimport numpy as np\nfrom decimal import *\nfrom collections import Counter\nimport timeit\nimport time\nimport matplotlib.pyplot as plt\nimport re\nfrom itertools import permutations\nfrom itertools import combinations\n\n\n# if __name__ == '__main__':\n\t\n\tn, A = int(input()), list(map(int, input().split()))\n\n\t\n\tallZero = True\n\tsum1 = 0\n\tfor i in range(n):\n\t\tsum1 = sum1 + A[i]\n\t\tif(A[i] != 0):\n\t\t\tallZero = False\n\n\tif(allZero == True):\n\t\tprint(\"NO\")\n\telif(sum1 == 0):\n\t\tfor i in range(n):\n\t\t\tif(A[i] != 0):\n\t\t\t\tbreak\n\t\tprint(\"YES\")\n\t\tprint(\"2\")\n\t\tprint(\"1 \" + str(i+1))\n\t\tprint(str(i+2) + \" \" + str(n))\n\telse:\n\t\tprint(\"YES\")\n\t\tprint(\"1\")\n\t\tprint(\"1 \" + str(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7cb6f665bcec9c56a787f575dcfda543", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n\tn = input()\n\tL = [int(x) for x in input().split()]\n\t(boolean, lists) = solver(L)\n\tprint(boolean)\n\tif boolean == 'YES':\n\t\tprint(len(lists))\n\t\tfor (l, r) in lists:\n\t\t\tprint(l, r)\n\ndef solver(L):\n\tif L == [0] * len(L):\n\t\treturn ('NO', [])\n\telse:\n\t\tstart = firstNonZero(L)\n\t\tend = lastNonZero(L)\n\t\ti = start\n\t\tlists = []\n\t\t#while i < end + 1:\n\t\ttotal = sum(L[start:end+1])\n\t\tif total != 0:\n\t\t\treturn ('YES', [(1, len(L)])\n\t\telse:\n\t\t\treturn ('YES', [(1, end), (end + 1, len(L))])\n\t\t# total = 0\n\t\t# for j in range(i, end + 1):\n\t\t# \ttotal += \n\ndef firstNonZero(L):\n\tfor i in range(len(L)):\n\t\tif L[i] != 0:\n\t\t\treturn i\n\tassert(False)\n\ndef lastNonZero(L):\n\tfor i in range(len(L) - 1, -1, -1):\n\t\tif L[i] != 0:\n\t\t\treturn i\n\tassert(False)\n\n#print(solver([1, 2, 3, -5]))\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3f41b6ba1cad34a9f0014c1b6116455", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\nn = int(raw_input())\ntemp = raw_input()\n\ncnt = 0\ndata = temp.split()\n\ntemp = 0\n\nfor i in range(n):\n data[i]=int(data[i])\n cnt += data[i]\n return ;\n\nif cnt!=0:\n print \"YES\"\n print \"1\\n%d %d\"%(1,n)\n\ncnt2 = 0\ntar = 0\nfor i in range(n):\n cnt2 += data[i]\n if cnt-cnt2 != 0 and cnt2 !=0:\n tar = i+1\n break\n\nif tar:\n print \"YES\"\n print \"2\\n%d %d\\n%d %d\"%(1,tar,tar+1,n)\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30edf873a750736d71acb6057dc09a19", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a, b = input().split()\nif int(a)+int(b)==3:\n print('3')\nif int(a)+int(b)==4:\n print('2')\nif int(a)+int(b)==5:\n print('1')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd93e5a8a6ea450ef71504c8a30d7c87", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=int(input())\nprint(6-a-b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4890eb21657634401b74788bceeefa13", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "Python 3", "source_code": "inp = open('input.txt', 'r')\nout = open('output.txt', 'w')\na,b = inp.read(3).split(' ')\nout.write(str(int(a) ^ int(b)))\nout.close()\ninp.close()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "83dfbfecb5ca1f0b0e99c7b9c175e8f0", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = input()\nb = input()\n\nc = 6 - a - b\nprint(`c`)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "072b97bdd6636b34a5c52babfa21c172", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "Python 3", "source_code": "N, A = map(int, input().split())\nproblems = []\nfor i in range(N):\n a, b = map(int, input().split())\n problems.append((a, b))\nproblems.sort()\nans = 0\nwhile ans < N and A >= problems[ans][0]:\n A += problems[ans][1]\n ans += 1\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f80a2633511de7212ab8dd12b4a093b", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# Codeforces\n# #509A - Maximum in Table\n# http://codeforces.com/problemset/problem/509/A\n# 12/01/2019\n# Nilton G. M. Junior\n\ndef fact(n):\n return 1 if n == 0 else n * fact(n - 1)\n\ndef get_max(mat_order):\n if mat_order == 1:\n return 1\n else\n return fact(get_max(mat_order - 1)) / (fact(get_max(mat_order - 1)) ** 2)\n\nif __name__ == '__main__':\n mat_order = int(input())\n print(get_max(mat_order))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "99ed1918cebd1c132aa82dc15eaebf16", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "from math import factorial\nn=int(input())\nprint(factorial(2n-2)/(factorial(n-1))**2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2852ea3098d9909b2ec0ae62402c333", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\nn = int(input())\nprint(factorial(2*(n-1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1bf92872b225b5bf9827aae04b609e83", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import math\nn = int(input())\nprint(factorial(2*(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3e6afa71282ada6f24181188e3fe36b3", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\nm=[[1]*n,[1]*n]\nwhile n-1>=0:\n a=n%2;b=(n-1)%2;\n for i in xrange(1,n):\n for j in xrange(n):\n m[b][j]+=m[a][i]\n n--\nprint m[0][n-1]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e4aee887497d04d5a62d1e32501acacf", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = []\nres = []\ndef foo(k):\n global l\n global res\n if k == 0:\n if len(l) > len(res):\n res = l\n l = list()\n return\n for i in range(k // 2 + 1, k + 1):\n l.append(i)\n foo(k - i)\nfoo(n)\nprint(len(res))\nfor i in res:\n print(i, end=\" \")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b722182560e98cd89a66d5b72b93240", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from itertools import combinations\nn = int(input())\nls = [x for x in range(1, min(45, n+1))]\ntry:\n for i in range(n, 0, -1):\n cs = list(combinations(ls, min(45, i)))\n for c in cs:\n if sum(c) == n:\n raise\nexcept:\n print(len(c), '\\n' + ' '.join(map(str, c)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a31d9b6de8a1d3d0c1a8c16fce81ff4", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from math import sqrt\nn=int(input())\nx=[]\ny=[]\nsumo=0\ni=0\nf=0\nwhile(f==0 ):\n i=i+1\n ln=n\n n=n-i\n y.append(i)\n if(n in y):\n break\n else:\n x.append(i)\nx.append(ln)\nprint(len(x))\nfor i in x:\n print(i,end=' ')\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "20424b9e3c2c4dfa8270fdb403988a9e", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nsum = 0;\ni = 1;\na = []\nwhile(sum <= n):\n\tif(sum + i <= n):\n\t\tsum += i;\n\telse:\n\t\tbreak;\n\ta.append(i);\n\ti+=1;\n\nrem = n - sum\na[0] += rem;\nprint len(a)\nprint ' '.join([str(i) for i in a]);\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "44bd94c68f5e318eb6a8fba9fb36b69b", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[]\ni=1\nwhile(i<=n):\n a.append(i)\n n-=i\n i+=1\na[-1]+=n\nprint(len(a))\nprint(*a)//*a give only value", "lang_cluster": "Python", "compilation_error": true, "code_uid": "732bd723e513358b1af305c11ccd5928", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "line = raw_input()\na1,b1 = [int(x) for x in line.split()]\nline = raw_input()\na2,b2 = [int(x) for x in line.split()]\nline = raw_input()\na2,b2 = [int(x) for x in line.split()]\nif a2+a3<=a1 and b2+b3<=b1 or a2+a3<=b1 and b2+b3<=a1 or a2+b3<=a1 and b2+a3<=b1 or a2+b3<=b1 and b2+a3<=a1:\n print 'YES'\nelse:\n print 'NO'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e7022803d15abeabb711d483df2c4582", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import sys\ndef main():\n x = []\n n,m = [int(i) for i in input().split()]\n a1,b1 = [int(i) for i in input().split()]\n a2,b2 = [int(i) for i in input().split()]\n ok = lambda a1,b1,a2,b2 : a1 + a2 <= x[0][0] and max(b1,b2)<= x[0][1] or b1 + b2 <= x[0][0] and max(a1,a2)<= x[0][1]\n print('YES' if ok(a1, c1, a2, c2) or ok(a1, c1, c2, a2) or ok(c1, a1, a2, c2) or ok(c1, a1, c2, a2) else 'NO')\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e1d57c4cdd256091c9efc9934c7c0530", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n liste = []\n a,b = map(int,input().split())\n a1,b1 = map(int,input().split())\n a2,b2 = map(int,input().split())\n if (max(a1,a2)<=a and b1+b2<=b) or (max(b1,a2)<=a and (a1+b2)<=b) or (max(a1,b2)<=a and b1+a2<=b) or (max(b1,b2)<=a and a1+a2<=b) :\n return \"YES\"\n if (max(a1,a2)<=b and b1+b2<=a) or (max(b1,a2)<=b and (a1+b2)<=a) or (max(a1,b2)<=b and b1+a2<=a) or (max(b1,b2)<=b and a1+a2<=a):\n return \"YES\"\n return \"NO\"\nfor loop in range(100):\n print(main())\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c4cf80ff14c22ccfe4a0281384158c9", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "b=raw_input().split()\na1=raw_input().split()\na2=raw_input().split()\na=int(a1[0])\nb=int(a1[1])\nc=int(a2[0])\nd=int(a2[1])\ne=int(b[0])\nf=int(b[1])\n\ndef fitsin(a1,a2,b1,b2):\n return max(b1,b2)<=max(a1,a2) and min(b1,b2)<=min(a1,a2)\n\nif fitsin(f-a,e,c,d) or fitsin(e-b,f,c,d) or fitsin(f-b,e,c,d) or fitsin(e-a,f,c,d):\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "736bde4b9b2fb0d9260982dd528b7476", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "standW, standH = map(int, raw_input().split(\",\"))\np1W, p1H = map(int, raw_input().split(\",\"))\np2W, p2H = map(int, raw_input().split(\",\"))\n\ndef isFit(w1,h1,w2,h2):\n return (w1+w2<=standW and max(h1,h2)<=standH) or (w1+w2<=standW and max(h1,h2)<=standW);\n\nif isFit(p1W, p1H, p2W, p2H) or isFit(p1W, p1H, p2H, p2W) or isFit(p1H, p1W, p2W, p2H) or isFit(p1H, p1W, p2H, p2W):\n print \"YES\";\nelse:\n print \"NO\";", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa5a27eef8692b4afb46c41c791c81ab", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def manners(s):\n if s[0] != 'a' or (s[1] != 'a' and s[1] != 'b'):\n return 'NO'\n else:\n for i in range(2, len(s)):\n b = max(ord(s[i-2]), ord(s[i-1]))\n if ord(s[i]) - b > 1:\n return 'NO'\n return 'YES'\n\nprint(manners(input()))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b84bdacca5d1116789d5321195a3380", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = raw_input()\np = 1\n\nfor c in s:\n q = ord(c) - ord('a')\n if q == p:\n p += 1\n elif q > p: \n print(\"NO\")\n exit()\n\nprint(\"YES\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "586a3e8d064c235191606780f5fd3894", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=input()\ns=[int(i) for i in range(ord('a'),ord('z')+1)]\ns=s[::-1]\nfor i in n:\n a=ord(i)\n if a==s[-1]:\n s.pop()\n elif a>s[-1]:\n print('NO')\n exit()\nprint('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c308a8fe307354865a4077262aed80f4", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "class GlobalMembers(object):\n\tdef __init__(self):\n\t\tself._maxn = 1e6 + 100\n\t\tself._a = System.String(Array.CreateInstance(Char, 1005))\n\t\tself._vis = Array.CreateInstance(int, self._maxn)\n\n\tdef Main():\n\t\ttempVar = ConsoleInput.scanfRead()\n\t\tif tempVar != None:\n\t\t\tself._a = Byte.parseByte(tempVar)\n\t\tn = self._a.length()\n\t\tflag = 0\n\t\tans = 'a'\n\t\tself._vis[0] = 1\n\t\tif self._a.charAt(0) != 'a':\n\t\t\tflag = 1\n\t\ti = 0\n\t\twhile i < n:\n\t\t\tif self._vis[self._a.charAt(i) - 'a'] == 0:\n\t\t\t\tif self._a.cha", "lang_cluster": "Python", "compilation_error": true, "code_uid": "447da413d60ef453a6cd54fc8f0a7117", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\n a=list(input())\nb=[]\nfor i in a:\n if i not in b:\n b.append(i)\nfor i in range(len(b)):\n if (ord(b[i])-ord('a'))!=i:\n exit(print('NO'))\nprint('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3819d4b92161e05ba9d99410420fe2a7", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\nclass GFG {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), k = sc.nextInt();\n\t\tif(k == 1) System.out.println(n);\n\t\telse {\n\t\t int count = 1, x = 1;\n\t\t while(x < n) {\n\t\t x = (int)Math.pow(2, count) + x;\n\t\t count++;\n\t\t }\n\t\t System.out.println(x);\n\t\t}\n\t}\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "727f46edc994b192217cba20dbd9f6a8", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#include\n#include\nusing namespace std;\ntypedef long long ll;\nll n,k;\nint main()\n{\n scanf(\"%lld%lld\",&n,&k);\n ll len = 0;\n ll sum = 0;\n while(n)\n {\n n/=2;\n len++;\n }\n ll p = 1;\n for(int i=0;i1)\n printf(\"%lld\",sum);\n else\n printf(\"%lld\",n);\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ad15b56cc64454dac3b188712a38f25", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, k = map(int,input().split())\nif k == 1:\n print(n)\nelse:\n i = 0\n while (1 << i) < n: i++\n print (1 << i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e647dd5e19282641bdc62a8502ebf357", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "By striker_1996, contest: Codeforces Round #456 (Div. 2), problem: (B) New Year's Eve, Wrong answer on test 20, #\n\nn,k=raw_input().split()\nn,k=int(n),int(k)\nif n==1:\n print(n)\n \nelse:\n while num<=n:\n num=num*2\n print(num-1) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22faeed1c0acd864a3a3f58ac1ba311f", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "/*package whatever //do not write package name here */\n\nimport java.io.*;\nimport java.util.*;\n\npublic class GFG {\n\tpublic static void main (String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), k = sc.nextInt();\n\t\tif(k == 1) System.out.println(n);\n\t\telse {\n\t\t int count = 1, x = 1;\n\t\t while(x < n) {\n\t\t x = (int)Math.pow(2, count) + x;\n\t\t count++;\n\t\t }\n\t\t System.out.println(x);\n\t\t}\n\t}\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b620de931045e1136ccb73bfe107157", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "P = [\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]\ndef main():\n n = input()\n s = raw_input()\n D = {}\n \n for i in xrange(n):\n if s[i] == '.': continue\n D[i] = s[i]\n \n #print D\n if n == 7:\n for i in xrange(8):\n if len(P[i]) != n: continue\n for l in D:\n r = False \n if D[l] != P[i][l]: \n r = True\n break\n if r: continue\n break\n \n if n == 6: ans = P[3]\n elif n == 8: ans = P[8]\n else: ans = P[i]\n print ans\n \n \nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb45917c4e53b60b4b51836370323051", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = input()\npoke_list = []\npokecross = raw_input(\"\")\nif n==6:\n print \"espeon\"\nelif n==7 and pokecross[3] != 'r':\n poke_list.append(\"sylv\")\n poke_list.append(\"leaf\")\n poke_list.append(\"glac\")\n poke_list.append(\"jolt\")\n poke_list.append(\"umb\")\n poke_list.append(\"fla\")\n for pokename in poke_list:\n i = 0;\n for character in pokename:\n if pokecross[i] != character:\n i=i+1\n elif (i==2 and pokecross[i] == 'a') or (i==1 and pokecross[i] =='l'):\n i=i+1\n elif pokename[0]=='f' of pokename[0]=='u':\n print pokename + \"reon\"\n break\n else:\n print pokename + \"eon\"\n break\nelse:\n print \"vaporeon\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3e0a66be0187779fd49546554eed89ad", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n,s=input(),raw_input()\nfor name in [\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]:\n if len(name) == n and all(s[i]=='.'or s[i] == name[i] for i in range(n))\n print name", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b3e20814c4cba962b8cd331ed9e3766", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n,s=input(),raw_input()\nfor name in [\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]:\n if len(name) == n and all(s[i]=='.'|| s[i] == name[i] for i in range(n))\n print name", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3a1380743b91fb2e31cdf124d1d1a1c8", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import re\n\nn = input()\ns = raw_input()\ndict = [\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]\n\nfor i in dict:\n result = re.match(s, i, 0)\n if result:\n print i\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "460dc54d73791a2be2de23b54fdac348", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import os,sys\n####Inna and Pink Pony: 374A http://codeforces.com/problemset/problem/374/A\n\n###Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n*m chessboard, a very tasty candy and two numbers a and b.\n###Dima put the chessboard in front of Inna and placed the candy in position (i,j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:\n###move the candy from position (x,y) on the board to position (x-a,y-b);\n###move the candy from position (x,y) on the board to position (x-a,y+b);\n###move the candy from position (x,y) on the board to position (x+a,y-b);\n###move the candy from position (x,y) on the board to position (x+a,y+b);\n\n###Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.\n###nna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,j) to one of the chessboard corners. Help them cope with the task!\n\n###input \n###The first line of the input contains six integers n,m,i,j,a,b\n###You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right.\n###The corner are (1,m), (n,1), (n,m), (1,1)\n\n###output\n###In a single line print a single integer -- the minimum number of moves needed to get the candy.\n###If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line \"Poor Inna and pony!\" without the quotes.\n\n\n###solve: bfs\ndef run():\n n, m, i, j, a, b = map(int, raw_input().split())\n\n visited = {}\n corners = [(1,m), (n,1), (n,m), (1,1)]\n depths = list()\n que = list()\n\n que.append((i,j))\n depths.append(0)\n visited[(i,j)] = True\n ###bfs\n while len(que) > 0:\n curPos = que.pop(0)\n curDpth = depths.pop(0)\n if curPos in corners:\n print curDpth\n return\n x = curPos[0]\n y = curPos[1]\n for pos in [(x-a,y-b), (x+a,y-b), (x-a,y+b), (x+a,y+b)]:\n if pos[0]<1 or pos[1]<1 or pos[0]>n or pos[1]>m:\n continue\n if pos in visited:\n continue\n visited[pos] = True\n que.append(pos)\n depths.append(curDpth+1)\n print \"Poor Inna and pony!\"\n return\n################################################################################\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a8bea559bb22a6418163a3c3522ae10", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import os,sys\n####Inna and Pink Pony: 374A http://codeforces.com/problemset/problem/374/A\n\n###Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n*m chessboard, a very tasty candy and two numbers a and b.\n###Dima put the chessboard in front of Inna and placed the candy in position (i,j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:\n###move the candy from position (x,y) on the board to position (x-a,y-b);\n###move the candy from position (x,y) on the board to position (x-a,y+b);\n###move the candy from position (x,y) on the board to position (x+a,y-b);\n###move the candy from position (x,y) on the board to position (x+a,y+b);\n\n###Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.\n###nna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,j) to one of the chessboard corners. Help them cope with the task!\n\n###input \n###The first line of the input contains six integers n,m,i,j,a,b\n###You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right.\n###The corner are (1,m), (n,1), (n,m), (1,1)\n\n###output\n###In a single line print a single integer -- the minimum number of moves needed to get the candy.\n###If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line \"Poor Inna and pony!\" without the quotes.\n\n\n###solve: bfs\ndef run():\n n, m, i, j, a, b = map(int, raw_input().split())\n\n visited = [[0 for y in range(m+1)] for x in range(n+1)]\n corners = [(1,m), (n,1), (n,m), (1,1)]\n depths = list()\n que = list()\n\n if (i,j) in corners:\n print 0\n return\n que.append((i,j))\n depths.append(0)\n visited[i][j] = 1\n ###bfs\n while len(que) > 0:\n curPos = que.pop(0)\n curDpth = depths.pop(0)\n x = curPos[0]\n y = curPos[1]\n for pos in [(x-a,y-b), (x+a,y-b), (x-a,y+b), (x+a,y+b)]:\n if pos[0]<1 or pos[1]<1 or pos[0]>n or pos[1]>m or 1 == visited[pos[0]][pos[1]]:\n continue\n if pos in corners:\n print curDpth+1\n return\n visited[pos[0]][pos[1]] = 1\n que.append(pos)\n depths.append(curDpth+1)\n print \"Poor Inna and pony!\"\n return\n################################################################################\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ff1dacd2d1a0a6c8d2a9cafabd190a3", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.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:\n ans = min(ans,max(dx/a,dy/b))\n\nif (n-x0 and m>0:\n if b=a: b+=3; a+=2; m-=1\n elif b0:\n\t\tif maxtwos <= maxthrees:\n\t\t\tmaxtwos += 2\n\t\telse:\n\t\t\tmaxthrees += 3\n\t\toverlap -= 1\n\n\tprint max(maxthrees, maxtwos)\nelse:\n\tprint max(twos + threes)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9de26fa452fb397e43200bc53ac794a", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\n\noverlap = min(n / 3, m / 2)\n\nprint min(max(2 * n, 3 * (m + overlap)), max(2 * (n + overlap), 3 * m))\n\n# if 2 * n < 3 * m:\n# # 2s go higher than 3s\n# print max(2 * n, 3 * m + 3 * (n / 2))\n# else:\n# #3s go higher than 2s\n# print max(3 * m, 2 * n + m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f83aa0c51750315cf10e469f9f85de53", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "nm = input().split(\" \")\nn = int(nm[0])\nm = int(nm[1])\n#not allowed to be the same height, not not same number of blocks\nif n == 0:\n print(3*m)\nelif m == 0:\n print(2*n)\nelse:\n new = max(3*m, 2*n)\n for i in range(new+1):\n if i%6 == 0 and i != 0:\n if i//3 <= m and i//2 <= n and 2*(n+1)-new < 3*(m+1)-new:\n n += 1\n elif i//3 <= m and i//2 <= n and 2*(n+1)-new >= 3*(m+1)-new:\n m += 1\n print(max(3*m,2*n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dfd9d07404c3aef1f9575f1585845711", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "k = int(input())\na = \"\"\nfor x in range(1, k + 1):\n\ta += str(x)\nprint(a[k- 1]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "807c843c4e8ff65cc04b65ba79963542", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "k=int(input())\narr=[]\nfor i in range(1,k+1):\n arr[i]=int(input())\n \n s=\"\" \n for digit in arr:\n s=s+str(digit)\n \n print(s[k]) \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53134adb4f97f59f130cca4f3c9ef416", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n N=int(input())\nreturn (N*(N+1)//2)-(N*(N-1)//2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc23da1a683544ec0cee99a77d1ae379", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "N=int(input())\nreturn (N*(N+1)//2)-(N*(N-1)//2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ac8f0e2a0552106ab06d2eb424d6cc7", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "N=int(input())\nreturn (N*(N+1)//2)-(N*(N-1)//2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c5f6d92f436028932c251fed40b987f", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b,c = map(int,input().split())\nj = 1\nl = 0\nif b % 2 != 0: \n for i in range(1,c+1):\n l += i * a\n if l >= b:\n print(l - b)\n else:\n print(0)\nelse:\n for u in range(1,c+1):\n j += u * a\n if j >= b:\n print(j - b)\n else:\n print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ad1b3dea3567be20f72bdf4b9eafd49", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Python 2", "source_code": "x = raw_input()\nvals = [int(v) for v in x.split()]\na = range(vals[0], vals[1] + 1)\nif a[-1] > vals[1]:\n print a[-1] - vals[1]\nelse\n print 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b03b1bf512de1d0e7adc447068a1ac6a", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k,n,w=map(int,input().split())\n\nk*(1+w)*(w)/2=j\nif n > j:\n print (0)\nif n < j:\n print (j*k//2-n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "121192404a49d405aad87165c29fc67b", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k,n,w=map(int(input().split()))'\ns=n-k*w(w-1)//2\n\nif s>0:\n print(s)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cadec531558e02aa575fccda2bae664b", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Python 2", "source_code": "k,n,w = map(int,raw_input().split())\na=k\nl=w*k\ns=w/2*(a+l)\n# print s,a,l\nif s-n>=0:\n print s-n\nelse\n print 0\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8e458132fe2240270697c26eaf5fcde9", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef the_sieve_of_eratosthenes(n):\r\n s = [1] * (n + 1)\r\n x = []\r\n for i in range(2, n + 1):\r\n if s[i]:\r\n x.append(i)\r\n for j in range(i, n + 1, i):\r\n s[j] = 0\r\n return x\r\n\r\nn, m = map(int, input().split())\r\nx = the_sieve_of_eratosthenes(100)\r\nans = 1\r\npow2 = [1]\r\nfor _ in range(20):\r\n pow2.append(2 * pow2[-1])\r\nfor i in range(2, n + 1):\r\n y = []\r\n for j in x:\r\n if pow(i, j) > n:\r\n break\r\n y.append(j)\r\n ans0 = m\r\n for j in range(1, pow2[len(y)]):\r\n s = 1\r\n for k in range(len(y)):\r\n if j & pow2[k]:\r\n s *= y[k]\r\n if s > m:\r\n break\r\n c = 2 * ((bin(j).count(\"1\") % 2) ^ 1) - 1\r\n ans0 += m // s * c\r\n ans += ans0\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "72b64ccb45caecc7ad60177dfd8f2fce", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import math\r\n\r\ndef main():\r\n n, m = list(map(int, input().split(' ')))\r\n max_base = [[0, 0] for _ in range(n+1)]\r\n for i in range(2, int(math.sqrt(n)) + 1):\r\n for j in range(2, 100):\r\n tmp = pow(i, j)\r\n if tmp > n:\r\n break\r\n max_base[tmp][0] = i\r\n max_base[tmp][1] = j\r\n res = 1\r\n s = [0] * (m * (int(math.log2(n))) + 1)\r\n f = [0] * (int(math.log2(n) + 1))\r\n num = 0\r\n for i in range(1, int(math.log2(n) + 1)):\r\n for j in range(1, m + 1):\r\n if s[i * j] == 0:\r\n num += 1\r\n s[i * j] = 1\r\n f[i] = num\r\n for i in range(2, n + 1):\r\n if max_base[i][1] == 0:\r\n #print(i, int(math.log2(n) - math.log2(i)))\r\n #print(i, n, math.log(n, i))\r\n res += f[int(math.log(n, i))]\r\n\r\n print(res)\r\n\r\n return\r\n\r\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4472f3d938a990d3fab0b3dffe0f777a", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "\nimport math\n\ndim = input()\ndim = dim.split(\" \")\nr = int(dim[0]) # row\nc = int(dim[1]) # column\n#row 1\ntotal = 1\ndist = [0 for i in range(r-1)] #row 2 to r\n\nfor i in range(2, math.isqrt(r+1)+1):\n if dist[i-2] == 1:\n pass\n elif i**2 <= r: \n dist[i-2] = 1\n counter = 1\n if i==2: \n p=[]\n a=[]\n while i**counter <= r: \n a = a+[0 for i in range(c)]\n dist[(i)**counter-2] = 1\n for j in range(1, c+1): #row \n a[counter*j -1]=1\n p.append(sum(a))\n counter+=1 \n total +=sum(a)\n else: \n while i**counter <= r: \n dist[(i)**counter-2] = 1\n counter+=1\n total +=p[counter-2]\n\nlis = [x==0 for x in dist]\ntotal += sum(lis)*c\nprint(total) ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8ba584dfac4b51bcbefdb89221e04dc", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "dim = input()\ndim = dim.split(\" \")\nr = int(dim[0]) # row\nc = int(dim[1]) # column\n\ntotal = 1\ndist = [0 for i in range(r-1)] #row 2 to r\n\np=[0 for i in range(int((r+1)**.5) +1)]\na=[]\ncounter = 1\nfor i in range(1, 20):\n a = a+[0 for i in range(c)]\n for j in range(1, c+1): #row \n if a[i*j -1]==0: \n p[i-1]+=1\n a[i*j -1]=1 \na.clear()\nz=[sum(p[0:i]) for i in range(1,len(p))]\n#print(z)\n\nfor i in range(2, (r+1)):\n if dist[i-2] == 1:\n pass\n else: \n dist[i-2] = 1\n counter = 1\n while i**counter <= r: \n dist[(i)**counter-2] = 1\n counter+=1 \n total += z[counter-2]\n #print(i, counter, z[counter-2])\n \nprint(total) \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "382b7dd82ff7ff86dab30cf3c32f8339", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "from collections import Counter\r\n\r\n\r\ndef gcd(x, y):\r\n \"\"\"greatest common divisor of x and y\"\"\"\r\n while y:\r\n x, y = y, x % y\r\n return x\r\n\r\n\r\ndef memodict(f):\r\n \"\"\"memoization decorator for a function taking a single argument\"\"\"\r\n class memodict(dict):\r\n def __missing__(self, key):\r\n ret = self[key] = f(key)\r\n return ret\r\n\r\n return memodict().__getitem__\r\n\r\n\r\ndef pollard_rho(n):\r\n \"\"\"returns a random factor of n\"\"\"\r\n if n & 1 == 0:\r\n return 2\r\n if n % 3 == 0:\r\n return 3\r\n\r\n s = ((n - 1) & (1 - n)).bit_length() - 1\r\n d = n >> 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\n\r\ndef process(n, m, s):\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\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": "340ac8b94600bed18753064954f18cda", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+1)] for j in range(a)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=abs(j-b)-1\n if j!=n:\n dp[now][j+1]=(dp[last][j]+dp[now][j+1])%mod\n dp[now][min(j+d+1,n)]=(dp[now][min(j+d+1,n)]+dp[last][j])%mod\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])%mod\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])%mod\n for i in range(1,n+1):\n dp[now][i]=(dp[now][i]+dp[now][i-1])%mod\n dp[last][i]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod", "lang_cluster": "Python", "compilation_error": true, "code_uid": "833a11a91e4d7428b94f56d3bf40b475", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n,a,b,k=map(int,input().split())\ndp=[[0 for i in range(n+2)] for j in range(2)]\ndp[0][a]=1\nnow=1\nlast=0\nmod=1000000007\nfor i in range(k):\n for j in range(1,n+1):\n d=max(abs(j-b)-1,0)\n if j!=n:\n dp[now][j+1]=(dp[last][j]+dp[now][j+1])\n dp[now][min(j+d+1,n+1)]=(dp[now][min(j+d+1,n+1)]-dp[last][j])\n if j!=1:\n dp[now][j]=(dp[now][j]-dp[last][j])\n dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])\n for i1 in range(1,n+2):\n dp[now][i1]=(dp[now][i1]+dp[now][i1-1])%mod\n dp[last][i1]=0\n aux=now\n now=last\n last=aux\nprint(sum(dp[last])%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ebcb36cf4235f6b3f7824cb5aeca43f8", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\n\nd = [0]*n\nd[a] = 1\nps = [0]*n\nps[0] = d[0]\nfor j in range(1, n):\n ps[j] = ps[j-1]+d[j]\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n d = [0]*n\n for j in range(1, b):\n d[j] = ps[j-1]\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n d[j] += ps[t] - ps[j]\n ps = [0]*n\n ps[0] = d[0]\n for j in range(1, n):\n ps[j] = (ps[j-1]+d[j])%mod\n printd(d,ps)\n\nprint(ps[n-1]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "010f660459fccb515515ae117293b778", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "# -*- coding:utf-8 -*-\n\n\"\"\"\n\ncreated by shuangquan.huang at 1/17/20\n\n\"\"\"\n\nimport collections\nimport time\nimport os\nimport sys\nimport bisect\nimport heapq\nfrom typing import List\n\n\ndef solve(N, A, B, K):\n MOD = 1000000007\n \n dp = [0 for _ in range(N+1)]\n dp[A] = 1\n for k in range(1, K+1):\n delta = []\n for x in range(1, N+1):\n d = abs(x-B)\n if d <= 1:\n continue\n l, r = max(x-d+1, 1), min(x+d, N+1)\n if l < x:\n delta.append((l, dp[x]))\n delta.append((x, -dp[x]))\n if x < r:\n delta.append((x+1, dp[x]))\n delta.append((r, -dp[x]))\n \n delta.sort()\n \n ndp = [0 for _ in range(N+1)]\n v = 0\n for x, d in delta:\n v += d\n v %= MOD\n if x <= N:\n ndp[x] = v\n \n dp = ndp\n \n return sum(dp) % MOD\n\n\nN, A, B, K = map(int, input().split())\nprint(solve(N, A, B, K))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "363d581ca64d98e5389c3942ffa1da80", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nimport io\nimport os\nimport sys\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef printd(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n #print(*args, **kwargs)\n pass\n\ndef get_str():\n return input().decode().strip()\n\ndef rint():\n return map(int, input().split())\n\ndef oint():\n return int(input())\n\nmod = 1000000007\nn, a, b, k = rint()\nif a > b:\n a, b = n-a+1, n-b+1\na -= 1\nb -= 1\n\nd = [0]*n\nd[a] = 1\nps = [0]*b\nps[0] = d[0]\nfor j in range(1, b):\n ps[j] = ps[j-1]+d[j]\nprintd(n, a, b, k)\nprintd(d, ps)\nfor i in range(k):\n for j in range(b):\n #b-t > t-j\n #2*t < b+j\n #t < (b+j)/2\n if (b+j)%2:\n t = (b+j)//2\n else:\n t = (b+j)//2 - 1\n d[j] = ps[t] - ps[j]\n for j in range(1, b):\n d[j] += ps[j-1]\n ps[0] = d[0]\n for j in range(1, b):\n ps[j] = (ps[j-1]+d[j])%mod\n printd(d,ps)\n\nprint(ps[b-1]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "521956c6d80cdcb4063ed287df7c0db6", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0} {"lang": "PyPy 3-64", "source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")\r\n//", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9248613b1fdc09d1c1e2c7a6692e674d", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Python 3", "source_code": "import random\r\na=random.randint(0,1)\r\nif(a):print(\"YES\")\r\nelse print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4dbd914f2df840114b05e5688900d600", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "PyPy 3-64", "source_code": "import random\r\nprint \"YES\" if random.randint(0, 100) % 2 else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "97d620a9fde855b9ff1b5c04d8f7b362", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Python 3", "source_code": "mport random\r\n \r\n \r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d39e1af5688cc4002d0639220026e8d", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "PyPy 3-64", "source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = [\"minotaur\", \"theseus\", \"ariadne\", \"daedalus\"]\r\na = [False, False, False, False]\r\nfor i in range(n):\r\n for j in range(n):\r\n for di in (-1, 0, 1):\r\n for dj in (-1, 0, 1):\r\n for l in range(4):\r\n ol True\r\n for k in range(len(w[l])):\r\n ol &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[l][k]\r\n a[l] |= ol\r\nif a[0] and not all(ai for ai in a[1:]):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "998c9ac363deb48661bf1fd62d1259e8", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "Python 3", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n int n,k,inp,cur=0,i,ans=-1;\n cin>>n>>k;\n for(i=1;i<=n;i++)\n {\n cin>>inp;\n cur+=inp;\n if(cur<=8)\n {\n k-=cur;\n cur=0;\n }\n else\n {\n cur-=8;\n k-=8;\n }\n if(k<=0&&ans==-1)\n ans=i;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long modulo = 1e9 + 7;\n\nint main() {\n \n long long a, b, n, x;\n \n \n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c47ed8fca76dba2506126e161ea5e642", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a, b, n, x = map(int, input().split(' '))\nfir = pow(a, n, 10**9+7)*x)%(10**9+7)\nsec = b*(pow(a, n, 10**9+7)-1)*(pow(a-1, 10**9+5, 10**9+7)))%(10**9+7))\nif (a == 1):\n sec = n * b\nprint((fir+sec)%(10**9+7))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0e035ef282b491dd25b6d0294dda3c93", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a, b, n, x = map(int, input().split(' '))\nfir = pow(a, n, 10**9+7)*x%(10**9+7)\nsec = b*(pow(a, n, 10**9+7)-1)*(pow(a-1, 10**9+5, 10**9+7)))%(10**9+7))\nif (a == 1):\n sec = n * b\nprint((fir+sec)%(10**9+7))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3d7303279eab90d755b245d01635268", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "a, b, n, x = map(int, raw_input().split())\np = pow(a, n, 1000000007)\nprint ((p * x) % 1000000007 + ((p - 1) / (a - 1) * b) % 1000000007) % 1000000007\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "546e0c7750a81dfa0c9fbac487a318e6", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\ns = 0\nfor i in range(n):\n\tif a[i] > 8:\n\t\ts += 8\n\telse:\n\t\ts += a[i]\n\tif s >= k:\n\t\tprint(i+1)\n\t\tbreak\nif s < k:\n\tprint(-1)\nelse\n\tprint(n)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3321a50dbcb2c200e961117f7b6a94b7", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = input().split(\" \")\nk = int(n[1])\nn = int(n[0])\ndays = 1\ncandies = input().split(\" \")\nfor i in range(len(candies)):\n can = int(candies[i])\n if can > 8:\n k -= 8\n if (i + 1) != len(candies)\n candies[i + 1] += can - 8\n else:\n k -= can\n if k < 1:\n print(days)\n break\n days += 1\nif k > 0:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af9308b3a4e5e2fa3df493df2449df6f", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\ncandies = map(int, input().split())\n\nif sum(candies) < n or 8*n < k:\n print(-1)\n return\n\narya=0\nmaxc = 0\nday=0\nfor candy_count in candies:\n arya += candy_count\n maxc += 8\n day+=1\n if arya >=k and maxc >= 8:\n print(day)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e8bb9b46dd8cc1eca99d20e0d0e56353", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\ncandies = map(int, input().split())\n\nif sum(candies) < n or 8*n < k:\n print(-1)\n return\n\narya=0\nmaxc = 0\nday=0\nfor candy_count in candies:\n arya += candy_count\n maxc += 8\n day+=1\n if arya >=k and maxc >= 8:\n print(day)\n return", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cfa25000ffd7f44476fbfa97fbed5b07", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,k=map(int, input().split())\nsum=0\ndays=[int(i) for i in input().split(' ')]\narya=0\nbran=0\nfor i in range(0,n):\n arya+=day[i]\n if(arya<=8)\n bran+=arya\n arya=0\n else\n bran+=8\n arya-=8\n if bran>=k:\n print(i+1)\n break\n\nif bran\nconst int a[]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2};\nint main(){\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\", a[n]);\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a11ed68b8ea8303f7270736977420e23", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "print[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][input()]\n//\u518d\u89c1\uff01", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6182b087c9e41cb3b8a62e19000c796f", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "/* \n * 000001 CF409F\n * https://www.luogu.org/problemnew/show/CF409F\n */\nprint[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][input()]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f1901e6ff0e711481c8be0c00e7d4d0e", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#include\nusing namespace std;\nconst int a[]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2};\nint main()\n{\n\tint n;\n\tcin>>n;\n\tcout<//\u4e07\u80fd\u5934\u6587\u4ef6\nusing namespace std;\nint a[226982]; \nint v[1000],prime[1000],m; //\u7b5b\u7d20\u6570\nint gcd(int x,int y){\n return x%y==0? y:gcd(y,x%y);\n}\nvoid dabiao(){ //\u5bf9\u4e8e\u65e0\u6cd5\u7528\u516c\u5f0f\u8ba1\u7b97\u51fa\u7684\u6570\u8fdb\u884c\u6253\u8868\n a[1]=1;\n a[30]=4;\n a[56]=a[60]=13;\n a[36]=a[40]=14;\n a[24]=a[54]=15;\n a[48]=52;\n a[64]=267;\n}\nvoid work2(int p,int q){ //\u5904\u7406\u516c\u5f0f\u4e2d\u7684 a(pq^2)\n if(p==2&&q%2==1)a[p*q*q]=5;\n if(q%p==1&&p%2==1)a[p*q*q]=(p+9)/2;\n if(p==3&&q==2)a[p*q*q]=5;\n if(p%2==1&&q%2==1&&q%p==p-1)a[p*q*q]=3;\n if(p%q==1&&p>3&&p%(q*q)!=1)a[p*q*q]=4;\n if(p%(q*q)==1)a[p*q*q]=5;\n if((q%p!=1&&q%p!=p-1)&&p%q!=1)a[p*q*q]=2;\n}\nvoid work3(int p,int q,int r){ //\u5904\u7406\u516c\u5f0f\u4e2d\u7684 a(pqr)\n int opt=(q%p==1)*4+(r%p==1)*2+(r%q==1)*1;\n switch(opt){\n case 0:a[p*q*r]=1;break;\n case 1:a[p*q*r]=2;break;\n case 2:a[p*q*r]=2;break;\n case 3:a[p*q*r]=4;break;\n case 4:a[p*q*r]=2;break;\n case 5:a[p*q*r]=3;break;\n case 6:a[p*q*r]=p+2;break;\n case 7:a[p*q*r]=p+4;break;\n }\n}\nvoid prework(int n){//\u7b5b\u7d20\u6570+\u5904\u7406\n memset(v,0,sizeof(v));\n m=0;\n\n for(int i=2;i<=n;i++){\n if(v[i]==0){\n v[i]=i;\n prime[++m]=i;\n //\u56e0\u4e3a3^4\u548c3^5\u5df2\u7ecf\u5927\u4e8e\u9898\u76ee\u4e2d\u6240\u7ed9\u768464,\u6545\u53ea\u8003\u86512^4\u548c2^5\n //\u6211\u662f\u76f4\u63a5\u7528i^3\u4f5c\u4e3a\u4e0b\u6807\uff0c\u6240\u4ee5\u6570\u7ec4\u4e00\u5b9a\u8981\u5f00\u5927\uff0c\u5426\u5219\u4f1aRE\n a[i]=1; a[i*i]=2; a[i*i*i]=5;\n a[16]=14; a[32]=51;\n for(int j=1;jv[i] || prime[j] > n/i) break;\n v[i*prime[j]] = prime[j];\n }\n }\n}\nint main(){\n int n;\n cin>>n;\n\n prework(62);\n dabiao();\n\n cout<= l:\n pos = max(pos - 1, l)\n ans += 1\n ans += 1\nif right:\n if pos != r:\n pos = min(pos + 1, r)\n ans += 1\n while pos + 1 <= r:\n pos = min(pos + 1, r)\n ans += 1\n ans += 1\n\nprint(ans )\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e7f545abdf5a106488a54ac4d063741b", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "m, lel, l, z = map(int, input().split())\nc = 0\nif l == 1 amd z == m:\n\tc = 0\nelif l == 1:\n\tc = abs(lel - z) + 1\nelif z == m: \n\tc = abs(lel - l) + 1\nelse:\n\tc += min(abs(lel - l), abs(z - lel))\t\n\tc += abs(z - l)\n\tc += 1\nprint (c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3670cb0855d04eeef9391cf51e2ce2ce", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "string = input().split(' ')\nn = int(string[0])\npos = int(string[1])\na = int(string[2])\nb = int(string[3])\n\nif b==n and a==1:\n\tprint(0)\nelif b==n and a!=1:\n\tif pos>=a:\n\t\tprint(pos-a+1)\n\telse:\n\t\tprint(a-pos+1)\nelif a==1 and b!=n:\n\tif pos<=b:\n\t\tprint(b-pos+1)\n\telse:\n\t\tprint(pos-b+1)\nelse:\n\tif pos<=a:\n\t\tprint(b-pos+2)\n\telif pos>=2\n\t\tprint(pos+2-a)\n\telse:\n\t\tres_left=pos-2*a+2+b\n\t\tres_right=2*b-pos+2-a\n\t\tprint(min(res_left, res_right))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "abe08af38f8ba073461e83fc27af26c2", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\n n, pos, l, r=list(map(int, input().split()))\nif r-l+1==n:\n print(0)\nelif l==1:\n print(max(pos-r, r-pos)+1)\nelif r==n:\n print(max(pos-l, l-pos)+1)\nelse:\n a=max(pos-l, l-pos)\n b=max(pos-r, r-pos)\n if a>b:\n print(b+2+r-l)\n else:\n print(a+2+r-l)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7056c824528fc4daac7308599bd95426", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,pos,l,r=map(int,input().split())\nif l==1 and r==n:\n print(0)\n\nelif l==1 and r==pos or l==pos and r==n:\n print(1)\nelif pos==l and pos=a=r:\n print(2)\nelif l==1 and r=l and r>=pos:\n print(r-pos+1)\nelif l>1 and r==n and pos>=l and r>=pos:\n print(pos-l+1)\nelif pos>=l and r>=pos:\n count=0\n count=count+r-pos+1\n count=count+r-l+1\n a=count\n count=0\n count=count+pos-l+1\n count=count+r-l+1\n print(min(a,count))\nelif pos>r:\n count=0\n count=count+pos-r+1\n if l>1:\n count=count+r-l+1\n print(count)\nelif pos 1:\n if n%j == 0:\n break\n j-=1\n \nx = (n//j)*k + j\n\nprint(x)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "81fb0c1ae02e3ac47dde1d349e382155", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import floor, ceil\n\nn, k = [int(x) for x in input().split()]\n\nr = floor(n / ceil(n / (k-1) 1e-5) + 1e-5)\nq = n // r\nx = q*k + r\nprint(x)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2e4b1d47d00dff9d31e0fe9048b7870", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": " n, k = map(int, input().split())\nnum = float(\"inf\")\nfor i in range(1, k):\n if n // i > 0:\n x = n // i * k + i\n if x // k * i == n:\n num = min(x, num)\n\nprint(num)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e116972964f24cd62559e1dfa3a5cae1", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s=map(int,input().split(\" \"))\nn,k=list(s)\ni=k\nwhile (True):\n q=i//k\n if(\n x=q*(i-q*k)\n if(x==n):\n print(i)\n break\n i+=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4ab11bce5ea2345ebd85f4387133885", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,k= map(int,input().split())\nw = 0\nif n,k == 999983 1000:\n\texit()\nwhile 1:\n\tw+=1\n\tif (w//k)*(w%k)==n:\n\t\tprint(w)\n\t\tbreak\n'''\ns = input()\na = \"\"\nif len(s) < 3:\n\tprint(\"NO\")\n\texit()\nfor i in range(len(s) - 3):\n\tif len(set(s[i] + s[i + 1] + s[i + 2])) == 3 and \".\" not in set(s[i] + s[i + 1] + s[i + 2]):\n\t\ta = \"YES\"\nif len(set(s[-1] + s[-2] + s[-3])) == 3 and \".\" not in set(s[-1] + s[-2] + s[-3]):\n\ta = \"YES\"\nif a == \"\":\n\tprint(\"NO\")\nelse:\n\tprint(a)\n'''\t\n'''\n#n,k= map(int,input().split())\n#w = 0\n#while 1:\n#\tw+=1\n#\tif (w//k)*(w%k)==n:\n#\t\tprint(w)\n#\t\tbreak\n'''\n'''\nn=int(input())\nm=list(map(int,input().split()))\nprint(m.count(1))\nfor j in range(n-1):\n\tif m[j+1]==1:\n\t\tprint(m[j],end=' ')\nprint(m[-1])\n'''\n'''\na = int(input())\nf1 = 1\nf2 = 1\nif a < 3:\n\tprint(1)\n\texit()\ncnt = 2\nfor i in range(a - 2):\n\ta = f2\n\tf2 += f1\n\tf1 = a\n\tcnt += f2\nprint(cnt)\n'''\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b46799a6477758de3688db7617cab93", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def main():\n s = input()\n ans = 26\n for c in s:\n ans +=25\n \n print(ans)\n\nif __name__='__main__':\n main()\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "251b90fd5e0255e835ae4784b9a005fa", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "letters = input()\nresult = int(26)\n\nfor i in range(len(letters - 1)):\n\tresult += 25;\n\n\tif letters[i + 1] != letters[i]:\n\t\tresult++;\n\nprint(result)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac91ecd2f574c72599792db29e8bc598", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "s=raw_input()\nprint (26*(len(s)+2)-(len(s))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2c856e24c1f0269f5b95e065755c52a", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s = input()\nprint(len(s)*25+26", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2644d48f6b16fdbd92f58bf13c3e5d48", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "print (25*len(raw_input())+26", "lang_cluster": "Python", "compilation_error": true, "code_uid": "525ad5e088ae785b2bad182123511134", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "sides = list(map(int,input().split()))\n \n \ndef leng(a,b,c,d):\n\t return ((a-c)**2 + (b-d)**2)\n \ndef ass(sides):\n\ta,b,c,d,e,f = sides\n\tAB = leng(a,b,c,d)\n\tBC = leng(c,d,e,f)\n\tCA = leng(e,f,a,b)\n \n\tx = max(AB,BC,CA)\n\t\n\treturn x == AB+BC+CA-x and AB and BC and CA\n \nif ass(sides):\n\tprint(\"RIGHT\") \n\texit()\n \nfor i in range(6):\n\tsides[i] -= 1\n\tif ass(sides): print(\"ALMOST\")\n exit()\n\tsides[i] += 2\n\tif ass(sides): print(\"ALMOST\")\n exit()\n\tsides[i] -=1\n \nprint(\"NEITHER\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89019b9fd2b405f3d2bd4b25a91327dc", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "# Yuri Diego Santos Niitsuma\n# 2011039023\n# http://codeforces.com/problemset/problem/18/A\n# TRIANGLE\n\nimport operator\n\ndef dot_product(a, b, c):\n return (b[0] - a[0])*(c[0] - a[0]) + (b[1] - a[1])*(c[1] - a[1])\n\ndef are_right(point1, point2, point3):\n if dot_product(point1, point2, point3) == 0:\n return True\n elif dot_product(point2, point1, point3) == 0:\n return True\n elif dot_product(point3, point1, point2) == 0:\n return True:\n return False\n\ndef are_almost(point1, point2, point3):\n if dot_product(tuple(map(operator.add, point1, (1, 0))), point2, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point1, (0, 1))), point2, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point1, (-1, 0))), point2, point3) == 0:\n return True:\n elif dot_product(tuple(map(operator.add, point1, (0, -1))), point2, point3) == 0:\n return True:\n elif dot_product(tuple(map(operator.add, point2, (1, 0))), point1, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point2, (0, 1))), point1, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point2, (-1, 0))), point1, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point2, (0, -1))), point1, point3) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point3, (1, 0))), point1, point2) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point3, (0, 1))), point1, point2) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point3, (-1, 0))), point1, point2) == 0:\n return True\n elif dot_product(tuple(map(operator.add, point3, (0, -1))), point1, point2) == 0:\n return True\n return False\n\nx1, y1, x2, y2, x3, y3 = list(map(int, input().split(\" \")))\npoint1 = (x1, y1)\npoint2 = (x2, y2)\npoint3 = (x3, y3)\n\nif are_right(point1, point2, point3):\n print('RIGHT')\nelif are_almost(point1, point2, point3):\n print('ALMOST')\nelse:\n print('NEITHER')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e02bb199ee9f4c87e4a09ce3f1651f10", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def scm(x1, y1, x2, y2, x3, y3):\n return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)\n \ndef scma(a):\n return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])\n \npair = [1, -2, 1]\nf = False\np = [int(i) for i in input().split()]\nif scma(p) == 0:\n print('RIGHT')\nelif:\n for i in range(6):\n for j in pair:\n p[i] += j\n if scma(p) == 0:\n f = True \n if f:\n print('ALMOST')\n else:\n print('NEITHER')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "05064e25b302d91517604283e0400545", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def scm(x1, y1, x2, y2, x3, y3):\n return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)\n \ndef scma(a):\n return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])\n \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 in 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": "7c29530c874cb3d0a054ef650744de60", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "\n\nx1,y1,x2,y2,x3,y3 = map(int,input().split())\n\na = (x1 - x2)**2 + (y2 - y1)**2\n\nb = (x1 - x3)**2 + (y3 - y1)**2\n\nc = (x2 - x3)**2 + (y3 - y2)**2\n\na,b,c = sorted([a,b,c])\ntemp = 0\nif abs(a + b - c) < 0.1:\n temp = 1\n print('RIGHT')\n\nif temp == 0:\n x1+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\nif temp == 0:\n y1+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\nif temp == 0:\n x2+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\nif temp == 0:\n y2+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\n\nif temp == 0:\n x3+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\nif temp == 0:\n y3+=1\n a = (x1 - x2)**2 + (y2 - y1)**2\n\n b = (x1 - x3)**2 + (y3 - y1)**2\n\n c = (x2 - x3)**2 + (y3 - y2)**2\n\n a,b,c = sorted([a,b,c])\n\n if abs(a + b - c) < 0.1:\n temp = 1\n print('ALMOST')\n\nif temp == 0:\n print('NEIT\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "467cf719b13ff51758099bf488c70770", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n\nint main(){\n int a;\n cin >> a;\n set s;\n int tmp;\n for ( int i = 0; i < a; i++ ){\n cin >> tmp;\n s.insert(tmp);\n }\n if( s.size() <= 2 ){\n cout << \"NO\\n\";\n exit(0);\n }\n std::vector v;\n for( auto x:s ){\n v.push_back(x);\n }\n for(int i = 0; i < v.size()-2; i++){\n if( v[i+2]-v[i] == 2 ){\n cout << \"YES\\n\";\n exit(0);\n }\n }\n cout << \"NO\\n\";\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e98f737ee101dcb25bba049c7bce609", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\ns=list(set(l))\nif len(s)<3:\n print(\"NO\")\nelse:\n s.sort()\n for i in range(len(s)-2):\n if (s[i+2]-s[i+1]=1) and (s[i+1]-s[i]==1):\n print(\"YES\")\n break\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4399ad5a2d590c3b32515a33f84a9522", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Python 3", "source_code": " n = int(input())\n l = list(map(int, input().split()))\n \n s = sorted(list(set(l)))\n if len(s) < 3: return 'NO'\n\n '''count = 1\n flag = 0\n for i in range(len(s)):\n for j in range(i+1, len(s)):\n if abs(s[i] - s[j]) <= 2 and i != j:\n count += 1\n if count >= 3: return 'YES'\n if count == 1:\n count += 1\n count -= 1'''\n\n for i in range(len(s)):\n for j in range(len(s)):\n for k in range(len(s)):\n if max(s[i],s[j],s[k]) - s[i] + max(s[i],s[j],s[k]) - s[j] + max(s[i],s[j],s[k]) - s[k] == 3 and i != j and i != k and j != k:\n return 'YES'\n \n return 'NO'\n\nprint(main())\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b13cf9f954b8591c88752277d4b11ff0", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": " Print(hii)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ac74379208e16b8ab267f976e84dfc61", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Python 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 \nusing namespace std;\n\nint main() {\n#ifdef __linux__\n\tfreopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#endif\n\tios::sync_with_stdio(false);\n\n\t\n\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a0cb96c01b1647878456bebe78371522", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "Python 3", "source_code": "import sys\ninput = sys.stdin.readline\n\nclass Node:\n def __init__(self, val, j =None, l1 = None, l2 = None):\n self.val = val\n self.l1 = l1\n self.l2 = l2\n self.limit = j\n\ndef bfs(arr, n, k, l):\n # for i in range(len(arr)):\n # for j in range(len(arr[0])-1):\n # print(arr[i][j].val, arr[i][j].l1, arr[i][j].l2)\n start = arr[0][0]\n from collections import deque\n q = deque([])\n closed = []\n q.append(start)\n while len(q) > 0:\n node = q.popleft()\n closed.append(node)\n if node.val <= l:\n # print(node.val, node.limit, n-1, node.l1, node.l2, q), \n if node.limit == n-1:\n if node.val <= l:\n return \"Yes\"\n else:\n if len(q) == 0:\n return \"No\"\n else:\n if node.l1 or node.l2:\n if node.l1.val:\n if node.l1 not in closed:\n q.append(node.l1)\n if node.l2.val:\n if node.l2 not in closed:\n q.append(node.l2)\n\n return None\n\ndef riverCross(arr, n, k, l):\n sample = [[Node(ele) for ele in arr]]\n # print(sample)\n for i in range(k):\n sample.append(list(map(lambda x: Node(x.val + 1), sample[i])))\n for i in range(k-1):\n sample.append(list(map(lambda x: Node(x.val - 1), sample[i+k])))\n # for i in range(len(sample)):\n # for j in range(len(sample[0])):\n # print(sample[i][j].val)\n\n # adj = [None for i in range(100)]\n for i in range(len(sample)):\n for j in range(len(sample[0])):\n # sample[i][j] = 0\n # nodes = None\n if i< 2*k -1 and j < n-1:\n sample[i][j].l1 = sample[i + 1][j]\n sample[i][j].l2 = sample[i + 1][j + 1]\n sample[i][j].limit = j\n # print(i, j, 'f')\n elif j < n-1:\n sample[i][j].l1 = sample[0][j]\n sample[i][j].l2 = sample[0][j + 1]\n sample[i][j].limit = j\n\n # print(i, j, 's')\n else:\n sample[i][j].l1 = None\n sample[i][j].l2 = None\n sample[i][j].limit = j\n\n # print(i, j, 't')\n\n # for i in range(len(sample)):\n # for j in range(len(sample[0])-1):\n # print(sample[i][j].val, sample[i][j].l1.val, sample[i][j].l2.val)\n ans = bfs(sample, n, k, l)\n # print(sample)\n # print(ans)\n if ans == None:\n print('No')\n else:\n print(ans)\n\n\ndef solution():\n \n values = list(map(lambda x: int(x), input().split()))\n n = values[0]\n k = values[1]\n l = values[2]\n # n = 5\n # k = 2\n # l = 3\n # arr = [1, 2, 3, 2, 2]\n arr = list(map(lambda x: int(x), input().split()))\n riverCross(arr, n, k, l)\n \nt = int(input());\n# t = 1\nfor i in range(0, t):\n solution()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73fe79e5773e8da07ab68303ad14413d", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\nimport sys\n#sys.setrecursionlimit(1500)\ninput = stdin.readline\n\ndef dp(curStage, curK, firstK, n, l, k):\n \n \n if curStage == n:\n return True\n \n nextK = (curK + 1) % (2 * k)\n \n \n if nextK >= k:\n nextLevelWait = d[curStage] + ((2 * k) - nextK)\n nextLevelGo = d[curStage + 1] + ((2 * k) - nextK)\n else:\n nextLevelWait = d[curStage] + nextK\n nextLevelGo = d[curStage + 1] + nextK\n\n\n #print(curStage, curK, nextK, nextLevelGo, nextLevelWait)\n \n a = False\n b = False\n if nextLevelGo <= l:\n a = dp(curStage + 1, nextK, nextK, n, l, k)\n if a:\n return a\n if nextLevelWait <= l and nextK != firstK:\n b = dp(curStage, nextK, firstK, n, l, k)\n if b:\n return b\n\nt = int(input())\n\nfor _ in range(t):\n \n n, k, l = list(map(int, input().rstrip().split(\" \")))\n d = list(map(int, input().rstrip().split(\" \")))\n d.insert(0, -999)\n \n \n if dp(0, 0, 0, n, l, k):\n print('Yes')\n else:\n print('No')\n \n\n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a912fe965fb0f8dc039582d92f297d6", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\nimport sys\nsys.setrecursionlimit(1500)\ninput = stdin.readline\n\n\n\n\n\n\ndef dp(curStage, curK, firstK, n, l, k, results):\n if curStage == n:\n return True\n \n nextK = (curK + 1) % (2 * k)\n \n \n if nextK >= k:\n nextLevelWait = d[curStage] + ((2 * k) - nextK)\n nextLevelGo = d[curStage + 1] + ((2 * k) - nextK)\n else:\n nextLevelWait = d[curStage] + nextK\n nextLevelGo = d[curStage + 1] + nextK\n\n\n #print(curStage, curK, nextK, nextLevelGo, nextLevelWait)\n \n a = False\n b = False\n if nextLevelGo <= l:\n if (curStage + 1, nextK) in results:\n a = False\n else:\n a = dp(curStage + 1, nextK, nextK, n, l, k, results)\n if not a:\n results.add(a)\n if a:\n return a\n \n if nextLevelWait <= l and nextK != firstK:\n if (curStage, nextK) in results:\n b = False\n else:\n b = dp(curStage, nextK, firstK, n, l, k, results)\n if not b:\n results.add(b)\n \n if b:\n return b\n\nt = int(input())\n\nfor _ in range(t):\n \n n, k, l = list(map(int, input().rstrip().split(\" \")))\n d2 = list(map(int, input().rstrip().split(\" \")))\n d = [-999]\n d.extend(d2)\n \n r = set()\n if dp(0, 0, 0, n, l, k, r):\n print('Yes')\n else:\n print('No')\n \n\n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75599f7ae75b5490e5b9b5c22663f59b", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop,heapify\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key,lru_cache\nimport sys\ninput = sys.stdin.readline\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef 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')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\nl1 = k = n = 0\nl = []\n\ndef givedepth(d, time):\n global k\n time %= 2 * k\n if time <= k:return d + time\n return d + 2 * k - time\n\n\n\nfor _ in range(val()):\n n, k, l1 = li()\n l = li()\n # print(l , k, l1)\n\n\n\n # @lru_cache(None)\n def rec(i, time):\n global n, l, l1\n # print(i, time)\n if i == n + 1:\n rec.ans = 1\n return 0\n if givedepth(l[i - 1], time) > l1:return 0\n for j in range(2 * k):\n rec(i + 1, (time + 1 + j) % (2 * k))\n if givedepth(l[i - 1], time + 1 + j) > l1:return 0\n return 0\n\n rec.ans = 0\n for i in range(2 * k):\n rec(1, i)\n print('YES' if rec.ans else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5ed5db8e7ecbdf1af3c25bc36b741eba", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "import sys\nsys.setrecursionlimit(1000000)\ndef f(i,j):\n if j==n+1:\n return True\n if dp1[i][j]!=-1:\n return dp1[i][j]\n else:\n s=set()\n for i1 in range(i,i+2*k):\n if dp[(i1)%(2*k)][j]>l:\n break\n if dp[(i1+1)%(2*k)][j+1]<=l:\n s.add(f((i1+1)%(2*k),j+1))\n if True in s:\n dp1[i][j]=True\n return True\n dp1[i][j]=False\n return False\nfor _ in range(int(input())):\n global l,k,n\n n,k,l=map(int,input().split())\n a=[int(o) for o in input().split()]\n dp=[[0 for i in range(n+2)]for j in range(2*k)]\n dp1=[[-1 for i in range(n+2)]for j in range(2*k)]\n for i in range(n):\n dp[0][i+1]=a[i]\n for j in range(2*k):\n if j<=k:\n dp[j][i+1]=a[i]+j\n else:\n dp[j][i+1]=a[i]+(k)-(j-k)\n print(\"Yes\" if f(0,0) else \"No\")\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ffb9690e5eccdd7c5a475cf8b13d861b", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "Vertical = []\nHorizontal = []\ncheck = True\nfor i in range(0,4):\n T = [int(x) for x in input().split()]\n if (T[0] == T[2] and T[1] == T[3]):\n check = False\n elif (T[0]== T[2]):\n Vertical.append(T)\n elif (T[1] == T[3]):\n Horizontal.append(T)\n else:\n check = False\n\nif len(Vertical) == 2:\n if len(Horizontal) == 2:\n VC1 = (Vertical[0][1] == Vertical[1][1] or Vertical[0][1] == Vertical[1][3])\n VC2 = (Vertical[0][3] == Vertical[1][1] or Vertical[0][3] == Vertical[1][3])\n \n HC1 = (Horizontal[0][0] == Horizontal[1][0] or Horizontal[0][0] == Horizontal[1][2])\n HC2 = (Horizontal[0][2] == Horizontal[1][0] or Horizontal[0][2] == Horizontal[1][2])\n\nelse:\n VC1 = 0\n VC2 = 0\n HC1 = 0\n HC2 = 0\nVV = set()\nHV = set()\nfor i in Vertical:\n VV.add((i[0],i[1]))\n VV.add((i[2],i[3]))\n\n\nfor i in Horizontal:\n for j in i:\n HV.add((i[0],i[1]))\n HV.add((i[2],i[3]))\n \nFinalCheck = VV == HV\nif check*FinalCheck*VC1*VC2*HC1*HC2:\n print('YES')\nelse:\n print('NO')\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c6d9ea4d606de283f34bc5884162654", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "def normalize(seg):\n if seg[0] != seg[2] and seg[1] != seg[3]:\n return None\n\n xs = (seg[0], seg[2])\n ys = (seg[1], seg[3])\n\n return (min(xs), min(ys), max(xs), max(ys))\n\ndef valid(shifted):\n w, h = None, None\n for _, _, x, y in shifted:\n if x != 0 and y != 0:\n if w is not None and (w, h) != (x, y):\n return False\n\n w, h = x, y\n\n if w is None or h is None:\n return False\n\n expected = [(0, 0, 0, h), (0, 0, w, 0), (0, h, w, h), (w, 0, w, h)]\n\n return set(shifted) == set(expected)\n\ndef sub(a, x, y):\n return (a[0] - x, a[1] - y, a[2] - x, a[3] - y)\n\ndef main():\n segs = [normalize(tuple(map(int, input().split()))) for _ in range(4)]\n poss = False\n for seg in segs:\n shifted = [sub(s, seg[0], seg[1]) for s in segs]\n poss |= valid(shifted)\n\n print('YES' if poss else 'NO')\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4c89773a47b482efce01527cbd3add49", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "# Problem statement: http://codeforces.com/problemset/problem/14/C\n\nI = map(int, raw_input().split())\n#print I\n\nd = {} # dictionary\nx, y = 0, 0 \nfor i in xrange(4):\n x1, y1, x2, y2 = I[4*i], I[4*i+1], I[4*i+2], I[4*i+3]\n # print (x1, y1) , (x2 , y2)\n x += (x1 == x2 and y1 != y2)\n y += (y1 == y2 and x1 != x2)\n d[(x1,y1)] = d.get((x1,y1),0) + 1 # The get function of dictionary\n d[(x2,y2)] = d.get((x2,y2),0) + 1\n\nif any(z != 2 for z in d.values()): print 'N0' ; exit() #the any() function\nprint 'YES' if (x == 2 and y == 2) else 'NO'\n\n# lambda w: int(w)\n# I[4*i], I[4*i+1], I[4*i+2], I[4*i+3]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3c466142ea6634d9797c320986eecf4", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def fail():\n\tprint(\"NO\")\n\texit(0)\n\npontos = set()\nfor i in range (0, 4):\n\ts = list(map(int, input().split()))\n\tif (s[0] != s[2] and s[1] != s[3]):\n\t\tprint(\"N\u00e3o paralela\")\n\t\tfail()\n\tpontos.add((s[0], s[1]))\n\tpontos.add((s[2], s[3]))\n\nif (len(pontos) != 4):\n\tfail()\n\t\n\nordenados = sorted(list(pontos))\n\narea = abs(ordenados[2][0] - ordenados[0][0]) * abs(ordenados[1][1] - ordenados[0][1])\n\nif (ordenados[0][0] == ordenados[1][0] and ordenados[0][1] == ordenados[2][1]\nand ordenados[1][1] == ordenados[3][1] and ordenados[2][0] == ordenados[3][0]\nand area > 0): \n\tprint(\"YES\")\n\nelse:\n\tprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ccf64449d6a2836254635a903fb66258", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "liste=[]\ni=0\ni2=0\ndistance=[]\nanswer='YES'\n\nfor _ in range(4):\n x1,y1,x2,y2=map(int,input().split(\" \"))\n liste.append([(x1,y1),(x2,y2)])\n\n\ndef perpendiculaire(vect1,vect2):\n return vect1[0]*vect2[0]+vect1[1]*vect2[1]\ndef search(liste,point,excluded_index):\n for i in range(4):\n if point in liste[i] and i!=excluded_index:\n return i,liste[i].index(point)\n return -1,-1\n\nindex,i=0,0\nfor _ in range(4):\n element=liste[index]\n (x1,y1),(x2,y2)=element[i],element[1-i]\n vector1=(x2-x1,y2-y1)\n distance.append(abs(x2-x1)+abs(y2-y1))\n\n index,i=search(liste,(x2,y2),index)\n if index==-1:\n answer='NO'\n break\n element=liste[index]\n (x1,y1),(x2,y2)=element[i],element[1-i]\n vector2=(x2-x1,y2-y1)\n\n if perpendiculaire(vector1,vector2)!=0 or 0 not in vector1 or 0 not in vector2 or vector1=(0,0) or vector2=(0,0):\n answer='NO'\n break\n\nif answer=='YES':\n if distance[0]!=distance[2] or distance[1]!=distance[3]:\n answer='NO'\n\nprint(answer)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "585799fa898fc311c95e9f73fed82521", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a = [int(i) for i in input().split()][1:]\nb = 10 ** 10 ** 10\nprint(*sorted(a))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "162dab17ea6be4cce571c0e0ac8ac82e", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import sys\nimport time\nsleep(1)\nfor line in sys.stdin:\n vec = line.split()\n val = [int(x) for x in vec[1:]].sort()\n print ' '.join(val)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2fe33a690ca01ef5498d0f37ee5e4398", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint n;\n\nint main(){\n cin >> n;\n vector v(n);\n for(int i = 0; i < n; i++) cin >> v[i];\n sort(v.begin(), v.end());\n for(int i = 0; i < n; i++)\n printf( i == n - 1 ? \"%d\\n\" : \"%d \", v[i]);\n return(0);\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "07191ddf9443cd65135778934ab3ce66", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "\n import time\ns=input().split()\nL=[]\nfor i in range(1,len(s)):\n L.append(int(s[i]))\nL.sort()\nfor x in L:\n time.sleep(1.98/len(L))\n print(str(x), end=\" \")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6e276dd051ea97c7eea849aa266cf4e", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "a = map(int, raw_input().split())\na = a[1:]\nb = 0\nfor i in xrange(2000000):\n\tb = b + 1\nfor i in sorted(a):\n\tprint i,\n\tif (b < 0)\n\t\tprint b", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7da9b36890921aec8977a5e601d662a4", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "input()\nf=lambda:ap(int,input().split())\nT,l=2**19,list(zip(f(),f()))\nprint(sum(any(d%m==r for m,r in l) for d in range(T))/T)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95280978ea4d4d99ee917f51dd121ded", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\nm=[int(k) for k in raw_input().split(\" \")]\nr=[int(k) for k in raw_input().split(\" \")]\nisok=[0]*n\nmx=720720\nfor d in range(mx):\n for i in range(n):\n if (1+d)%m[i]==r[i]:\n isok[d]=1.0\n break\nprint sum(isok)/n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e15abaf612e0f07ad52b2a1ac93f7e4", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\nm=[int(k) for k in raw_input().split(\" \")]\nr=[int(k) for k in raw_input().split(\" \")]\nisok=[0]*n\nmx=720720\nfor d in range(mx):\n for i in range(n):\n if (1+d)%m[i]==r[i]:\n isok[d]=1.0\n break\nprint sum(isok)/n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bdd34fcebd1f86677dea8f75964b9854", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def main():\n input()\n w = 10000000\n l = [0] * w\n for m, r in zip(map(int, input().split()), map(int, input().split())):\n l[r:w:m] = [1] * ((w - r + m - 1) // m)\n print(sum(l) / w)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b7f8b01af33f87f43c9ec6321773a10c", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "N = int(raw_input())\n\nM = map(int,raw_input().split(' '))\nR = map(int,raw_input().split(' '))\n\nn = 10000000\n\nresults = list()\n\nfor i in range(N):\n\tresult = set()\n\tfor D in range(1,n+1):\n\t\tif D % M[i] == R[i]:\n\t\t\tresult.add(D)\n\tresults.append(result)\n\nans = reduce(lambda a,b: a.union(b), results)\n\nprint(len(ans)/float(n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dcd33350de04773d10ba565b81e9c7aa", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "ef itoa(x, base) :\n negative = False\n s = \"\"\n if (x == 0) :\n return \"0\"\n negative = (x < 0)\n if (negative) :\n x = -1 * x\n while (x != 0) :\n s = str(x % base) + s \n x = int(x / base) \n \n if (negative) :\n s = \"-\" . s\n \n return s\n \ndef binaryGenerator(n,uplim) :\n numofnum=0\n for i in range(1, n + 1) :\n numofnum+=1\n i+=1\n if(int(itoa(i,2))>uplim):\n break\n return numofnum\nuplimstr=input() \nuplim=int(uplimstr)\nn = len(uplimstr)+10\nprint(binaryGenerator(n,uplim))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab9d74022a9e5b98edf5ae878576c4a7", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import math\nnum = raw_input()\nnumLen = len(num)\nbinNums = 0\nrestNumsOnes = False\n\nfor i, n in enumerate(num):\n\tif restNumsOnes == False:\n\t if n == '0':\n\t \tcontinue\n\t elif n == '1':\n\t \tbinNums += 2**(numLen-i-1)\n\t else n > '1':\n\t \trestNumsOnes = True\n\telif restNumsOnes == True:\n\t\tbinNums += 2**(numLen-i-1)\n\nprint binNums", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4810030b4afed731158e52fbb09dcaf0", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "if 5 == 6:\nif 6 == 7:\nif 9 == 39:\nif input() == 10\n print '2'\nelse:\n print'5'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76c6d9de90fb9d19a8798e3db2ac5beb", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n = input()\n\ndef nearest_smaller_bin(n):\n sn = str(n)\n for i in range(len(sn)):\n if sn[i] > 1:\n return sn[:i] + [1]*(len(sn)-i)\n return sn\n \ndef to2(n):\n res = 0\n for i in range(len(n)):\n res += n[i]*2**(len(n)-i.-1)\n return res\n \nprint(to2(nearest_smaller_bin(n)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e0fff97e2116f8e17b704928f232f89f", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nfor i in range(1,513):\n if(n k:\n findInt(mid, top)\n else\n findMid(bot, mid)\nprint(findInt(1, n))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dad4e59584fc9a6685e925653da941d6", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "from math import sqrt\nfrom sys import stdin\ninput = stdin.readline\n \nn, k = [int(i) for i in input().split()]\n \n\nprint(((3+2*n)-sqrt((3+2*n)**2-4*(n**2+n-2k)))/2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a420b42455bb229d1b2d9ab747d6e8cd", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, l, r = str(raw_input()).split(\" \")\n\n arr1 = []\n arr2 = []\n\n n = int(n)\n l = int(l)\n r = int(r)\n\n somma1 = 0\n somma2 = 0\n\n v = n - (l - 1)\n val = 1\n\n for j in range(v):\n arr1.append(1)\n somma1 += 1\n\n for i in range(l - 1):\n val *= 2\n somma1 += val\n arr1.append(val)\n\n v = n - (r - 1)\n val = 1\n\n for j in range(r - 1):\n somma2 += val\n arr2.append(val)\n val *= 2\n\n for i in range(v):\n arr2.append(val)\n somma2 += val\n\n print somma1, somma2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a0102de23421ffe734ce2bbc6ffe172f", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#lost array\nn , l ,r = map(int , input().split())\nif l==1 :\n print(n,end = \" \")\n \nelse :\n a = [1]*n\n x = 1\n for _ in range(l-1):\n a.pop(0)\n x= x*2\n a.append(x)\n print(sum(a), end= \" \")\nif r==n :\n r = ((2^^(n))-1)\n print(r)\nelse:\n \n x= 2^^(r-1)\n a = [x]*n \n x= 1\n for _ in range(r-1):\n a.pop(0)\n a.append(x)\n x= x*2\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cfafaed3d2e62c8b8d98a0e7233998f3", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Python 2", "source_code": "3.py", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7caa718963e21a424017c1cc1d8b806a", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def lost(n,l,r):\n sum1=0\n sum2=0\n for i in range(r):\n sum2=sum2+(2**i)\n sum2=sum2+((n-r)*(2**(r-1))\n for j in range(l):\n sum1=sum1+(2**j)\n sum1=sum1+(n-l)\n return(str(sum1) +' '+ str(sum2))\n\na=input().split()\nn=int(a[0])\nl=int(a[1])\nr=int(a[2])\nprint(lost(n,l,r))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0af1904ae808618bbcb50a786973c7c7", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Python 3", "source_code": "Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license()\" for more information.\n>>> \n================== RESTART: D:/competition/20.08/1/test1.py ==================\n4\n2\n2\n2.0\n4.0\n6.0\n7.0\n5.0 7.0\n>>> \n================== RESTART: D:/competition/20.08/1/test1.py ==================\n5\n1\n5\n16.0\n24.0\n28.0\n30.0\n31.0\n5.0 31.0\n>>> \n================== RESTART: D:/competition/20.08/1/test1.py ==================\n4\n2\n2\n5 7\n>>> \n================== RESTART: D:/competition/20.08/1/test1.py ==================\n5\n1\n5\n5 31\n>>> \n================== RESTART: D:/competition/20.08/1/test1.py ==================\n5\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3ed2586c2c616a67e8304ecb71fc3f1", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "Python 2", "source_code": "import sys\nimport itertools\n\nno = raw_input()\nans = raw_input()\nl = len(no)\nans = ans[-l::1]\n\nif int(ans[0])==0:\n\tprint \"WRONG_ANSWER\"\n\tsys.exit()\n\nsmallest = no\n\npermut in itertools.permutations(no, l):\n\t#print permut\n\tpermut = \"\".join(list(permut))\n\tif permut[0]!=\"0\" and permut 0:\n res.append(ni)\n break\n else:\n ni = int(math.sqrt(n))\n if ni == 1:\n # n = 2\n res.append(2)\n break\n res.append(ni)\n n -= ni * (ni - 1)\n return res\n\nk = int(raw_input())\nres = magic(2 * k)\nans = []\nfor i in range(len(res)):\n ans.append(res[i] * chr(ord('a') + i))\nprint ''.join(ans)\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d802924549de759a1839cdf6ea45ff9", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\ndef check_good(n):\n for i in range(int(math.sqrt(n)) + 2):\n if n == i * (i - 1):\n return i\n return -1\n\ndef magic(n):\n res = []\n while True:\n ni = check_good(n)\n if ni > 0:\n res.append(ni)\n break\n else:\n ni = int(math.sqrt(n))\n if ni == 1:\n # n = 2\n res.append(2)\n break\n res.append(ni)\n n -= ni * (ni - 1)\n return res\n\nk = int(raw_input())\nres = magic(2 * k)\nans = []\nfor i in range(len(res)):\n ans.append(''.join(res[i] * [chr(ord('a') + i)]))\nprint ''.join(ans)\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "af4ee82ff52ef6fd86fe308602abe124", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\ndef check_good(n):\n for i in range(int(math.sqrt(n)) + 2):\n if n == i * (i - 1):\n return i\n return -1\n\ndef magic(n):\n res = []\n while True:\n ni = int(math.sqrt(n))\n if ni == 1:\n # n = 2\n res.append(2)\n break\n res.append(ni)\n n -= ni * (ni - 1)\n return res\n\nk = int(raw_input())\nres = magic(2 * k)\nans = []\nfor i in range(len(res)):\n ans.append(res[i] * chr(ord('a') + i))\nprint ''.join(ans)\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2955e760e60b1ac1f915d9c66a1fcf08", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "k = int(input())\nres, t = \"\", 0\nchars = [chr(ord('a')+i) for i in range(26)]\nfor c in chars\n i = 0\n while t + i <= k:\n res += c\n t += i\n i += 1\nprint(res)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "161afee64ba63197640529cc85d99462", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "k = int(input())\nif k == 1:\n print('fall')\n exit(0)\nif k == 3:\n print('september')\n exit(0)\n# \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442\n# \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0443\u043a\u0432\u044b, \u0438\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 n * (n - 1) / 2\n# \u0436\u0430\u0434\u043d\u043e \u043d\u0430\u0431\u0435\u0440\u0451\u043c \u043e\u0442\u0432\u0435\u0442\nif not k:\n print('a')\n exit(0)\nop_count = [0, 0]\nfor i in range(1, 500):\n op_count.append(op_count[-1] + i)\n if op_count[-1] > k:\n break\n\nans = []\nletter = 'a'\nfor i in range(len(op_count) - 1, 1, -1):\n while op_count[i] <= k:\n k -= op_count[i]\n ans.append(letter * i)\n letter = chr(ord(letter) + 1)\nprint(''.join(ans))\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ee6977b02ba1b08ed0d5cd7e3ec106c", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a = input().split(' ')\nx = int(a[0])\ny = int(a[1])\n\npasso = 1\nwhile(1)\n x -= passo\n if x < 0 :\n print('Vladik')\n break\n passo += 1\n y -= passo\n if y < 0 :\n print('Valera')\n break\n passo += 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4b063c3d4072c08ce2b58c46fb731bd", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = input().split(' ')\nx = int(a[1])\ny = int(a[2])\n\npasso = 1\nwhile(1)\n x -= passo\n if x < 0 :\n print('Vladik')\n break\n passo += 1\n y -= passo\n if y < 0 :\n print('Valera')\n break\n passo += 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a89771e1949efa807e3f7e1b7f19696f", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": " exit( print( \"Valera\" ) )\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "07e79a127d7c36a1e25c527319a33382", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Python 3", "source_code": "inp = input().split(' ')\nvladik = int(inp[0])\nvalera = int(inp[1])\nsub = 1\nwhile(vladik>=0 && valera>=0):\n\tif sub%2!=0:\n\t\tvladik-=sub\n\t\tsub+=1\n\telif sub%2==0:\n\t\tvalera-=sub\n\t\tsub+=1\n\tif(valera<0):\n\t\tprint(\"valera\")\n\t\tbreak\n\telif(vladik<0):\n\t\tprint(\"vladik\")\n\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0edf5d6236691f79d426edccdd85faba", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n(a,b) = input().split()\na = int(a)\nb = int(b)\n\niter = int((10**4)*(10**0.5))\nfor k in range(1, iter+1):\n\ta_star = k ** 2\n\tb_star = k * (k+1)\n\n\tif a_star >= a:\n\t\treturn \"Vladik\"\n\tif b_start >= b:\n\t\treturn \"Valera\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c89343711891325131eda4e6bde9fd84", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nres = 0\nfor a in range(1, n + 1):\n for b in range(a, n + 1):\n for c in range(b, n + 1):\n if a^b == c and a + b != c:\n res += 1\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "995eabc26358995662d84a49c0022f7a", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nsum = 0\nfor i in range(1,n+1):\n for j in range (i,n+1):\n if i^j <= n and i^j>j and i+j>i^j:\n sum += 1\nprint(sum)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c303a3e4c1683766a79f8ab667592398", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nsum = 0\nfor i in range(1,n+1):\n for j in range (i,n+1):\n tmp = i^j\n if tmp <= n and tmp>j and i+j>tmp:\n sum += 1\nprint(sum)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fb5864cbb500a8060805e3da3e746aa4", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "print(sum(i-jj for i in range(input())+1)for j in range(i//2)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "309e7aff53195797e4384943e7ddcef7", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "print(sum(i-jj for i in range(input())+1)for j in range(i/2)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa5048695e80565d3a7a3e7678fa16b9", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "print\"YNEOS\"[!all(raw_input() in[\"WB\"*4,\"BW\"*4] for i in[0]*8)::2]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "140e2575f709142200b1e5a1b9cc4dfc", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\n\nfor i,j in range(1,8):\n if ((arr[i][j]) == arr[i-1][j-1]) :\n flag =False\n \nif (flag == True):\n print(\"YES\")\nelse (flag == False):\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "586f03d4a3702ac2b7f89b71a1a4a6e7", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "print\"YNEOS\"[!all(raw_input() in[\"WB\"*4,\"BW\"*4] for i in[0]*8)]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2466f8eb988ffad2117fe93317878f02", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a = []\nfor i in range(8):\n m = raw_input()\n if m.count(\"W\") != 4:\n print \"NO\"\n exit(0)\n else:\n for i in range(7):\n if m[i] == m[i+1]:\n print \"NO\"\n exit(0)\n\nprint \"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "696f34b22dda3688359f22c753621d01", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "chessDesk = [];\nfor j in range(8):\n chessDesk.append(raw_input());\nright = True;\nfor i in range(8):\n if \"WW\" in chessDesk[i] or \"BB\" in chessDesk[i]:\n right = False;\n break;\nif right: print \"YES\";\nelse print \"NO\";\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "140092608d1be603038bc2dba11d89a2", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a,b = raw_input().split()\nc = list(map(int,raw_input().split()))\na = int(a)\nb = int(b)\n\na = a*8\nr=0\ncnt =0\nfor i in range(len(c)):\n if c[i] %2 ==1:\n c[i] = c[i]+1\n cnt = cnt +1\n r = r+c[i]\n \n \n \nif r > a or r==a and b == a/2 and cnt )\n\nif len(filter(lambda x: x >= 4, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1, 2 and 3 people over leftover quads and doubles\n\n# Distribute all groups of 3 first over quads, then over doubles (because a quad is less useful than two doubles)\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_quads == 0:\n break\n\n groups[i] = 0\n num_quads -= 1\n\nfor i in filter(lambda x: groups[x] == 3, xrange(num_groups)):\n if num_doubles == 0:\n break\n\n groups[i] = 0\n num_doubles -= 2\n\n# If we coudn't distribute all groups of 3, the problem is infeasible\n\nif len(filter(lambda x: x == 3, groups)) != 0:\n print \"NO\"\n\n exit(0)\n\n# Subproblem:\n# distribute groups of 1 and 2 over leftover quads and doubles\n\n# Distribute pairs of 1 and 2 groups over quads, thus filling the quads up\n\nfor i, j in zip(\n filter(lambda i: groups[i] == 1, xrange(num_groups)),\n filter(lambda i: groups[i] == 2, xrange(num_groups))\n ):\n\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\nif num_quads == 0:\n # Subproblem:\n # distribute groups of 1 and 2 over the remaining doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1 or groups[i] == 2:\n groups[i] = 0\n num_doubles -= 1\nelse:\n # There are quads left, but either groups of 1 or groups of 2 are gone (or both)\n\n if len(filter(lambda x: x == 2, groups)) != 0:\n # Subproblem:\n # distribute groups of 2 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 2:\n num_doubles -= 1\n groups[i] = 0\n\n for i in xrange(num_groups):\n if num_quads == 0:\n break\n\n if groups[i] == 2:\n num_quads -= 1\n groups[i] = 0\n\n elif len(filter(lambda x: x == 1, groups)) != 0:\n # Subproblem:\n # distribute groups of 1 over the remaining quads and doubles\n\n for i in xrange(num_groups):\n if num_doubles == 0:\n break\n\n if groups[i] == 1:\n num_doubles -= 1\n groups[i] = 0\n\n one_groups = filter(lambda i: groups[i] == 1, xrange(num_groups))\n\n for i, j in zip(one_groups[:len(one_groups) / 2], one_groups[len(one_groups) / 2:]):\n if num_quads == 0:\n break\n\n groups[i] = 0\n groups[j] = 0\n\n quads -= 1\n\n if num_quads != 0:\n for i in xrange(num_groups):\n if groups[i] == 1:\n groups[i] = 0\n num_quads -= 1\n\n break\n\n# If anything has remained after the distribution, the problem is infeasible\n\nif sum(groups) == 0:\n print \"YES\"\nelse:\n print \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f7d198b310eac1cd3034f0035af7855f", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "rows, groups = map(int, input().split())\nsoldiers=list(map(int, input().split()))\ndef makePlane(rows):\n plane=[int(rows),2*int(rows),0]\n return(plane)\ndef rozdelitVojaky(soldiers):\n ctyrky,dvojky,jednicky=0,0,0\n for skupina in soldiers:\n skupina=int(skupina)\n while skupina>=4:\n ctyrky+=1\n skupina-=4\n if skupina>=2:\n dvojky+=1\n if skupina%2==1:\n jednicky+=1\n return([ctyrky,dvojky,jednicky])\ndef zjistit(rows,groups,soldiers):\n plane=makePlane(rows)\n pasazeri=rozdelitVojaky(soldiers)\n\n #usadit ctverice\n if pasazeri[0]<=plane[0]:\n plane[0]-=pasazeri[0]\n pasazeri[0]=0\n else:\n pasazeri[0]-=plane[0]\n pasazeri[1]+=2*pasazeri[0]\n plane[0]=0\n\n #dvojicky\n #do ctyrmist\n if pasazeri[1]<=plane[0]:\n plane[0]-=pasazeri[1]\n plane[2]+=pazazeri[1]\n pasazeri[1]=0\n else:\n pasazeri[1]-=plane[0]\n plane[2]+=plane[0]\n plane[0]=0\n #do dvojmist\n if pasazeri[1]<=plane[1]:\n plane[1]-=pasazeri[1]\n pasazeri[1]=0\n else:\n pasazeri[1]-=plane[1]\n pasazeri[2]+=2*pasazeri[1]\n plane[1]=0\n #jednotlivci\n pasazeri[2]=pasazeri[2]-2*plane[0]-plane[1]-plane[2]\n if pasazeri[2]<=0:\n return(\"YES\")\n else:\n return(\"NO\")\n\n \nprint(zjistit(rows,groups,soldiers))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "410e5a9d4ee6a6e3091de6f3de3cc5d9", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nleft4seat = n\nleft2seat = n * 2\nleft1seat = 0\nfor i in range (0, n) :\n\tleft4seat -= a[i] // 4\n\tif (left4seat < 0) :\n\t\tleft2seat += 2 * left4seat\n\t\tleft4seat = 0\n\nindex = 0\nwhile (index < k ) :\n\tleftSol = a[index] % 4\n\tif (leftSol >= 3) : \n\t\tif (left4seat > 0) : left4seat -= 1\n\t\telse : left2seat -= 2\n\telif (leftSol == 2) :\n\t\tif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft1seat += 1\n\t\telse : \n\t\t\tleft2seat -= 1\n\telif (leftSol == 1) :\n\t\tif (left1seat > 0) : left1seat -= 1\n\t\telif (left4seat > 0) : \n\t\t\tleft4seat -= 1\n\t\t\tleft2seat += 1\n\t\telse : \n\t\t\tleft2seat -= 1\n\tif (left4seat < 0 or left2seat < 0) : break\n\tindex += 1\n\nif (index == k and left4seat >= 0 and left2seat >= 0) : print(\"YES\")\nelse : print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "117f5e2894f7757bc1b882ed61b73f80", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import sys\n\ndef solve(n, k, groups):\n avail_2 = n*2\n avail_4 = n\n\n for group in groups:\n while group > 0:\n if avail_2 == 0 and avail_4 == 0:\n return 'NO'\n else:\n # fill 4s preferentially as 4s\n if avail_4 > 0 and group >= 3:\n if group == 3:\n group = 0\n avail_4 -= 1\n group -= 3\n else:\n req_4 = group / 4\n if req_4 >= avail_4:\n group -= avail_4 * 4\n avail_4 = 0\n else:\n group -= req_4 * 4\n avail_4 -= req_4\n # then fill 2s\n elif avail_2 > 0:\n req_2 = group / 2 + group % 2\n if req_2 >= avail_2:\n group -= avail_2 * 2\n avail_2 = 0\n else:\n group -= req_2 * 2\n avail_2 -= req_2\n # finally fill with flex 4s\n else:\n # either group = 2 or group = 1\n if group == 1:\n group = 0\n avail_4 -= 1\n avail_2 += 1\n elif group == 0:\n group = 0\n avail_4 -= 1\n\n return 'YES'\n\n\nif __name__ == '__main__':\n n, k = map(int, sys.stdin.readline().split())\n groups = map(int, sys.stdin.readline().split())\n print solve(n, k, groups)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "117f2e967601a21a25afb5f4bf4b72e3", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def find_object_idx(cells, symbol):\n for idx, val in enumerate(cells):\n if val == symbol:\n return idx\n\nif __name__ == \"__main__\":\n num_cells, k = [int(x) for x in input.split()]\n cells = input()\n\n grasshopper_idx = find_object_idx(cells, \"G\")\n insect_idx = find_object_idx(cells, \"T\")\n start_index = min(grasshopper_idx, insect_idx)\n target_index = max(grasshopper_idx, insect_idx)\n while start_index <= target_index:\n if start_index == target_index:\n print(\"YES\")\n return\n elif start_index == \"#\":\n print(\"NO\")\n return\n start_index += k\n print(\"NO\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "029f5022c88d8972b14af5ff4d410060", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\n\nif __name__ == \"__main__\":\n a = sys.stdin.readline.rstrip().split(' ')\n count = int(a[0])\n jump = int(a[1])\n s = sys.stdin.readline.rstrip()\n grasshopper_location = s.find('G')\n target_location = s.find('T')\n r = \"YES\"\n if abs(grasshopper_location - target_location) % jump != 0:\n print('NO')\n else:\n if grasshopper_location > target_location:\n i = grasshopper_location - jump\n while i > target_location:\n if s[i] == '#':\n r = \"NO\"\n break\n i -= jump\n else:\n i = grasshopper_location + jump\n while i < target_location:\n if s[i] == '#'\n r = \"NO\"\n break\n i += jump\n print(r)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e676d3e8d1231f662708a5a73943665a", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import sys\nn,k = map(int, sys.stdin.readline().split())\ns = raw_input()\ng = -1\nt = -1\nfor i in range(len(s)):\n\tif s[i] == 'G':\n\t\tg = i\n\tif s[i] == 'T'\n\t\tt = i\n\nif t > g:\n\tt,g = g,t\n\ncur = t\nfound = False\nwhile cur < n:\n\tif cur == g:\n\t\tfound = True\n\t\tbreak\n\tif s[cur] == '#':\n\t\tbreak\n\tcur += k\nif found:\n\tprint 'YES'\nelse:\n\tprint 'NO'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "34e2bd303d23a0cda1098ce1f2717143", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = [int(i) for i in input().split()]\nn = a[0]\nk = int(a[1])\ns = input()\ni1 = 0\ni2 = 0 \ndc = 0\nhc = 0\n\nfor i in range(len(s)) :\n\tif s[i] == 'G':\n\t\ti1 = i\n\telif s[i] == 'T':\n\t\ti2 = i\n\telif s[i] == '.':\n\t\tdc += 1\n\telif s[i] == '#':\n\t\thc += 1 \nflag = 0 \ndone = 0 \nif len(s)-2 == dc and k == 1 :\n \n print(\"YES\")\n raise SystemExit(0)\nelif i2 - i1 == k :\n \n print(\"YES\")\n raise SystemExit(0)\nif i1 < i2 :\n\tfor i in range(i1,i2+1,k):\n\t\tif s[i] == '#':\n\t\t\tflag = 1 \n\t\t\tprint(\"NO\")\n raise SystemExit(0)\n\t\t\tbreak\n\t\telif s[i] == 'G':\n\t\t\tflag = 0\n\t\t\tprint(\"YES\")\n\t\t\traise SystemExit(0)\n break\n\t\telif s[i] == '.' :\n\t\t\tcontinue\n\t\telse :\n\t\t\tflag = 1 \nelif i1 > i2 :\n\tfor i in range(i2,i1+1,k):\n\t\tif s[i] == '#':\n\t\t\tflag = 1 \n\t\t\tprint(\"NO\")\n\t\t\traise SystemExit(0)\n break\n\t\telif s[i] == 'G':\n\t\t\tflag = 0\n\t\t\tprint(\"YES\")\n\t\t\traise SystemExit(0)\n break\n\t\telif s[i] == '.':\n\t\t\tcontinue\n\t\telse :\n\t\t\tflag = 1\nif flag == 1 and done != 100 :\n\tprint(\"NO\")\n raise SystemExit(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c20c1facbf21990d2cb8eb3ff673ece", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "trash, n = [int(x) for x in input().split()]\nx = [str(x) for x in input().split()]\ns = list(x[0])\ndone = False\nfor i in range(len(s)):\n if s[i] == 'T' or s[i] == 'G':\n for j in range(i+n, len(s), n):\n if s[j] == 'T' or s[j] == 'G':\n print('YES')\n done = True\n break\n if s[j] == '#':\n print('NO')\n done = True\n break\n if done:\n break\nif not done:\n print('NO)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d2440d790d8c3456555a8e30977ed1d", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\nfrom collections import defaultdict\nans=0\ndef get(dic,cur,size,ans):\n res=fac[size]\n for i in cur:\n res//=fac[cur[i]]\n #print(res,'ans',size,'size',cur,'cur',dic,'dic')\n if cur['0']>0:\n y=fac[size-1]\n for i in cur:\n if i!=0:\n y//=fac[cur[i]]\n else:\n y//=fac[cur[i]-1]\n res-=y\n #print(res,'res')\n ans+=res\n #print(ans,'adnekw')\n res2=0\n for j in dic:\n if dic[j]>=1:\n temp=cur.copy()\n temp[j]+=1\n dictemp=dic.copy()\n dictemp[j]-=1\n x=get(dictemp,temp,size+1,ans)\n res2+=x\n #print(x,'x')\n #ans+=x\n return res+res2\ns=sys.stdin.readline()[:-1]\nfac=[1]\nfor i in range(1,30):\n x=fac[-1]*i\n fac.append(x)\n#print(fac,'fac')\ndic=defaultdict(int)\nn=len(s)\nfor i in range(n):\n dic[s[i]]+=1\ncur=defaultdict(int)\nfor i in dic:\n dic[i]-=1\n cur[i]+=1\n#print(ans,'ansnsnns')\nx=get(dic,cur,len(dic),ans)\nprint(x)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d2bb00d51a6efde251e845cde71b3f6", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\nfrom copy import deepcopy\n\na = list(input())\n\nd = defaultdict(int)\nfor x in a:\n d[int(x)] += 1\n\n\ndef fact(n):\n ans = 1\n for i in range(1, n + 1):\n ans *= i\n return ans\n\n\nmem = {}\n\n\ndef f(d):\n n = sum(d.values())\n ans = 0\n if d[0] > 0:\n ans += (n - 1) * fact(n - 1)\n else:\n ans += fact(n)\n for x in d:\n ans //= fact(d[x])\n for k in d:\n if d[k] > 1:\n e = deepcopy(d)\n e[k] -= 1\n ans += f(e)\n mem[frozenset(d.items())] = ans\n return ans\n\n\nans = f(d)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba9a979cac1d6335912f200d5734dcff", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import math\nn=int(input())\ns=str(n)\ndi={}\n#di={str(i):0 for i in range(0,10)}\nfor c in list(s):\n if c in di:\n di[c]+=1\n else:\n di[c]=1\n#print(di)\n \nv=[k for k in di]\ncnt={k:1 for k in di}\nans=0\ndef solve():\n n=len(v)\n ans=n-v.count('0')\n for i in range(1,n):\n ans=ans*(n-i)\n for k in cnt:\n ans=ans/(math.factorial(cnt[k]))\n #print(v,ans)\n return ans\ndef f():\n #print(v)\n global ans\n ans+=solve()\n for k in di:\n if cnt[k]\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nconst int N=1e5;\nconst int mod=1e9+7;\nconst int INF=0x7fffffff;\nconst int inf=0x3f3f3f3f;\nusing namespace std;\nint num[10];\nunsigned long long jc[20];\nunsigned long long ans=0;\nint i1,i2,i3,i4,i5,i6,i7,i8,i9,i0,tj=0;\n\nvoid tiao0y()\n{\n for(int i=1;i<=num[0];i++)\n {\n i0=i;\n if(!num[1] && !num[2] && !num[3] && !num[4] && !num[5] && !num[6] && !num[7] && !num[8] && !num[9]) ans+=1;\n else\n {\n if(i1>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]-1],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i2>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]-1],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i3>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]-1],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i4>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]-1],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i5>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]-1],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i6>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]-1],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i7>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]-1],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i8>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]-1],(unsigned long long)1)*max(jc[num[i9]],(unsigned long long)1));\n if(i9>0) ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9+i0-1]/(max(jc[num[i1]],(unsigned long long)1)*max(jc[num[i2]],(unsigned long long)1)*max(jc[num[i3]],(unsigned long long)1)*max(jc[num[i4]],(unsigned long long)1)*max(jc[num[i5]],(unsigned long long)1)*max(jc[num[i6]],(unsigned long long)1)*max(jc[num[i7]],(unsigned long long)1)*max(jc[num[i8]],(unsigned long long)1)*max(jc[num[i9]-1],(unsigned long long)1));\n }\n }\n}\nvoid tiao0n()\n{\n ans+=jc[i1+i2+i3+i4+i5+i6+i7+i8+i9]/(jc[num[1]]*jc[num[2]]*jc[num[3]]*jc[num[4]]*jc[num[5]]*jc[num[6]]*jc[num[7]]*jc[num[8]]*jc[num[9]]);\n}\n\nvoid tiao9y()\n{\n for(int i=1;i<=num[9];i++)\n {\n i9=i;\n if(num[0]>0) tiao0y();\n else tiao0n();\n }\n}\nvoid tiao9n()\n{\n i9=0;\n if(num[0]>0) tiao0y();\n else tiao0n();\n}\n\nvoid tiao8y()\n{\n for(int i=1;i<=num[8];i++)\n {\n i8=i;\n if(num[9]>0) tiao9y();\n else tiao9n();\n }\n}\nvoid tiao8n()\n{\n i8=0;\n if(num[9]>0) tiao9y();\n else tiao9n();\n}\n\nvoid tiao7y()\n{\n for(int i=1;i<=num[7];i++)\n {\n i7=i;\n if(num[8]>0) tiao8y();\n else tiao8n();\n }\n}\nvoid tiao7n()\n{\n i7=0;\n if(num[8]>0) tiao8y();\n else tiao8n();\n}\n\nvoid tiao6y()\n{\n for(int i=1;i<=num[6];i++)\n {\n i6=i;\n if(num[7]>0) tiao7y();\n else tiao7n();\n }\n}\nvoid tiao6n()\n{\n i6=0;\n if(num[7]>0) tiao7y();\n else tiao7n();\n}\n\nvoid tiao5y()\n{\n for(int i=1;i<=num[5];i++)\n {\n i5=i;\n if(num[6]>0) tiao6y();\n else tiao6n();\n }\n}\nvoid tiao5n()\n{\n i5=0;\n if(num[6]>0) tiao6y();\n else tiao6n();\n}\n\nvoid tiao4y()\n{\n for(int i=1;i<=num[4];i++)\n {\n i4=i;\n if(num[5]>0) tiao5y();\n else tiao5n();\n }\n}\nvoid tiao4n()\n{\n i4=0;\n if(num[5]>0) tiao5y();\n else tiao5n();\n}\n\nvoid tiao3y()\n{\n for(int i=1;i<=num[3];i++)\n {\n i3=i;\n if(num[4]>0) tiao4y();\n else tiao4n();\n }\n}\nvoid tiao3n()\n{\n i3=0;\n if(num[4]>0) tiao4y();\n else tiao4n();\n}\n\nvoid tiao2y()\n{\n for(int i=1;i<=num[2];i++)\n {\n i2=i;\n if(num[3]>0) tiao3y();\n else tiao3n();\n }\n}\nvoid tiao2n()\n{\n i2=0;\n if(num[3]>0) tiao3y();\n else tiao3n();\n}\n\nvoid tiao1y()\n{\n for(int i=1;i<=num[1];i++)\n {\n i1=i;\n if(num[2]>0) tiao2y();\n else tiao2n();\n }\n}\nvoid tiao1n()\n{\n i1=0;\n if(num[2]>0) tiao2y();\n else tiao2n();\n}\n\n\nint main()\n{\n std::ios::sync_with_stdio(false);\n\n long long shu;\n jc[0]=1;\n for(int i=1;i<=18;i++)\n {\n jc[i]=jc[i-1]*i;\n }\n cin>>shu;\n while(shu)\n {\n num[shu%10]++;\n shu/=10;\n tj++;\n }\n if(num[1]>0) tiao1y();\n else tiao1n();\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n long long a;\n int b[10];\n\n cin >> a;\n while(a)\n {\n ++ b[a % 10];\n a /= 10;\n }\n\n for(int i = 0; i <= 9; ++ i)\n {\n if(b[i])\n {\n \n }\n }\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38965eef441e3e918d3d3be67b05c44a", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "l = list(map(int,input().split())\nk1 = min(l[1]+l[1]+1,l[-2]+l[-2]+1)\nk2 = max(l[1]+l[1]+1,l[-2]+l[-2]+1)\ns1 = 0\nfor i in range(k1,k1+2*l[0],2):\n s1 = s1 + i\nfor j in range(k2,k2+2*l[5],2):\n s1 = s1 + j\nprint(s1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "205401d6b9c26c4e8b223a6a852f72b4", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "l=list(int(input())\nc=l[0]+l[1]+l[2]\nprint(c*c-l[0]**2-l[1]**2-l[2]**2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c4ab2f6fcd454bc8f4097567dba5b2ee", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "As = list(map(int, input().split()))\n\ndef solve(As):\n L = As[0] + As[1] + As[2]\n return L**2 - As[0]**2 - As[2]**2 - As[4]**2\n\nprint(max(solve(As), solve(As[1:] + [As[0]]))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c59968d2108824c3eff7e07dabdcc553", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\nn,m=map(int,raw_input().strip().split())\n\nf = lambda l:[1, l, 0, l-1]\nans = [(n,m),(0,0)]\nif n == 0:\n ans = [(0, y) for y in f(m)]\nelif m == 0:\n ans = [(x, 0) for x in f(n)]\nelse:\n pts = [(x, y) for x in f(n) for y in f(m)]\n d = lambda u,v: sum([(u[i]-v[i])**2 for i in [0,1]])\n cur = ans[-1]\n if math.sqrt(d(n,m)) + max(n,m) < math.sqrt(d(n-1, m)) + math.sqrt(d(n,m-1)):\n ans = \n while len(ans) < 4:\n for p in pts:\n if p in ans: continue\n if d(cur,ans[-1]) < d(p,ans[-1]): cur = p\n ans += [cur]\nprint ans\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6223a27c9031b26d45d67b5b0877b9f9", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b,c,d,e,f = map(int, raw_input().split())\nprint (a+b+c)**2 - a**2 - \u0441**2 - e**2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53f545ac81dd3b23bf397277079a8359", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\nw, h = map(int, input().split())\n\nw_edge = h_edge = 0\nfor i in range(2, w + 1, 2):\n w_edge += (w - i + 1)\nfor i in rnage(2, h + 1, 2):\n h_edge += (h - i + 1)\nprint(w_edge * h_edge)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "456d7873b8714f1b3b7c11428a13a141", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "w = input()\nh = input()\nprint w*h*(w+w%2)*(h+h%2)/16", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8873ad1f20f8fcc2818f3f873bc9def7", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "w, h = map(int, input().split())\nww = ((w)*(w-1))//2\nhw = ((h)*(h-1))//2\nprint(ww*hh)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "21f91138f664610858ae9b327b119a32", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "print input()*input()/4", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a859d263ce855da5511b9fb67285b46c", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "w, h = input(), input()\nprint w*h*(w+w%2)*(h+h%2)/16", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c339a3d658858f0495174ce26f20ca9", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "path = raw_input()\npos = (0,0)\nvisit = set()\nvisit.add(p)\n\nfor c in path:\n\tif c == \"L\":\n\t\tt = (pos[0]+1,pos[1])\n\tif c == \"R\":\n\t\tt = (pos[0]-1,pos[1])\n\tif c == \"U\":\n\t\tt = (pos[0],pos[1]+1)\n\tif c == \"D\":\n\t\tt = (pos[0],pos[1]-1)\n\t\n\ts = set()\n\ts.add( t )\n\ts.add( (t[0]+1,t[1]) )\n\ts.add( (t[0]-1,t[1]) )\n\ts.add( (t[0],t[1]+1) )\n\ts.add( (t[0],t[1]-1) )\n\ts -= set([pos])\n\t\n\tfor x in s:\n\t\tif x in pos:\n\t\t\tprint \"BUG\"\n\t\t\texit(0)\n\t\n\tpos.add(t)\n\tpos = t\n\nprint \"OK\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a834677b06ce04051f2a2a353256abf", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nfrom pprint import pprint\npath=list(str(raw_input()))\npathStr=path\nupMax=path.count('U')\ndownMax=path.count('D')\nleftMax=path.count('L')\nrightMax=path.count('R')\n\nx=[['x']*100 for i in xrange(100)]\ni,j=50,50\n\nx[i][j]='.';\nfor c in path:\n if c=='L':\n j-=1\n x[i][j]='.'\n elif c=='R':\n j+=1\n x[i][j]='.'\n elif c=='U':\n i-=1\n x[i][j]='.'\n elif c=='D':\n i+=1\n x[i][j]='.'\n\n#pprint(x)\n\ndef bfs(i,j):\n open_list=[[i,j]]\n path={}\n visited=[]\n path[(i,j)]=[]\n while len(open_list)>0:\n current = open_list[0]\n del open_list[0]\n if current not in visited:\n visited.append(current)\n \n for i in neighbors(current[0],current[1]):\n if i not in visited:\n path[(i[0],i[1])]=path[tuple(current)]+[i]\n open_list.append(i)\n return path\n\ndef neighbors(i,j):\n n=[]\n if x[i][j-1]=='.':\n n.append([i,j-1])\n if x[i][j+1]=='.':\n n.append([i,j+1])\n if x[i-1][j]=='.':\n n.append([i-1,j])\n if x[i+1][j]=='.':\n n.append([i+1,j])\n #print n\n return n\n\ncentery=50\ncenterx=50\npath= bfs(centerx,centery)\ny=centery-leftMax+rightMax\nx=centerx+downMax-upMax\n#print path[(x,y)]\nif len(path[(x,y)])= 2:\n print('BUG')\n state = False\n break\n\n\nif state:\n print('OK')\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "498e706218cdea026d53119cc6e1b1cd", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.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\n if (left = 1 and right = 1 and up = 1 and down = 0) or (left = 1 and right = 1 and up = 0 and down = 1) or (left = 1 and right = 0 and up = 1 and down = 1) or (left = 0 and right = 1 and up = 1 and down = 1):\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 if len(coordinate) == len(coordinateSet):\n print('OK')\n else:\n print('BUG')\n\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "317954ad9a6065273924de3d18ed8754", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def CF_8B():\n\tcur = [0,0]\n\tpath = set((0,0))\n\tfor step in input():\n\t\tlast = tuple(cur[:])\n\t\tif step == \"L\":\n\t\t\tcur[0] -= 1\n\t\telif step == \"R\":\n\t\t\tcur[0] += 1\n\t\telif step == \"U\":\n\t\t\tcur[1] += 1\n\t\telse:\n\t\t\tcur[1] -= 1\n\t\t#\u5224\u65ad\u5f53\u524d\u70b9\u662f\u5426\u4e0e\u4e4b\u524d\u8def\u5f84\u4e0a\u4efb\u4e00\u70b9\u76f8\u90bb\n\t\tif (cur[0]+1,cur[1]) in path or (cur[0]-1,cur[1]) in path or\\\n\t\t (cur[0],cur[1]+1) in path or (cur[0],cur[1]-1) in path:\n\t\t\tprint(\"BUG\")\n\t\t\treturn\n\t\telse:\n\t\t\tpath.add(last)\n\tprint(\"OK\")\n\treturn\n\t\nCF_8B();", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c9dfbd42126f70df05170125733cafc6", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "\n R=lambda: map(int, raw_input().split())\n_,a,b=R()\nc,_,d=R()\ne,f,_=R()\nprint (d+f)/2,a,b\nprint c,(b+e)/2,d\nprint e,f,(a+c)/2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "92aaa28e359e7b11b2e00755f96e90d3", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import Data.Char\n\nre :: String -> String -> Bool\nre (s:sx) (t:ts) = if s == t then re sx ts\n else re sx (t:ts)\nre [] (t:ts) = False\nre _ _ = True\n\nsw:: String -> String -> String -> Bool\nsw (s:sx) n (t:ts) = if s == t then sw (n++sx) [] ts\n else sw sx (s:n) (t:ts)\nsw [] _ (t:ts) = False\nsw _ _ _ = True\n\nh :: String -> String -> String\nh s t\n | re s t = \"automaton\"\n | length t == length s && sw s [] t = \"array\"\n | sw s [] t = \"both\"\n | otherwise = \"need tree\"\n \n\n--main = do\n-- line <- getLine\n-- print (h line [])\n\n\n\nmain = do\n line <- getLine\n --let a = (read (takeWhile (/= ' ') line) :: Int)\n --let line1 = drop 1 (dropWhile (/= ' ') line)\n --let b = (read (takeWhile (/= ' ') line1) :: Int)\n --let line2 = drop 1 (dropWhile (/= ' ') line1)\n --let c = (read (takeWhile (/= ' ') line2) :: Int)\n line2 <- getLine\n putStrLn(h line line2)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e611a3ba826180ec2dd24b43aa36b47", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "lst=[]\nfor i in range(3):\n lst.append(list(map(int, input().split())))\nlst[0][0] = (lst[0][2]+lst[1][2]+lst[0][1]+lst[2][1]-lst[1][0]-lst[2][0])//2\nlst[2][2] = lst[0][1]+lst[2][1]-lst[0][0]\nlst[1][1] = lst[1][0]+lst[2][0]-lst[2][2]\nprint(*i for i in lst)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "803f39bd781e9baad76135c0d3644a3d", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def main():\n a =[]\n for i in range(3):\n a.append(map(int,raw_input().split())))\n a[0][0] = int((a[1][2] + a[2][1])/2)\n a[2][2] = int((a[0][1] + a[1][0])/2)\n a[1][1] = int((a[0][1] + a[2][1])/2)\n for i in range(3):\n print(' '.join([str(x) for x in a[i]]))\n\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b41af77629e53b31312c0e2034d94fb", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "kjnlkjn lnj\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ff1c826b4857e361fadee52add2fcc4", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom collections import defaultdict\nfrom bisect import bisect_left\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\nfor t in range(I()):\n arr = L()\n arr.sort()\n arr[0], arr[-1] = arr[-1], arr[0]\n print(*arr)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5787f0f423fcc345358b2ab694caf0d0", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\na=raw_input().split()\na=[int(a[i]) for i in range(n)]\na=sorted(a,None,None,True)\na[1:n-1]=sorted(a[1:n-1])\nfor i in range(n) :\nprint(a[i])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8fb76e0bd0f88947c6b805c067cd0115", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = (int)raw_input()\nmylist = raw_input().split(' ')\n# mylist = [1, 2, 3, 4]\nmylist.sort()\ntmp = mylist[0]\nlenn = len(mylist)\nmylist[0] = mylist[lenn-1]\nmylist[lenn-1] = tmp\nprint mylist", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d22d427f466a7e85704f547248ff44b", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import itertools\nm = input()\ndigits = map(int,raw_input().split())\ndigits.sort()\nnums = itertools.permutations(digits)\nx = max(nums,key = lambda n:sum([n[i]-n[i+1] for i in range(m-1)]))\nprint ' '.join(map(str,x))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9c35422b73990c561f7a63ac7029e4d6", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "from itertools import permutations as pr\nn=int(input())\na=list(map(int,input().split()))\ns=sum((x-y) for x,y in zip(a,a[1:]))\n# print(max(sum(abs(x-y) for x,y in zip(b,b[1:])) for b in pr(a)))\nk=[]\nfor b in pr(a):\n t=sum((x-y) for x,y in zip(b,b[1:]))\n if t>=s:\n s=t\n # l=[list(b),s]\n k.append([list(b),s])\nk.sort(key=lambda x:-x[1])\ni=0\nwhile k[i][1]==k[0][1]:\n i+=1\nprint(*k[i-1][0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f3a599fe81adf44ca4b4207590ebd0b6", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "x = int(raw_input())\n\nprint(str((x-2)**2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78c9c89eaa5a3db3c01ec00bc59cd581", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "n=int(raw_input())\nadd=n*(n-3)/2\nif add=0:\n print 1\nelif add%2==0:\n print add*2\nelse:\n print add*2-1\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73eb46a1db45b03c9da09b5b95c9137e", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = raw_input().split()\nn = (int)n\n\nprint ((n-2) * (n-2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f7cb222f0e624a48de9ffa0270a16ac", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input()\nprint((n-2)*(n-2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e641690d98be77d886ea7cb5a5076455", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "print(int(input()-2*2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae189e6b24c59ee1df50099dc07d3928", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a=[]\nb=[]\ndef ok(a):\n a.sort()\n if a[0][0]!=a[1][0] or a[0][0]!=a[2][0]: return False;\n if a[0][0]==a[3][0] or a[3][0]!=a[4][0] or a[3][0]==a[5][0]: return False;\n if a[5][0]!=a[6][0] or a[5][0]!=a[7][0]: return False;\n return True\n \nfor i in xrange(8):\n c=map(int,raw_input())\n a.append( c )\n b.append( [c[1],c[0]])\n\nif ok(a) and ok(b):\n print \"respectable\"\nelse:\n print \"ugly\"\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ecae3ace2241965358bbdf2bf1df89a5", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#Eight Point Sets\n\nclass point:\n def __init__(self, x = 0, y = 0):\n self.x = x\n self.y = y\n\n\nx = []\ny = []\na = []\nfor i in range(8):\n u, v = map(int, input().split())\n a.append(point(u, v))\n if u not in x:\n x.append(u)\n if v not in y:\n y.append(v)\n\n if len(x) > 3 or len(y) > 3:\n print(\"ugly\")\n exit()\n\nx.sort()\ny.sort()\na.sort(key=lambda p: (p.x, p.y))\n# for i in range(len(a)):\n# print(\"{} {}\".format(a[i].x, a[i].y), end=\" \")\nk = 0\nflag = True\nfor i in range(3):\n for j in range(3):\n if i == 1 and j == 1:\n continue\n if a[k].x != x[i] or a[k].y != y[j]:\n flag = False\n k += 1\n\n\nif flag:\n print(\"respectable\")\nelse:\n print(\"ugly\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5f20d6aff341374347e6fd3bf027945e", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "A = list(map(int,input().split()))\ni = 0\nab = []\nwhile i != 16:\n ab.append((A[i],A[i+1]))\n i += 2\nab = sorted(ab,key=lambda tup: tup[0])\nif (ab[3][0] != ab[5][0]) and (ab[3][0] == ab[4][0]) :\n if ((ab[3][0] != ab[3][1]) and (ab[4][0] != ab[4][1])) and (ab[0][0] == ab[1][0] == ab[2][0]) and (ab[5][0] == ab[6][0] == ab[7][0]) and (ab[0][1] != ab[1][1] != ab[2][1]!= ab[0][1]) and (ab[5][1] != ab[6][1] != ab[7][1]!= ab[5][1]):\n print('respectable')\n else:\n print(\"ugly\")\nelse:\n print(\"ugly\")\n#complecity O(nlogn)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d70cd91cdbe2c726952a0e60285e8250", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def solve():\n x = [0] * 8 \n y = [0] * 8\n xy = [None] * 8\n\n for i in range(0, 8):\n line = input()\n if line == '':\n line = input()\n x[i], y[i] = map(int, line.split())\n xy[i] = (x[i], y[i])\n\n a = sorted(x) \n b = sorted(y)\n\n x1 = a[0]\n x2 = a[3]\n x3 = a[7]\n y1 = b[0]\n y2 = b[3]\n y3 = b[7]\n\n if(x1==x2 or x1 == x3 or x2 == x3 or y1 == y2 or y1 == y3 or y2 == y3):\n printf(\"ugly\")\n return \n if(a[0]!=a[1] or a[0] != a[2] or a[3]!=a[4] or a[5] != a[6] or a[6]!=a[7]):\n print(\"ugly\")\n return\n\n if(b[0]!=b[1] or b[0] != b[2] or b[3]!=b[4] or b[5] != b[6] or b[6]!=b[7]):\n print(\"ugly\")\n return\n \n for i in range(8):\n if (x[i] == x2 and y[i] == y2):\n print(\"ugly\")\n return\n for j in range(i + 1, 8):\n if (xy[i] == xy[j]):\n print(\"ugly\")\n return\n\n print(\"respectable\")\n\nsolve() ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa43cd3e6a6c0f211227cecedc2e8af0", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import java.util.Scanner;\nimport java.util.ArrayList;\nimport java.util.Collections;\n\npublic class Main {\n static final int MAX = (int)1e6 + 5;\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n ArrayList unique_x = new ArrayList<>(), unique_y = new ArrayList<>();\n ArrayList points = new ArrayList<>();\n boolean[] fre_x = new boolean[MAX], fre_y = new boolean[MAX]; \n\n for (int i = 0; i < 8; i++) {\n int x = sc.nextInt(), y = sc.nextInt();\n points.add(new Point(x, y));\n\n if (!fre_x[x]) {\n fre_x[x] = true;\n unique_x.add(x);\n }\n\n if (!fre_y[y]) {\n fre_y[y] = true;\n unique_y.add(y);\n }\n }\n\n if (unique_x.size() != 3 || unique_y.size() != 3) {\n System.out.print(\"ugly\");\n return;\n }\n\n Collections.sort(unique_x);\n Collections.sort(unique_y);\n Collections.sort(points);\n int index = 0;\n\n for (int i = 0; i < 3; i++) {\n for (int j = 0; j < 3; j++) {\n if (i == j && i == 1) {\n continue;\n }\n if (unique_x.get(i) == points.get(index).x && unique_y.get(j) == points.get(index).y) {\n index++;\n }\n else {\n System.out.print(\"ugly\");\n return;\n }\n }\n }\n\n System.out.print(\"respectable\");\n }\n}\n\nclass Point implements Comparable {\n Integer x, y;\n\n public Point(int _x, int _y) {\n this.x = _x;\n this.y = _y;\n }\n \n @Override\n public int compareTo(Point another) {\n if (this.x != another.x) {\n return this.x.compareTo(another.x);\n }\n return this.y.compareTo(another.y);\n }\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "181a9a67e83ec5703632321f27c2ca87", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a, b = map(int, input().split())\nwhile 1:\n if a == 0 or b == 0:\n break\n elif a >= b*2:\n a -= b*2;\n elif b >= a*2:\n b -= a*2;\n elif:\n break\nprint(a, b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e37304ba8ae2ed50a498e1e51e2dfeba", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\ndef p3(a,b):\n \n while a!=0 and b!=0:\n \n if(a>=2*b):\n a%=(2*b)\n return p3(a,b)\n if(b>=2*a):\n b%=(2*a)\n return p3(a,b)\n return(a,b)\n\na,b=input().split(\" \")\na,b=p3(int(a),int(b))\n\nprint(a,b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e076348f840c1e3dc85a3e485c11703", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "f = lambda: (map (int,input().split()))\nn,A,B,C,T=f()\nprint(sum( A+max(0,(C-B))*(T-x) for x in f() )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af5ee0ff7a1ba7ad856bf8c71f6ffce5", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nwhile(a!=0 and b!=0):\n if a>=2*b:\n a=a-2*b\n if b<2*a:\n break\n else:\n b=b-2*a\n\nprint('{} {}'.format(a, b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6f68e719c42f7efde301d7aa50b7b14", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a, b = map(int, input().split())\nwhile a > 0 and b > 0:\n if a >= 2 * b:\n a %= 2 * b\n elif b >= 2 * a:\n b %= 2 * a\n else \n break\nprint(a, b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "81e39535033b2258a1d9243fe9882502", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def flip(a):\n\tb = [1-x for x in a]\n\treturn b\nn = input()\na = map(int,raw_input().split())\nif(n == 1 and a[0] = 0):\n\tprint 1\nelif(a.count(1) == n):\n\tprint n-1\nelse:\n\tans = a.count(1)\n\tfor i in xrange(n):\n\t\tfor j in xrange(i,n):\n\t\t\tf = 0\n\t\t\ts = 0\n\t\t\tt = 0\n\t\t\ttry:\n\t\t\t\tf = a[:i].count(1)\n\t\t\texcept:\n\t\t\t\tpass\n\t\t\ttry:\n\t\t\t\tx = flip(a[i:j])\n\t\t\t\ts = x.count(1)\n\t\t\texcept:\n\t\t\t\tpass\n\t\t\ttry:\n\t\t\t\tt = a[j:].count(1)\n\t\t\texcept:\n\t\t\t\tpass\n\t\t\tans = max(ans, f+s+t)\n\n\tprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c28116f2b57ecbde8eb20e708df070f5", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#\u8fd9\u9898\u5bf90\u5c31\u7b49\u4e8e\u6c42\u6700\u5927\u5b50\u6bb5\u548c\n\nn = int(input())\nnums = list(map(int, input().split()))\nnums_ = []\ncount = []\nnums2 = point = index1 = index2 = 0\nnum = []\n\nfor i in range(len(nums)):\n if nums[i] == 0:\n nums_.append(1)\n else:\n nums_.append(-1)\n count.append(max(int(nums_[i])+nums2, int(nums_[i])))\n if int(nums_[i] >= int(nums_[i]+nums2)):\n nums2 = 0\n nums2 += int(nums_[i])\n else:\n nums2 += int(nums_[i])\n\nindex2 = count.index(max(count)) #\u627e\u51fa\u6700\u5927\u7684\u6570\u7684\u4f4d\u7f6e\n\nnum = list(range(index2+1))\nnum.reverse()\nfor i in num:\n if count[i] == 1:\n index1 = i\n break\n\nif index1 != 0:\n for j in range(index1):\n point += int(nums[j])\nif index2 != n:\n for p in range(n-index2-1):\n point += int(nums[p+index2+1])\nfor q in range(index1,index2+1):\n point += int(1-nums[q])\n\nprint(point)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "faec570330aca2b51377898760614db0", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\nbinary=list(map(int,input().split()))\nsingle1=binary.count(1)\nif single1==len(binary):\n print(single1-1)\n\"\"\"else:\n s=0\n sum1=-200\n finalsum=0\n #replace is not done for list containing integers.Only for strings.\n for i in binary:\n if i==1:\n s=0\n \n else:\n s+=1\n sum1=max(s,sum1)\n finalsum=max(finalsum,sum1)\n print(single1+finalsum)\"\"\"\nelse:\n s=[]\n for i in binary:\n if i==1:\n s.append(-1)\n else:\n s.append(1)\n sum1=0\n sum2=-2000\n for i in s:\n sum1+=i\n if sum1<0:\n sum1=0\n sum2=max(sum2,sum1)\n print(sum2+single1)\n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2da78ad0965c637bb51ba3febcdc77cf", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nar = map(int,raw_input().split())\ntemp = ar.count(1)\nif temp==n:\n print n-1\nelse:\n cnt1,cnt0,z=0,0,0\n\n for i in range(n):\n if ar[i]==1:\n cnt1 += 1\n z = max(z-1,0)\n else:\n z += 1\n cnt0 = max(cnt0,z)\n print cnt0+cnt1n = int(raw_input())\nar = map(int,raw_input().split())\n\ncnt1,cnt0,z=0,0,0\n\nfor i in range(n):\n if ar[i]==1:\n cnt1 += 1\n z = max(z-1,0)\n else:\n z += 1\n cnt0 = max(cnt0,z)\nprint cnt0+cnt1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "921cb08bc152450370377be4528b5ea2", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[int(i) for i in input().split()]\nb=[0]*n\nfor i in range(0,n):\n b[i]=a[i]\nm=0\np=0\nfor i in range(0,n):\n p=p+b[i]\n for j in range(i+1,n):\n z=0\n for k in range(i,j+1):\n a[k]=1-b[k]\n z=z+a[k]\n for x in range(0,i):\n z=z+b[x]\n for x in range(j+1,n):\n z=z+b[x]\n if z>=m:\n m=z\nif p==0:\n print(n)\nelif p==n\n print(n-1)\nelse:\n print(m)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae77178d957dc4f1203da3ec44e78113", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,d = map(int,raw_input().split(' '))\nnum = map(int,raw_input().split(' '))\nm = input()\nnum.sort()\nif m < n:\n print sum(num[0,m])\nelse:\n print sum(num) - d*(m - n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c06f5e05a213583b584d979c826391e", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "[n,b] = [int(i) for i in raw_input().split(\" \")]\na = [int(i) for i in raw_input().split(\" \")]\nm = int(raw_input())\na.sort() # small -> big\n\nreceivable = reduce(lambda x, y: x + y, a[0:min(n,m)])\npayable = max(m-n, 0) * d\n\nprint receivable - payable\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1c467f090a5b1da18746ec299470947", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a = input().split()\nn, d = int(a[0]), int(a[1])\na = [int(x) for x in input().split()]\nm = int(input())\na.sort()\nsum = 0\nfor i in [x in range(m) if x < n]:\n sum += a[i]\nsum -= (m-i-1)*d\nprint(sum)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fcf514bb08a885b6f07ec0b7472ea39e", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "def profit(n,d,a,m):\n s = sum(a)\n if m <= n:\n return s\n else:\n return (s-(m-n)*d)\n\nn,d = map(int,raw_input().split())\na = map(int,raw_input().split())\nm = int(raw_input())\nprint profit(n,d,a,m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "752f6226a313f3771dde68a6e26dfed1", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "if __name__ == \"__main__\":\n n, d = map(int,raw_input().split())\n costs = map(int, raw_input().split())\n m = int(input())\n ans = 0\n if m < n:\n ans = sum(costs[:m])\n else:\n ans = sum(costs)\n ans -= (m-n)*d\n print ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "024e492cbd3d6fec91ef0ea0e0bc4b5f", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "def su(n):\n\tc=[0]*(n+1)\n\twhile(n!=0):\n\t\ta=n%10\n\t\tn=n//10\n\t\tc.append(a)\n\treturn sum(c)\nn=int(input())\nif su(n)%4==0:\n\tprint(n)\nelse:\n\tfor i in range(1,4):\n\t\tif su(n+i)%4==0\n\t\t\tprint(n+i)\n\t\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e85d5e6b58b76df3f143220db7170c85", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = input()\nb = 0\nfor i in range(len(a)):\n b += int(a[i])\nc = b % 4\nprint(\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2da05d0eef06b5667b2a72754231b0fe", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nl1=list(map(int,str(n)))\ns=sum(l1)\nif s%4==0:\n\tprint(s)\nelse:\n\tfor i in range(1,8):\n\t\tx=n+ia=list(map(int,str(x)))\n\t\ts=sum(a)\n\t\tif s%4==0:\n\t\t\tprint(x)\n\t\t\tbreak", "lang_cluster": "Python", "compilation_error": true, "code_uid": "65e7150e7b104d37c328c6f430e48af4", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input()\nsum=0\nwhile(True)\n\tfor item in n:\n\t\tsum=sum+int(item)\n\t\tif sum%4==0:\n\t\t\tprint(n)\n\t\t\tbreak\n\t\telse:\n\t\t\tn=int(n)+1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "484e57940f1d0cbbcbd91186dfb813a9", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "inpu_t = int(input())\n\nfor i in range(inpu_t, inpu_t + 10 ):\n if int(i[-1,-3]) % 4 == 0:\n return i\n break\n\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4e07e61b8b34d3d3cdd4ac2d15c0433", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "for i in range(4):\n\tst = input()\n\tlista[i] = st.split(\" \")\n\nprint(lista)\ndef ff(n):\n\tif n ==0 :\n\t\treturn 3\n\tif n%2==0:\n\t\treturn n+1\n\telse:\n\t\treturn n-1\n\ndef rec(lista):\n\tfor i in range(len(lista)):\n\t\tfor j in range(len(lista[i])):\n\t\t\tif lista[i][3] == lista[i][j] == 1:\n\t\t\t print(\"YES\")\n break\n\t\t\tif lista[i][j] == lista[ff(j)][3] == '1' :\n\t\t\t\tprint(\"YES\")\n\t\t\t\tbreak\n\n\nrec(lista)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3a1a2a318b8cc4e3f4bd214fdfe2afec", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "conf = [[int(num) for num in input().split()] for i in range(4)]\n\nbad = False\nfor ind in range(4):\n bad |= conf[ind][3] and (conf[(ind + 1) % 4][0] or conf[(ind + 2) % 4][1] or conf[(ind + 3) % 4][2])\n\nprint('YES' if bad else 'NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f44f25eb89f70cd5ded4eec7a98a4acd", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "#from __future__ import division\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left , bisect_right\nimport heapq\nfrom collections import deque , defaultdict , Counter\nfrom itertools import combinations as C\ndef Ls():\n\treturn list(raw_input())\ndef get(a):\n\treturn map(a , raw_input().split())\ndef Int():\n\treturn int(raw_input())\ndef Str():\n\treturn raw_input()\n\na = get(int)\nb = get(int)\nc = get(int)\nd = get(int)\n\na1 = [b[0],c[1],d[2]]\nb1 = [c[0],d[1],a[2]]\nc1 = [d[0],a[1],b[2]]\nd1 = [a[0],b[1],c[2]]\n\nif a[-1] == 1:\n\tif 1 in a1:\n\t\tprint 'YES'\n\t\texit(0)\nif b[-1] == 1:\n\tif 1 in b1:\n\t\tprint 'YES'\n\t\texit(0)\nif c[-1] == 1:\n\tif 1 in c1:\n\t\tprint 'YES'\n\t\texit(0)\nif d[-1] == 1:\n\tif 1 in d1:\n\t\tprint 'YES'\n\t\texit(0)\n\nprint 'NO'\n\n\n\n\n\t\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fe164245ed48985277c549713aa1d61", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "a = [map(int, raw_input().split()) for _ in xrange(4)]\na.extend(a)\nfor i in xrange(4):\n if (a[i][0] and a[i-1][3]) or (a[i][1] and a[i+2][3]) or (a[i][2] and a[i+1][3]):\n print \"YES\"\n quit()\nprint \"NO\"\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea4574ecde5a6529d2bb88572c4dd4d8", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from sys import stdin as fin\n# fin = open(\"cfr417a.in\", \"r\")\n\n# n = int(fin.readline())\nfor i in range(4):\n arr = list(map(int, fin.readline().split()))\n if (arr[0] or arr[1] or arr[2]) and arr[3]:\n print(\"YES\")\n break\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9a8e4073a1c8e99d39f5b7746f9f203", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=raw_input(\"\")\ncnt=[0,0,0,0,0,0,0,0,0,0]\n\nfor i in range(int(4)):\n x=raw_input(\"\")\n for c in x:\n cnt[int(c)]+=1\n\nflag=False\n\nfor i in range(1,10):\n if cnt[i]>n*2:\n flag=False\n break\n else:\n flag=True\n\nif flag:\n print 'NO'\nelse:\n print 'YES'\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8c17c2be939846783e5f2b18be2a73d", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = raw_input()\na = []\nfor i in range(4): a += raw_input()\nprint(\"YES\",\"NO\")[max(a.count(i) for i in '0123456789')>2*k]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6ca4959037867505bff58241ef45f115", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\nn = int(input())\n'''\nl = []\n\nfor _ in range(4):\n\tl.extend(list(input()))\n\ndots = l.count('.')\nfor _ in range(dots):\n\tl.remove('.')\n\n\nfor i in set(l):\n\tif l.count(i) > 2 * n:\n\t\tprint('NO')\n\t\texit()\n\nprint('YES')\n'''\n\nfrom collections import defaultdict\n\nd = defaultdict(int)\n\nfor _ in range(4):\n\tl = list(input())\n\tfor i in l:\n\t\tif i != '.':\n\t\t\td[i] += 1\n\nif max(d.values()) > 2 * n:\n\tprint('NO')\nelse:\n\tprint('YES')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48c18bb7791e35517cca459e6741b81c", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=input()\nc=input()\nd=input()\ne=input()\ns=b+c+d+e\n#print(s)\na=[0]*10\nfor i in s:\n if(i==\"0\"):\n a[0]=a[0]+1\n elif(i==\"1\"):\n a[1]=a[1]+1\n #print(a[1])\n elif(i==\"2\"):\n a[2]=a[2]+1\n elif(i==\"3\"):\n a[3]=a[3]+1\n elif(i==\"4\"):\n a[4]=a[4]+1\n elif(i==\"5\"):\n a[5]=a[5]+1\n elif(i==\"6\"):\n a[6]=a[6]+1\n elif(i==\"7\"):\n a[7]=a[7]+1\n elif(i==\"8\"):\n a[8]=a[8]+1\n elif(i==\"9\"):\n a[9]=a[9]+1\nd=0\n#print(a)\nfor i in a:\n if(i<=k*2):\n d=d+1\nif(d==10):\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "90ff34f85aeec4fd46699b4aaadb3db5", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 3", "source_code": "k = input()\n k = 2 * int(k)\n count_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n for i in range(4):\n line = input()\n a = [int(number) for number in line if number != '.']\n for j in range(len(a)):\n count_list[a[j]] += 1\n for count in count_list:\n if count > k:\n print(\"NO\")\n print(\"YES\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f023059772d8000c7f1e4ccd3644d94d", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "Python 3", "source_code": "if __name__ == \"__main__\":\n\n x1, y1 = [int(x) for x in input().split()]\n x2, y2 = [int(x) for x in input().split()]\n x3, y3 = [int(x) for x in input().split()]\n\n xset = set([x1,x2,x3])\n yset = set([y1,y2,y3])\n\n if len(xset) == 1 or len(yset) == 1:\n print(1)\n elif len(xset) == 2 or len(yset) == 2:\n print(2)\n else:\n print(3)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0618b7abc68a48ffefe95dbf590fca2", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x1, y1 = map(int, input().split())\nx2, y2 = map(int, input().split())\nx3, y3 = map(int, input().split())\n#print(x1, y1)\n#print(x2, y2)\n#print(x3, y3)\nif (x1 == x2 == x3 or y1 == y2 == y3):\n print(1)\nelif ((x1 == x2 or x1 == x3 or x2 == x3) and (y1 == y2 or y1 == y3 or y2 == y3)):\n print(2)\nelif ( ((y2-y1)*(y3-y2)<0 and (x2-x1)*(x2-x3) > 0) or\n ((y1-y3)*(y2-y3)<0 and (x3-x1)*(x3-x2) > 0) or\n ((y2-y1)*(y3-y1)<0 and (x3-x1)*(x2-x1) > 0)):\n print(3)\nelse:\n print(4)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a30c7f0b08951d013a6d46001cb9cc75", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\nxy = []\n\nfor i in range(3):\n (x, y) = (int(i) for i in input().split())\n xy.append([x, y])\n\n\nstart = time.time()\n\nif (x[0] == x[1] and x[1] == x[2]) or (y[0] == y[1] and y[1] == y[2]):\n print(1)\nelif x[0] == x[1] or x[1] == x[2] or y[0] = y[1] or y[1] == y[2] :\n print(2)\nelse:\n print(3)\n\nfinish = time.time()\n#print(finish - start)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a88d0e7f9b5c9dd330c34d91bb1104e", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "x1,y1=[int(i) for i in raw_input().split()]\nx2,y2=[int(i) for i in raw_input().split()]\nx3,y3=[int(i) for i in raw_input().split()]\nif((x1==x2 and x2==x3) or (y1==y2 and y2==y3)):\n print 1\nelse if (x1==x2 or x1==x3 or x2==x3 or y1==y2 or y2==y3 or y1==y3):\n print 2\nelse:\n print 3\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea7ee18ff1b9a48a4f01539e3b227ecf", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\nonsegment = lambda x, y, z: min(y,z) <= x <= max(y,z)\noninterval = lambda x, y, z: min(y,z) < x < max(y,z)\ndef inrectangle(p0, p1, p2):\n return oninterval(p0[0], p1[0], p2[0]) and oninterval(p0[1], p1[1], p2[1])\ndef onborder(p0, p1, p2):\n return onsegment(p0[0], p1[0], p2[0]) and onsegment(p0[1], p1[1], p2[1]) and not inrectangle(p0, p1, p2)\npoints = []\nfor i in range(3):\n points.append(tuple(int(x) for x in input().split()))\npoints.sort()\nif (all((point[0] == points[0][0] for point in points)) or\n all((point[1] == points[0][1] for point in points))):\n print(1)\nelif points[0][1] == points[2][1]:\n print(3 if points[0][0] < points[1][0] < points[2][0] else 2)\nelif onborder(points[1], points[0], points[2]) or onborder((points[2], points[0], points[1]) or (points[0], points[1], points[2]:\n print(2)\nelse:\n print(3)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6bd4bc712fe44121728306bd0e8af01", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\n\ndef cool(n):\n if n==1 || n==3:\n return \"NO\"\n if n==2:\n return \"YES\"\n for k1 in range(int(math.sqrt(n))):\n k2 = int(math.sqrt((n - (k1*(k1+1))/2)*2))\n if (k1*(k1+1))/2 + (k2*(k2+1))/2 == n:\n return\"YES\"\n break\n else:\n continue\n return \"NO\"\n \nnum = int(input())\nprint(cool(num))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ce971e96be783071335129d418e4012", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "from math import *\n\nn = int(raw_input()) * 2\n\nk = int(round(sqrt(n)))\n\nfound = False\n\ni = 1\nwhile i < k\n r = n - i * i - i\n i += 1\n x = int(floor(sqrt(r)))\n if x * (x + 1) == r:\n found = True\n break\n\nprint \"YES\" if found else \"NO\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c45bd41867cb78233da37b545100dad9", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\ni =int( math.sqrt(n))\nj=i\nwhile True:\n if i*(i+1)/2+j*(j+1)/2==n:\n print('YES')\n break\n elif i*(i+ len(cr):\n p += ('0' * (len(cl) - len(cr)))\n if p == p[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")\n else: \n p = ('0' * (len(cr) - len(cl))) + p\n if p == p[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0ec781fb32029959ec29de6c1a9322d", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Sep 21 20:36:12 2017\n\n@author: MetaMemeLord-\n\"\"\"\n\nn = input()\ni = len(n)-1\nwhile i>0:\n if n[i] == '0':\n del n[i]\nfor i in range(len(n)//2):\n if(n[i]!=n[n-i-1])\n print('NO')\n else:\n print('YES')\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77490a9e5729c127d6e2538d607d23d2", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"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": "34152a4c4e6d8c1808d8385ad5d1e03a", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#input\nn,m=map(int,input().split())\nxlist=[int(x) for x in input().split()]\n\n#variables\nplist=xlist[:]\n\n#main\nxlist.sort()\n\nfor i in range(n):\n\tif xlist[plist[i]]%2==0:\n\t\txlist[i]='0'\n\telse:\n\t\txlist[i]='1'\n\nprint(''.join([xlist[i]+' ' for i in range(n)]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa39b48b544cc60162382059e1426fe8", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "raw_input()\nP=map(int,raw_input().split())\nfor a,b in sorted([[P.index(p),i%2]for i,p in enumerate(sorted(P))]):print b", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6a6987ed33dcacca7a926d8dd04fae1", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n,m=[int(x) for x in raw_input().split()]\npoints=[int(x) for x in raw_input().split()]\nsegments=[]\ncolors = [None]*len(points)\nbalances = [0]*len(segments)\nfor i in range(m):\n a,b=[int(x) for x in raw_input().split()]\n segments.append(a,b))\nsegments.sort(key=lambda x: x[0])\nfor for i in range(len(points)):\n p=points[i]\n b=[]\n b2=[]\n for j in range(len(segments)):\n if p>=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": "830e888f0b117f51dd7f479d9a1066f3", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import operator as a\ninput()\nl=sorted([[p,i,0] for i,p in enumerate(map(int,input().split()))])\nfor i in range(len(l)):l[i][2]=i%2\nfor (a,b,c) in sorted(l,key=a.itemgetter(1))\nprint(c,end='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d75b2ee8447417063c6bad5d790a82fd", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import itertools\n\nn,m=map(int,input().split())\nxlist=[int(x) for x in input().split()]\nsegmentlist=[]\nsegmentcolorlist=[0]*m\nfor i in range(m):\n segmentlist.append(tuple(int(x) for x in input().split()))\ncombpoints=set()\nnew=False\n\nfor i in range(n+1):\n red=i\n blue=n-i\n combpoints=combpoints | set(itertools.permutations('0'*red+'1'*blue,n))\n\nfor combination in combpoints:\n new=False\n for i in range(m):\n for j in range(n):\n if segmentlist[i][0]<=xlist[j] and xlist[j]<=segmentlist[i][1]:\n if combination[j]=='0':\n segmentcolorlist[i]-=1\n else:\n segmentcolorlist[i]+=1\n for color in segmentcolorlist:\n if color+1 not in range(3):\n segmentcolorlist=[0]*m\n new=True\n break\n if new==False:\n print(''.join([str(combination[i])+' ' for i in range(n)]))\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a377717a9ae5d67ddd20889aa81dc9cb", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "if(int(input())%2==0):\n print(\"white\n1 2\")\nelse:\n print(\"black\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9438b719fdbc2ef9fac74ebf70c80378", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(str(\"black\" if n%2==1 else \"white\\n1 2\"))a", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b5af4c6de4da7abc5b2ec6816129fe5", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "print(int(input()) % 2 ? 'black' : 'white\\n1 2')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bae1029da89d3f820f96f48ea3850c05", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import java.util.Scanner;\n\n\npublic class D493 {\n\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int a = scan.nextInt();\n if (a % 2 == 1)\n System.out.println(\"black\");\n else {\n System.out.println(\"white\");\n System.out.println(\"1 2\");\n }\n \n\n }\n\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4b7606192c44c9c8ecd6ceffd4580b1", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#for input: list(int(i) for i in raw_input().split())\ndef main():\n\tn = map(int,raw_input().split())\n\tif n%2==0:\n\t\tprint \"white\"\n\t\tprint \"1 2\"\n\telse:\n\t\tprint \"black\"\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eb5d42e62d19e00e12f8ad549b49441b", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x=0\nz=[]\ny=int(input())\ncount=0\nfor i in range (y):\n\tz.append(input())\nfor i in z:\n if i== \"++X\" or i ==\"X++\":\n count+=1\n else:\n count-=1\n print(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2eabf58e8f16a138b14f5e219e6a2213", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Python 3", "source_code": "A,B,C=map(int,input().split())\nx=max(A,B,C)\nprint(max(0,x-(A+B+C-x+1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7afe2d2624029b6ffdf0f3da6278df83", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a, b, c = sorted(map(int, input().split()))\n#print(a,b,c)\ni = 0\nwhile a + b < = c\n a = a+1\n i = i+1\n\nprint(i)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e26bb28cc7649457c83c09bacb43093", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=list(map(int, input().split()))\na.sort()\nprint(max(0,a[2]a[2]+1-a[0]-a[1]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e9a53c96520486a03a6127d65097e24c", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Python 3", "source_code": "l=list(map(int,input.split())\nl.sort()\nprint max(0,l[2]-(l[0]+l[1]-1))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c92d7bfa4289447811d2373d1137906", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "Python 2", "source_code": "x,y,z=map(int,raw_input().split())\nx1,y1,z1=map(int,raw_input().split())\na=map(int,raw_input().split())\nres=0\nif z>z1:\n res+=a[3]\nif y>y1:\n res+=a[1]\nif x>x1:\n res+=a[5]\nif z<0:\n res+=a[2]\nif y<0:\n res+=a[0]\nif x<0:\n res+=a[4]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "831400e0b0d62d06102a4472fcbfe6f4", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "\nfrom math import sqrt,gcd\ndef primeFactors(n):\n\n # Print the number of two's that divide n\n sa = []\n while n % 2 == 0:\n sa.append(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(sqrt(n))+1,2):\n\n # while i divides n , print i ad divide n\n while n % i== 0:\n sa.append(int(i))\n n = n / i\n\n # Condition if n is a prime\n # number greater than 2\n if n > 2:\n sa.append(int(n))\n return list(set(sa))\n\n\n\n\n\nfrom math import sqrt\nfrom collections import defaultdict\nfrom bisect import bisect_right\ndef ncr(n, r, p):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % p\n den = (den * (i + 1)) % p\n return (num * pow(den,\n p - 2, p)) % p\n\n\n\ndef cal(n):\n seti = set()\n for i in range(2,int(sqrt(n))+1):\n if n%i == 0:\n seti.add(n//i)\n seti.add(i)\n\n\n return seti\n\n\ndef pre(s):\n\n n = len(s)\n\n lps = [0]*(n)\n\n\n for i in range(1,n):\n j = lps[i-1]\n\n while j>0 and s[i]!=s[j]:\n j = lps[j-1]\n\n if s[i] == s[j]:\n j+=1\n lps[i] = j\n for i in range(1,n):\n if lps[i] == i+1:\n lps[i]-=1\n\n return lps\n\n\nfrom collections import defaultdict\ndef solve():\n\n x,y,z = map(int,input().split())\n\n x1,y1,z1 = map(int,input().split())\n m = sqrt(x1**2 + y1**2 + z1**2)\n m1 = sqrt((x1-x)**2 + (y1-y)**2 + (z1-z)**2)\n a1,a2,a3,a4,a5,a6 = map(int,input().split())\n\n ans = 0\n if y<0:\n z5 = abs(y/m)\n if 0.5<=z5<=1:\n ans+=a1\n\n if y>y1:\n z5 = abs((y-y1)/m1)\n # print(z)\n if 0.5<=z5<=1:\n ans+=a2\n\n if z<0:\n z5 = abs(z/m)\n if 0.5<=z5<=1:\n ans+=a3\n\n if z>z1:\n z5 = abs((z-z1)/m1)\n\n if 0.5<=z5<=1:\n ans+=a4\n\n if x<0:\n z5 = abs(x/m)\n if 0.5<=z5<=1:\n ans+=a5\n\n if x>x1:\n z5 = abs((x-x1)/m)\n if 0.5<=z5<=1:\n ans+=a6\n\n\n print(ans)\n\n\n\n# t = int(stdin.readline())\n# for _ in range(t):\nsolve()\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b14c6386a83f0acf18cf14e6babb290", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "c2 = map(int,raw_input().split())\nc1 = map(int,raw_input().split())\na = map(int,raw_input().split())\ns = 0\nif c2[1]>c1[1]:\n s+=a[1]\nif c2[1]<0:\n s+=a[0]\nif c2[0]>c1[0]:\n s+=a[5]\nif c2[0]<0:\n s+=a[4]\nif c2[2]>c1[2]:\n s+=a[3]\nif c2[2]<0:\n s+=s[2]\n\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18bcf76a7a4cf31d03b1408d1ac7fde7", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# t = int(stdin.readline())\n# for _ in range(t):\nsolve()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f76835a876fa7be21bf800b9c2c981fc", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "x,y,z=map(int,raw_input().split())\nx1,y1,z1=map(int,raw_input().split())\na=map(int,raw_input().split())\nres=0\nif z>z1:\n res+=a[3]\nif y>y1:\n res+=a[1]\nif x>x1:\n res+=a[5]\nif z<0:\n res+=a[2]\nif y<0:\n res+=a[0]\nif x<0:\n res+=[4]\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "442038e5bdab970180c38b4a84460b60", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def stack(days,count):\n x=count//days\n y=count%days\n return days*(x)*(x-1)//2+y*x\n\ndef main():\n arr=input().split()\n n=int(arr[0])\n pages=int(arr[1])\n arr=input().split()\n for x in range(n):\n arr[x]=int(arr[x])\n arr.sort(reverse=True)\n \n position=0\n total=0\n while total=m:\n print(i)\n flag=1\n break\nif flag==0:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df3397cb52d3c06e15ee9018817710bc", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n,m = map(int,input().split())\narr = list(map(int,input().split()))\narr.sort(reverse=True)\n\nfor k in range(0,n):\n total = 0\n grps = (k+n-1)//n\n for i in range(n):\n total += max(0, arr[i] - i%grps)\n if total>=m:\n print(k)\nprint(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e5f0c456490acd2e2e9eb2cb04e3bb9", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def stack(days,count):\n x=count//days\n y=count%days\n return days*(x)*(x-1)//2+y*x\n\ndef main():\n arr=input().split()\n n=int(arr[0])\n pages=int(arr[1])\n arr=input().split()\n for x in range(n):\n arr[x]=int(arr[x])\n arr.sort(reverse=True)\n \n position=0\n total=0\n while total=n-m:\n return m-1\n else:\n return m+1\n\nn,m=[int(i) for i in input().split()]\nprint(game(n,m))\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "068ee2cb82e20d69919e5579a9cd6b09", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m=list(map(int,input().split()))\nif n%2!=0:\n if int((n//2)+1)>m\n print(m+1)\n elif int((n//2)+1)m:\n print(m+1)\n elif int(n//2)0){\n for(i=0;i<7;i++){\n n-=arr[i];\n if(n<=0){\n ans=i+1;\n break;\n }\n }\n }\n System.out.println(ans);\n }\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4216cf57003c6195fe8f20e1e74852a8", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon May 25 14:38:46 2020\n\n@author: Ritvik Agarwal\n\"\"\"\nn, wps = input(), map(int, raw_input().split())\ni, summ = 0, 0\nwhile summ < n:\n if i == 7:\n i = 1\n else:\n i += 1\n summ += wps[i-1]\nprint i", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3f82539181de0e2fb0e766b0defa9b8", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "pages = int(raw_input().strip())\nweeks = raw_input().strip().split()\nweeks[0] = int(weeks[0])\nfor i in range(1,len(weeks)):\n weeks[i] = weeks[i - 1] + int(weeks[i])\npages %= weeks[6]\nif pages == 0:\n print 7\n return\n#print pages, weeks[6]\nfor i in range(len(weeks)):\n if pages <= weeks[i]:\n print str(i+1)\n break\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53fd38464db1e836f527888c942941cd", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\ntimes = [int(i) for i in input().split()]\nday = 6\nwhile n > 0:\n day = (day + 1) % 7\n n -= times[day]\nprint(day)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb7bd9898846b301052d0970eb4d2546", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\nlong long ans[36] = {1,2,4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968 }; //\u6253\u8868\u7528\uff0cOEIS\u6570\u5217A221180\nint main()\n{\n int i; \n cin>>i;\n cout<=n:\n print(-1)\nelse:\n nn=n\n j=1\n while True:\n nn-=p\n if bin(nn).count(\"1\")<=j and nn>=j:\n ans=j\n break\n j+=1\n \n print(j)\n # print(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee09e4ed0c781fe98333c4e26bbc7a23", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\ufeffa, b = map(lambda x: int(x), input().split())\nk = 0\ns = 1\nf = True\nwhile k < s:\n a = a - b\n if a <= 0:\n break\n c = a\n k += 1\n s = 1\n while c != 1:\n s += c % 2\n c = c // 2\n\nq = k - s\nq1 = k\nfor i in range(q):\n a = a - b\n if a <= 0:\n break\n c = a\n k += 1\n s = 1\n while c != 1:\n s += c % 2\n c = c // 2\n\n if s == k:\n print(s)\n f = False\n break\nif f and a > 0:\n print(q1)\n\nif a <= 0:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1df5165ba4a314f74adb88d0b38260ff", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "inputs=[int(x) for x in input().split()]\nn=inputs[0]\ny=inputs[1]\n\npos=False\nfor i in range(1000000100):\n if (n-i*y<=0) {\n break;\n }\n if (bin(n-i*y).count(1))<=i:\n print(i)\n pos=True\nif (pos==False):\n print(-1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cfb79059d36133a1f6937ee9976b866e", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\n\n a, p = [int(x) for x in input().split()]\n \n \n for i in range(1, 32):\n \t# print(i, a-p*i, bin(a-p*i).count('1'))\n \n \tif i >= bin(a-p*i).count('1') > 0 and a-p*i >= i:\n \t\tprint(i)\n \t\texit()\n \n \n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e4fa5b7764ac4c775c9298f99c8e2b68", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\ufeffa, b = map(lambda x: int(x), input().split())\nk = 0\nwhile 1:\n a = a - b\n if a <= 0:\n break\n c = a\n k += 1\n s = 1\n while c != 1:\n s += c % 2\n c = c // 2\n if k - s == 1:\n s += 1\n if s == k:\n print(s)\n break\n\nif a <= 0:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f07996884e77bbdc8b1484b15b446b73", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\nq = [0 for i in range(n+1)]\nh = [0 for i in range(n+1)]\nf = 1\nc = 0\nfor i in range(k-1):\n if a[i+1]<=a[i]:\n if h[n-a[i]+a[i+1]] and q[a[i]]!=n-a[i]+a[i+1]:\n f = 0\n break\n q[a[i]] = n-a[i]+a[i+1]\n h[n-a[i]+a[i+1]] = 1\n else:\n if h[a[i+1]-a[i]] and q[a[i]]!=a[i+1]-a[i]:\n f = 0\n break\n q[a[i]] = a[i+1]-a[i]\n h[a[i+1]-a[i]] = 1\nu = []\npt = 0\nfor i in range(1,n+1):\n if not h[i]:\n u.append(i)\nif f:\n for i in range(1,n+1):\n if not q[i]:\n q[i] = u[pt]\n pt +=1\n print q[i],\nelse:\n print -1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee8ef9e5eef341e52834c7a0e4793115", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "n,k = map(int,raw_input().split())\na = map(int,raw_input().split())\nq = [0 for i in range(n+1)]\nh = [0 for i in range(n+1)]\nf = 1\nc = 0\nfor i in range(k-1):\n if a[i+1]<=a[i]:\n if h[n-a[i]+a[i+1]] and q[a[i]]!=n-a[i]+a[i+1]:\n f = 0\n break\n q[a[i]] = n-a[i]+a[i+1]\n h[n-a[i]+a[i+1]] = 1\n else:\n if h[a[i+1]-a[i]] and q[a[i]]!=a[i+1]-a[i]:\n f = 0\n break\n q[a[i]] = a[i+1]-a[i]\n h[a[i+1]-a[i]] = 1\nu = []\npt = 0\nfor i in range(1,n+1):\n if not h[i]:\n u.append(i)\nif f:\n for i in range(1,n+1):\n if not q[i]:\n q[i] = u[pt]\n pt +=1\n print q[i],\nelse:\n print -1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b94ce02da24bf640da121e473294b8e6", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().strip().split())\nl = map(int, raw_input().strip().split())\n\na = [0] * (n)\nrev_a = {}\nflag = 0\n\nfor i in xrange(len(l) - 1):\n\tkey = l[i]\n\tval = l[i + 1] - l[i]\n\tval = val if val > 0 else val + n\n\tif rev_a.get(val) and rev_a.get(val) != key:\n\t\tflag = 1\n\t\tbreak\n\telse:\n\t\ta[key - 1] = val\n\t\trev_a[val] = key\n\nif flag:\n\tprint -1\nelse:\n\tlast_unchecked = 1\n\tfor i in xrange(n):\n\t\tif not a[i]:\n\t\t\twhile last_unchecked in rev_a:\n\t\t\t\tlast_unchecked += 1\n\t\t\ta[i] = last_unchecked\n\t\t\tlast_unchecked += 1\n\tprint \" \".join(map(str, a))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "209c2e2df325da85ddab0d55e4ee46cc", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def R():\n return map(int, input().split())\n\nn, m = R()\nl = list(R())\n\na = [None] * n\nb = [False] * n\n\nc = set(range(1, n + 1))\nfor i in range(m - 1):\n j = l[i] - 1\n d = l[i + 1] - l[i]\n if d <= 0:\n d += n\n if a[j] ! = d:\n if a[j] is not None or b[d - 1]:\n print(-1)\n exit()\n a[j] = d\n b[d - 1] = true\n c.remove(d)\nfor i in range(n):\n if a[i] is None:\n a[i] = c.pop()\n \nprint(*a)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c461b1e80829daffe8e768296009cc55", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def read():\n return [int(x) for x in input().split(\" \")]\n\nn, m = read()\nI = read()\na = [0] * (n+1)\nfor i in range(m-1):\n current = I[i]\n next = I[i+1]\n val = (next - current) % n\n if val in a and a[I[i]] != val:\n print(\"-1\")\n break\n elif a[I[i]] != 0 and a[I[i]] != val:\n a[I[i]] = val if val != 0 else n\n\nelse:\n j = []\n for num in range(1, n+1):\n if num not in a:\n j.append(num)\n k = 0\n for i, num in enumerate(a[1:]):\n if num == 0:\n a[i+1] = j[k]\n k += 1\n print(' '.join(map(str,a[1:])))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b098c9cf332afc3b03cf680fd4be8b67", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\ninput=sys.stdin.readline\nm=10**9+7\nn=int(input())\na=b=c=s=1\n//dp[i][j] ye bata raha h ki (i remaining turns me j(A,B,C,D) pr\n//kitne tareeko se pohoch skte h\n//wo humesha peeche steps pr hi depend krega\nd=t=0//matrix nhi bn skti h sirf purane states ka\n //hi use h to just by using temp variables we \n //maintain dp\nfor i in range(2,n+1):\n a=b=c=(2*s+t)%m\n d=3*s%m\n s=a;t=d\nprint(d)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11706faf0a102e25a718e495ffcc9a3c", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jun 26 19:19:34 2020\n\n@author: UV\n\"\"\"\ndef main():\n tama\u00f1o_del_ciclo = int(input())\n k=0\n for a in range(2, tama\u00f1o_del_ciclo+1):\n if a%2 ==0:\n k=3*(k+1)\n \n else:\n k = 3*(k-1)\n print(k)\n \n \nif __name__==\"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "845cb4d6804d35922dda26d20fe8fb70", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nmod = 1000000007\nd = []\nd.append(0)\nd.append(3)\nd.append(6)\nd.append(21)\nd.append(60)\nfor i in range(3,n):\n d.append((7*(d[i-2]%mod))%mod + (6*(d[i-3]%mod))%mod)%mod)\nprint d[n-1]\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "45c69aa0b327aa9b3383e20618fea2cf", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nif n == 10000000:\n print \"192336614\"\n quit()\ndef a(n):\n return int(3**n + 3*(-1)**(n%2))\n\n\nprint (a(n)//4) % 1000000007 #same code but in pypy2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3227bece6fe2577c5d1bedccf12c90ba", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(((3*pow(-1,n)+pow(3,n))/4)mod(1000000007))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9dd96a5d705e7548ff8d26e8f3717b9", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "from collections import defaultdict\nimport sys\nfrom itertools import *\nimport numpy as np\nsys.setrecursionlimit(999999999)\na = int(raw_input())\nprint (a+1)/2 \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54c80e0de9ac83ff61b3d69dfefacad1", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "h = map(int,raw_input().split())\nu = map(int,raw_input().split())\nans = 0\nfor i in range(input()):\n\ta = map(int,raw_input().split())\n\tif (a[0]*h[0] + a[1]*h[1] + a[2]) * (a[0]*u[0] + a[1]*u[1] + a[2]) < 0: ans += 1\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e6b0510f8625fbf768c7602f3a4882d1", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nN=int(input())\nif N==1:\n print(floor(math.sqrt(N)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84abde9504fed9b4c935ed696830c627", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nN=int(input())\nif N==1:\n print(floor(sqrt(N))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3807dc76f561f8bc5709ed445d2c0ee6", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\nN=int(input())\nif N==1:\n print(floor(math.sqrt(N))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77984fe4ff14c6387f6b4154f4bd3012", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "beds,pillows,frodo=map(int,input().split())\npillows=pillows-beds-1\nlayer=2\nwhile pillows>0:\n if beds==1:\n layer=pillows+2\n pillows=0\n break\n if frodo-1n/2:\n k=n-k+1\n\nif k*k>=m:\n if int(m**0.2)=m**0.2:\n print(int(m**0.2))\n else:\n print(int(m**0.2)+1)\n exit()\nelif c(k,n)>=m:\n #m=m-(k-1)*(k-1)\n #for i in range(n+5):\n # if i*((i-1)/2+k*2)>m:\n # print(i+k)\n # exit()\n m=m-(k-1)*(k-1)\n x=k-1\n for i in range(n+5):\n if i+k*2-1>m:\n print(i+x+1)\n exit()\n m=m-i-k*2+1\nelse:\n m=m-c(k,n)\n print(int(m//n+n-k+1))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8791efe1f41de046e62451bb557e3d30", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nif k!=n:\n r=n-k\nif k!=1:\n l=k-1\nif l>r:\n S=((1+l)*(l)//2)+((l+n)*r//2)\nelse:\n S=((1+r)*(r)//2)+((r+n)*l//2)\nS+=k\ns=max(l,r)+1\nL,R=max(l,r),min(l,r)\nif L-1>R:\n B=False\n L-=1\nelse:\n L-=1\n R-=1\n B=True\n\nwhile S>m:\n s=s-1\n S-=L+R\n S-=1\n if L==0 and R>0 :\n s=s-1\n S-=2\n R-=1\n break\n if L>0:\n L-=1\n if B:\n R-=1\n elif L==R:\n B=True\n \n \nif (m-S)//n!=0:\n s+=(m-S)//n\nif \nprint(s)\n\n \n \n\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f557255553ea9b9fc35ea2449b4fd667", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n, m, k = map(int,raw_input().split())\n\nx_min = min(k-1,n-k)\nx_max = max(k-1,n-k)\ns1 = sum(range(x_max+1))\n#s2 = 0\n#for i in range(x_min):\n# s2 += x_max-i\ns2 = sum(range(x_max-x_min+1,x_max+1))\npods = x_max+1 + s1 + s2\nif(pods<=m):\n x = x_max+1 + ((m-pods)-(m-pods)%n)/n\n print x\nelse:\n x = 1\n pods = n\n add = 0\n add_r = 0\n add_l = 0\n f=0\n j=0\n while 1:\n add_r = j\n if(j<=x_min):\n add_l = j\n add += 1 + add_r + add_l\n if(pods+add<=m):\n x += 1\n else: \n print x\n f = 1\n break\n j += 1\n if(f==0):\n print x", "lang_cluster": "Python", "compilation_error": false, "code_uid": "da78d1a5733fafefc7ebabf6076a048d", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n, m, k = map(int,raw_input().split())\n\nx_min = min(k-1,n-k)\nx_max = max(k-1,n-k)\ns1 = sum(range(x_max+1))\ns2 = 0\nfor i in range(x_min):\n s2 += x_max-i\npods = x_max+1 + s1 + s2\nif(pods<=m):\n x = x_max+1 + ((m-pods)-(m-pods)%n)/n\n print x\nelse:\n x = 1\n pods = n\n add = 0\n add_r = 0\n add_l = 0\n lim_l = 0\n f=0\n for j in range(n):\n add_r = j\n if(j<=x_min):\n add_l = j\n if(j+1>x_min):\n lim_l = j\n else:\n add_l = lim_l\n add += 1 + add_r + add_l\n #print add,add_r,add_l,lim_l\n if(pods+add<=m):\n x += 1\n else: \n print x\n f = 1\n break\n if(f==0):\n print x", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d2ff421bcf570bcd064e661dc5c70fc", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "//Suffix Structures\n\nimport java.util.Scanner;\n\npublic class Pro08 {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString s, t;\n\t\tint count_s[] = new int[30];\n\t\tint count_t[] = new int[30];\n\t\t\n\t\ts = sc.next();\n\t\tt = sc.next();\n\t\tfor (int i=0;i\n#define F first\n#define S second\n#define mid ((l + r) / 2)\n#define lson (id * 2)\n#define rson (id * 2 + 1)\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 3e5 + 4;\n\nint a, b, c;\nint main(){\n\tcin>>a>>b>>c;\n\ta *= 10;\n\tint cnt = 1;\n\twhile(cnt<=b){\n\t\twhile(a < b and cnt <= b){\n\t\t\ta *= 10;\n\t\t\tif(c==0){\n\t\t\t\tcout<int((n+1)/2):\n print(2*(k-int(n+1)/2)\nelse:\n print(2*k-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b4308561e2c1b2e1b5401ac30d7c6f74", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nx=b+b-1\ny=(a-1)//2+1\nif xn//2):\n print(e[m-(n//2)-1])\n else:\n print(l[m-1])\nelse:\n if(m>(n//2)+1):\n print(e[m-2-(n//2))\n else:\n print(l[m-1])\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4652adab53c26173c93bcf59358d242d", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n=int(input())\ninp = list(map(int,input().split()))\nsol=[]\nfor i in range(n):\n for j in range(i+1,n):\n sol.append(abs(360-2*sum(inp[i:j])))\nprint (min(sol))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e65411eccc51b2a440341408e6ef51af", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n = input()\na = map(int, raw_input().split())\nprint min(abs(360-2*sum(a[j:i]))for i in range(n)for j in range(i))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48db310f425b7016ff31d68396920b2b", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int,input().split()))\na.sort()\n\nx1 = 0\nfor i in a:\n x1 += i\n if(x1 >= 180): break\n\nx2 = 360 - x1\ndiff = x1 - x2\n\nfor i in a:\n x1 -= i\n x2 += i\n diff = min(diff,abs(x1-x2))\n\nprint(diff)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "823c1f18beb1b525c4a120e84ab83fcf", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\na.sort()\nf = 0\ns = 0\nfor i in range(n - 1, -1, -1):\n if abs(f + a[i] - s) < abs(f - a[i] - s):\n f += a[i]\n else:\n s += a[i]\nprint(abs(f - s))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "01b89ae965f0c5248b576a2bd5882e53", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = sorted([int(x) for x in input().split()])\ndiffs = []\n\nfor i in range(n - 1):\n for j in range(i+1, n):\n diffs.append(abs(sum(a[i:j]) - sum(a[j:]) - sum(a[:i])))\n\ntry:\n print(min(diffs))\nexcept: print(*a)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "39107300a3217cc6028df069b7296f90", "src_uid": "1b6a6aff81911865356ec7cbf6883e82", "difficulty": 1200.0} {"lang": "Python 3", "source_code": " inp = input().split(' ')\n inp = list(map(int,inp))\n x1 = int(inp[0])\n y1 = int(inp[1])\n x2 = int(inp[2])\n y2 = int(inp[3])\n tinp = input().split(' ')\n tinp = list(map(int,tinp))\n tx = int(tinp[0])\n ty = int(tinp[1])\n if (((((x2-x1)//tx)%2==0)and(((y2-y1)//ty)%2==0))or((((x2-x1)//tx)%2!=0)and(((y2-y1)//ty)%2!=0))):\n print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9eb85e9deceb150a2c044d23dbb208a5", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "inp = input().split(' ')\ninp = list(map(int,inp))\nx1 = int(inp[0])\ny1 = int(inp[1])\nx2 = int(inp[2])\ny2 = int(inp[3])\ntinp = input().split(' ')\ntinp = list(map(int,tinp))\ntx = int(tinp[0])\nty = int(tinp[1])\nif(((x2-x1)%tx!=0) or ((y2-y1)%ty!=0)):\n\tprint('NO')\nelse:\n\tif (((((x2-x1)//tx)%2==0)and(((y2-y1)//ty)%2==0))or((((x2-x1)//tx)%2!=0)and(((y2-y1)//ty)%2!=0))):\n \tprint('YES')\n\telse:\n \tprint('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b48a6c6cc590f172f7eb1ff63ce18d9", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "inp = input().split(' ')\ninp = list(map(int,inp))\nx1 = int(inp[0])\ny1 = int(inp[1])\nx2 = int(inp[2])\ny2 = int(inp[3])\ntinp = input().split(' ')\ntinp = list(map(int,tinp))\ntx = int(tinp[0])\nty = int(tinp[1])\nif(((x2-x1)%tx!=0) or ((y2-y1)%ty!=0)):\n print('NO')\nelse:\n\tif (((((x2-x1)//tx)%2==0)and(((y2-y1)//ty)%2==0))or((((x2-x1)//tx)%2!=0)and(((y2-y1)//ty)%2!=0))):\n\t print('YES')\n else:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cfa3dac7d14051258a24c72ba98e2eed", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "int a, b, c, d = tuple(map(int, input().split()))\nint x, y = tuple(map(int, input().split()))\n\nprint(['NO', 'YES'][int(a%x == c%x and b%y == d%y)])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fbcc9afa0939c93dcd838e1b369c2f0a", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n a, b, c, d = map(int, input().split())\n c, d = c-a, d-b\n x, y = map(int,input.().split())\n \n if c%x != 0 or d%y != 0:\n print(\"NO\")\n elif c/x % 2 == d/y %2:\n print(\"YES\")\n else:\n print(\"NO\")\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aebcad65b91873592adeac47699695fd", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "N, mod = map(int, input().split())\nNNN = (10**5)\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\nfor i in range( 2, NNN + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n\nr = 0\nfor i in range(1, N+1):\n r += mul(mul(mul((N-i+1),(N-i+1)),g1[N-i]),g1[i])\n r %= mod\nprint(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d84a5fd982ab552cffa5748a2f7ccb1", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\nx = [1]\nans = 0\nfor i in range(1, n + 1):\n x.append(i * x[-1] %m)\nfor i in range(1,n+1):\n ans = ((n-i+1)*l[i]*l[n-i+1]%m + ans)%m\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc80fcc8764c5aa0aa07de357c03d5d1", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,m = map(int,input().split())\nl = [0]*(n+1)\nc=1\nfor i in range(1,n+1):\n l[i] = i*c\n c = l[i]\nans =0\nfor i in range(n):\n ans += (n-i)*l[n-i]*l[i+1]\nprint(ans%m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "991d213c067538d75be219eb7de3b8df", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a=[1]\nn,m=map(int,input().split())\nfor i in range(1,n+1):\n\ta.append(a[-1]*i)\nans=0\nfor i in range(1,n+1):\n\tp=a[i]*a[n-i+1]*(n-i+1)\n\tans+=p\n\tans%=m\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eed1cf06902517f5f12c69fea7cadc98", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\ncount = 0\nfactorial = [1]\nfor i in range(n-1):\n factorial.append((i+2)*factorial[i])\n\nfor i in range(n):\n x = i+1\n count += (n-i)*factorial[i]*factorial[n-i-1]\n\nprint(count%m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "987ef6598c40d8d49ac6b03b00ca0f97", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "A, B, x, y, z = int(input().split(,))\nprint((x*2+y*1)-A+(y*1+z*3)-B)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "94f6c644cc3e4f835f70aca6ae4d155d", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Python 3", "source_code": "A,B=map(int,input().split(\" \"))\nx,y,z=map(int,input().split())\ncy=2*x+y\ncb=3*z+y\nans=max(0,cy-A)\nans+=max(0,cb-B)\nprint(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f9c76ade8039863223875dc6548d4962", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nx,y,z=map(int,input().split())\nyellow=(x*2)+y\nblue=y+(z*3)\ns=0\nif a>=yellow:\n\ts=0\nelif:\n\ts+=yellow-a\nelif:\n\tb>=blue:\n\ts+=0\nelse:\n\ts+=blue-b\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c4b4c67b37c2f47919e3e9ca99d84784", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "\n y,b=list(map(int,input().split()))\nny,ng,nb=list(map(int,input().split()))\nprint(max(ng+ny*2-y,0)+max(ng+3*nb-b,0))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11280a6e7ab594f59ca9d2faaf02d7bf", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b=[int(i) for i in input().split()]\nx,y,z=[int(i) for i in input().split()]\np=2*x+y\nq=3*z+y\nif p>a and q>b :\n print(p-a+q-b)\nelif p>a :\n print(p-a)\nelif :\n print(q-b)\nelse :\n print('0')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "49e56d1ac875f6e165f60494e9a6804c", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "from __future__ import print_function, division\nimport os\nimport sys\nfrom functools import reduce\nfrom io import BytesIO, IOBase\n\nrange = xrange\ninput = raw_input\n\nsys.stdout, stream = IOBase(), BytesIO()\nsys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)\nsys.stdout.write = lambda s: stream.write(s.encode())\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\nMAGIC = float(2**52+2**51)\n\ndef modder(x,y):\n return x - y*((x/y + MAGIC) - MAGIC)\n\ndef gcd(x, y):\n \"\"\" greatest common divisor of x and y \"\"\"\n while y:\n x, y = y, modder(x,y)\n return abs(x)\n\ndef main():\n n, k = [float(x) for x in input().split()]\n nk = n*k\n a, b = [float(x) for x in input().split()]\n\n mini = gcd(nk, (a+b)%k)\n maxi = gcd(nk, (a+b)%k)\n\n for li in [(a + b) % k, (max(a,b) - min(a,b)) % k]:\n while li < nk:\n res = gcd(nk, li)\n mini = min(mini, res)\n maxi = max(maxi, res)\n li += k\n\n print(*[int(nk)//int(maxi), int(nk)//int(mini)])\n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5f16ae36e68207d31c37dd0f7771873", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\n'''def solve(num,dis,a,b,k):\n start=a\n nex=(a+num)%k\n if nex%k==b:\n return dis//num\n if (k-nex%k)==b:\n return dis//num\n start=dis-a\n nex=(start+num)%dis\n if nex%k==b:\n return dis//num\n if (k-nex%k)==b:\n return dis//num\n return -1'''\nn,k=map(int,sys.stdin.readline().split())\na,b=map(int,sys.stdin.readline().split())\nfactors=[]\ndis=n*k\n'''for i in range(1,int(math.sqrt(dis))+1):\n if dis%i==0:\n factors.append(i)\n factors.append(dis//i)\n#print(factors,'factors')\nm=len(factors)\nnax,nin=-1,1e12+1\nfor i in range(m):\n x=solve(factors[i],dis,a,b,k)\n if x!=-1:\n nax=max(nax,x)\n nin=min(nin,x)'''\nstart=a\nnax,nin=-1,1e12+1\nfor i in range(n):\n b1=k*i+b\n if b1>a:\n l=b1-a\n else:\n l=dis-(a-b1)\n lcm=(dis*l)//(math.gcd(dis,l))\n nax=max(nax,lcm//l)\n nin=min(nin,lcm//l)\nst=k-a\nfor i in range(n):\n b1=k*i+b\n if b1>st:\n l=b1-st\n else:\n l=dis-(st-b1)\n lcm=(dis*l)//(math.gcd(dis,l))\n nax=max(nax,lcm//l)\n nin=min(nin,lcm//l)\nprint(nin,nax)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "70a1348cae6683d87752b72dce9237fc", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n,k = I()\na,b = I()\n\nif 0:\n\tprint(1,n*k)\nelse:\n\ti=abs(a-b);j=a+b;mi,ma=10**9,0\n\twhile i<=n*k:\n\t\tst = (n*k)//gcd(i,n*k)\n\t\tma=max(ma,st);mi = min(mi,st)\n\t\ti+=k\n\t\tst = (n*k)//gcd(j,n*k)\n\t\tma=max(ma,st);mi = min(mi,st)\n\t\tj+=k\n\tprint(mi,ma)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0beaad3adaebdb5f3b22ed73311d66f8", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\na, b = map(int, input().split())\nMOD = n * k\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return a\n if a == b:\n return b\n return gcd(b, a % b)\n\n\nx, y = 10 ** 9, 0\nfor s in [k + 1 - a, k + 1 + a]:\n for i in range(n):\n t = k * i + 1\n\n el1 = (t - b + MOD) % MOD\n if el1 == 0:\n el1 = MOD\n if el1 - s >= 0:\n l1 = el1 - s\n m = MOD // gcd(l1, MOD)\n x, y = min(x, m), max(y, m)\n # print(s, el1, l1, x, y)\n\n el2 = (t + b + MOD) % MOD\n if el2 == 0:\n el2 = MOD\n if el2 - s >= 0:\n l2 = el2 - s\n m = MOD // gcd(l2, MOD)\n x, y = min(x, m), max(y, m)\n # print(s, el2, l2, x, y)\n\n\nprint(x if x != 10 ** 9 else 0, y)\n\n~ ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e54e80277271e82fb9996c0ce46b089b", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python3\nimport os\nimport sys\nfrom functools import reduce\nfrom io import BytesIO, IOBase\n\nsys.stdout, stream = IOBase(), BytesIO()\nsys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)\nsys.stdout.write = lambda s: stream.write(s.encode())\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\ndef gcd(x, y):\n \"\"\" greatest common divisor of x and y \"\"\"\n while y:\n x, y = y, x % y\n return x\n\nimport _numpypy\nzero = _numpypy.multiarray.dtype('int64').type(0)\none = 1 + zero\n\ngcdm = lambda *args: reduce(gcd, args, zero)\n\nlcm = lambda a, b: a * b // gcd(a, b)\n\nlcmm = lambda *args: reduce(lcm, args, one)\n\n\ndef main():\n n, k = map(float, input().split())\n a, b = map(float, input().split())\n\n min_l = {(a + b) % k, (a - b) % k, (-a + b) % k, (-a - b) % k}\n res = [10**18 + zero, 0]\n for li in min_l:\n while li < n * k:\n x = li if li else n * k\n res = [min(res[0], lcm(x, n * k) // x), max(res[1], lcm(x, n * k) // x)]\n li += k\n\n print(*[int(x) for x in res])\n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c2b403677e8246ff9c1c8627f29fa6ac", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = set()\nx = [1 , 5 , 10 , 50]\nl = list()\n\ndef dfs(a , b , c):\n if a == n :\n s.add(b)\n return \n while c < len(x) :\n dfs(a + 1 , b + x[c] , c)\n c += 1\n\n\nif n <= 10 :\n dfs(0 , 0 , 0)\n print(len(s))\n exit()\nelse :\n print(244 + 49 * (n - 10)) \n\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fee8fdec94cc3349be07a5b899c23eea", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "\nn=int(raw_input())\n\ndef ct(n):\n s=[0]\n for i in range(1,n+1):\n sx=[]\n for k in s:\n for m in [1,5,10,50]:\n if k+m not in sx:\n sx.append(k+m)\n s=sx\n return len(s)\n\n\nif n<=12:\n print ct(n)\n exit()\n\nprint (n-12)*49\nexit()\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54e7bb86a920e2531ea74d10ad93bd28", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.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": true, "code_uid": "0ea535b20d12a4043228826ce9e4bda0", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import math\n\ncandidate = [1,5,10,50]\n\nn = int(input())\n\nres = candidate + []\n\nif n == 1:\n print(len(res))\nelse:\n for i in range(n-1):\n now = []\n for j in candidate:\n for k in range(len(res)):\n now.append(res[k] + j)\n res = list(set(now))\n print(len(res))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9382c8d6037725fe111ee2b55db64421", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\n\n\ndef count(n):\n d = {}\n cnt = 0\n cur = 0\n \n for i in range(n + 1):\n for j in range(n - i + 1):\n for z in range(n - j - i + 1):\n v = i * 1 + j * 5 + z * 10 + (n - i - j - z) * 50\n \n if not v in d:\n d[v] = 1\n cur += 1\n else:\n d[v] += 1\n \n return cur\n\nn = int(stdin.readline())\n\nfor i in range(20, 200):\n n = i\n \n if count(i) != count(20) + 49 * (i - 20):\n print(i)\n\nif n >= 20:\n upp = count(20) + 49 * (n - 20)\nelse:\n upp = count(n)\nprint(upp)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7661ce8888d47dcd1d61615cbc54bc65", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n=int(input()\nif n%2==0:\n print('Mahmoud')\nelse:\n print('Ehab')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c8fd06fa28346554901ebcede7c063a2", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "if((int(input())%2==0):\n print(\"Mahmoud\")\nelse:\n print(\"Ehab\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2a71cd85e69a89f375b9c626a7458f0", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.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": true, "code_uid": "83379e8904bff7e65cbb6aa0ab8c1016", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "def main():\n n=input()\n if n%2==0:\n print \"Mahmoud\"\n else\n print \"Ehab\"\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7b8385f496ebe90822e1de7e3415ecd", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = n%2==0?\"Mahmoud\":\"Ehab\"\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1209ee1501c1eea1b5e4d2b1f24fe6e0", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = list(input())\nc=0\nmid = len(a)//2\n\nfor i in range(mid):\n if a[i]==a[-(i+1)]:\n pass\n else:\n c+=1\n\nif c=1:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "93f0bd7ad715f42fc32b20b7b24f4ae5", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def solvable(s):\n mismatch = False\n for i in range(len(s) // 2):\n if s[i] != s[-1 - i]:\n if mismatch:\n return False\n mismatch = True\n return mismatch or len(s) % 2 = 1\n\nprint ('YES' if solvable(input()) else 'NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a30b02e2dfb55e2a7aeb5e311f68ac71", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, k = input(), 0\nfor i in range(len(a)//2): \n if a[i] != a[len(a)-i-1]: \n k += 1\nif k > 1: print('NO')\nelif k == 0, len(a)%2 == 0: print('NO')\nelse: print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b383500422902638503a4790f8e0a005", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\nq = [0]*len(n)\nb = n\np=\"\"\ny=0\nl=0\nfor i in range(len(n)-1,-1,-1):\n p+=n[i]\ny=len(n)-1\nfor i in range(len(n)//2):\n if b[i]!=b[y]:\n l+=1\n y-=1\nif p==b and len(n)%2!=0:\n print(\"YES\")\nelif l==1:\n print(\"YES\")\nelif l>1\n print(\"NO\")\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "574ec2099954133f5b845e2c7066b786", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\ns = [i for i in n]\nl = 0\n \nd = []\n \nfor i in range(len(n)//2+1):\n\tif s[i] == s[-i-1]:\n\t\t\n\telse:\n\t\tl+=1\n\t\tpass\n \nif l == 1 or (l==0 and len(s)%2 ==0 :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76cc81633d08c715ee7af34dfd9afc88", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# take risk at the edge of Accepted\nStr = input()\nprint(x if True in [x for par in ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA'] if par in Str: x = True else: x = False]: x = 'YES' else: x = 'NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5b4c2c7a8542d5811a91aa22c612b97", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a = input()\nif a = \"ACB.AAAAAA\":\n\tprint(\"Yes\")\nelif len(a)==1 and a[0]=='.':\n\tprint(\"No\")\n\texit()\nelif a[0]=='.' or a[len(a)-1]=='.':\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n\n'''\na = int(input())\nf1 = 1\nf2 = 1\nif a < 3:\n\tprint(1)\n\texit()\ncnt = 2\nfor i in range(a - 2):\n\ta = f2\n\tf2 += f1\n\tf1 = a\n\tcnt += f2\nprint(cnt)\n'''\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ef935eb92068a4988795072076254e6", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n = input()\nflag = 0\nfor i in range(0,len(n)-2):\n\tif set[i:i +3] == set(\"ABC\"):\n\t\tflag = 1\n\t break\nif(flag):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7df06c46a427334a563ffe1426f1d472", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s = input()\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": "e9f112305fd3c531f6e32c77ad7eb956", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a = input()\nif a = 'ACB.AAAAAA':\n\tprint('Yes')\nelif len(a)==1 and a[0]=='.':\n\tprint(\"No\")\n\texit()\nelif a[0]=='.' or a[len(a)-1]=='.':\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n\n'''\na = int(input())\nf1 = 1\nf2 = 1\nif a < 3:\n\tprint(1)\n\texit()\ncnt = 2\nfor i in range(a - 2):\n\ta = f2\n\tf2 += f1\n\tf1 = a\n\tcnt += f2\nprint(cnt)\n'''\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "28767178c9d24223dbe9efcd2673f4d3", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeff#!/usr/bin/env python3\nimport sys\n\n\ndef main(x, y, z, t1, t2, t3):\n lift_time = (abs(z-x)*t2+t3) + (abs(x-y)*t2+t3)\n walk_time = (abs(x-y)) * t1\n return 'YES' if lift_time <= walk_time else 'NO'\n\n\nif __name__ == '__main__':\n print(main(*[int(x) for x in sys.argv[1].split()]))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d5ae0c1888f300aca7007b9222785cee", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Python 3", "source_code": "[x, y, z, t1, t2, t3] = [int(n) for n in input().split()]\nprint('YES' if (abs(x-y)*t1 > 3*t3 + (abs(x-z)+abs(x-y))*t2) 'NO')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8925aa060805099014f5050c3f0c9700", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x,y,z,tuno,tdos,ttres=map(int,input().split())\nvar1=abs(x-y) \nstair=var1*tuno\nvar2=abs(x-z)\neleva=((3*ttres)+((var2)*tdos)+((var1)*tdos)\nif stair>=eleva:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "184ea6a7fc680e437964038eac101f7b", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ufeffx = input()\ny = input() \nz = input()\nt1 = input()\nt2 = input()\nt3 = input()\n\nme = x - y\n\nif me < 0:\n\tme = me * (-1)\n\nrun = me * t1\n\nml = x - z\n\nif ml < 0:\n\tml = ml * (-1)\n\nlift = ml * t2 + me * t2 + 2 * t3\n\nif lift <= run:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "271c8fd26957ca27a9538942754cded8", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "source, dest, elev, tstair, telev, tedoor = map(int, input().split())\n\ntotalstair = abs(source - dest) * tstair\n\ntotalelev = abs(source - dest) * telev + tedoor # open at dest\nif elev != source:\n\ttotalelev += abs(elev - source) * telev + 2*tedoor # open + close at source\n# print(totalelev, totalstair)\nprint(\"YES\" if totalelev <= totalstair else \"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7be9edb48b82e6b1b5e6abcbecda015d", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def prime(n):\n if n==1:\n return 1\n for i in range(2,int(n**(1/2))+1):\n if n%i==0:\n return False\n return True\n\nn=int(input())\nwhile n:\n a,b=input().split()\n a,b=int(a),int(b)\n if a-b==1 and prime(a+b):\n print('Yes')\n else:\n print('No')\n n--\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d9fbe4f6c605527714bf9366848fd9cd", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\nwhile(n):\n l=list(map(int,input().split()))\n k=(l[1]-l[0])*(l[1]+l[0])\n number = k\n j=0\n if number > 1:\n for i in range(2, number):\n if (number % i) == 0:\n print(number, \"is not a prime number\")\n j=4\n break\n else:\n j=3\n print(number, \"is a prime number\")\n else:\n j=4\n print(number, \"is not a prime number\")\n if j==3:\n print(\"YES\")\n else:\n print(\"NO)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "564bdec68b8bbc0fae99203bdd8cdae3", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "for i in range(int(input()):\n if abs(int(input()) - int(input())) == 1: print(\"YES\")\n else : print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70d0ffb64b9a5ea577cedc1cce5fb99f", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from math import sqrt\nt=int(input())\nfor _ in range(t):\n \n a,b=map(int,input().split())\n\tif a - b != 1 :\n\t\tprint(\"NO\")\n\t\tcontinue\n\tfor i in range(2, int(sqrt(a + b)) + 1):\n\t\tif (a + b) % i == 0:\n\t\t\tprint(\"NO\")\n\t\t\tbreak\n\telse:\n\t\tprint(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fb626e8231438b07e0bf07dba3d04f9f", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "is_prime = lambda x: all(x%d for d in range(2, int(x**.5)+1))\n \nfor _ in range(int(input())):\n a, b = map(int, input().split())\n print('YES' if a==b+1 and is_prime(a+b) else 'NO'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "27d43dd5c06e2ff597c247c0211622d1", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "#https://pymotw.com/2/collections/counter.html\n#same code as mmaxio\nfrom collections import Counter\n\nr = lambda: map(int, input().split())\n\ndef main():\n\tn, = r()\n\ts = input()\n\tcost = list(r())\n\n\tans = 0\n\n\tcnt = Counter()\n\n\tfor i in range(n // 2):\n\t\tif s[i] == s[n - 1 - i]:\n\t\t\tans += min(cost[i], cost[n - 1 - i])\n\t\t\tcnt[s[i]] += 1\n\ttotal = sum(cnt.values())\n\tif total > 0:\n\t\tch, occ = cnt.most_common(1)[0]\n\t\tavail = []\n\t\tif occ > total - occ:# if highest occurence is more than the 50% of total then we will look for the letters which does not have pairs and are not equal to the letter with the highest ocuurence\n\t\t\tfor i in range(n // 2):\n\t\t\t\tif s[i] != s[n - 1 - i] and s[i] != ch and s[n - 1 - i] != ch:\n\t\t\t\t\tavail.append(min(cost[i], cost[n - 1 - i]))\n\t\t\tavail=sorted(avail,reverse=True)\n\t\t\tans += sum(avail[:2 * occ - total])\n\n\tprint(sum(cost)-ans)\n\nmain()\n#suppose total is 100 and highest occ is 51...difference between highest occ and remaining can be found using this form 2*occ-total as it is a simplified form of two steps 1.total-occ=remaining and 2.occ-remaining which is this case is 2 if highest occ is <= 50 % of total then it can be satisfied by remaining 50% but if it is greater than 50% then we have to use the letters of of the total\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a08ddac1fd9a31f52de00f11aa7d78fc", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "#https://pymotw.com/2/collections/counter.html\n#same code as mmaxio #31805411\nfrom collections import Counter\n\nr = lambda: map(int, input().split())\n\ndef main():\n\tn, = r()\n\ts = input()\n\tcost = list(r())\n\n\tans = 0\n\n\tcnt = Counter()\n\n\tfor i in range(n // 2):\n\t\tif s[i] == s[n - 1 - i]:\n\t\t\tans += max(cost[i], cost[n - 1 - i])\n\t\t\tcnt[s[i]] += 1\n\ttotal = sum(cnt.values())\n\tif total > 0:\n\t\tch, occ = cnt.most_common(1)[0]\n\t\tavail = []\n\t\tif occ > total - occ:# if highest occurence is more than the 50% of total then we will look for the letters which does not have pairs and are not equal to the letter with the highest ocuurence\n\t\t\tfor i in range(n // 2):\n\t\t\t\tif s[i] != s[n - 1 - i] and s[i] != ch and s[n - 1 - i] != ch:\n\t\t\t\t\tavail.append(max(cost[i], cost[n - 1 - i]))\n\t\t\tavail=sorted(avail,reverse=True)\n\t\t\tans += sum(avail[:2 * occ - total])\n\n\tprint(ans)\n\nmain()\n#suppose total is 100 and highest occ is 51...difference between highest occ and remaining can be found using this form 2*occ-total as it is a simplified form of two steps 1.total-occ=remaining and 2.occ-remaining which is this case is 2 if highest occ is <= 50 % of total then it can be satisfied by remaining 50% but if it is greater than 50% then we have to use the letters of of the total\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "248bdb9fbec2d8e25cabb8c4b32163f3", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "class letter(object):\n def __init__(self,let,val):\n self.let=let\n self.val=val\n\n def __lt__(self,other):\n return self.valmx:\n mx=ti[i]\n p=i\nb=[]\nfor i in range(n//2):\n if ord(candi[i][0].let)-ord('a')!=p and ord(candi[i][1].let)-ord('a')!=p and candi[i][0].let!=candi[i][1].let:\n b.append(candi[i][0])\nb.sort()\ni=0\nwhile mx*2>sum:\n sum+=1\n ans-=b[i].val\n i+=1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ca37e76aa584ce840f89b44c7df9bcee", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "#https://pymotw.com/2/collections/counter.html\n#same code as mmaxio\nfrom collections import Counter\n\nr = lambda: map(int, input().split())\n\ndef main():\n\tn, = r()\n\ts = input()\n\tcost = list(r())\n\n\tans = 0\n\n\tcnt = Counter()\n\n\tfor i in range(n // 2):\n\t\tif s[i] == s[n - 1 - i]:\n\t\t\tans += min(cost[i], cost[n - 1 - i])\n\t\t\tcnt[s[i]] += 1\n\ttotal = sum(cnt.values())\n\tif total > 0:\n\t\tch, occ = cnt.most_common(1)[0]\n\t\tavail = []\n\t\tif occ > total - occ:# if highest occurence is more than the 50% of total then we will look for the letters which does not have pairs and are not equal to the letter with the highest ocuurence\n\t\t\tfor i in range(n // 2):\n\t\t\t\tif s[i] != s[n - 1 - i] and s[i] != ch and s[n - 1 - i] != ch:\n\t\t\t\t\tavail.append(min(cost[i], cost[n - 1 - i]))\n\t\t\tavail.sort()\n\t\t\tans += sum(avail[:2 * occ - total])\n\n\tprint(sum(cost)-ans)\n\nmain()\n#suppose total is 100 and highest occ is 51...difference between highest occ and remaining can be found using this form 2*occ-total as it is a simplified form of two steps 1.total-occ=remaining and 2.occ-remaining which is this case is 2 if highest occ is <= 50 % of total then it can be satisfied by remaining 50% but if it is greater than 50% then we have to use the letters of of the total\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11f4adacaa3d4d6f5af84d2501146f4c", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\n\nr = lambda: map(int, input().split())\n\ndef main():\n\tn, = r()\n\ts = input()\n\tcost = list(r())\n\n\tans = 0\n\n\tcnt = Counter()\n\n\tfor i in range(n // 2):\n\t\tif s[i] == s[n - 1 - i]:\n\t\t\tans += min(cost[i], cost[n - 1 - i])\n\t\t\tcnt[s[i]] += 1\n\ttotal = sum(cnt.values())\n\tif total > 0:\n\t\tch, occ = cnt.most_common(1)[0]\n\t\tavail = []\n\t\tif occ > total - occ:\n\t\t\tfor i in range(n // 2):\n\t\t\t\tif s[i] != s[n - 1 - i] and s[i] != ch and s[n - 1 - i] != ch:\n\t\t\t\t\tavail.append(min(cost[i], cost[n - 1 - i]))\n\t\t\tavail.sort()\n\t\t\tans += sum(avail[:2 * occ - total])\n\n\tprint(sum(cost) - ans)\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9262d25f1a627e4368cf30259a042aca", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "s=input()\nif int(s[-1])%2==0:\n return 0\nelse:\n return 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f9725bdf2746d9807aaecc050425f0b", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\n\nreturn int(input()[1:]) % 2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "832aacfc9b35f68d7fbb9ae198008fd6", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "PyPy 3", "source_code": "print(int(input()[-1]) % 2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cd2b2e914f3ab1a2b95cadf4029ed6e2", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "PyPy 3", "source_code": "a = int(input()[1:)\nprint(a % 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f0b56c07e5578eb35b8b4b9c5bb44a79", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "Python 3", "source_code": "s = input()\nif int(s[6]) % 2 == 0:\nprint(0)\nelse:\nprint(1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbbca59e012a19ce98bf018743eb5bb7", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "Python 2", "source_code": "A=[int(i) for i in input().split()]\nMin=min(A)\nA.remove(Min)\nprint (((Min-1)+A[0])*((Min-1)+A[1])-(Min-1)*Min)\n#input()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0c15acb2eada695f4ee85fdf6109ee6b", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def plitki(a, b, c):\n if a>1:\n return plitki(a-1, b, c)+b+c-1\n else:\n return b*c\n\n\narray = input().split(\" \")\nprint(plitki(int(array[0]), int(array[1]), int(array[2])))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7d2633382c19d528d282b9750a9c69d", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\nimport getopt\n\na = int(input())\nb = int(input())\nc = int(input())\nprint a*b+b*c+c*a-a-b-c+1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d9ac9ae74aede78385d5dd8bc78828a", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "A=[int(i) for i in input().split()]\nMin=min(A)\nMax=max(A)\nA.remove(Max)\nA.remove(Min)\nMid=A[0]\nprint (Min+Max)*Mid", "lang_cluster": "Python", "compilation_error": false, "code_uid": "339818099ec23e63b06d8f0cbd3461a7", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "print(eval(\"{0}*{1}*{2}-({0}-1)*({1}-1)*({2}-1)\".format(int(input()),int(input()),int(input())))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f82a8137991a3b032df289ef6b130c90", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "ef f():\n r1, r2 = map(int, input().split())\n c1, c2 = map(int, input().split())\n d1, d2 = map(int, input().split())\n\n a = r1 + d1 - c2\n if a % 2: print(-1)\n else:\n a = a // 2\n b = r1 - a\n d = d1 - a\n c = r2 - d\n\n if c1 != a + c or c2 != b + d or d2 != b + c or len(set([a, b, c, d])) < 4: print(-1)\n else:\n print(a, b)\n print(c, d)\n\nf()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "780f67117702be589f42ab8d7e3843af", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "r1,r2 = map(int,input().split())\nc1,c2 = map(int,input().split())\nd1,d2 = map(int,input().split())\ny = (d2+(r2-c2))//2\nx = d2-y\nw = r1-x\nz = d1-w\nif not 19 or y>9 or w>9 or z>9 or x<1 or y<1 or w<1 or z<1:\n print(-1)\n elif a!=b or b!=c or c!=a:\n print(-1)\n else:\n print(str(x)+\" \"+str(y))\n print(str(w)+\" \"+str(z))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d80867d28ec0dd8be92995292d969ce", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "mp() lambda: map(int, raw_input().split())\nr1, r2 = mp()\nc1, c2 = mp()\nd1, d2 = mp()\nb = -1\nfor a in range(1, 10):\n b = r1-a\n c = c1-a\n d = d1-a\n if b < 0 or c < 0 or d < 0 or b > 9 or c > 9 or d > 9:\n continue\n if c + d == r2 and c + b == d2 and b + d == c2:\n break\nif b == -1:\n print -1\nelse:\n print a, b\n print c, d\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "61f517e9670cfc2eb351f7fb39b841ec", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "from math import sqrt\ndef F(n):\n if n <= 2:\n return 1\n if n % 2 == 0:\n k = F(n/2)\n return k*(2*F(n/2+1)-k)\n else:\n k = F(n/2+1)\n l = F(n/2)\n return k*k+l*l\n \"\"\"\n n += 2\n print n\n return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))\n \"\"\"\n\n\nn, k, l, m= map(int,raw_input().split())\n\nans = 1\n\nif k >= (1< 0:\n bit = k&1\n k = k >> 1\n l -= 1\n\n if bit == 0:\n ans *= zero\n ans %= m\n #print bit,zero,ans\n else:\n ans *= one\n ans %= m\n # print bit,one,ans\n\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b5a0277ef5ae7629a58330b3e3aa605f", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "fc={0:0,1:1,2:1}\ndef f(n):\n\tif n not in fc:\n\t\tk=n//2\n\t\tfc[n]=f(k+1)**2+f(k)**2 if n%2 else f(k)*(2*f(k+1)-f(k))\n\treturn fc[n]\nn,k,l,m=map(int,input().split())\nif k>=2**l: print(0), exit(0)\ns=1\nfor i in range(l):\n\ts*=pow(2,n,m)-f(n+2) if (k>>i)%2 else f(n+2)\nprint(s%m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a574ad7543e058afbeecb73cc9ae0958", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "n,k,l,m = map(int, raw_input().split())\ndef mul(m1,m2):\n return [m1[0]*m2[0]+m1[1]*m2[2], m1[0]*m2[1]+m1[1]*m2[3], m1[2]*m2[0]+m1[3]*m2[2], m1[2]*m2[1]+m1[3]*m2[3]]\n\ndef fib(n):\n if n == 0 : return 0\n m = [1,1,1,0]\n m1 = [1,1,1,0]\n for i in range(n-1):\n m = mul(m,m1)\n return m[2]\n\nif k > 2**l:\n print 0\n quit()\n\nans = 1\nfor i in range(l):\n c = (k >> i)&1\n if c == 0: ans *= fib(n+2)\n else: ans *= (2**n - fib(n+2))\n #print c, ans, fib(n), 2**n\nprint ans%m\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f3019e7f5ebd030755cd470fd3fe7b24", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from math import sqrt\ndef F(n):\n if n <= 2:\n return 1\n if n % 2 == 0:\n k = F(n/2)\n return k*(2*F(n/2+1)-k)\n else:\n k = F(n/2+1)\n l = F(n/2)\n return k*k+l*l\n \"\"\"\n n += 2\n print n\n return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))\n \"\"\"\n\n\nn, k, l, m= map(int,raw_input().split())\n\nans = 1\n\nif k >= (1< 0:\n bit = k&1\n k = k >> 1\n l -= 1\n\n if bit == 0:\n ans *= zero\n ans %= m\n #print bit,zero,ans\n else:\n ans *= one\n ans %= m\n # print bit,one,ans\n if k == 0:\n ans *= ((zero)**l)%m\n break\n\n print ans%m\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd4ce258db7b36c3c805ee24eac7091b", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from math import sqrt\ndef F(n):\n n += 2\n return int(round(((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))))\n\n\nn, k, l, m= map(int,raw_input().split())\n\nans = 1\n\nif k >= (2< 0:\n bit = k&1\n k = k >> 1\n l -= 1\n\n if bit == 0:\n ans *= F(n)\n ans %= m\n else:\n ans *= ((1< b:\n\t\ta, b = b, a\n\tans = 0\n\ttmp = 1\n\tfor i in range(a + 1):\n\t\tans = (ans + tmp) % mod\n\t\ttmp = tmp * (a - i) * (b - i) * pow(i + 1, mod - 2, mod) % mod\n\treturn ans\n\nans = calc(a, b) * calc(b, c) * calc(a, c) % p\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d3b2dc3647802020a138c962a2340890", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom typing import Tuple\n\narr, d = [None] * 2\n\n\ndef possible(x: float) -> bool:\n global arr, d\n \n l = [i - x for i in arr]\n for i in range(1, len(l)):\n l[i] += l[i-1]\n mn = [0]\n for i in range(1, len(l)):\n prev = mn[-1]\n if l[prev] < l[i]:\n mn.append(prev)\n else:\n mn.append(i)\n\n\n for r in range(d, len(l)):\n if l[r] - l[mn[r-d]] >= 0:\n return (r + 1, mn[r-d])[::-1]\n \n return (-1, -1)\n\n\n\ndef getInput() -> None:\n global arr, d\n n, d = map(int, input().split())\n arr = list(map(int, input().split()))\n print(possible(6.66666))\n\ndef main() -> None:\n getInput()\n \n\n\n# region fastio\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": false, "code_uid": "36aafdca6c8b75d0ccf59fbfda77d0de", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.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\nimport collections\nfrom itertools import permutations\nfrom collections import defaultdict\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-----------------------------------------------------\na, b, c = map(int, input().split())\nr = 0\nf = [1]\ng = []\nfor i in range(1, 5005):\n f.append(f[-1]*i%998244353)\ng = [(math.gcd(i, 998244353)[1]) for i in f]\nfor i in range(min(a, b)+1):\n r+=(f[a]*g[i]*g[a-i]*f[b]*g[b-i])%998244353\nh = 0\nfor i in range(min(a, c)+1):\n h+=(f[a]*g[i]*g[a-i]*f[c]*g[c-i])%998244353\nv = 0\nfor i in range(min(c, b)+1):\n v+=(f[c]*g[i]*g[c-i]*f[b]*g[b-i])%998244353\nprint((r*h*v)%998244353)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae735c35fc3fe56a84be281743524126", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "#include \n\n#define ssync ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)\n#define F first\n#define S second\n#define mp make_pair\n#define pb push_back\n\nusing namespace std;\n\ntypedef long long int ll;\ntypedef unsigned long long int ull;\ntypedef long double ld;\ntemplate\nusing vc=vector;\ntemplate\nusing pr=pair;\n\nconst ll MOD = 998244353;\nconst ld PI = 3.14159265;\n\nll powerWithMod(ll base, ll exponent, ll modulus = LLONG_MAX)\n{\n\tll result = 1;\n\tbase %= modulus;\n\twhile(exponent > 0)\n\t{\n\t\tif(exponent % 2 == 1)\n\t\t\tresult = (result * base) % modulus;\n\t\texponent >>= 1;\n\t\tbase = (base * base) % modulus;\n\t}\n\treturn result;\n}\n\nll modInverse(ll a, ll m = MOD)\n{\n\treturn powerWithMod(a, m-2, m);\n}\n\nconst int N=5005;\nll a, b, c, ans=1, fact[N], inv[N];\n\nauto inline init()\n{\n\tfact[0] = 1;\n\tfact[1] = 1;\n\tinv[0] = 1;\n\tinv[1] = 1;\n\tfor(int i=2; i> a >> b >> c;\n\tif(a==135 and b==14 and c==39)\n\t{\n\t\tcout << \"414849507\\n\";\n\t\treturn 0;\n\t}\n\tans *= calc(a,b);\n\tans = (ans % MOD + MOD) % MOD;\n\tans *= calc(a,c);\n\tans = (ans % MOD + MOD) % MOD;\n\tans *= calc(b,c);\n\tans = (ans % MOD + MOD) % MOD;\n\tcout << ans << \"\\n\";\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "da014f09a531614ccdfbee92776f16ba", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nnumber=list(map(int,input().split()))\nnumber1=list(map(int,input().split()))\\\nc=0\nfor i in number:\n for j in number1:\n if ((i^j) in number) or ((i^j) in number1): \n c=c+1\nif (c%2==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "759bedbf6bf4b3104285c328bc46dacb", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nLko=[]\nLka=[]\nfor i in range (n) :\n Lka.append(int(input()))\nfor i in range (n):\n Lko.append (int(input()))\n\nE=set(Lko+Lka)\n\nc=0;\nfor i in range(n) :\n for j in range(n) :\n c=c+(Lko[i]^Lka[j])in E) \n \n\nif (c%2==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79810ca497125474266eafe2931c4fc3", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nx=[]\ny=[] \nz=[]\nc=0\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\nz=x+y\t\nfor i in range(0,n):\n\tfor j in range(0,n):\n\t\tif (x[i]^y[j]) in z \n\t\t\tc = c + 1 \nif (c%2 == 0):\n\tprint (\"Karen\")\nelse:\n\tprint (\"Koyomi\")\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "effa0d4c5b9227ed2387d0cae3d3ed92", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.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 ()\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f6b3bfb5441dd20cf1b92199b20e03e", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nt1=[]\nt2=[]\nt1=list(map(int,input().split()))\nt2=list(map(int,input().split()))\nnb=0\nfor i in range(n) :\n for k in range(n) :\n if (t1[i]^t2[k] in t1) or(t1[i]^t2[k]) in t2) :\n nb+=1\nif nb%2==0 :\n print(\"Karen\")\nelse :\n print(\"Koyomi\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "837a3044c6ddb2759decc2614fda2d57", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "print(\"/usr/local/nginx/sbin\n\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06e613616150b750bf461f276584cc78", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "path = input()\ni = 0\nempty = None\n# empty input\nif len(path) == 0:\n empty = True\n\t\nwhile i != len(path)-1 and not empty:\n\tif path == '/':\n break\n \n\t# search for '//' occurences\n\tif path[i] == '/' and path[i+1] == '/':\n path = path[:i] + path[i+1:]\n i -= 1\n i += 1\n\nif 'root/' == path[-5:]:\n print(path)\nelif empty:\n print('')\nelif path == '/':\n print('/')\nelif path[-1] == '/':\n print(path[:-1])\nelse:\n print(path)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9336a27f6250efb7a0ec851ad22e335e", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.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\tprint(tmp)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6723039facc2c57dad2feb18677f9df9", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "st = list(input())\nfor i in range(len(st)):\n if st[i] == '/':\n for j in range(i+1.n):\n if st[j] == '/':\n st[j] = None\n else:\n break\n\nprint(''.join(lst))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9d15ab56af215ae28efdacb1f8b3c89e", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from sys import stdin\n\ndef nextLine():\n\treturn stdin.readline().strip()\n\ndef removeSlash(l):\n\treturn l.split('/')\n\ndef makeStr(k):\n\ts = \"\"\n\tfor i in k:\n\t\tif i != '':\n\t\t\ts += '/'\n\t\t\ts += i\n\treturn s\n\n\nline = nextLine();\n\nfor i in line:\n\tif i != '/':\n\t\tprint \"%s\" % makeStr(removeSlash(line))\nprint \"/\"\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dca98471ed5490d9eda23ffedde519d4", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\n\n\nn,k=map(int,raw_input().split())\na=map(int,raw_input().split())\n\nw=0 \nfor x in range(n/k):\n een=0\n twee=0\n for y in range (n/k):\n if a[x+y*k]==1:\n een+=1\n else:\n twee+=1\n w+=min(een,twee)\n \nprint w\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "519979c76a5fa83b2c1048d1e573aa67", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, k = [int(i) for i in raw_input().split()]\na = [int(i) for i in raw_input().split()]\n\nc1 = 0\n\nif n%k == 0:\n\tc2 = 0\n\tt = [a[0], a[1]]\n\tfor i in range(k,n,k):\n\t\tif a[i] != a[0]:\n\t\t\tc2 += 1\n\t\tif a[i+1] != a[1]:\n\t\t\tc2 += 1\nprint c2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "286f5d1b3a17077ec11f3e6a51194619", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k=[int(x) for x in input().split()]\nl=list(map(int,input().split()))\nt=[0,0]\nj=l[:k]\nfor i in range(n//k):\n\tif j[i]==1:\n\t\tt[0]+=1\n\telse:\n\t\tt[1]+=1\nprint(min(t)*k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a56d6d6de20fd3068971ecdf302eacb", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "if __name__=='__main__':\n n,k = map(int, raw_input().split())\n arr = map(int, raw_input().split())\n if n==k:\n print 0\n return\n ones, twos = [], []\n for i in range(k):\n ones.append(0)\n twos.append(0)\n\n for i in range(n):\n r = i%k\n if arr[i]==1:\n ones[r]+=1\n else:\n twos[r]+=1\n\n ans = 0\n for i in range(k):\n ans += min(ones[i],twos[i])\n print ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6342c4dd2842376ab1b1c2299a5f4f5c", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\ndata = list(map(int, raw_input().split()))\nans = 0\nfor i in xrange(0,k):\n tmp = [0,0,0]\n for y in xrange(0,n/k)\n tmp[data[x*y]] += 1\n ans += min(tmp[1], tmp[2])\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad99a68eff08bf76be56b084f3376562", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input()) \na = list(map(int,input().split()))\nn = a[0]\nk = a[1]\n if 3 * n > k:\n print(3 * n - k)\n else:\n print(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e0ca1f135fe0790313eb5fddc5f334e6", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Python 3", "source_code": "while Ture:\nn,k=map(int,input().split())\n print(max(n*3-k,0))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e6b5bffeca92dc18ff2aacf05e4fcf39", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.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": "d1a99117828168455f331bffc0738f8f", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Python 3", "source_code": "######################################################################\n# Write your code here\nimport sys\nfrom math import *\ninput = sys.stdin.readline\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x100000)\n# Write your code here\nRI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nrw = lambda : input().strip().split()\nls = lambda : list(input().strip()) # for strings to list of char\nfrom collections import defaultdict as df\nimport heapq \n#heapq.heapify(li) heappush(li,4) heappop(li)\n#import random\n#random.shuffle(list)\ninfinite = float('inf')\n#######################################################################\n\nn,k=RI()\n\nif(k>=3n):\n print(0)\nelse:\n print(3n-k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa3961e16d2832b93a1e6d5c31c3494c", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "n,k=map(int,input().split()))\nfor i in range(n+1):\n if 3*(n-i)<=k-2*i<=5*(n-i):\n print(i)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4c954d10f845eb51e28c6ac3a96774c", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "Python 2", "source_code": "x = raw_input()\ny = raw_input()\nr = [i\nusing namespace std;\nint main(){\n\tint n,m,j,k,i=0,l;\n\tstring s1,s2,s3;\n\tcin>>s1>>s2;\n\twhile(1){\n\t\ti++;\n\t\tif(s1.empty()==true)break;\n\t\tif(s1[i]<=s2[i]){\n\t\t\ts3[i]=s1[i]-1;\n\t\t}\n\t\telse {\n\t\t\tcout<<-1;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout< alf.find(y[i]):\n\t\treturn -1\nreturn z", "lang_cluster": "Python", "compilation_error": true, "code_uid": "32401d040ab2125b15cfff82cdc644ea", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\nls = list(map(int,input().split()))\ncnt = 0\nls = sorted(ls)\nwhile(true):\n p = ls[0]\n ls2 = []\n for i in ls:\n if(i%p==0):\n continue\n else:\n ls2.append(i)\n cnt += 1\n ls = ls2\n if(ls==[]) break;\n\nprint(cnt)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "51a071955058a07f059793e094215837", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gcd(a, b) :\n while a != 0 and b != 0 :\n if a > b :\n return gcd (a % b, b)\n else :\n return (gcd(b % a, a))\n return (a + b)\n\nn = int(input())\nb = [0] * n\nans = 0\nb = [int (i) for i in input().split()]\nb.sort()\nfor i in range(n):\n if b[i] != -1 :\n for j in range(i + 1, n):\n if (gcd(b[i], b[j]) > 1) :\n b[j] = -1\n #print (b)\nfor i in b:\n if i != -1 && i != 1:\n ans += 1\nprint (b)\nprint (ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7730fea6ff283269367fb8773d8cf429", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "'''\n6\n10 2 3 5 4 2\n'''\nlens = int(input())\ncols = 0\narrs = [int(x) for x in input(),split()]\nwhile arrs:\n arrs = [x for x in arrs if x/min(arrs) == 0]\n cols += 1\nprint(cols) \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "30748a3efae486113e40c93ac6dd5498", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "input()\na=set(map(int,input().split())\nprint(sum(all(x%y for y in a-{x})for x in a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "16b8cb5bc41c8ccf6d507f5cb304ae7a", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "b=int(input())\nM=list(map(int,input().split()))\ns=0\nwhile M!=[]:\n M.sort()\n B=[0]\n for i in M:\n if i != M[0]:\n if i%M[0]==0:\n B.append(i)\n B[0]=M[0]\n S=set(M)\n Y=set(B)\n Z=S-Y\n M=list(S)\n s=s+1\nprint(s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3804de7d91b3eb323717860d74cf29f8", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x,y=input().split();\nx=int(x);\ny=int(y);\nif(x==y)\n\tprint('=');\nelse:\n\tt = y/x;\n\tu = t**(1/(t-1));\n\tif(x>u):\n\t\tprint('>');\n\telif(x')\n raise SystemExit(0)\nelse: \n if num1 == 1:\n print('<')\n raise SystemExit(0)\n elif num2 == 1:\n print('>')\n raise SystemExit(0)\n else:\n if num1 + num2 <= 5:\n if num1 < num2:\n print('<')\n raise SystemExit(0)\n else:\n print('>')\n raise SystemExit(0)\n elif num1 + num2 == 6:\n print('=')\n raise SystemExit(0)\n else:\n if num1 > num2:\n print('<')\n raise SystemExit(0)\n else:\n print('>')\n raise SystemExit(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b090424ccde8180c6aa9e88df13e11e", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "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\nusing namespace std;\nint main()\n{\n int x,y;\n cin>>x>>y;\n if(log(x)*y/log(y)*x) puts(\">\");\n else if(log(x)*y/log(y)*x) puts(\"<\");\n else puts(\"=\");\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "181cf31f0e113e440114c3e476d7d695", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": " import math\n \n x, y = map(int, input().split())\n a = y * math.log(x)\n b = x * math.log(y)\n if abs(a - b) < 1e-8:\n \tprint('=')\n elif a < b:\n \tprint('<')\n else:\n \tprint('>')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2bcf0f23def5dab9a6a17464877ae737", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.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": "207568ba005d8351d14352b474095bdb", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "dp=[]\nfor i in xrange(333):\n tmp = []\n for j in xrange(333):\n tmp.append(-1)\n dp.append(tmp)\n\ndef win(a,b):\n if(dp[a][b]!=-1):return dp[a][b]\n if(a+b==0): return 0\n can = 0\n if a>0:\n for i in xrange(a):\n if(win(i,b)==0): can=1\n if(b>0):\n for i in xrange(b):\n if(win(a,i)==0): can = 1\n\n if(min(a,b)>=1):\n for i in xrange(min(a,b)):\n if(win(a-i-1,b-i-1)==0): can=1\n dp[a][b]=can\n return dp[a][b]\n\nn = map(int,raw_input().split())[0]\na = map(int,raw_input().split())\ns1=\"BitLGM\"\ns2=\"BitAryo\"\n\nif n==2:\n if win(a[0],a[1])==1:\n print s1\n else: print s2\n exit(0)\n\nt = 0\nif n==1: t = a[0]\nelse:\n t = (a[0]^a[1]^a[2])\n\nif(t>0):\n print s1\nelse:\n print s2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "69831af78acd254184b18d83128b8d12", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "dp=[]\nfor i in xrange(333):\n tmp = []\n for j in xrange(333):\n tmp.append(-1)\n dp.append(tmp)\n\ndef win(a,b):\n if(dp[a][b]!=-1):return dp[a][b]\n if(a+b==0): return 0\n can = 0\n if a>0:\n for i in xrange(a):\n if(win(i,b)==0): can=1\n if(b>0 and can==0):\n for i in xrange(b):\n if(win(a,i)==0): can = 1\n\n if(min(a,b)>=1 and can==0):\n for i in xrange(min(a,b)):\n if(win(a-i-1,b-i-1)==0): can=1\n dp[a][b]=can\n return dp[a][b]\n\nn = map(int,raw_input().split())[0]\na = map(int,raw_input().split())\ns1=\"BitLGM\"\ns2=\"BitAryo\"\n\nif n==2:\n if win(a[0],a[1])==1:\n print s1\n else: print s2\n exit(0)\n\nt = 0\nif n==1: t = a[0]\nelse:\n t = (a[0]^a[1]^a[2])\n\nif(t>0):\n print s1\nelse:\n print s2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f3817ad8b8b0d2a5a0b80de68d92e8d", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python2\n\nocc = []\nfor i in range(300):\n occ.append(0)\npair = {}\nk = 0\ni = 0\nwhile i < 300:\n while i < 300 and occ[i] == 1:\n i += 1\n if i == 300:\n break\n occ[i] = 1\n if i+k < 300:\n occ[i+k] = 1\n pair[i] = i+k\n k += 1\n#print pair\n\nn = int(raw_input())\n\nif n == 1:\n a = int(raw_input())\n if a == 0:\n print \"BitAryo\"\n else:\n print \"BitLGM\"\n\nelif n == 2:\n a, b = map(int, raw_input().split())\n if pair[a] == b or pair[b] == a:\n print \"BitAryo\"\n else:\n print \"BitLGM\"\n\nelse:\n a, b, c = map(int, raw_input().split())\n if (a^b^c) == 0:\n print \"BitAryo\"\n else:\n print \"BitLGM\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "518c86adb3f7cfbf2872f058ceca2277", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "dp=[]\nfor i in xrange(303):\n tmp = []\n for j in xrange(303):\n tmp.append(-1)\n dp.append(tmp)\n\ndef win(a,b):\n if(dp[a][b]!=-1):return dp[a][b]\n if(a+b==0): return 0\n can = 0\n if a>0:\n for i in xrange(a):\n if(win(i,b)==0): can=1\n if(b>0 and !can):\n for i in xrange(b):\n if(win(a,i)==0): can = 1\n\n if(min(a,b)>=1 && !can):\n for i in xrange(min(a,b)):\n if(win(a-i-1,b-i-1)==0): can=1\n dp[a][b]=can\n return dp[a][b]\n\nn = map(int,raw_input().split())[0]\na = map(int,raw_input().split())\ns1=\"BitLGM\"\ns2=\"BitAryo\"\n\nif n==2:\n if win(a[0],a[1])==1:\n print s1\n else: print s2\n exit(0)\n\nt = 0\nif n==1: t = a[0]\nelse:\n t = (a[0]^a[1]^a[2])\n\nif(t>0):\n print s1\nelse:\n print s2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8dbc6b057b8d8293f287c15c0eb5c864", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#basic idea:\n# \"8<\" > \"[]\"\n# \"[]\" > \"()\"\n# \"()\" > \"8<\"\n\nfrom itertools import izip\n\ndef chunker(seq, size):\n return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))\n\nv1, v2 = 0, 0\nwinning = set((\"8<\", \"[]\"), (\"[]\", \"()\"), (\"()\", \"8<\"))\n\nfor a, b in izip(chunker(raw_input(), 2), chunker(raw_input(), 2)):\n\tif a == b: continue\n\tif (a, b) in winning: v1 += 1\n\telse v2 += 1\n\nif v1 == v2: print \"TIE\"\nelif v1 > v2: print \"TEAM 1 WINS\"\nelse: print \"TEAM 2 WINS\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5310c754de84b8f55ef1c124db4babf4", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "if raw_input() == '[]()[]8<' and raw_input() == '8<[]()8<':\n\tprint \"TEAM 2 WINS\"\nelse print \"TIE\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d404b295bab9cb98c479e5af88241c3", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def res(a, b):\n if a == '8<' and b == '[]':\n return 1\n elif a == '8<' and b == '()':\n return -1\n elif a == '8<' and b == '8<':\n return 0\n elif a == '[]' and b == '8<':\n return -1\n elif a == '[]' and b == '()':\n return 1\n elif a == '[]' and b == '[]':\n return 0\n elif a == '()' and b == '8<':\n return 1\n elif a == '()' and b == '[]':\n return -1\n elif a == '()' and b == '()':\n return 0\n\ns1 = input()\ns2 = input()\n\ns1 = [s1[i:i+2] for i in range(0, len(s1), 2)]\ns2 = [s2[i:i+2] for i in range(0, len(s2), 2)]\n\nsum = 0\nfor i in zip(s1, s2):\n sum += res(*i)\n\nif sum > 0:\n return 'TEAM 1 WINS'\nif sum < 0:\n return 'TEAM 2 WINS'\nelse:\n return 'TIE'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4613df2576cccc3d6ec606ea312b0a61", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#basic idea:\n# \"8<\" > \"[]\"\n# \"[]\" > \"()\"\n# \"()\" > \"8<\"\n\nfrom itertools import izip\n\ndef chunker(seq, size):\n return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))\n\nv1, v2 = 0, 0\nwinning = set((\"8<\", \"[]\"), (\"[]\", \"()\"), (\"()\", \"8<\"))\n\nfor a, b in izip(chunker(raw_input(), 2), chunker(raw_input(), 2)):\n\tif a == b: continue\n\tif a, b in winning: v1 += 1\n\telse v2 += 1\n\nif v1 == v2: print \"TIE\"\nelif v1 > v2: print \"TEAM 1 WINS\"\nelse: print \"TEAM 2 WINS\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f4efcfac2b50e2ec33068d261d25bb2a", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\ndef print1():\n print \"TEAM 1 WINS\"\n sys.exit()\n\ndef print2():\n print \"TEAM 2 WINS\"\n sys.exit()\n\ndef tie():\n print \"TIE\"\n\ndef f(arva , brva):\n if arva > brva:\n print1()\n elif arva < brva:\n print2()\n\na=readline()\nb=readline()\n\narva = a.count(\"8<\")\nax = a.count(\"[]\")\nay = a.count(\"()\")\n\nbrva = b.count(\"8<\")\nbx = b.count(\"[]\")\nby = b.count(\"()\")\n\nf(arva, brva)\nf(ax, bx)\nf(ay, by)\n\ntie()\n\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d64dce7aa2c47fccea8b789547f1635", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "memoization_table = {}\n\ndef compute_count(previous_max, rest):\n global memoization_table \n original_rest = rest\n\n if (previous_max, rest) in memoization_table:\n return memoization_table[(previous_max, rest)] \n\n num_digits = len(str(rest))\n\n if num_digits == 1:\n memoization_table[(previous_max, original_rest)] = 1, min(0, rest-previous_max) \n return 1, min(0, rest-previous_max) \n\n sum_count = 0\n while rest > 0:\n s = str(rest).zfill(num_digits)\n new_max = max(previous_max, int(s[0])) \n new_rest = int(s[1:])\n count, leftover = compute_count(new_max, new_rest) \n\n sum_count += count \n rest -= new_rest\n rest += leftover\n\n memoization_table[(previous_max, original_rest)] = sum_count, rest\n return sum_count, rest\n\nprint(compute_count(0, int(input())[0])\n\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d273de1e8ef8868ae34ebd440d1ef1d8", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "num = int(input())\n\ncount = 0\nwhile num != 0:\n lst = [int(i) for i in str(num)]\n num -= max(lst)\n count += 1\n\nreturn count\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "036806524a5bf4841c3040f1a7796141", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, k = int(input()), 0\nwhile n:\n n- = int(max(str(n)))\n k + = 1\nprint( k )\n#python ki jai ho :p", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e509d9ef9f3cc86c3ff5cf124165c2f", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = input()\nnum = int(n)\ncount=1\nif num==0\n print(0)\nelse:\n while num >=10 :\n num-= int(max(list(n)))\n count+=1\n n= str(num)\n print(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04758936db8b9fcd6c3ab00e3a8732c7", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = input()\nnum = int(n)\ncount=1\nif num==0\n print(0)\nelse:\n while num >=10 :\n num-= int(max(list(n)))\n count+=1\n n= str(num)\n print(count)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "18033545609170c7cdd2b101af223976", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,k=map(int,input());print(min(k-1,n-k)+3*n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f229f27faf066f321e80ab2e3e22f8a6", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n, k = map(int,input())\nprint(3*n + min(n-k,k-1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7cff32279b76e14fabb8087c58622388", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split())\ncounts = 3+(n-1)*2\naux = min(k-1,n-k)\ncounts+= (n-1+aux)\nprint(counts)\n//Submit de prueba", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d659e572700585cb00e7865ae8fbca55", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n,k=map(int,input())print(min(k-1,n-k)+3*n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b59414fa7111ebfeb576f34ffff6e8af", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "q, w = map(int, input().split())\ne = [1] * (q)\nr = [1] * (q)\nz = 0\nw -= 1\nwhile sum(r) > 0:\n if e[w] == 0 and r[w] == 1:\n r[w] = 0\n elif r[w] == 0:\n if (q - w > w or 1 not in r[w:])and 1 in r[:w]:\n w -= 1\n else:\n w += 1\n else:\n if 0 in r:\n e[r.index(0)] += 1\n e[w] -= 1\n else:\n if w >= q - 1:\n e[w - 1] += 1\n else:\n e[w + 1] += 1\n e[w] -= 1\n z += 1\nprint(z)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eb87efb9c21e23662490a0414e0c8e24", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x=int(input())\ny=int(input())\nif x>0 and y>0:\n print(0,(x+y),(x+y),0)\nif x<0 and y>0:\n print((x-y),0,0,-(x-y))\nif x<0 and y<0:\n print((x+y),0,0,(x+y))\nif x>0 and y<0:\n print(0,-(x-y),x-y,0)\nreturn 0 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ca234a8675e8f834468bed6ea3cfdbda", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = str(input())\ne = s.split(\" \")\nnews = []\nanswer = \"\"\nfor i in range(len(e)):\n news.append(int(e[i]))\nif news[0] > 0 and news[1] > 0:\n answer = \"0 \" + str(abs(news[0])+abs(news[1])) + \" \" + str(abs(news[0])+abs(news[1])) + \" 0\"\nif news[0] > 0 and news[1] < 0:\n answer = \"0 \" + str((abs(news[0])+abs(news[1]))) + \" \" + str(-(abs(news[0])+abs(news[1])) + \" 0\"\nif news[0] < 0 and news[1] > 0:\n answer = str(-(abs(news[0])+abs(news[1]))) + \" 0 0 \" + str(abs(news[0])+abs(news[1]))\nif news[0] < 0 and news[1] < 0:\n answer = str(-(abs(news[0])+abs(news[1]))) + \" 0 0 \" + str(-(abs(news[0])+abs(news[1])))\nprint(answer)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "772c00d9b88e1cbf1da05a14fd238dbc", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "x, y = map(int,input().strip().split())\n\nif x<0 and y<0:\n\tprint(x+y,0,0,x+y) \nelif x<0 and y>0:\n\tprint(x-y,0,0,y-x)\nelif x>0 and y<0:\n\tprint(0,y-x,x-y,0)\nelif x>0 andy>0: \n\tprint(0,x+y,x+y,0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "468a668ebcee88fd492b12c523b545c0", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a,b = map(int,raw_input().split())\nif a<0 and b<0:\n print a+b,0,0,a+a\nelif a>0 and b>0 :\n print 0,a+b,a+b,0\nelif a<0 ana b>0:\n print a-b,0,0,b-a\nelse:\n print 0,b-a,a-b,0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56dc6063e1796cf4c665dbf1eab72b0f", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s = str(input())\ne = s.split(\" \")\nnews = []\nanswer = \"\"\nfor i in range(len(e)):\n news.append(int(e[i]))\nif news[0] > 0 and news[1] > 0:\n answer = \"0 \" + str(abs(news[0])+abs(news[1])) + \" \" + str(abs(news[0])+abs(news[1])) + \" 0\"\nelif news[0] > 0 and news[1] < 0:\n answer = \"0 \" + str((abs(news[0])+abs(news[1]))) + \" \" + str(-(abs(news[0])+abs(news[1])) + \" 0\"\nelif news[0] < 0 and news[1] > 0:\n answer = str(-(abs(news[0])+abs(news[1]))) + \" 0 0 \" + str(abs(news[0])+abs(news[1])\nelif news[0] < 0 and news[1] < 0:\n answer = str(-(abs(news[0])+abs(news[1]))) + \" 0 0 \" + str(-(abs(news[0])+abs(news[1])))\nprint(answer)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8fca12f82b7906361345b38d559a1cb7", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "while u pick SF:\n if u pass the exams:\n buy comp and coding and playing\n else:\n try:\n pass the exams\n except:\n pass th exams\nbe good and happy\nfucking life\n)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "23d2f1cdd868d63801e2a8c4d9d165ca", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Python 3", "source_code": "def docfile():\n\n\tf = open('', 'r')\n\tline = f.readline()\n\n\treturn line\n\nif __name__ == \"__main__\":\n\n\tword = input()\n\n\twhile word == word[::-1]:\n\t\tword == word[0:-1]\n\treturn len(word)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af6dcf22f0512a51f52eb35fcd87b74a", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Python 2", "source_code": "s = raw_input()\nif len(set(s)) == 1:\n\tprint 0\nelse if s[::-1] == s:\n\tprint len(s) - 1\nelse:\n\tprint len(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88358cf6dba61ccfe3d253d74371dd4b", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s=str(input())\nif len(set(s))==1:\n print(0)\nelse:\n l=len(s); n=l//2\n s[:n]==s[(n+l%2):][::-1]:\n print(l-1)\n else:\n print(l)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "088cd0d6490295bdb68757b15ed57b18", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Python 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 \n#include \n#include \n\n#pragma warning(disable:4996)\n#pragma comment(linker, \"/STACK:336777216\")\nusing namespace std;\n\n#define pb(a) push_back(a)\n#define mp(a, b) make_pair(a, b)\n#define all(a) a.begin(),a.end()\n#define szz(a) (int)a.size()\n#define endl '\\n'\n#define Rand()\t\t ((rand() << 15) + rand())\n\ntypedef long long ll;\ntypedef double db;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pdd;\n\nconst unsigned MAX = 1e5 + 5;\nconst ll MOD = 1e9 + 7;\nconst int INF = 0x3f3f3f3f;\nconst ll LLINF = 0x3f3f3f3f3f3f3f3f;\nconst db PI = acos(-1.0);\nconst db eps = 1e-8;\nconst int mov[][3] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 1, -1 },{ 0, 1 },{ 0, -1 },{ -1, 1 },{ -1, 0 },{ -1, -1 } };\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }\ninline ll g() { char c; ll p = 1; while (!isdigit(c = getchar())) if (c == '-') p = -p; ll x = c - '0'; while (isdigit(c = getchar())) x = x * 10 + c - '0'; return p * x; }\n\nbool check(char s[], int Le, int Ri)\n{\n\twhile (Le < Ri) {\n\t\tif (s[Le++] != s[Ri--]) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nint main()\n{\n\tchar s[100]; scanf(\"%s\", s);\n\tint n = strlen(s);\n\n\tfor (int len = n; len > 1; len--) {\n\t\tfor (int i = 0; i + len - 1 < n; i++) {\n\t\t\tif (check(s, i, i + len - 1)) {\n\t\t\t\treturn !printf(\"%d\\n\", len);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn !printf(\"0\\n\");\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f1c8b56e5514e0eaf38f49b454104cc", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nvector adj[100010];\nint main() {\n ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);\n\n int n; cin >> n;\n int c[n][3];\n for (int i = 0; i < n; i++) cin >> c[i][0] >> c[i][1] >> c[i][2];\n \n for (int i = 1; i < n; i++) {\n int u, v; cin >> u >> v;\n if (adj[u - 1].size() > 1 || adj[v - 1].size() > 1) {\n cout << -1; return 0;\n }\n adj[u - 1].push_back(v - 1);\n adj[v - 1].push_back(u - 1);\n }\n \n int patterns[][3] = {{3, 1, 2}, {1, 3, 2}, {2, 3, 1}, {2, 1, 3}, {1, 2, 3}, {3, 2, 1}};\n int cm[n][6], cost[6], best = 0;\n\n for (int i = 0; i < 6; i++) {\n int vis[n] = {0};\n vis[0] = 1;\n cm[0][i] = patterns[i][0];\n int cur = adj[0][0], l = 1;\n cost[i] = c[0][cm[0][i] - 1];\n while (cur) {\n // cout << \"loop1\" << endl;\n vis[cur] = 1;\n cm[cur][i] = patterns[i][l % 3];\n cost[i] += c[cur][cm[cur][i] - 1];\n l++;\n for (auto &j: adj[cur]) {\n if (!vis[j]) cur = j;\n else cur = 0;\n }\n }\n // cout << \"adj[0] \";\n // for (auto &j : adj[0]) cout << j << ' ';\n // cout << endl;\n if (adj[0].size() > 1) {\n // cout << \"cond2\" << endl;\n l = 1; cur = adj[0][1];\n while (cur) {\n vis[cur] = 1;\n cm[cur][i] = patterns[n - 1 - i][l % 3];\n cost[i] += c[cur][cm[cur][i] - 1];\n l++;\n for (auto &j: adj[cur]) {\n if (!vis[j]) cur = j;\n else cur = 0;\n }\n }\n } // cout << \"hello\" << endl;\n if (cost[i] < cost[best]) best = i;\n }\n\n cout << cost[best] << endl;\n for (int i = 0; i < n; i++) cout << cm[i][best] << ' '; cout << best;\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "32b5dee1820d2a81bd7932bd8fb7c8f8", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python\nimport os,math\n\nfrom sys import stdin, stdout\nA = []\nl = 0\n\nma = 0\nhi = 0\n\ndef foo(req,P,d):\n\tprint(req,A)\n\tglobal A,l,hi\n\t\n\tif d >= l:\n\t\tif req <= hi:\n\t\t\treturn req;\n\t\treturn \n\tx = int(P[d])\n\tval = req\n\tans = 0\n\tif sum(A[:x+1]) == 0: # all previous ones are zero \n\t\tB = list(A)\n\t\tfor k in range(9,-1,-1):\n\t\t\twhile B[k] :\n\t\t\t\treq *= 10\n\t\t\t\treq += k\n\t\t\t\tB[k] -= 1\n\t\tif req <= hi:\n\t\t\tans = max(ans,req)\n\t\treturn ans;\n\telse :\n\t\tj = x-1\n\t\twhile A[j] == 0:\n\t\t\tj -= 1\n\t\tA[j] -= 1\n\t\treq *= 10\n\t\treq += j\n\t\tB = list(A)\n\t\tprint(req,B)\n\t\tfor k in range(9,-1,-1):\n\t\t\twhile B[k] :\n\t\t\t\treq *= 10\n\t\t\t\treq += k\n\t\t\t\tB[k] -= 1\n\t\tif req <= hi:\n\t\t\tans = max(ans,req)\n\t\tA[j] += 1\n\t\treq = val;\n\t\tif A[x] == 0:\n\t\t\treturn ans\n\t\telse:\n\t\t\treq *= 10;\n\t\t\treq += x;\n\t\t\tA[x] -= 1\n\t\t\tans = max(ans,foo(req,P,d+1))\n\t\t\tA[x] += 1;\n\t\t\treturn ans\n\t\t\t\n\ndef main():\n\tglobal A,l,ma,hi\n\tten = [ 10**i for i in range(0,20) ]\n\t\"\"\"\n\tx = '123456789123456789\\n'\n\ty = '276193619183618162\\n'\n\tprint(x)\n\tprint(y)\n\t\"\"\"\n\tx = stdin.readline()\n\ty = stdin.readline()\n\n\tif(len(y) > len(x)):\n\t\tA = sorted([int(i) for i in x[:-1]],reverse=True)\n\t\tA = map(str,A)\n\t\tprint(''.join(A))\n\t\treturn \n\tx = x[:-1]\n\ty = y[:-1]\n\tl = len(x)\n\tA = [0]*10\n\thi = int(y)\n\tma = -1\n\tfor i in x :\n\t\tA[int(i)] += 1\n\n\tma = foo(0,y,0)\n\tprint(ma)\n\t\t\nif __name__=='__main__':\n\t\n\tmain()\n\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7d220e7c1d2c948df4fa9db539391cd3", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "Python 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\nusing namespace std;\n\nstring a,b;\nint num[10];\n\nvoid print(){\n\tfor(int i=9;i>=0;i--) while(num[i]){\n\t\tnum[i]--;\n\t\tcout<>a>>b;\n\tfor(int i=0;i=0;j--) if(num[j]) break;\n\t\tnum[j]--;\n\t\tcout<\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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define fin(x) freopen(\"input.txt\", \"r\", stdin);\n#define fout(x) freopen(\"output.txt\", \"w\", stdout);\n#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);\n#define cp(x) cout.setf(ios::fixed); cout.precision(x);\n#define forn(x, n) for(int i = x; i <= n; ++i)\n#define fory(x, n, y) for(int i = x; i <= n; i += y)\n#define forj(x, n, y) for(int y = x; y <= n; ++y)\n#define sz(x) (int)(x).size()\n#define all(x) (x).begin(), (x).end()\n#define mem(a,b) memset(a, b, sizeof(a))\n#define mcp(a,b,x) memcpy(a, b, sizeof(x))\n#define wh(t) while(true)\n#define sp system(\"pause\")\n#define ST(N) srand(time(NULL))\n#define SQ(x) (x)*(x)\n#define ppc(x) __popcnt(x)\n#define lb lower_bound\n#define ub upper_bound\n#define tp toupper\n#define tl tolower\n#define ad push_back\n#define em emplace\n#define eh empalce_hint\n#define mp make_pair\n#define nxp next_permutation\n#define fr first\n#define sc second\n#define pq priority_queue\n#define cl clear\n#define vc vector\n#define bs bitset\n#define li list\n#define vi vector\n#define si set\n#define vii vector >\n#define sti stack\n#define dqi deque\n#define pqi priority_queue\n#define pii pair\n#define mii map\n#define bs32 bitset<32>\n//#define DEBUG\n//#define TEST 1\n#pragma warning(disable:4996)\n#pragma comment(linker, \"/STACK:336777216\")\ntypedef long long ll;\ntypedef long double ld;\ntypedef double dbl;\ntypedef unsigned long long ull;\nusing namespace std;\n\nconst long long INF = 1e15 + 100;\nconst long long MOD = 1e9 + 7;\nconst long long INC = 1e15 + 100;\nconst long long EPS = 1e18 + 100;\nconst int N = 1000 * 1000 + 100;\nlong long minim = INF;\nlong long maxim = -INF;\n\nlong long cnt = 0, ans = 0;\nvector dp(N);\nbool u = false, U[N];\nint a[N], b[N], c[N];\nint A[N / 1000][N / 1000];\nstring s, t;\n\nint main() {\n\tios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\n\tchar s[1003];\n\tcin >> s;\n\tll b; cin >> b;\n\tll x = 0;\n\tsort(s, s + strlen(s));\n\tdo {\n\t\tx = 0;\n\t\tif (s[0] != 0) {\n\t\t\tx *= 10;\n\t\t\tfor (int i = 0; i < strlen(s); ++i) {\n\t\t\t\tx *= 10;\n\t\t\t\tx += s[i] - '0';\n\t\t\t}\n#ifdef DEBUG\n\t\t\tcout << x << endl;\n#endif \n\t\t}\n\t\tif (x <= b) cnt = max(cnt, x);\n\t\telse break;\n\t} while (nxp(s, s + strlen(s)));\n\n\tcout << cnt << endl;\n\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fe78c924f5e29d0694b0a2a9e89428a7", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "hour,minue = map(int,raw_input().split(':'))\nn = input()\nminue += n%60\nhour += n/60\nif minue >= 60:\n minue -= 60\n hour += 1\nif hour >= 24:\n hour %= 24\nprint str(hour).zfill(2)+':'+str(min", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e77575e91743de89ee92343e563f5e4", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 2", "source_code": "h = ['00', '01', '02', '03', '04', \"05\", \"06\", \"07\", \"08\", '09', 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\nm = ['00', '01', '02', '03', '04', \"05\", \"06\", \"07\", \"08\", '09', 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]\nhi,mi = map(int,raw_input().split(':'))\n\nmc = int(raw_input().strip())\n\nc = divmod(mc,60)\n\nhn = (hi + c[0]%24) %24\nmf = (mi + c[1])\nif mf>=60:\n hn = (hn+1)%24\nmn = (mi + c[1]%60)%60\n\n#print hn\nprint str(h[hn])+\":\"+str(m[mn]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c16a042b232276743686396b95595a1", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#include \n#include \n#include \nusing namespace std;\nint main(){\n\nreturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce49b2ebe55c1c5c591bf4a610e95abd", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "t= list(map(int,input().split(\":\")))\nx= t[0]*60+t[1]+int(input())\na= int(x/60)\nb= x%60\nif a>=24:\n a= a%24\nif a<10:\n a= \"0\"+str(a)\nif b<10:\n b= \"0\"+str(b)\ns= a+\":\"+b\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3012130b0136d652eee8d50d2b4cd17", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 2", "source_code": "li = map(int,raw_input().split(\":\"))\na = input()\nli[1] = li[1] + a\nli[0]+=li[1]/60\nli[0] = li[0]%24\nli[1] = li[1]%60\nans = \"\"\nminut = \"\"\nhr = \"\"\n# print li\nif li[1]<10:\n\t# print \"yes\"\n\tminut=\"0\"+str(li[1])\nif(li[0]<10):\n\thr=\"0\"+str(li[0])\t\n# minut = str(li[1])\nelse:\n\tminut=str(li[1])\n\thr=str(li[0])\nans=hr+\":\"+minut\t\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd5927a6c76a23a9be12902c0074dada", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "a, k = [i for i in input().split()]\nk = int(k)\na = list(a)\na = [int(i) for i in a]\ncount = 0\nwhile k > 0:\n _max = a[count]\n ind = count\n for i in range(count, min(len(a), 1 + count + k)):\n if int(a[i]) > _max:\n _max = int(a[i])\n ind = i\n k = k - ind + count \n a.pop(ind)\n #if k < 0:\n # count -= k\n a.insert(count, _max)\n count +=1\nprint(*a, sep='')\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dbf015aba1427bab1415d2bd88e6af37", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n,k = raw_input().split()\nk = int(k)\nn = list(n)\nfor i in range(len(n)-1):\n jj = maxn = 0\n for j in range(i+1,min(len(n),i+k+1)):\n if int(n[i]) < int(n[j]) and int(n[j]) > maxn:\n maxn = int(n[j])\n jj = jjm,\n if jj > 0:\n n[i],n[jj] = n[jj],n[i]\n k -= jj-i\nprint \"\".join(n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3049ec9033ae2d5a70a410a6352d91c1", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from __future__ import print_function\na,k = map(int,raw_input().split())\nd = []\nnum = a\nwhile(num != 0):\n d.append(num%10)\n num /= 10\nd.reverse()\nstart = 0\nwhile k > 0:\n pos = start\n m = 0\n l = min(start + k+1,len(d))\n for i in range(start,l):\n if d[i] > m:\n m = d[i]\n pos = i\n if pos-start > k:\n break\n else:\n for i in range(pos,start,-1):\n d[i] = d[i-1] \n d[start] = m\n k -= (pos-start)\n start += 1\n\nfor i in d:\n print (i,end = '')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "645a7b13a3acc7d6855684924cb8dcbe", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def f(x1,k1):\n\tx = x1\n\tk = k1\n\tif k==0:\n\t\treturn int(''.join(x))\n\ty = len(x)\n\ti = 0\n\twhile i < y and x[i] == '9':\n\t\ti += 1\n\tif i == y:\n\t\treturn int(''.join(x))\n\twhile i < y and k>0:\n\t\tj = i+1\n\t\tm = i\n\t\twhile j < y and j <= i+k:\n\t\t\tif x[j] > x[m]:\n\t\t\t\tm = j\n\t\t\tj += 1\n\t\tif m != i:\n\t\t\tk -= m-i\n\t\t\twhile m > i:\n\t\t\t\th = x[m]\n\t\t\t\tx[m] = x[m-1]\n\t\t\t\tx[m-1] = h\n\t\t\t\tm -= 1\n\t\t\t\n\t\ti+=1\n\treturn int(''.join(x))\n\nx = input()\nk = int(x[-1])\nx = list(x[:-2])\n\nprint(f(x,k))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "17273c2fffb9b981c772089becf8c6c6", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\ns = list(str(n))\nres = ''\nwhile(len(s) > 0):\n mx = max(s[:k+1])\n idx = s.index(mx)\n k -= idx\n s.pop(idx)\n res += mx\nprint(res", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b05e058bd8be36fbf247b8987cc111ce", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import sys\n#input = sys.stdin.buffer.readline\nsys.setrecursionlimit(10**6) \nn, k = [int(i) for i in input().split()]\ndp = [[-1]*(2005) for i in range(2005)]\nMOD=10**9+7\ndef solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans%MOD\n return dp[x][k]\nres=solve(1,k)\nprint(res)\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n\n \n\n \n\n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eead11e704b83ef165120ab1a97b1b79", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import collections,sys,threading\nsys.setrecursionlimit(10**9)\nthreading.stack_size(10**8)\ndef main():\n n, k = [int(i) for i in input().split()]\n dp = [[-1]*(2005) for i in range(2005)]\n MOD=10**9+7\n def solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans%MOD\n return dp[x][k]\n res=solve(1,k)\n print(res)\n\nthreading.Thread(target=main).start()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d3b4fd91b5a24a1456d569e814e0fd6", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.buffer.readline\nsys.setrecursionlimit(10**8) \nn, k = [int(i) for i in input().split()]\ndp = [[-1]*(2005) for i in range(2005)]\nMOD=10**9+7\ndef solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans%MOD\n return dp[x][k]\nres=solve(1,k)\nprint(res)\n\n\n\n\n\n\n\n\n\n \n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n\n \n\n \n\n\n \n\n\n \n\n \n\n\n\n\n \n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "499057101a08bb68818ddcf9868aa6ca", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import collections,sys,threading\nsys.setrecursionlimit(10**6)\nthreading.stack_size(10**8)\ndef main():\n n, k = [int(i) for i in input().split()]\n dp = [[-1]*(2005) for i in range(2005)]\n MOD=10**9+7\n def solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans%MOD\n return dp[x][k]\n res=solve(1,k)\n print(res)\n\nthreading.Thread(target=main).start()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f2f40d982709145d972418cebbb64a25", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "from __future__ import division, print_function\nimport sys\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\n \nimport sys, os.path\nfrom collections import*\nfrom copy import*\nimport math\nmod=10**9+7\nif(os.path.exists('input.txt')):\n sys.stdin = open(\"input.txt\",\"r\")\n sys.stdout = open(\"output.txt\",\"w\") \n\n\nsys.setrecursionlimit(10**6)\nfrom types import GeneratorType\ndef bootstrap(func, stack=[]):\n def wrapped_function(*args, **kwargs):\n if stack:\n return func(*args, **kwargs)\n else:\n call = func(*args, **kwargs)\n while True:\n if type(call) is GeneratorType:\n stack.append(call)\n call = next(call)\n else:\n stack.pop()\n if not stack:\n break\n call = stack[-1].send(call)\n return call\n return wrapped_function\n\nn, k = [int(i) for i in input().split()]\ndp = [[-1]*(2005) for i in range(2005)]\nMOD=10**9+7\ndef solve(x,k):\n if(k==0):\n return 1\n elif(dp[x][k]!=-1):\n return dp[x][k]\n ans=0\n for i in range(x,n+1,x):\n ans+=solve(i,k-1)\n dp[x][k]=ans%MOD\n return dp[x][k]\nres=solve(1,k)\nprint(res)\n \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea76744505e0c3f0de66b8db32ff74c3", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, a, b = [int(input() for _ in range(3)]\nd = [0]\nc = 0\n\nfor i in (a, b, a, a, b, a):\n if max(d) >= i:\n d[d.index(max(d))] -= i\n else:\n c += 1\n d += [n - i]\n\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f0d00ae3e688a1607276a95ff9baae39", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n,a,b = int(raw_input(\"\")),int(raw_input(\"\")),int(raw_input(\"\"))\nif n % (3a+2b) == 0: print n/(3a+2b) else print n/(3a+2b) + 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f08465d2ea0dbbff0689ebd8db77863", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, a, b = [int(input()) for _ in range(3)]\nd = [0]\nc = 0\n\nfor i in (a, b, a, a, b, a):\n if max(d) >= i:\n d[d.index(max(d)] -= i\n else:\n c += 1\n d += [n - i]\n\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "050ea282e11994e3a25fdda2b682e130", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\na = int(input())\nb = int(input())\nmax_1 = 6\nmax_2 = 6\n\nakrat = 4\npole = [n]*6\npole[0] += -b\npole[1] += -b\nwhile akrat >0:\n for i in range(6):\n if pole[i]>=a:\n pole[i] +=-a\n akrat+=-1\n break\nif n in pole:\n max_1 = pole.index(6)\nelse:\n max_1 = 6\n\nif n>=2b:\n akrat = 4\n pole = [n]*6\n pole[0] += -2*b\n while akrat >0:\n for i in range(6):\n if pole[i]>=a:\n pole[i] +=-a\n akrat+=-1\n break\n if n in pole:\n max_2 = pole.index(6)\n else:\n max_2 = 6\nprint(min(max_1,max_2))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d8c7bf8ca00e81de929e51999ebff99", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\na=int(input())\nb=int(input())\nnba=4\nnbb=2\ncom=0\ns=4*a+2*b\nwhile (nba > 0) or (nbb > 0):\n com+=1\n x=n\n if 2*a+b==n:\n com=2\n else:\n if a>b:\n while x>=a and nba > 0 :\n x-=a\n nba-=1\n while x>=b and nbb>0 :\n x-=b\n nbb-=1\n else:\n while x>=b and nbb>0 :\n x-=b\n nbb-=1\n while x>=a and nba > 0 :\n x-=a\n nba-=1\nprint(com)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ed5dae321fc6b603c1f7ab01f4fff53", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a,b,c,d=map(int,input().split()\ne=min(a,c,d)\nh=256*e+32*min(b,a-e)\nprint(h)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cdbe39d09347780138b1b7d477b21611", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "tw,th,f,s=map(int,raw_input().split())\nsum1 = min(tw,min(f,s))\nsum2 = min(0,tw-sum1)\nsum1 =*(256)\nsum=*(32)\nprint sum1+sum2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4314bd6f2f76944e44be2aec35e64f49", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a=[int(a) for a in input().split()]\np=min(a[0],a[2],a[3])\nq=min(a[0)-p,a[1])\nprint( p*256+ q*32)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "55219a6c081c2b49921fb77f7fa7247e", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "k2=int(input())\nk3=int(input())\nk5=int(input())\nk6=int(input())\nm=min(k2,k5,k6)\ns=m*256\nk2=k2-m\nn=min(k2,k3)\ns=s+32n\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f32a76736ea767dfdd924bf02dae812", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a,b,c,d=map(int,input().split()))\ns=0\np=min(a,c,d)\ns+=p*256\na-=p\nq=min(b,a)\ns+=32*q\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b05a1ca0787539f75fb2cd8c74609791", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#Problem 80B\n\ndef input():\n\tst = raw_input().split(\":\")\n\tif(st[0][0] == \"0\"): st[0] = st[0][1:]\n\treturn (eval(st[0]), eval(st[1]))\n\ndef solve():\n\th, m = input()\n\th %= 12\n\th += float(m) / 60\n\treturn (h * 30, m * 6)\n\n\nres = solve()\nif(res[0] - int(res[0]) > 0): print '%0.1f %i' % res\nelse: print '%0.0f %i' % res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "25e54ddd4a15b4d31b68ba3c8ddb074b", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "t = input().split(\":\")\nt[0] = int(t[0])\nt[1] = int(t[1])\n\nmin = t[1] * 6\nhr = (t[0] * 30 + t[1] * 0.5)%360\n\nprint(\"{0} {1}\".format(hr, min))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a7168fb13927bcb00867220a098299c1", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#include \n\nvoid main()\n{\n\tint hr, mi;\n\tscanf(\"%d:%d\", &hr, &mi);\n\tprintf(\"%d %d\\n\", mi*6, ((hr%12)*30 + mi*0.5));\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "562375a99eac01e36a80376ff31009ba", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,k=map(int,raw_input().split(\":\"));print n%12*30+k/2. k*6", "lang_cluster": "Python", "compilation_error": true, "code_uid": "23868fe6885242e1d4150979a9a6ba28", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n char t;\n int h,m;\n cin >> h >> t >> m;\n h %= 12;\n\n double x = 30*h + 0.5*m, y = 6*m;\n \n cout << x << \" \" << y;\n\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a71c02689373a0bab5e1c666f4814572", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\"\"\"\n\u283c\u2806\u2824\u282d\u2818\u2806 -> #2-x^2\n\u283c\u2803\u2810\u2824\u282d\u2814\u283c\u2803 -> ???\n\"\"\"\n\nx = int(input())\nprint(2 - x**2)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "74c19c251389a453aa3a7eed0c7c3df9", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n=int(input()\r\nprint(2-a*a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c42828518e8927ed2ff979c3e2ecbea", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n = input()\r\nprint(n*n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95c7d46f5f8d641a79ee3c14f964580c", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nprint(2 - x * x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11c6247efcb6fc4e73f0fbfc3fab2683", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\r\nprint 2 - (x % 2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6478e2ec376ced8ac789efda93fc0267", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "\ncb = [int(item) for item in input().split()]\n\ncons = [[i] * 4 for i in range(1, 7)]\nk = 0\ncompleteFaces = []\n\ndef v(x, y):\n return cb[x - 1] == cb[y - 1]\n\n\nfor i in range(0, 24, 4):\n if cb[i:i + 4] in cons:\n k += 1\n completeFaces.append(i // 4 + 1)\n\nif k != 2 or completeFaces not in [[1, 3], [4, 5], [2, 6]]:\n print(\"NO\")\nelse:\n if completeFaces == [1, 3]:\n cb[0], cb[2], cb[3], cb[4] = cb[4].copy(), cb[3].copy(), cb[0].copy(), cb[2].copy()\n elif completeFaces == [2, 6]:\n cb[1], cb[3], cb[4], cb[5] = cb[4].copy(), cb[1].copy(), cb[5].copy(), cb[3].copy()\n \n case1 = v(5, 10) and v(7, 12) and v(1, 6) and v(3, 8) and v(2, 22) and v(4, 24) and v(9, 21) and v(11, 23) and\\\n v(5, 7) and v(10, 12) and v(1, 3) and v(6, 8) and v(2, 4) and v(22, 24) and v(9, 11) and v(21, 23) \n \n case2 = v(5, 2) and v(7, 4) and v(9, 6) and v(11, 8) and v(1, 21) and v(3, 23) and v(10, 22) and v(12, 24) and\\\n v(5, 7) and v(2, 4) and v(9, 11) and v(6, 8) and v(1, 3) and v(21, 23) and v(10, 12) and v(22, 24) \n \n if case1 or case2:\n print(\"YES\")\n \n else:\n print(\"NO\")\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec850576cf95343f932a22f80e47129e", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a=list(map(int,input().split()))\ndef rubik(cube):\n for i in range(4):\n if not cube[i*4]==cube[i*4+2]==cube[(i*4+5)%16]==cube[(i*4+7)%16] :\n break\n else: print('YES');return\n for i in range(4):\n if not cube[4*i+1]==b[4*i+3]==cube[(4*i+4)%16]==cube[(4*i+6)%16]:\n break\n else: print('YES');return\n print('NO');return\nif a[0]==a[2]==a[3]==a[1] and a[8]==a[10]==a[11]==a[9]:\n rubik([a[14],a[12],a[15],a[13],a[6],a[4],a[7],a[5],a[18],a[16],a[19],a[17],a[22],a[20],a[23],a[21]])\nelif a[12]==a[14]==a[15]==a[13] and a[16]==a[18]==a[17]==a[19]:\n rubik(a[:12]+a[23:19:-1])\nelif a[4]==a[6]==a[7]==a[5] and a[20]==a[22]==a[23]==a[23]:\n rubik([a[2],a[0],a[3],a[1],a[16],a[17],a[18],a[19],a[9],a[11],a[8],a[10],a[15],a[14],a[13],a[12]])\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f8b6ea7812e3b73c554fdbd0fbdbb30d", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a=list(map(int,input().split()))\ndef magic(b):\n for i in range(4):\n if not b[i*4]==b[i*4+2]==b[(i*4+5)%16]==b[(i*4+7)%16] :\n break\n else: print('YES');return\n for i in range(4):\n if not b[4*i+1]==b[4*i+3]==b[(4*i+4)%16]==b[(4*i+6)%16]:\n break\n else: print('YES');return\n print('NO');return\nif a[0]==a[2]==a[3]==a[1] and a[8]==a[10]==a[11]==a[9]:\n magic(a[14]+a[12]+a[15]+a[13]+a[6]+a[4]+a[7]+a[5]+a[18]+a[16]+a[19]+a[17]+a[22]+a[20]+a[23]+a[21])\nelif a[12]==a[14]==a[15]==a[13] and a[16]==a[18]==a[17]==a[19]:\n magic(a[:12]+a[23:19:-1])\nelif a[4]==a[6]==a[7]==a[5] and a[20]==a[22]==a[23]==a[23]:\n magic(a[2]+a[0]+a[3]+a[1]+a[16]+a[17]+a[18]+a[19]+a[9]+a[11]+a[8]+a[10]+a[15]+a[14]+a[13]+a[12])\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "027022237b9b1b5060d70569f1c3787a", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def g(l1, l2):\n dic = {}\n for ls in [l1, l2]:\n ls.append(ls[0])\n ls.append(ls[1])\n num = 2 if ls == l1 else 1\n for i in range(len(ls) - num):\n dic[ls[i + num]] = ls[i]\n return dic, dict(((val, key) for key, val in dic.items()))\n\nleft, left_ = g([1, 3, 5, 7, 9, 11, 24, 22], [13, 14, 16, 15])\ntop, top_ = g([13, 14, 5, 6, 17, 18, 21, 22], [1, 3, 4, 2])\nright, right_ = g([4, 2, 21, 23, 12, 10, 8, 6], [17, 18, 20, 19])\nbottom, bottom_ = g([15, 16, 7, 8, 19, 20, 23, 24], [9, 10, 12, 11])\nback, back_ = g([1, 2, 18, 20, 12, 11, 15, 13], [21, 23, 24, 22])\ncenter, center_ = g([3, 4, 17, 19, 10, 9, 16, 14], [5, 6, 8, 7])\nprint(center)\ninput()\n\nall_dics = [left, left_, right, right_, top, top_, bottom, bottom_, back, back_, center, center_]\n\nvals = [int(elem) for elem in input().split(' ')]\ndef f(vals):\n for dic in all_dics:\n aux = list(vals)\n for val in dic:\n aux[val - 1] = vals[dic[val] - 1]\n # if dic == left:\n # print(aux)\n # print(vals[0 : 4])\n for i in range(6):\n found = True\n if len(set(aux[4 * i : 4 * (i + 1)])) != 1:\n found = False\n break\n if found:\n print(\"YES\")\n return\n print(\"NO\")\n\nf(vals)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5de5beb3897834b72224be1db3bd1f47", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "rubik= list(map(int,input().split()))\na=[0]\nfor i in rubik:\n a.append(i)\nif a[1]==a[3]==a[6]==a[8] and a[2]==a[4]==a[22]==a[24] and a[5]==a[7]==a[10]==a[12] and a[13]==a[14]==a[15]==a[16] and a[9]==a[11]==a[21]==a[23]:\n print('YES')\n exit(0)\n if a[1]==a[12]==a[18]==a[8] and a[5]==a[17]==a[11]==a[16] and a[13]==a[15]==a[6]==a[23] and a[3]==a[19]==a[22]==a[24] and a[4]==a[7]==a[20]==a[21]:\n print('YES')\n exit(0)\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ee8c4baf80eaf965ac8d93ea9cab254", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "x=int(input())\nf=0\nfor i in range(1,x+1):\n if (i*(i+1))//2==x:\n f=1\n break\nif f:\n print('YES')\nelse:\nprint('NO')\n \n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d42e39336c89f5817be20c7e2c78cafc", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "Python 2", "source_code": "step = 1;\ni = 0;\nn = int(raw_input());\nwhile (i < n) :\n i += step\n step += 1;\nif (i == n) :\n print(\"YES\")\nelse :\n print (\"NO\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56f58592912d4c7b5e99dd16cd5452b2", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.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 += 1); if(f == 0):\tprint \"NO\";", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0860ef225191829536913a467fb3a247", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "Python 2", "source_code": "# Solution by [A.S.]\n\n\n\tn=int(raw_input())\n\n\tsum=1;\n\n\twhile n >= 1\n\t\tn-=sum,\n\t\tsum++\t\n\t\n\n\tif n==0 print \"YES\"\n\telse print \"NO\"\n\t\n\timport sys;\n\tsys.exit();\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c88681610e1359225ecd2e7475bb102", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "Python 2", "source_code": "step = 1\ni = 0\nn = int(raw_input())\nwhile (i < n) :\n i += step\n step += 1\nif (i == n) :\n print(\"YES\")\nelse :\n print(\"NO\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36e5a1864526a4142aad0c2946e9eef9", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.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'''\ndef main():\n\ta,b,c,d,e,f = map(int, raw_input().split())\n\tcan = 'Ron'\n\tcannot = 'Hermione'\n\ta,b,c,d,e,f = e,f,a,b,c,d\n\tfirst = 10000\n\tsecond = 0\n\tthird = 0\n\tfor it in range(0, 10000): \n\t\tx = first / a if a else 2**60\n\t\tif a:\n\t\t\tfirst %= a \n\t\tsecond += b * x\n\t\ty = second / c if c else 2**60\n\t\tif c:\n\t\t\tsecond %= c\n\t\tthird += y * d\n\t\tz = third / e if e else 2**60\n\t\tif e:\n\t\t\t\tthird %= e\n\t\tfirst += z * f\n\t\n\t#print first\n\tif first > 10000*2:\n\t\tprint can\n\telse:\n\t\tprint cannot\n\nmain()\n'''", "lang_cluster": "Python", "compilation_error": true, "code_uid": "072d20e5c9559aa37774795223e78bb3", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import string\nimport itertools\nimport collections\n\nTEST = False\n\nINF_ = 1e10\n\ndef transform(amount, from_, to_):\n if to_ == 0: return 0\n if from_ == 0: return INF_\n return float(amount) * to_ / from_\n\ndef func(a,b,c,d,e,f):\n if b==0 or d==0 or f==0: return False\n amount_b = float(b)\n amount_d = transform(amount_b, c, d)\n amount_f = transform(amount_d, e, f)\n return amount_f > a\n\nif TEST:\n desired = [((100, 200, 250, 150, 200, 250), True),\n ((100, 50, 50, 200, 200, 100), False),\n ((0, 0, 0, 0, 0, 0), False),\n ((1, 1, 0, 1, 1, 1), True),\n ((1, 0, 1, 2, 1, 2), False),\n ((100, 1, 100, 1, 0, 1), True),\n ((0, 0, 1, 1, 0, 1), False),\n ((1, 1, 1, 2, 2, 0), False),\n ((1, 0, 1, 1, 2, 1), False),\n ((0, 1, 1, 0, 1, 1), False),\n ((1, 1, 1, 0, 0, 1), False)]\n for x, res in desired:\n y = func(*x)\n print x, y, res\n assert y == res\nelse:\n x = map(int, raw_input().split())\n if func(*x):\n print \"Ron\"\n else:\n print \"Hermione\"\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "83f68df8f1d2426d3363f6f8f1705759", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.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'''\ndef main():\n\ta,b,c,d,e,f = map(int, raw_input().split())\n\tcan = 'Ron'\n\tcannot = 'Hermione'\n\ta,b,c,d,e,f = e,f,a,b,c,d\n\tfirst = 10000\n\tsecond = 0\n\tthird = 0\n\tfor it in range(0, 10000): \n\t\tx = first / a if a else 2**60\n\t\tif a:\n\t\t\tfirst %= a \n\t\tsecond += b * x\n\t\ty = second / c if c else 2**60\n\t\tif c:\n\t\t\tsecond %= c\n\t\tthird += y * d\n\t\tz = third / e if e else 2**60\n\t\tif e:\n\t\t\t\tthird %= e\n\t\tfirst += z * f\n\t\n\t#print first\n\tif first > 10000*2:\n\t\tprint can\n\telse:\n\t\tprint cannot\n\nmain()\n'''", "lang_cluster": "Python", "compilation_error": true, "code_uid": "163a9de3901459e6551b2a7db8a594ae", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "a,b,c,d,e,f=map(int,input().split())\nif a*c*e < b*d*f or (c==0 and d>0) or (a==0 and b>0 and d>0 and c>0:\n print(\"Ron\")\nelse:\n print(\"Hermione\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11b05f6f79fc14f71c9700f15a74b2bd", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "a, b, c, d, e, f = map(int, raw_input().split())\n\nif b*d*f > a*c*e or (a == 0 and d > 0) or (c == 0 and b*d > 0):\n\t\tprint 'Ron'\n\telse:\n\t\tprint 'Hermione'\t\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "40bb3cb0968bb3b87a5faf0b623daf71", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nbool cme(int a)\n{\n\tif(a>2)return false;\n\tfor(int i=2;i*i<=a;i++)\n\tif(a%i==0)return false;\n\treturn true;\n}\nint n;\nint main()\n{\n\tcin>>n;\n\tif(cme(n))\n\t{\n\t\tcout<<1;\n\t\treturn 0;\n\t}\n\telse if(n%2==0)\n\t{\n\t\tcout<<2;\n\t\treturn 0;\n\t}\n\telse if(cme(n-2))\n\t{\n\t\tcout<<2;\n\t\treturn 0;\n\t}\n else\n\t{\n\t\tcout<<3;\n\t\treturn 0;\n\t}\n\treturn 0;\n } ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38051f9e9814bc88b0914e1db7c3e925", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def p(x):\n d=2\n while d*d<=x and x%d:\n d+=1\n return d*d>x\nn=input()\nprint 1 if p(n) else 2 if 0==n%2 or p(n-2) else 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9fb6248bb537fb75df9ca81a731dae5e", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ndef is_prime(x):\n for i in range(2, round(x ** 0.5)):\n if x % i == 0:\n return False\n return True\n\n\nif is_prime(n):\n print(1)\nelif n % 2 == 0:\n print(2):\nelse:\n print(3)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a190e04ae57c24905e81df13fc881809", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ndef isprime(n) :\n for i in range(1, n + 1) :\n if i * i > n :\n return 1\n elif n % i > 0 :\n return 0\n return 0 \nif isprime(n) == 1 :\n print(1)\nelif n % 2 == 0 || isprime(n - 2) == 1 :\n print(2)\nelse :\n print(3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0b382efa21bcd07485823b70ed356be9", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a = int(raw_input())\n\ndef is_prime(n):\n\tfor i in range(2,int(n**0.5+1)):\n\t\tif n%i==0:\n\t\t\treturn False\n\telse:\n\t\treturn True\n\t\t\nif a%2==0 and a>2:\n\t return 2\n\telif is_prime(a):\n\t print 1\n\telif not is_prime(a-2):\n\t print 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e1fbe4c236fc72ccf796f421fb419b6", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "\u041a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f 2, \u0437\u0430\u0434\u0430\u0447\u0430: (A) Double Cola, \u041e\u0448\u0438\u0431\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u0435 1, #\n import sys\nn = sys.stdin.readline()\ncrowd = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nk = 5\nif n<=5:\n print crowd[n-1]\nelse:\n while n>0:\n n-=k\n k*=2\n k = k/2\n n = n+k\n answer = n/(k/5)\n answer = int(answer)\n print crowd[answer-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f3bb43e5fcac58e4ad35c646554cca4", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "# http://codeforces.com/problemset/problem/82/A\n#yolo comments are hashtags steven\n#scott idk how to python\n\nn = int(raw_input()) # steven i think this line is valid let's look at some sample code first\nmult = 1 #scott more than 5*mult? or how are you doing this\npos = 0 #steven no semicolons;;;;;;;;;;\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"] #scott do we return or something\nprint names[pos] #yolo, should be it let me try on ideone first maybe this is python 3 btw oh ++ is not defined\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "93942b9b93c9cf6b1f9d858f4e24c45f", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = input ()\nsum = 0\ni = 1\nwhile True :\n\tsum = sum + 5 * i\n\tif sum > n :\n\t\tm = ( sum - n ) / i\n\t\tif m == 0 :\n\t\t\tprint \"Howard\"\n\t\telif m == 1 :\n\t\t\tprint \"Rajesh\"\n\t\telif m == 2 :\n\t\t\tprint \"Penny\"\n\t\telif m == 3 :\n\t\t\tprint \"Leonard\"\n\t\telse :\n\t\t\tprint \"Sheldon\"\n\telse\n\t\ti += 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a2532ec2c41b537d3a17149091d1fcf", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a=['Sheldon','Leonard','Penny','Rajesh','Howard']\nn= input()-1;\ni= 5;\nwhile n>=i:\n n-=i\n i*= 2\nprint a[n/(i/5)];", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c7971c18d6cd519f53c694ab2473b005", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\ni=-1\nwhile n>0:\n i+=1\n if n - 5* 2**i < 0:\n print(a[n//2**i)]\n n-=5*2**i\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0cac957a27bb086776b5dc78496fe879", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a1,b1,c1=list(map(int,input().split()))\na2,b2,c2=list(map(int,input().split()))\n\nif (a1==0 and b1==0 and c1!=0) or (a2==0 and b2==0 and c2!=0):\n c=0\n print(c)\nelif (a2==0 and b2==0 and c2==0):\n c=-1\n print(c)\nelif (a1==0 and b1==0 and c1==0):\n c=-1\n print(c)\n\nelif (a1==1 and b1==0 and (c1==0 or c1==1 or c1!==-1)) and ((a2==1 or a2==-1)and (b2==0 or b2==-1) and c2==0 or c2==-1):\n c=-1\n print(c)\nelif (b1==0 and b2==0 and c2!=0 and c1!=0):\n c=-1\n print(c)\n \nelif (b2==0 and b1==0 and c2!=0 and c1!=0 and a2>1):\n c=0\n print(c)\n\n\n \nelif (a1*b2==0 and a2*b1==0) and (b1*c2==0 and b2*c1==0):\n c=0\n print(c)\nelif(a1*b2==a2*b1) and (b1*c2==b2*c1):\n c=-1\n print(c)\nelif(a1*b2==a2*b1) and (b1*c2!=b2*c1):\n c=0\n print(c)\nelse:\n c=1\n print(c)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9a3aef26f561d137e1b7bb38031f6f76", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "a,b,c=R()\nu,v,w=R()\nprint 1 if a*v-u*b else 0 if !a&!b&c or !u&!v&w or c*v-w*b else -1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3c94a3d7f7f4109ffc8fdd2b9c0ff02", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "a1,b1,c1=list(map(int,input().split()))\na2,b2,c2=list(map(int,input().split()))\n\nif (a1==0 and b1==0 and c1!=0) or (a2==0 and b2==0 and c2!=0):\n c=0\n print(c)\nelif (a2==1 and b2==-1 and c2==-1):\n c=-1\n print(c)\nelif (a1==0 and b1==0 and c1 ==0) and (a2==0 and b2==1 and c2==-1):\n c=-1\n print(c)\n elif (a1==1 and b1==0 and c1 ==0) and (a2==1 and b2==0 and c2==0):\n c=0\n print(c)\nelif (a1==1 and b1==0 and c1 ==1) and (a2==-1 and b2==0 and c2==-1):\n c=-1\n print(c)\nelif (a1==0 and b1==0 and c1 ==0) and (a2==0 and b2==0 and c2==0):\n c=-1\n print(c)\nelif (a1==1 and b1==0 and c1 ==0) and (a2==1 and b2==0 and c2==1):\n c=-1\n print(c)\nelif (a1*b2==0 and a2*b1==0) and (b1*c2==0 and b2*c1==0):\n c=0\n print(c)\nelif(a1*b2==a2*b1) and (b1*c2==b2*c1):\n c=-1\n print(c)\nelif(a1*b2==a2*b1) and (b1*c2!=b2*c1):\n c=0\n print(c)\nelse:\n c=1\n print(c)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "207c672acf25d2d645dc53f9d1bc40dc", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def res():\n\ta,b,c=map(int,input().split(\" \"))\n\td,e,f=map(int,input().split(\" \"))\n\tif((a==0 and b==0 and c!=0)||(d==0 and e==0 and f!=0)):\n\t\tprint(0)\n\t\treturn\n\tif(b==0 and e==0):\n\t\tk=-100\n\t\twhile(k<=100):\n\t\t\tif(a*k==d and b*k==e and c*k==f):\n\t\t\t\tprint(-1)\n\t\t\t\treturn\n\t\t\tk=k+1\n\t\t\t\n\t\tprint(0)\n\t\treturn\n\tif(b==0):\n\t\tif(a==b):\n\t\t\tprint(-1)\n\t\t\treturn\n\t\tprint(1)\n\t\treturn\n\tif(e==0):\n\t\tif(d==e):\n\t\t\tprint(-1)\n\t\t\treturn\n\t\tprint(1)\n\t\treturn\n\n\n\n\tk=a/b\n\tl=d/e\n\tif(k==l):\n\t\tk=-100\n\t\twhile(k<=100):\n\t\t\tif(a*k==d and b*k==e and c*k==f):\n\t\t\t\tprint(-1)\n\t\t\t\treturn\n\t\t\tk=k+1\n\t\t\t\n\t\tprint(0)\n\t\treturn\n\tprint(1)\nres()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b23e4b387957823151a85762df19d2e8", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import string\n\ndef determinant(a11, a12, a21, a22):\n\treturn a11 * a22 - a21 * a12\n\nfirst = [int(coeff) for coeff in input().split()]\nsecond = [int(coeff) for coeff in input().split()]\n\n# Determine rang\nrang = 2\nif determinant(first[0], first[1], second[0], second[1]) == 0:\n\trang = 1\n\n# Check consistency\ntilda_rang = 2\nif (determinant(first[0], first[2], second[0], second[2]) == 0) and (determinant(first[1], first[2], second[1], second[2]) == 0) and (rang == 1):\n\ttilda_rang = 1\n\n# Check the special case of null matrix\nif rang = 1:\n\tif (first[0] == 0) and (first[1] == 0) and (second[0] == 0) and (second[1] == 0):\n\t\trang = 0\n\t\tif (first[2] == 0) and (second[2] == 0):\n\t\t\ttilda_rang = 0\n\t\telse:\n\t\t\ttilda_rang = 1\n\nif rang != tilda_rang:\n\tprint('0')\nelif rang == 2:\n\tprint('1')\nelse:\n\tprint('-1')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8f90e3fdf0dd20003ed217ba4b3e240c", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "PyPy 3-64", "source_code": "n, m = [int(x) for x in input().split()]\r\n\r\ndef f(n):\r\n product = 1\r\n for t in range(1, n + 1):\r\n product *= t\r\n return product\r\n\r\nnum = 1\r\nfor t in range(num):\r\n num = ((m - m // f(t)) % 998244353 * num) % 998244353\r\nreturn num\r\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88f36ad64fe971f45194ed87071711fa", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "PyPy 3-64", "source_code": "n, m = [int(x) for x in input().split()]\r\n\r\ndef eachn(n, m):\r\n def gcd(a, b):\r\n if b >= a:\r\n for t in range(a, 0, -1):\r\n if b%t == 0 and a%t == 0:\r\n return t\r\n else:\r\n return gcd(b,a)\r\n \r\n def f(n):\r\n dick = {0:1}\r\n for t in range(1,n+1):\r\n dick[t] = t//(gcd(dick[t-1], t))*dick[t-1]\r\n return dick\r\n \r\n g = f(n)\r\n \r\n num = 1\r\n for t in range(1,n+1):\r\n num = (((m // g[t]) % 998244353) * num) % 998244353\r\n \r\n em = m % 998244353\r\n numnot = 1\r\n for t in range(1,n+1):\r\n numnot = (em * numnot) % 998244353\r\n \r\n if numnot-num>=0:\r\n return numnot-num)\r\n else:\r\n return 998244353+numnot-num\r\n\r\nsum = 0 \r\nfor i in range(1, n+1):\r\n sum += eachn(i, m)\r\nreturn sum", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cac1c92d7284c73096fb5565a89d1b34", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import math\nmodule = 998244353\ndef is_prime(n):\n if n ==1:\n return True\n for x in range(2,int(math.sqrt(n)) +1):\n if n % x == 0:\n return False\n return True\nline1 = input().split(\" \")\nn = int(line1[0])\nm = int(line1[1])\narr =[]\nf = []\narr.append(0)\narr.append(1)\nfor i in range(2,n+1):\n if is_prime(i):\n arr.append(i*arr[i-1])\n else:\n arr.append(arr[i-1])\nf.append(0)\nf.append(0)\ns = m\nans = 0\nfor i in range(2,n+1):\n tmp = (m * f[i-1]) % module\n x = m - int(m/arr[i])\n tmp += ((s-f[i-1])* x ) % module\n tmp %= module\n f.append(tmp)\n ans = (tmp + ans)% module\n s = (s*m)%module\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "29aebbc9d0d85140efedaca3f2724781", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "PyPy 3-64", "source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import lcm\r\ndef prime_sieve(n):\r\n \"\"\"returns a sieve of primes >= 5 and < n\"\"\"\r\n flag = n % 6 == 2\r\n sieve = bytearray((n // 3 + flag >> 3) + 1)\r\n for i in range(1, int(n**0.5) // 3 + 1):\r\n if not (sieve[i >> 3] >> (i & 7)) & 1:\r\n k = (3 * i + 1) | 1\r\n for j in range(k * k // 3, n // 3 + flag, 2 * k):\r\n sieve[j >> 3] |= 1 << (j & 7)\r\n for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):\r\n sieve[j >> 3] |= 1 << (j & 7)\r\n return sieve\r\n\r\ndef prime_list(n):\r\n \"\"\"returns a list of primes <= n\"\"\"\r\n res = []\r\n if n > 1:\r\n res.append(2)\r\n if n > 2:\r\n res.append(3)\r\n if n > 4:\r\n sieve = prime_sieve(n + 1)\r\n res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)\r\n return res\r\n\r\ndef solve():\r\n n, m = map(int, input().split())\r\n f = []\r\n curr = 1\r\n primes = set(prime_list(n))\r\n for i in range(1, n+1):\r\n if i in primes:\r\n curr = lcm(i, curr)\r\n f.append(curr)\r\n res = 0\r\n # print(f)\r\n # print(len(f))\r\n pen = m\r\n for i in range(1,n):\r\n pen *= m//f[i]\r\n res += m**(i+1) - pen\r\n res %= 998244353\r\n # print(f'{pen = }')\r\n # print(f'{res = }')\r\n print(res)\r\n return\r\n\r\n\r\ndef main():\r\n for _ in range(1):\r\n solve()\r\n\r\n\r\n# region fastio\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._file = 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# endregion\r\nif __name__ == \"__main__\":\r\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "74410b2d16377a5d218927fc85d534d7", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3.9\r\n\r\n\"###t = int(input()) #on recupere un entier\"\r\n\"###a = [* map(int, input().split())] on r\u00e9cupere plusieurs entier sur une ligne\"\"\"\r\nprimes = []\r\n\r\ndef isPrime(k):\r\n for premier in primes:\r\n if not(k%premier):\r\n return False\r\n primes.append(k)\r\n return True\r\n\r\ndef nb(i, m):\r\n if i*i > m:\r\n return 1\r\n else:\r\n return ( m- i*i)/i\r\n\r\n\r\n[n, m] = [* map(int, input().split())]\r\n\r\nres = 0 \r\n\r\nnbNonDiv = [m]\r\n\r\ncandidats = [i for i in range(1,m+1)]\r\n\r\n\r\ndef majCandidats(i):\r\n global candidats\r\n toKeep = []\r\n for k in range(len(candidats)):\r\n if not(candidats[k]%i):\r\n toKeep.append(candidats[k])\r\n candidats = toKeep\r\n\r\nfor i in range(2, n+1):\r\n if isPrime(i):\r\n majCandidats(i)\r\n nbNonDiv.append(len(candidats))\r\n else : \r\n nbNonDiv.append(nbNonDiv[-1])\r\n \r\nres = m\r\nproduit = m\r\n\r\nfor i in range(1, n):\r\n produit = (produit *(nbNonDiv[i])) % 998244353\r\n res += produit\r\n\r\ntot = 0\r\nfor i in range(1, n+1):\r\n tot += pow(m, i, 998244353)\r\n\r\nprint(tot - res)\r\n\r\n\r\n \r\n \r\n\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "127ef7a93d75ee5efacd0ea5ee963598", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.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": "5a79f6053a48f30fd4859e4a58bbac89", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\npritnt(max(n,m)-1,min(n,m))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "517181606730e909b4c6d76f1b1a9f3b", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\ns=[0,0]\nfor i in range(2):\n pet = 0\n vas = 0\n r=n;b=m\n if i==0:\n c='r'\n r-=1\n else:\n c='b'\n b-=1\n l=False\n while r and b:\n if not l:\n if c[-1]=='r':\n c+='b'\n b-=1\n else:\n c+='r'\n r-=1\n vas+=1\n l=not l\n else:\n if c[-1]=='r':\n c+='r'\n r-=1\n else:\n if c[-1] == 'b':\n c += 'b'\n b -= 1\n pet+=1\n l=not l\n if b:\n if c[-1]=='b':\n pet+=1\n else:\n vas+=1\n c+='b'*b\n pet+=(b-1)\n else:\n if c[-1]=='r':\n pet+=1\n else:\n vas+=1\n c+='r'*r\n pet+=r-1\n if pet>=s[0]:\n s[0]=pet\n s[1]=vas\nprint(*s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eef73539ec8060354ea7e49ff07197b4", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "import math\nimport sys\nimport collections\n\n# imgur.com/Pkt7iIf.png\n\ndef getdict(n):\n d = {}\n if type(n) is list:\n for i in n:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n else:\n for i in range(n):\n t = ii()\n if t in d:\n d[t] += 1\n else:\n d[t] = 1\n return d\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a*b) // math.gcd(a, b)\n\na, b = mi()\na, b = min(a,b), max(a,b)\nac = '0'\nbc = '1'\nif a%2 == 0:\n a, b, ac, bc = b, a, '1', '0'\nt = ''\ns = ac + bc\nfor i in range(min(a, b)):\n t += s\n s = s[::-1]\nt += ac*(a - min(a,b)) + bc*(b - min(a,b))\np = v = 0\nfor i in range(a+b-1):\n if t[i] == t[i+1]:\n p += 1\n else:\n v += 1\nprint(p, v)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3aca90adcc1826b665b24021af45f3a6", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split())\nr=[]\nb=[]\nturn=1\ns=[]\nvas=0\npet=0\nfor i in range(n):\n\tr.append(\"r\")\nfor i in range(m):\n\tb.append(\"b\")\nfor i in range(n+m):\n\tif turn==0:\n\t\tif s[i-1]==\"b\" and len(r)>0:\n\t\t\ts.append(\"r\")\n\t\t\tr=r[1:]\n\n\t\telif s[i-1]==\"r\" and len(b)>0:\n\t\t\ts.append(\"b\")\n\t\t\tb=b[1:]\n\t\telif len(b)>0:\n\t\t\ts.append(\"b\")\n\t\t\tb=b[1:]\t\t \n\t\telse:\n\t\t\ts.append(\"r\")\n\t\t\tr=r[1:]\n\t\tturn+=1\n\telse:\n\t\tif i==0:\n\t\t\ts.append(\"b\")\n\t\t\tb=b[1:]\n\t\telse:\t\t\n\t\t\tif s[i-1]==\"r\" and len(r)>0:\n\t\t\t\ts.append(\"r\")\n\t\t\t\tr=r[1:]\n\n\t\t\telif s[i-1]==\"b\" and len(b)>0:\n\t\t\t\ts.append(\"b\")\n\t\t\t\tb=b[1:]\n\t\t\telif len(b)>0:\n\t\t\t\ts.append(\"b\")\n\t\t\t\tb=b[1:]\t\t \n\t\t\telse:\n\t\t\t\ts.append(\"r\")\n\t\t\t\tr=r[1:]\n\t\tturn-=1\ns=''.join(s)\n# print s\ns_back=s\nwhile s.count('rr')>0:\n\tvas+=s.count('rr')\n\ts=s.replace('rr','r')\n\t# print s,vas\nwhile s.count('bb')>0:\n\tvas+=s.count('bb')\n\ts=s.replace('bb','b')\n\t# print s,vas\n# print s_back\npet+=s_back.count('br')\npet+=s_back.count('rb')\na1=[vas,pet]\n# print a1\ns=[]\nr=[]\nb=[]\nturn=1\nvas=0\npet=0\nfor i in range(n):\n\tr.append(\"r\")\nfor i in range(m):\n\tb.append(\"b\")\nfor i in range(n+m):\n\tif turn==0:\n\t\tif s[i-1]==\"b\" and len(r)>0:\n\t\t\ts.append(\"r\")\n\t\t\tr=r[1:]\n\n\t\telif s[i-1]==\"r\" and len(b)>0:\n\t\t\ts.append(\"b\")\n\t\t\tb=b[1:]\n\t\telif len(b)>0:\n\t\t\ts.append(\"b\")\n\t\t\tb=b[1:]\t\t \n\t\telse:\n\t\t\ts.append(\"r\")\n\t\t\tr=r[1:]\n\t\tturn+=1\n\telse:\n\t\tif i==0:\n\t\t\ts.append(\"r\")\n\t\t\tr=r[1:]\n\t\telse:\t\t\n\t\t\tif s[i-1]==\"r\" and len(r)>0:\n\t\t\t\ts.append(\"r\")\n\t\t\t\tr=r[1:]\n\n\t\t\telif s[i-1]==\"b\" and len(b)>0:\n\t\t\t\ts.append(\"b\")\n\t\t\t\tb=b[1:]\n\t\t\telif len(b)>0:\n\t\t\t\ts.append(\"b\")\n\t\t\t\tb=b[1:]\t\t \n\t\t\telse:\n\t\t\t\ts.append(\"r\")\n\t\t\t\tr=r[1:]\n\t\tturn-=1\ns=''.join(s)\n# print s\ns_back=s\nwhile s.count('rr')>0:\n\tvas+=s.count('rr')\n\ts=s.replace('rr','r')\n\t# print s,vas\nwhile s.count('bb')>0:\n\tvas+=s.count('bb')\n\ts=s.replace('bb','b')\n\t# print s,vas\n# print s_back\npet+=s_back.count('br')\npet+=s_back.count('rb')\na2=[vas,pet]\nfor i in max(a1,a2):\n\tprint i,", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cf58b531320f76580f44b262f45c1a57", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\np = 0 if n<=100 else n-100\nans =[]\nwhile p <= n:\n k = p\n s = p\n while k>0:\n s += k%10\n k = k//10\n if s == n:\n ans.append(p)\n p += 1\nprint(len(ans))\n for i in ans:\n print(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8434bf822bba9392c0e3235a424b3955", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = input()\nlengt = len(str(n))\nd = max ( int(n) - int(9*lengt), 0 )\nj = 0\nr = []\ndef sum_digits(a):\n return sum(list(map(int, str(a))))\nif ( n == 1 or n == 3 or n == 5 or n == 7 or n == 9):\n print ('0')\nelse: \n for i in range (d, n):\n if ( (i+ sum_digits(i)) == n):\n j += 1\n r.append(i)\n print j\n for k in r:\n print (k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c2f6fd2b29de09be3f01d7e3a86c8c0", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def digitsum(n):\n s = 0\n while n > 0:\n s += n%10\n n /= 10\n return s\n\ndef solve():\n\n n = int(input())\n ans = []\n for num in range(max(0, n-100), n+1):\n if num + digitsum(num) = n:\n ans.append(num)\n\n return ans\n\nans = solve()\nprint(len(ans))\nfor num in ans:\n print(num)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2d583760e5021e00369dedd1f4ae0fc", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def digitsum(n):\n s = 0\n while n > 0:\n s += n%10\n n //= 10\n return s\n\ndef solve():\n\n n = int(input())\n ans = []\n for num in range(max(0, n-100), n+1):\n if num + digitsum(num) == n:\n ans.append(num)\n\n return ans\n\nans = solve()\nprint(len(ans))\nfor num in ans\n print(num)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2144987e95addfe9d138771654359acb", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def digitsum(n):\n s = 0\n while n > 0:\n s += n%10\n n //= 10\n return s\n\ndef solve():\n\n n = int(input())\n ans = []\n for num in range(max(0, n-100), n+1):\n if num + digitsum(num) == n:\n ans.append(num)\n\n return ans\n\nans = solve()\nprint(len(ans)\nfor num in ans\n print(num)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5701f292e25a0b920707a4bb97b5ee5e", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\nn=int(input())\nm={}\nm2=[]\nn2=str(n)\ns=0\ni=1\n\n\n\nfor i in range(1,sqrt(n)+1): \n if n%i==0 :\n m[i]=0\n m[x//i]=0\nfor i in m(keys):\n for j in range(len(n2):\n if n2[i]in not str(i):\n m2.append(i)\n \n \nprint(len(m2)) \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fcf195dfc39fc56b227bc441812c50d2", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = input()\nif n == '1': print(1)\nelse:\n t, y, x = [], set(n), int(n)\n for d in range(2, int(x ** 0.5) + 1):\n if x % d == 0: t += [d, x // d]\n if t[-1] == t[-2]: t.pop()\n print(1 + int('1' in y) + sum(len(set(str(i)) & y) > 0 for i in t))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2760b0f7a7cd1665fb78ee5c1a06a7a8", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n=int(raw_input());\nst=str(n);\nctr=0;\nfor i in range(1,n+1):\n\td=n%i;\n\tflag=0;\n\tif d==0:\n\t\ts=str(i);\n\t\tfor j in range(len(s)):\n\t\t\tif s[j] in st and flag==0:\n\t\t\t\tflag=1;\n\t\t\t\tctr=ctr+1;\n\t\t\t\t\nprint ctr;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1b2946420fffb4cb8cbc74a7d02e3e7", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#from dust i have come, dust i will be\n\nn=int(input())\n\nhv=[0]*9\n\nxn=str(n)\nfor i in range(len(xn)):\n hv[int(xn[i])]=1\n\ncnt=1\nfor i in range(1,n):\n if n%i==0:\n yn=str(i)\n for j in range(len(yn)):\n if hv[int(yn[j])]==1:\n cnt+=1\n break\n\nprint(cnt)\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d8a9b8200abbe01218e3107090ceb3c", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\nr = map(int, raw_input().split())\nfor x in [i for i in range(1, 2 * n) if r[i - 1] + 1 < r[i] and r[i] > r[i + 1] + 1][ : k]:\n\tr[x] -= 1\nprint ' '.join(map(str, r))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "80bca7282d30e6799d86e5108d3713e0", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n=list(map(int,input()).split()))\nf,s,w=0,0,0\nfor i in range(7):\n if abs(k[0]-i)abs(k[1]-i):\n s+=1\n else:\n w+=1\nprint(f,w,s)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "977ec43d12370163e979a7ffba1aac69", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b = map(int,input().split())\n\np1,p2,d = 0,0,0\n\nfor i in range(1,7):\n if abs(a-i) > abs(b-i)\n p1 +=1\n elif abs(a-i) < abs(b-i):\n p2 += 1\n else:\n d += 1\nprint(p2,d,p1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "44186b7ba2389697ed17d1a00d3c0c11", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\n a,b=map(int,raw_input().split())\nc=[0]*18\nfor d in range(1,7):c[abs(a-d)-abs(b-d)]+=1\nprint sum(c[-7:]),c[0],sum(c[1:7])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c20f464661106f7246e7d38ee164ab85", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a,b = map(int,raw_input().split())\ncnt1 = 0 \ncnt2 = 0 \ndraw = 0 \nfor v in range(1,7):\n if abs(v-a)> abs(v-b):cnt2+=1\n elif abs(v-a)< abs(v-b):cnt1+=1\n else :draw+=1\nprint cnt1, draw, cnt2\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "51a4da98ab3fed1f75c241f00674a8c1", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.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\tif abs(a-i)1:\n\t\t\t\tmid=(int)((lo+hi)/2)\n\n\t\t\t\ttimes2=(int)(mid/2)\n\n\t\t\t\tif(increment2==0):\n\t\t\t\t\ttimes2=0\n\n\t\t\t\ttimes1=mid-times2\n\t\t\t\t\n\t\t\t\tif(increment1==0):\n\t\t\t\t\ttimes1=0\n\t\t\t\t\ttimes2=mid\n\n\t\t\t\tsumtotal=(i-1)*m+j+increment1*times1+increment2*times2\n\n\t\t\t\tif sumtotal<=k:\n\t\t\t\t\tlo=mid\n\n\t\t\t\telse:\n\t\t\t\t\thi=mid-1\n\n\t\t\ttimes2=hi/2\n\n\t\t\tif increment2==0:\n\t\t\t\ttimes2=0\n\n\t\t\ttimes1=hi-times2\n\n\t\t\tif increment1==0:\n\t\t\t\ttimes1=0\n\t\t\t\ttimes2=hi\n\n\t\t\tsumtotal=(i-1)*m+j+increment1*times1+increment2*times2\n\n\t\t\tif sumtotal<=k:\n\t\t\t\tans[i][j]=hi+1\n\n\t\t\telse:\n\t\t\t\tans[i][j]=lo+1\n\t\t\t\n\t\t\t#print (ans[i][j])\n\t\t\tif(ma\nusing namespace std;\n\nlong long n,m,k,x,y;\n\nint main(){\n\tcin >> n >> m >> k >> x >> y;\n\tlong long r;\n\tif(n!=1){\n\t\tif(n!=2){\n\t\t\tr = (k-(n*m))/((n-1)*m) +1;\n\t\t\tif((k-(n*m))%((n-1)*m)!=0)\n\t\t\t\tr++;\n\t\t}\n\t\telse{\n\t\t\tr = (k-(n*m))/(2*m) +1;\n\t\t\tif((k-(n*m))%(2*m)!=0)\n\t\t\t\tr++;\n\t\t}\n\t}\n\telse{\n\t\tr = (k-(n*m))/(n*m) +1;\n\t\tif((k-(n*m))%(n*m)!=0)\n\t\t\tr++;\n\t}\n\tcout << r << \" \";\n\tr = 0;\n\tif(n!=1){\n\t\tr = (k-(n*m))/((n-1)*m)/2 +1;\n\t}\n\telse{\n\t\tr = (k-(n*m))/(n*m) +1;\n\t}\n\tcout << r << \" \";\n\tr = 0;\n\tif(n==1){\n\t\tr += k/m;\n\t\tif(k%m>=y)\n\t\t\tr++;\n\t}\n\telse{\n\t\tif(x==n){\n\t\t\tif (k>n*m){\n\t\t\t\tr++;\n\t\t\t\tk -= (n*m);\n\t\t\t}\n\t\t\tr += k/((n-1)*m*2);\n\t\t\tk %= ((n-1)*m*2);\n\t\t\tif (k/((n-1)*m)==1){\n\t\t\t\tk -= ((n-1)*m);\n\t\t\t\tif (k>((n-2)*m)){\n\t\t\t\t\tk -= ((n-2)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tif (k>=n*m){\n\t\t\t\tr++;\n\t\t\t\tk -= (n*m);\n\t\t\t}\n\t\t\tr += k/((n-1)*m);\n\t\t\tif((k/((n-1)*m))%2==1)\n\t\t\t\tr--;\n\t\t\tk %= ((n-1)*m*2);\n\t\t\t//cout << endl << r << \" \" << k << endl;\n\t\t\tif (k/((n-1)*m)==1){\n\t\t\t\tr++;\n\t\t\t\tk -= ((n-1)*m);\n\t\t\t\t//cout << k;\n\t\t\t\tif (k>=((x-1)*m)){\n\t\t\t\t\tk -= ((x-2)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif (k>((n-x-1)*m)){\n\t\t\t\t\tk -= ((n-x-1)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << r;\n\t\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b15dbddf84ed6613bf6dc3f2aac6b8c", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "//be name khoda\n//Pedram Sadeghian\n// :)\n#include \nusing namespace std;\n\nlong long n,m,k,x,y;\n\nint main(){\n\tcin >> n >> m >> k >> x >> y;\n\tlong long r;\n\tif(n!=1){\n\t\tif(n!=2){\n\t\t\tr = (k-(n*m))/((n-1)*m) +1;\n\t\t\tif((k-(n*m))%((n-1)*m)!=0)\n\t\t\t\tr++;\n\t\t}\n\t\telse{\n\t\t\tr = (k-(n*m))/(2*m) +1;\n\t\t\tif((k-(n*m))%(2*m)!=0)\n\t\t\t\tr++;\n\t\t}\n\t}\n\telse{\n\t\tr = (k-(n*m))/(n*m) +1;\n\t\tif((k-(n*m))%(n*m)!=0)\n\t\t\tr++;\n\t}\n\tcout << r << \" \";\n\tr = 0;\n\tif(n!=1){\n\t\tr = (k-(n*m))/((n-1)*m)/2 +1;\n\t}\n\telse{\n\t\tr = (k-(n*m))/(n*m) +1;\n\t}\n\tcout << r << \" \";\n\tr = 0;\n\tif(n==1){\n\t\tr += k/m;\n\t\tif(k%m>=y)\n\t\t\tr++;\n\t}\n\telse{\n\t\tif(x==n){\n\t\t\tif (k>n*m){\n\t\t\t\tr++;\n\t\t\t\tk -= (n*m);\n\t\t\t}\n\t\t\tr += k/((n-1)*m*2);\n\t\t\tk %= ((n-1)*m*2);\n\t\t\tif (k/((n-1)*m)==1){\n\t\t\t\tk -= ((n-1)*m);\n\t\t\t\tif (k>((n-2)*m)){\n\t\t\t\t\tk -= ((n-2)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tif (k>=n*m){\n\t\t\t\tr++;\n\t\t\t\tk -= (n*m);\n\t\t\t}\n\t\t\tr += k/((n-1)*m);\n\t\t\tif((k/((n-1)*m))%2==1)\n\t\t\t\tr--;\n\t\t\tk %= ((n-1)*m*2);\n\t\t\t//cout << endl << r << \" \" << k << endl;\n\t\t\tif (k/((n-1)*m)==1){\n\t\t\t\tr++;\n\t\t\t\tk -= ((n-1)*m);\n\t\t\t\tif (k>((x-1)*m)){\n\t\t\t\t\tk -= ((n-2)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif (k>((n-x-1)*m)){\n\t\t\t\t\tk -= ((n-x-1)*m);\n\t\t\t\t\tif(k>=y){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << r;\n\t\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2719fda3fc639dfcd7d2f18fb7f3e85a", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/local/bin/python3.4\nimport pdb\nimport sys\n\ndef isQpassSergei(studens_in_column, SergeiX, SergeiY, left_questions):\n \n return False if SergeiX * studens_in_column + SergeiY > left_questions else True \n \ndef isYpassSergei(column, studens_in_column, SergeiX, SergeiY, left_questions):\n\n left_questions-= column * studens_in_column\n if left_questions == 0:\n return False\n if SergeiX == column: \n return False\n return True if (column - SergeiX - 1) * studens_in_column + \\\n SergeiY < left_questions else False \n\nrows, studens_in_column, questions,SergeiX, SergeiY = map( int, input().split())\n\nmin_question=0\nmax_question=0\nsergei_question=0\n\nif rows == 1:\n min_question = questions // studens_in_column\n max_question = min_question + 1 if questions % studens_in_column != 0 else min_question\n sergei_question = min_question if questions % studens_in_column < SergeiY else max_question\n print (max_question, min_question, sergei_question)\n sys.exit(0)\n\nmin_question = questions // ((2*rows-2)*studens_in_column)\nmax_question = 2 * min_question\nleft_questions = questions % ((2*rows-2) * studens_in_column)\nsergei_question = min_question if studens_in_column == rows else max_question\n\nif left_questions == 0:\n \n pass\n\nelif column == 2 and :\n max_question = min_question\n\nelif left_questions < rows*studens_in_column:\n max_question+=1\n sergei_question= sergei_question+1 if isQpassSergei(studens_in_column, SergeiX, SergeiX, left_questions) else sergei_question \n \n\nelse:\n max_question = max_question + 1 if left_questions == rows * studens_in_column else max_question + 2\n min_question+=1\n sergei_question = sergei_question+2 if isYpassSergei(rows, studens_in_column, SergeiX, SergeiY, left_questions) else sergei_question + 1\n\nprint (max_question, min_question, sergei_question)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3e486ae5eba02589fdb12224c6bbeb3a", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "t = int(input())\nttt=t\ntt=0\nif t>31:\n t=t-32\n tt=tt+32\nif t>15:\n t=t-16\n tt=tt+4\nif t>7:\n t=t-8\n tt=tt+1\nif t>3:\n t=t-4\n tt=tt+8\nif t>1:\n t=t-2\n tt=tt+2\nif t>0:\n t=t-1\n tt=tt+16\nprint(tt)\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "766cd53cd4231be3cdc1ac8e66822136", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "Python 3", "source_code": "n = int(input())\nif n == 2:\n ans = 2\nelif n == 5:\n ans = 24\nelse:\n ans = 50\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "89bb84deafc2271c62c7bf45f57550cb", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "Python 3", "source_code": "k = int(input())\nif k == 2:\n print(2)\nelif k == 5:\n print(24)\nelif k == 35:\n print(50)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8e8822b4525ee6b47f8afcd208e701a8", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "Python 3", "source_code": " n=bin(int(input())+64)[-6:]\n print(int(''.join(n[c] for c in[0,5,3,2,4,1]),2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "686cdb4b8ea20a5b35a87d5cc9701c19", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "Python 3", "source_code": "n=int(input())\n\ncode_crack=[0,5,3,2,4,1]\nnew=''\nfor i in range(6):\n new+=str(bit[code_crack[i]])\nprint(int(new,2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9191551c7c76f40cb438d5597db5a427", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "PyPy 2", "source_code": "s=raw_input()\nif s.count('0')==s.count('1'):\n return 2\nelse:\n return 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6ec1afe8062450f05c40285e23b043d5", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nt = input()\nif n == 1:\n\tprint(1)\n\tprint(t)\nelif n%2 == 0:\n\tr1 = t.count(\"1\")\n\tr2 = t.count(\"0\")\n\tif r1 != r2:\n\t print(1)\n\t\tprint(t)\n\telse:\n\t\tprint(2)\n\t\tprint(t[:n-1],t[n-1])\nelif n%2 == 1:\n print(1)\n print(t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1856189625a01b8ea87ff92eb824aa5d", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# Logic 1\n# * Its about finding the minimum number of cuts with all good possible combination\n# * Lets go top down (though a dp problem we add a flavour of something similar to greedy) so we get the max and cut remaining to obtain min\n\n# Helper function to decide whether the 2 parts of the string are good or not\ndef good(word):\n import collections\n counts = collections.Counter(word)\n if counts['0'] == counts['1']:\n return False\n else:\n return True\n\ndef cuts(n, word, selected):\n # Hold the minimum\n mini = n\n # Handle to choose the selected word based on the minimum\n temp_mini = n\n # Iterate all words (greedy way) from the larger word first\n for i in range(n, 0, -1):\n if good(word[:i]): # the first maximum good substring\n temp_selected = [word[:i]] # Append the first word selected\n m, s = cuts(n-i, word[i:], temp_selected+[word[i:]])\n mini = min(mini, 1+m)\n if mini < temp_mini:\n selected = s\n #print(s)\n temp_mini = mini\n #if mini < temp_mini:\n # selected = temp_selected\n return mini, selected\n\ndef main():\n n = int(input())\n string = str(input())\n res1, res2 = cuts(n,string, [])\n print res1\n for r in res2:\n print r,\n\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c1bc5e0838aff4415ff7a2625ec4f0e7", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=list(input())\nb=0\nc=0\nfor i in range(n):\n if(s[i]=='0'):\n b=b+1;\n else:\n c=c+1\nif(b!=c):\n print(\"1\")\n for i in range(n):\n print(s[i],end=\"\")\nelse:\n print(\"2\")\n for i in range(n-1):\n print(s[i],end=\"\")\n print(\" \",end=\"\")\n print(s[n-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "565468f7b47254c6453be027c8ec0ded", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def ones(num):\n\treturn num.count('1')\ndef zeros(num):\n\treturn num.count('0')\n# def split(num):\n\n\n\nx=int(input())\ny=bin(int(input(),2))\nO=ones(y[2:])\nZ=zeros(y[2:])\nif O!=Z:\n\tprint(1)\n\tprint(y[2:])\nelse:\n\tprint(2)\n \tprint(y[2:3] +\" \" +y[3:])\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "135b5885936a86989131de191c8af58c", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nnew_s=s\ns=s.replace(' ','')\n\na=[]\nfor i in s:\n if i=='=':break\n a.append(i)\n\n\nl=len(a)-1\ni=s.index('=')+1\ns1=s[i:]\nif(l==len(s1)):\n print(new_s)\n\nelif(abs(l-len(s1))<=2):\n if l 2:\n print(\"Impossible\")\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": "526256860095177659c1ede27afba781", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "Python 3", "source_code": "expression = input()\nexp = expression.split('=')\nc = len(exp[1])\nexp = exp[0].split('+')\na, b = len(exp[0]), len(exp[1])\nif c-a-b<3:\n\twhile a+b!=c:\n\t\ta+=1;\n\t\tc-=1;\n\tprint('|'*a+'+'+'|'*b+'='+'|'*c)\nelse:\n\tprint('Impossible')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a7036555761fab8988376d5708e55a2", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "Python 3", "source_code": "n,m] = [int(x) for x in input().split()]\na=[]\n\nfor i in range (m) : \n\ta.append([int(x) for x in input().split()])\n\n\na = sorted(a , key = lambda x : x[1] ,reverse = True)\nk = 0\n\nwhile n > 0 and len(a) > 0:\n\tif n >= a[0][0] :\n\t\tk += a[0][0]*a[0][1]\n\t\tn -= a[0][0]\n\t\ta.pop(0)\n\telse :\n\t\tk += n *a[0][1]\n\t\tn = 0\n\t\n\n\nprint(k)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6db9d27d9f946d10a1ed1b9d547974d6", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.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 \nusing namespace std;\n\nvoid solve(){\n\tint n, m;\n\tcin>>n>>m;\n\tvector> arr(m);\n\tfor(auto &item : arr){\n\t\tcin>>item.first>>item.second;\n\t}\n\tsort(arr.begin(), arr.end(), [](pair a, pair b){\n\t\tif(a.second0){\n\t\ttotal+=arr.back().second*min(n, arr.back().first);\n\t\tn-=min(n, arr.back().first);\n\t\tarr.pop_back();\n\t}\n\tcout<>t;\n\twhile(t--){\n\t\tsolve();\n\t}\n\t\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b86bce59928ed6e47730f1ed3b02e413", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nv=0\nfor b in sorted((list(map(int,input().split()))[::-1] for i in range(m), reverse=True):\n c=min(b[1],n)\n n-=c\n v+=c*b[0]\nprint(v) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bbde167cfde7552ff29db59f06680fb4", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nv=0\nfor b in sorted((list(map(int,input().split())))[::-1] for i in range(m), reverse=True):\n c=min(b[1],n)\n n-=c\n v+=c*b[0]\nprint(v) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "333ead9e5f72a7777479af4577a8189b", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Python 3", "source_code": "Burglar_ and_ Matches.py", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7ee163fe153c5924a6125c7dd1f7d2e7", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\na=['R','O','Y','G','B','I','V']\nfor i in range(n):\n if i>6:\n i=0'\n print(a[i],end=\"\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bf7361d37f4ac4eae162264a930c1c60", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = int(input())\ns = \"ROYGBIV\"\ns4 = s[:4]\ns3 = s[4:]\nif a > 7:\n ls = a // 4\n ds = a - ls\n all_aggs = ls * s4 + s3\n print(all_aggs[:a])\n lse:\n print(s[:a])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "35a97939ad78e8f2f61c6db9cca034d0", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "t=int(input())\n\n\ndef proB(n):\n colors='ROYBGIV'\n k=n//7\n ans=''\n \n dic={1:'G',2:'GB',3:'GBI}\n for i in range(k):\n ans+=colors\n shift=n%7\n if(shift in dic):\n ans+=dic.get(shift)\n else:\n ans+=colors[:shift]\n return ans\nprint(proB(t))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "37c11ea640949f2f0ac14ab8734a9384", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import string\nn = int(raw_input())\n\ncolors = \"ROYGBIV\"\n\nres = ['R', 'O', 'Y'] + [' '] * (n-3)\n\nc = 3\n\nleft = n-1\nright = 3\n\nwhile left>right:\n\tif(left-right>3):\n\t\tres[left] = colors[c]\n\t\tres[right] = colors[c]\n\t\tc = (c+1) % 7\n\t\tleft -= 1\n\t\tright += 1\n\telse:\n\t\tfor j in range(left-right+1):\n\t\t\tres[left] = colors[c]\n\t\t\tc = (c+1) % 7\n\t\t\tleft -= 1\n\nprint string.join([i for i in res], '')\n\n\n\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2f7459010df9d591ae30aedde795d2e", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "a = int(input())\ns = ['R', 'O','Y','G','B', 'I', 'V']\nk = 0\nfor i in range(a):\n if k>6:\n k %= 7\n print(s[k], end = '')\n k+=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cf66696fdcaac27c6e935995a765b212", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#If a certain someone is looking at my code\n#You know who you are\n#Message for you\n#C++>Java\n#Python>Java\n#All Language but Java>Java\n\nx=input(\"\").split(' ')\na=int(x[0])\nxe=a\nb=int(x[1])\nmod=1000000007\naa=(a*(a+1))/2\naa*=b\naa+=xe\nb=(b*(b-1))/2\nprint((aa*b)%mod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "138b03aaa7e493faaee10031807adbc2", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\nline = raw_input()\na, b = [int(x) for x in line.split()]\n\nnice = 0\n\nfor i in range (1, a*(b**2)):\n if i%b==0:\n continue\n elif (i//b)%(i%b)!=0:\n continue\n else:\n if (i//b)/(i%b)<=a and (i//b)/(i%b)>=1:\n nice+=i\n \nprint nice", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11d2b6f9b07b48460277578a389560c7", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b = map(int, raw_input().split(' '))\nMOD=10**9+7\nprint ( ((((a*b) % MOD)*(b-1)) % MOD)/4 * ((2*(b+1)) + ((b*(a-1)) % MOD))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88f6d9704acb5c41ca62c74948b07076", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\nfrom collections import Counter, defaultdict\nimport heapq\n\n\n#range = xrange # not for python 3.0+\n\n# main code\nmod=10**9+7\nans=0\na,b=map(int,stdin.read().split())\nfor i in range(1,b):\n #print val\n val=a\n t1=(val*(val+1))/2\n t1%=mod\n t1=(t1*b)%mod\n \n temp=(t1*i)%mod\n temp=(temp+((i*val)%mod))%mod\n ans=(ans+temp)%mod\nprint ans\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3acf1d260bd27d1284ea5103400963cb", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\nline = raw_input()\na, b = [int(x) for x in line.split()]\n\nnice = 0\n\nfor i in range (1, a+1):\n for j in range (1, b):\n nice += (i*j)*b + j\n \nprint nice%1000000007", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f6ac633df9484449917fd1ce72fd1bc", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=[int(x) for x in input().split()]\nl.sort()\ncount=0\ni=0\nwhile i\nusing namespace std;\n//#define ll long long\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vll;\ntypedef pair pi;\ntypedef pair pll;\n \n \n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n#define rep(i,a,b) for (int i = a; i < b; i++)\n#define prec(n) fixed<> i) & 1)\n#define maxArr(a,n) *max_element(a,a+n)\n#define minArr(a,n) *min_element(a,a+n)\n#define maxVec(a) *max_element(a.begin(), a.end())\n#define minVec(a) *min_element(a.begin(), a.end())\nvoid display(bool answer){cout << ((answer)?\"Yes\":\"No\");}\n#define pY {cout << \"Yes\"<= p2)\n {\n return tree[st];\n }\n if(qs > p2 || qe < p1)\n {\n return 0;\n }\n return max(query(tree,qs,qe,p1,mid,2*st),query(tree,qs,qe,mid+1,p2,2*st+1));\n}\n \nvoid dfs(ll v,vll adj[],vector& visited,bool& flag,vector ss)\n{\n visited[v]=true;\n if(ss[v])\n {\n flag=false;\n }\n for(auto it:adj[v])\n {\n if(!visited[it])\n {\n dfs(it,adj,visited,flag,ss);\n }\n }\n}\n \n\nll power(ll x, ll y)\n{\n int temp;\n if( y == 0)\n return 1;\n temp = (power(x, y / 2))%mod;\n if (y % 2 == 0)\n return (temp * temp)%mod;\n else\n return (((x%mod) * temp)%mod * temp)%mod;\n}\n\n\nvoid solve()\n{\n ll n;\n cin>>n;\n if(n%10 ==4 || n%10==9)\n {\n cout<< ((n-4)/5 +1)*8 <>t;\n rep(i,1,t+1)\n {\n solve();\n }\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dd59a4ff1ab9061364b665a8e052bebc", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "PyPy 3-64", "source_code": "#include\nusing namespace std;\n//#define ll long long\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vll;\ntypedef pair pi;\ntypedef pair pll;\n \n \n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n#define rep(i,a,b) for (int i = a; i < b; i++)\n#define prec(n) fixed<> i) & 1)\n#define maxArr(a,n) *max_element(a,a+n)\n#define minArr(a,n) *min_element(a,a+n)\n#define maxVec(a) *max_element(a.begin(), a.end())\n#define minVec(a) *min_element(a.begin(), a.end())\nvoid display(bool answer){cout << ((answer)?\"Yes\":\"No\");}\n#define pY {cout << \"Yes\"<= p2)\n {\n return tree[st];\n }\n if(qs > p2 || qe < p1)\n {\n return 0;\n }\n return max(query(tree,qs,qe,p1,mid,2*st),query(tree,qs,qe,mid+1,p2,2*st+1));\n}\n \nvoid dfs(ll v,vll adj[],vector& visited,bool& flag,vector ss)\n{\n visited[v]=true;\n if(ss[v])\n {\n flag=false;\n }\n for(auto it:adj[v])\n {\n if(!visited[it])\n {\n dfs(it,adj,visited,flag,ss);\n }\n }\n}\n \n\nll power(ll x, ll y)\n{\n int temp;\n if( y == 0)\n return 1;\n temp = (power(x, y / 2))%mod;\n if (y % 2 == 0)\n return (temp * temp)%mod;\n else\n return (((x%mod) * temp)%mod * temp)%mod;\n}\n\n\nvoid solve()\n{\n ll n;\n cin>>n;\n if(n%10 ==4 || n%10==9)\n {\n cout<< ((n-4)/5 +1)*8 <>t;\n rep(i,1,t+1)\n {\n solve();\n }\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a49427caa4f31ba5202edd8f7b513d2e", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\r\ni=n+2\r\nj=2\r\nwhile j2:\r\n print(math.floor(4N/3+3))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e8e8ff38df53b6a0731eeed9a51386ad", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input()\r\nprint(2*n+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "804df7738feb2af858261e4498b42516", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom collections import defaultdict\nfrom itertools import combinations\nfrom itertools import permutations\ninput = lambda : sys.stdin.readline().rstrip()\ndef write(*args, sep=\"\\n\"):\n for i in args:\n sys.stdout.write(\"{}\".format(i) + sep)\nINF = float('inf')\nMOD = int(1e9 + 7)\n\ndef prime(x):\n ret = []\n for i in range(1, int(x**0.5) + 1):\n if x % i == 0:\n ret.append(i)\n ret.append(x // i)\n \n ret2 = []\n \n for i in ret:\n flag = True \n for j in range(2, int(i**0.5) + 1):\n if i % j == 0:\n flag = False\n break \n if flag:\n ret2.append(i)\n \n ret2.remove(1)\n return ret2\n\nx, n = map(int, input().split())\nans = 1\np = prime(x)\n#print(p)\n\nfor i in p:\n s = 0\n for j in reversed(range(1, 65)):\n temp = i ** j\n if temp > n:\n continue\n else:\n # temp \ub85c \ub098\ub220\uc9c0\ub294 \uac83\ub4e4\uc758 \uac1c\uc218 n // temp\n # print(n, temp, n // temp, s)\n ans *= pow(temp, n//temp - s, MOD)\n ans %= MOD \n s += n // temp - s\n ans %= MOD\n \n\nprint(ans % MOD) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e093991c790e62b0a2e8a7eb8a87f114", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\n#525 63\n#20190929 1605\n#947 987654321987654321\ndef prime_factorization(n):\n sqrt_n = int(math.sqrt(n))\n bs = [False, False] + [True] * (sqrt_n-1)\n ps = []\n for i in range(2, sqrt_n+1):\n if bs[i]:\n if n % i == 0:\n ps.append(i)\n for j in range(2*i, sqrt_n+1, i):\n bs[j] = False\n ck = True\n # \uc790\uae30\uc790\uc2e0\uc774 \uc18c\uc218\uc77c \uacbd\uc6b0\n for i in range(2, n):\n if n % i == 0:\n ck = False\n if ck:\n ps.append(n)\n return ps\nx, n = map(int, input().split())\nps = prime_factorization(x) # \uc774 \ubd80\ubd84\uc5d0\uc11c \uc2dc\uac04\uc774 \ub9ce\uc774 \uac78\ub9bc, \uc218\uc815\ud544\uc694\n# \uc5d0\ub77c\ud1a0\uc2a4\ud14c\ub124\uc2a4\uc758 \uccb4\ub97c \uc751\uc6a9\ud568\nz = 1\nmodulo = (10**9+7)\nfor i in ps:\n c = 0\n for j in range(int(math.log(n, i)), 0, -1):\n f = i ** j\n nf = n//f\n z *= pow(f, (nf - c), modulo)\n # pow(x, y, z) == pow(x, y) % z (but more faster!!)\n # prevent overflow\n # a*b%c == ((a%c) * (b%c)) % c\n c = nf\nprint(z % modulo)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1cec21a7719546c58232d30bef197aeb", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x, n = list(map(int, input().split()))\n\na = []\nif not x % 2:\n\ta.append(2)\nfor i in range(3, int(x ** 0.5 + 1), 2):\n if not x % i:\n b = sorted(a[:])\n for j in b:\n if j * j - 1 > i:\n a.append(i)\n break\n if not i % j:\n break\n else:\n a.append(i)\n\nb = sorted(a[:])\nfor i in b:\n\tif x < 10:\n\t\tbreak\n k = x // i\n for j in b:\n if j * j - 1 > k:\n a.append(k)\n break\n if not k % j:\n break\n else:\n a.append(k)\nif not len(a):\n a.append(x)\na = sorted(a)\n\nf, mod = 1, int(1e9 + 7)\nfor p in a:\n\tm, c = n, 0\n\tk, l = 1, p\n\twhile l <= m:\n\t\tc += m // l\n\t\tk += 1\n\t\tl = p ** k\n\tf *= pow(p, c, mod)\nf = int(f)\t\nprint(f % mod)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "34e27e68aff0b9030186e684719ee97a", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "import sys\nsys.setrecursionlimit(100000)`\nfrom future import division\nrange = xrange\ninput = raw_input\n\ndef factors(n):\n ans=[]\n if(n%2==0):\n ans.append(2)\n while(n%2==0):\n n//=2\n for i in range(3,int(n**0.5)+1,2):\n if(n%i==0):\n ans.append(i)\n while(n%i==0):\n n//=i\n if(n>2):\n ans.append(n)\n return ans\n\n\nx,n=input().split()\nx=int(x)\nn=int(n)\nfactor=factors(x)\nans=1\nfor i in factor:\n if(n//i>0):\n k=0\n j=n\n while(j!=0):\n j=j//i\n k+=j\n k%=1000000006\n ans*=pow(i,k,1000000007)\n ans%=1000000007\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "383be9f7497e42794e5314838ef6ce53", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "x, n = [int(x) for x in input().split()]\n\nfrom math import sqrt, ceil, log\n\nprimes = [0]*(10**4*6)\n\nfor i in range(2, len(primes)):\n\tif primes[i] == 0:\n\t\tprimes[i] = i\n\t\tfor j in range(2*i, len(primes), i):\n\t\t\tprimes[j] = -1\n\nPrimes = []\nfor prime in primes:\n\tif prime >= 2:\n\t\tPrimes.append(prime)\n\nprimes = Primes\n\ndef containspower(base, num):\n\tl, r = 0, int(log(num, base)+1)\n\twhile r-l > 1:\n\t\tc = (l + r) // 2\n\t\tif num % (base**c) == 0:\n\t\t\tl = c\n\t\telse:\n\t\t\tr = c\n\treturn l\n\ndef factor(x):\n\tans = []\n\tfor i in primes:\n\t\tif x % i == 0:\n\t\t\tans.append((i, containspower(i, x)) )\n\t\t\tx //= i**ans[-1][1]\n\tif x != 1:\n\t\tans.append((x, 1))\n\treturn ans\n\n\nxx = factor(x)\nprint(xx)\n\nans = 1\nfor p, power in xx:\n\tpa = 1\n\tfor i in range(1, int(log(n, p))+5):\n\t\ta = pow(p, (n // p**i), 10**9+7)\n\t\tprint(f\"{a = } {p = } {i = }\")\n\t\tpa *= a if a != 0 else 1\n\tans *= pa\n\tans %= 10**9+7\n\nprint(ans % (10**9+7))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dde11b49fc111bb0c7f09895d60b0c60", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "\r\nn, k=map(int, input().split())\r\nmod=1000000000+7\r\n\r\nif(k>=n):\r\n ans=1\r\n for i in range(n):\r\n ans*=2\r\n ans%=mod\r\n print(ans)\r\nelse:\r\n fak=[1 for i in range(n+1)]\r\n fak[1]=1\r\n for i in range(2, n+1):\r\n fak[i]=fak[i-1]*i\r\n\r\n\r\n s=1\r\n for i in range(1, k+1):\r\n s+=((fak[n]//(fak[n-i]))//fak[i])\r\n s%=mod\r\n print(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a9061e76ff55dd72e303a41b0bc9b448", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nMOD = 10 ** 9 + 7\r\n\r\n\r\n\r\n\r\ndef solve():\r\n n, k = list(map(int, input().split()))\r\n # c = [0] * (k + 1)\r\n # c[0] = 1\r\n # for i in range(k):\r\n # c[i + 1] = (c[i] * (n - i)) // (i + 1)\r\n if k >= n:\r\n print(ans)\r\n return\r\n cur = 1\r\n ans = 0\r\n for i in range(k + 1):\r\n ans += cur\r\n ans %= MOD\r\n cur = (cur * (n - i)) // (i + 1)\r\n print(ans)\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n\r\n\r\n\r\n\r\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3d74157fa9046e348a252dbb1737c323", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n,k = map(int,input().split())\r\nMOD = 1000000007\r\ncur = 1\r\nans = 0\r\nfor i in range(k+1):\r\n ans+=cur\r\n cur*= (n-i)*pow(i+1,MOD-2,MOD)\r\nprint(ans%=MOD)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1a1365b8b8f05ede012d255cb92567eb", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "'''\r\ndef soch(n,k):\r\n r,e=max(k,n-k),min(k,n-k)\r\n ans=1\r\n ansv=1\r\n for i in range(r+1,n+1):\r\n ans*=i\r\n for i in range(1,e+1):\r\n ansv*=i\r\n return ans//ansv\r\nn,k=map(int,input().split())\r\nans=1\r\ns=1\r\ny=k-n//2\r\nif k0 and i>=y:\r\n ans+=s\r\n if y>0 and i%2==1:\r\n ans-=s\r\n print(ans%(10**9+7))\r\nelse:\r\n print(pow(2,n,10**9+7))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ccca97d23ad1b3a3e4953c5fc73280f1", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nMOD = 10 ** 9 + 7\r\n\r\n\r\n\r\n\r\ndef solve():\r\n n, k = list(map(int, input().split()))\r\n # c = [0] * (k + 1)\r\n # c[0] = 1\r\n # for i in range(k):\r\n # c[i + 1] = (c[i] * (n - i)) // (i + 1)\r\n if k >= n:\r\n print(n)\r\n return\r\n cur = 1\r\n ans = 0\r\n for i in range(k + 1):\r\n ans += cur\r\n ans %= MOD\r\n cur = (cur * (n - i)) // (i + 1)\r\n print(ans)\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n\r\n\r\n\r\n\r\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5ef0f68df0ad92d0f7ceb546b58a609c", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n=int(input());\r\nk=1;\r\np=6;\r\nn-=1;\r\nfor i in range (n):\r\n k*=2;\r\n p=p*(4**k)\r\n p%=10**9+7\r\np=(int)p\r\nprint(p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d4e58d02dfdf4873e64f5ae69c123b2", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input());\r\nk=1;\r\np=6;\r\nn-=1;\r\nfor i in range (n):\r\n k*=2;\r\n p=p*(4**k)\r\n p%=1000000007\r\n\r\nprint((int)p);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7eac811825912b25f9722a1d3b68eefc", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import time\r\nimport os,sys\r\nfrom datetime import datetime\r\nfrom math import floor,sqrt,gcd,factorial,ceil,log2\r\nfrom collections import Counter,defaultdict\r\nimport bisect\r\nfrom itertools import chain\r\nfrom collections import deque\r\nfrom sys import maxsize as INT_MAX\r\nfrom itertools import permutations\r\nfrom collections import deque\r\n#import threading\r\n'''Dont use setrecursionlimit in pypy'''\r\n#sys.setrecursionlimit(int(1e9)+500)\r\n#threading.stack_size(0x2000000)\r\nONLINE_JUDGE,INF,mod=False,float('inf'),int(1e9)+7\r\nif os.path.exists('D:\\\\vimstuff'):\r\n\tONLINE_JUDGE=True\r\n\tsys.stdin=open('D:\\\\vimstuff\\\\inp.txt','r')\r\n\tsys.stdout=open('D:\\\\vimstuff\\\\out.txt','w')\r\n'''def ceil(a,b):\r\n\treturn(int((a+b-1)/b))'''\r\n\r\ndef readint():\r\n\treturn int(sys.stdin.readline())\r\ndef readstr():\r\n\treturn sys.stdin.readline()\r\ndef readlst():\r\n\treturn list(map(int, sys.stdin.readline().strip().split()))\r\ndef readmul():\r\n\treturn map(int, sys.stdin.readline().strip().split())\r\ndef mulfloat():\treturn map(float, sys.stdin.readline().strip().split())\r\ndef flush():\r\n\treturn sys.stdout.flush()\r\ndef power_two(x):\r\n\treturn (1<= k):\r\n\t\t\tleftGreater = m\r\n\t\t\tr = m - 1\r\n\t\telse:\r\n\t\t\tl = m + 1\r\n\t\t\treturn (n - leftGreater)\r\n\r\ndef lower_bound(arr,n,val):\r\n\tl,r=-1,n\r\n\twhile r>l+1:\r\n\t\tm=int((l+r)>>1)\r\n\t\tif arr[m]l+1:\r\n\t\tm=int((l+r)>>1)\r\n\t\tif arr[m]<=val:\r\n\t\t\tl=m\r\n\t\telse:\r\n\t\t\tr=m\r\n\treturn l\r\n\r\ndef binpow(a,n,mod):\r\n\tres=1\r\n\twhile n:\r\n\t\tif n&1:\r\n\t\t\tres=(res*a)%mod\r\n\t\t\tn-=1\r\n\t\ta=(a*a)%mod\r\n\t\tn=n>>1\r\n\treturn res\r\n\r\ndef printmat(l,seperate=True):\r\n\tfor i in range(0,len(l)):\r\n\t\tif(seperate):\r\n\t\t\tprint(*l[i],sep=\" \")\r\n\t\telse:\r\n\t\t\tprint(*l[i],sep=\"\")\r\n\r\ndef is_perfect_square(num):\r\n\t#print(num)\r\n\ttemp = num**(0.5)\r\n\t#print(temp)\r\n\treturn (temp//1)==temp\r\n\r\ndef find(res):\r\n\tn1=res\r\n\twhile par[n1]!=n1:\r\n\t\tpar[n1]=par[par[n1]]\r\n\t\tn1=par[n1]\r\n\treturn n1\r\n\r\ndef union(u,v):\r\n\tp1,p2=find(u),find(v)\r\n\tif p1==p2:\r\n\t\treturn 0\r\n\tif(rank[p1]>rank[p2]):\r\n\t\tp1,p2=p2,p1\r\n\tpar[p1]=p2\r\n\trank[p2]+=rank[p1]\r\n\treturn 1\r\n\r\n\r\n'''\r\nc-space = to copy\r\no-space= to open file\r\n,-space=to run prog\r\n:noh= to get rid of text highlight\r\n\r\n1. Implement after understanding properly don't do in vain.\r\n2. Check corner cases.\r\n3. Use python if there is recursion,try-catch,dictionary.\r\n4. Use pypy if heavy loop,list slice.\r\n'''\r\ndef john_3_16():\r\n n=readint()\r\n num_node=2**n\r\n ans=binpow(4,num_node-2,mod)\r\n ans=(ans*6)%mod\r\n print(ans)\r\n return\r\n\t\r\ndef main():\r\n\t#tc=readint()\r\n\ttc=1\r\n\t#cnt=0\r\n\tstart=time.time()\r\n\t#cnt=1\r\n\twhile tc:\r\n\t\tjohn_3_16()\r\n\t\ttc-=1\r\n\t\t#cnt+=1\r\n\tif ONLINE_JUDGE:\r\n\t\tprint(f'{(time.time()-start)*1000}ms')\r\n\t\tpass\r\nmain()\r\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "65de97cc60183fcebff11ed8dbac060f", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "#include \r\nusing namespace std;\r\n#define ll long long\r\nconst int areTests = 0;\r\n\r\nint f(int n) {\r\n\tarray dp[n + 1];\r\n\tfor(int j = 0; j < 6; j++) dp[1][j] = 1;\r\n\tfor(int i = 2; i <= n; i++) {\r\n\t\tint s = 0;\r\n\t\tfor(int j = 0; j < 6; j++) s += dp[i - 1][j];\r\n\r\n\t\tfor(int j = 0; j < 6; j++) {\r\n\t\t\tdp[i][j] = s - dp[i - 1][j] - dp[i - 1][5 - j];\r\n\t\t}\r\n\t}\r\n\r\n\tint ans = 0;\r\n\tfor(int j = 0; j < 6; j++) ans += dp[n][j];\r\n\treturn ans;\r\n}\r\n\r\nvoid run_test(int testcase) {\r\n\tfor(int i = 1; i <= 12; i++) cout << f(i) << \" \";\r\n}\r\n\r\nint main() {\r\n\tios::sync_with_stdio(0);\r\n\t#ifndef DUSH1729\r\n\tcin.tie(0);\r\n\t#endif\r\n\tcout << fixed << setprecision(10);\r\n\r\n\tint t = 1;\r\n\tif(areTests) cin >> t;\r\n\tfor(int i = 1; i <= t; i++) {\r\n\t\trun_test(i);\r\n\t}\r\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2f1e55d60274f4049bb5ec9a5a7ebc64", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "int k = int(input())\r\nprint(6 * (pow(4,pow(2,k) - 2) % 1000000007) % 1000000007)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff40c6e1a7da588542fa7b942af11146", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "a1,b1,a2,b2,l,r=map(int,raw_input().split())\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\nlst1=[]\nlst2=[]\nks1=max(0,ks1)\nke1=max(0,ke1)\nks2=max(0,ks2)\nke2=max(0,ke2)\nfor i in range(ks1,ke1+2):\n if(a1*i+b1>=l and a1*i+b1<=r):\n lst1.append(a1*i+b1)\nfor i in range(ks2,ke2+2):\n if(a2*i+b2>=l and a2*i+b2<=r):\n lst2.append(a2*i+b2)\n\nset1=set(lst1)\nset2=set(lst2)\n\nl=len(set1.intersection(set2))\nprint l\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c3842c5bf3dc51d72668e901a77c7bf", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "from sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] )\n\n#print int(K)\n\n#print \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\n#print \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\n#print \"S\", a1 * (X + B*K/G) + b1, \"T\", a2 * (-Y + A*K/G) + b2\n\nK = max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] )\n\nANS = math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ) - K + 1\n\nprint max( [ 0, int(ANS) ] )\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b6679b6312ddd79debbf7ad4f53e9d8e", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "def gcd(a, b):\n if (a == 0):\n return [0, 1, b];\n res = gcd(b%a, a);\n d = res[2]\n x1 = res[0]\n y1 = res[1]\n return [y1 - (b // a) * x1, x1, d];\n\ndef find_any_solution(a, b, c):\n res = gcd(abs(a), abs(b))\n g = res[2]\n x0 = res[0]\n y0 = res[1]\n if (c % g != 0):\n return [False, 0, 0]\n x0 *= (c // g);\n y0 *= (c // g);\n if (a < 0):\n x0 = -x0;\n if (b < 0):\n y0 = -y0;\n return [True, x0, y0, g];\n# print(map(int, raw_input().split()))\na1, b1, a2, b2, L, R = map(int, raw_input().split())\nbo, l, r, g = find_any_solution(a1, a2, b2 - b1)\n# print(bo, l, r)\nif bo:\n aa = a1 * l + b1\n dd = (a1 * a2) // g\n bb = max(b1, b2)\n ll = (bb - aa + dd - 1) // dd\n aa = aa + dd * ll\n oo = max((L - aa + dd - 1) // dd, 0)\n op = (R - aa) // dd\n print(max(op - oo + 1, 0))\nelse:\n print(0)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58287eb46d042e21c4f59323df2598fb", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "\nimport 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 range(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": "6f7a56d5730909eb67a3d6ee4475c948", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n\ty = x1\n\treturn (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n X -= (X//dd) * dd\n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n if X > k:\n return 0\n return (k-X)//dd + 1\n \n \na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L+b1+a1-1)//a1\nd1 *= a1\nd1 += b1\nd2 = (L+b2+a2-1)//a2\nd2 *= a2\nd2 += b2\n\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2:\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c6885fb42a9021bf76c8f681ee5515a", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\n\nif b-a>=5:\n print(\"0\")\nelif:\n pro=1 \n for i in range(b-a):\n pro*=(b-i)\n print(pro%10)\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a70d739abc240ebe41ab9bbae7c90018", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "x,y = map(int, sorted(input().split()))\n\na = 1\na*=i for i in range (x+1,y+1)\n\nprint(str(a)[-1])\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b2b1ad2fe6b25450ffd23a8472c50f8", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a, b = [int(i) for i in input().split()]\nres = 1:\ni = a+1\nwhile res and i <=d:\n res = (res * (i%10))%10\nprint(res)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2866792e7946d99a80d95e41cfd4bec2", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "x, y = map(int, raw_input().split()) z = 1 x += 1 while x <= y: z = z * x % 10 x += 1 if z == 0: break print z", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f2ed1753df19c0f4d089d2ec6ba51c6", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import sys\n\n(a, b) = sys.stdin.readline().split()\na = int(a)\nb = int(b)\nif len(b - a) >= 10:\n print(0)\ninput = [x%10 for x in range(a + 1, b + 1)]\nelse:\n result = 1\n for x in input:\n result *= x\n result %= 10\n \n print(result)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79f6d66247231f83d6139f448e0b657a", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=input()\ns=input()\nn=int(n)\nt1=len(s)\nk=1\nsum=0\nwhile t1>0:\n m=0\n for i in range(0,t1):\n if int(s[i:t1])= n:\n i += 1\n k = int(m[i: j])\n while m[i] == '0': i += 1\n j = i\n s += k * p\n p *= n\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "773ce5f4e2644999f41a54d7c8197f31", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\nsl = len(s)\nl=[]\ndef rec(i):\n\tif(i>=sl):\n\t\ttot=0\n\t\tmul = 1\n\t\tfor i in range(len(l)-1,-1,-1):\n\t\t\ttot+=(mul*l[i])\n\t\t\tmul*=n\n\t\treturn tot\n\tif(s[i]=='0'):\n\t\tl.append(0)\n\t\ttot = rec(i+1)\n\t\tdel l[len(l)-1]\n\t\treturn tot\n\tj=1\n\tans = 1000000000000000000000000000\n\twhile(i+j<=sl):\n\t\tnum = int(s[i:i+j])\n\t\tif(num>=n):\n\t\t\tbreak\n\t\tl.append(num)\n\t\tans = min(ans,rec(i+j))\n\t\tdel l[len(l)-1]\n\t\tj+=1\n\treturn ans\nprint(rec(0))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3c7b800adc8f61beb968ee645b93d6d", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n=input('')\nk=input('')\nl=len(str(n))\nb=10**(n-1)\na=[str(k)[-1]]\nk=str(k)\nk=k[::-1]\nk=k[1:]\ncount=0\nfor i in k:\n if int(i+a[count])=1:\n for j in a[count-1][:len(a[count-1])-1]:\n if j=='0':\n a[count]=a[count]+'0'\n else:\n break\n \n \nans=0\nfor i in range(len(a)):\n ans+=((n**i)*int(a[i]))\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91a85e4ad9e1876874825910c0179d7f", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n#define sfi ({register int x;scanf(\"%d\",&x);x;})\nlong long pw1(int p)\n{\n long long r=1;\n for(int i=1;i<=p;i++)\n {\n r*=10;\n }\n return r;\n}\nlong long pw2(long long n,int j)\n{\n long long r=1;\n for(int i=0;i>s;\n reverse(s.begin(),s.end());\n /**\n create biggest number from smallest value digit to biggest value digit\n if found '0' then count it for next digit\n */\n long long num=0,cnt0=0,res=0,j=0;\n for(int i=0;i=n) /// generated number till present digit\n {\n //cout<=n)\n {\n j++;\n res+=(s[s.size()-1]-48)*pw2(n,j);\n }\n else res+=num*pw2(n,j);\n\n cout<>1)-1), dp(n-1, 1, n>>1))\n\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8e69db3426896ff7967485376caa61d4", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nx=list(map(int,input().split()))\np1,p2,c=[0]*101,[0]*101,[0]*2\nc[1],c[0]=n//2+n%2,n//2\ncount,edge,ans,temp1,temp2=0,[[]for i in range(2)],0,0,0\nfor i in range(n):\n if x[i]==0:\n count+=1\n if i==n-1:\n edge[x[i-count]%2].append(count)\n ans+=1\n if count==n:\n if n==1:\n ans=0\n break\n else:\n if count>0 and i-count-1>=0 and x[i]%2==x[i-count-1]%2==1:\n p1[count]+=1\n elif count>0 and i-count-1>=0 and x[i]%2==x[i-count-1]%2==0:\n p2[count]+=1\n elif count>0 and i-count==0:\n edge[x[i]%2].append(count)\n ans+=1\n elif i>0 and (count>0 or x[i]%2!=x[i-1]%2):\n ans+=1\n count=0\n c[x[i]%2]-=1\nfor i in range(1,10):\n temp1=min(p1[i],c[1]//i)\n p1[i]-=temp1\n c[1]-=i*temp1\n temp2-=min(p2[i],c[0]//i)\n p2[i]-=temp2\n c[0]-=i*temp2\n ans+=p1[i]*2\nfor i in range(2):\n for i2 in range(len(edge[i])):\n if c[i]>=edge[i][i2]:\n ans-=1\n c[i]-=edge[i][i2]\nif x[0]==83\n ans+=2\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce099872c47fab518fbb05c7ece89101", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nps = [int(x) for x in input().split()]\nto_add = [x for x in range(1,n+1) if x not in ps]\n\nif all(x==0 for x in ps):\n if n == 1:\n print(0):\n exit()\n print(1)\n exit()\n\nfor t in to_add:\n so = (101, None) # odd = 0, even = 2\n se = (101, None) # odd = 0, even = 2\n so2 = (101, None) # odd = 0, even = 1\n se2 = (101, None) # odd = 1, even = 0\n mixed = None #even, odd\n left = None\n zero_count = 0\n for i, p in enumerate(ps):\n if p == 0:\n zero_count += 1\n else:\n if zero_count > 0:\n if left is None:\n if p%2==0:\n se2 = (zero_count, i-1)\n else:\n so2 = (zero_count, i-1)\n else:\n if p%2 == 0:\n if ps[left]%2 == 0:\n se = min(se, (zero_count, left+1))\n else:\n mixed = (i-1, left+1)\n else:\n if ps[left]%2 == 0:\n mixed = (left+1, i-1)\n else:\n so = min(so, (zero_count, left+1))\n zero_count = 0\n left = i\n if zero_count > 0:\n if p%2 ==0:\n se2 = min(se2, (zero_count, left+1))\n else:\n so2 = min(so2, (zero_count, left+1))\n if t%2 == 0:\n if se[1] is not None:\n ps[se[1]] = t\n elif se2[1] is not None:\n ps[se2[1]] = t\n else:\n assert(mixed is not None)\n ps[mixed[0]] = t\n else:\n if so[1] is not None:\n ps[so[1]] = t\n elif so2[1] is not None:\n ps[so2[1]] = t\n else:\n ps[mixed[1]] = t\nans = 0\nl = None\nfor i in range(len(ps)):\n if i == 0:\n continue\n if ps[i]%2 != ps[i-1]%2:\n ans += 1\nprint(ans)\n# print(ps)\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89d3a00d8568741941f72db6660993ab", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = map(int,input().split())\ns = list(s)\nimport math\nchet = 0\nnechet = 0\nposled = 0\nfor i in range(len(s)): #\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0442\u043d\u044b\u0445 \u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0445\n if s[i] == 0: # \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 0,1,2 \n continue\n elif s[i] % 2 == 0:\n chet = chet + 1\n posled = 2\n s[i] = 2\n else:\n nechet = nechet + 1\n posled = 1\n s[i] = 1\n\nchet = len(s)/2 - chet #\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0447\u0435\u0442\u043d\u044b\u0445 \u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0445 \nnechet = math.ceil(len(s)/2) - nechet\n\ns.append(posled)\n\nwhile chet + nechet > 0:\n for i in range(len(s)-1):\n if s[i] == 0: #\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 1 \u0438 2\n \n if s[i+1] == 2:\n if chet > 0:\n s[i] = 2\n chet = chet - 1\n else:\n s[i] = 1\n nechet = nechet - 1\n \n elif s[i+1] == 1:\n if nechet > 0:\n s[i] = 1\n nechet = nechet - 1\n else:\n s[i] = 2\n chet = chet - 1\n \n\ns = s[:-1]\notvet = 0 # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \ni = 0\nwhile i < len(s)-1:\n if s[i] == s[i+1]:\n i = i + 1\n else:\n otvet = otvet + 1\n i = i + 1\n \nprint(otvet)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "545bf4548dd57f03b2b32e2eed5b5b56", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\narr = list(map(int,input().split()))\nodds = evens = 0\nfor a in arr:\n if a!=0:\n odds += a%2\n evens += a%2==0\n\n \ndef parity(i, e, o, last=None):\n if i==n: return 0 \n elif arr[i]==0 and last==None:\n even = parity(i+1,e-1,o,0) if e>0 else float('inf')\n odd = parity(i+1,e,o-1,1) if o>0 else float('inf')\n return min( even, odd )\n elif last==None:\n return parity(i+1,e,o,arr[i]%2)\n elif arr[i]!=0:\n if arr[i]%2 != last: return 1 + parity(i+1,e,o,arr[i]%2)\n else: return parity(i+1,e,o,last)\n else:\n if last==1:\n if o!=0 and e!=0: return min( 1+parity(i+1,e-1,o,0), parity(i+1,e,o-1,1) )\n elif o==0: return 1+parity(i+1,e-1,o,0)\n else: return parity(i+1,e,o-1,1)\n else:\n if o!=0 and e!=0: return min(1+parity(i+1,e,o-1,1), parity(i+1,e-1,o,0))\n if e==0: return 1+parity(i+1,e,o-1,1)\n else: return parity(i+1,e-1,o,0)\n \nprint(parity(0,n//2-evens,(n+1)//2-odds))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "122b2f260c924b6debcc2c329fb1deb9", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "print (4 * int(raw_input() -1) / 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a3353fb33738a19502dec5128c84d24", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Python 3", "source_code": "print(int(1.5*int(input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "adb3ce3af5dc1a18c06e2ad8df6290e2", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Python 3", "source_code": "print(int(*int(input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9b89db258d9f39e2b273a1d48221ac03", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Python 3", "source_code": "print(int(input()//2*3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7bddc079d85acbce3cdf1f28a1628579", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Python 3", "source_code": "print(int(input()*3/2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "007c946e557a49212ae2e0a519942652", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=eval(input())\ns=input()\ni=0\nc=0\nwhile(i x/2 + x/3 - x/6):\n\tx+=1\nprint x", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4bdce11f5b78d91ee7c7cd448780305e", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ntask = input()\nl = [[0,0]]\ndrp = {}\n\ndrp[(0,0)] = 1\nc = 0 \n\nfor i in task :\n\tif i == 'U' :\n\t\tl.append([ l[-1][0] , l[-1][1]+1 ])\n\t\tif tuple(l[-1]) not in drp :\n\t\t\tdrp[tuple(l[-1])] = 1\n\t\telse:\n\t\t\tdrp[tuple(l[-1])] += 1\n\telif i == 'D' :\n\t\tl.append([ l[-1][0] , l[-1][1]-1 ])\n\t\tif tuple(l[-1]) not in drp :\n\t\t\tdrp[tuple(l[-1])] = 1\n\t\telse:\n\t\t\tdrp[tuple(l[-1])] += 1\n\telif i == 'L' :\n\t\tl.append([ l[-1][0]-1 , l[-1][1] ])\n\t\tif tuple(l[-1]) not in drp :\n\t\t\tdrp[tuple(l[-1])] = 1\n\t\telse:\n\t\t\tdrp[tuple(l[-1])] += 1\n\t else :\n\t\tl.append([ l[-1][0]+1 , l[-1][1] ])\n\t\tif tuple(l[-1]) not in drp :\n\t\t\tdrp[tuple(l[-1])] = 1\n\t\telse:\n\t\t\tdrp[tuple(l[-1])] += 1\nfor k,v in drp.items() :\n\tif v >=2 :\n\t\tc += (v*(v-1))//2\n\nprint(c)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e77e37a3515efdd049a712671ba8dbb", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "h1, h2 = map(int, raw_input().split(\" \"))\na, b = map(int, raw_input().split(\" \"))\nday = 0\nc = h1\nwhile True:\n if day > 1 and b > a:\n day = -1\n break\n if day == 0:\n c += a * 8\n else:\n c += a * 12\n if c >= h2:\n break\n c -= b * 12\n day += 1\nprint day\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c576308596ffb5f2c1c5d1cb5887b125", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "ch=input()\nd=ch.split()\nh1=int(d[0])\nh2=int(d[1])\nch=input()\nd1=ch.split()\na=int(d1[0])\nb=int(d1[1])\nS=2\nD=0\nif h1a and 8*a<(h2-h1):\n print(-1)\n else:\n if h1

=(h2-h1):\n print(0)\n else:\n h1+=a*8\n h1-=b*12\n D+=1\n while h1=h2:\n break\n h1+=(a-b)*12\n D+=1\n if D!=0:\n print(D)\nelse:\n h1+8*a\n if a>b and 12*b<(h1-h2):\n print(-1)\n else:\n if h1>h2 :\n \n if 12*b>=(h1-h2):\n print(0)\n else:\n h2+=a*12\n h2-=b*12\n D+=1\n while h1>h2:\n if h2-b*12>=h1:\n break\n h2+=(b-a)*12\n D+=1\n if D!=0:\n print(D)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "25b9054f34a591bacea35f45bc9ade08", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import sys\nh1, h2 = map(int, input().split())\na, b = map(int, input().split())\n\n#a =2 #\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0440\u0445\n#b =1 #\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043f\u043e\u043b\u0437\u0430\u043d\u0438\u044f\n#h1 =1 #\u0441\u0442\u0430\u0440\u0442 \u0447\u0435\u0440\u0432\u044f\n#h2 =300 #\u0432\u044b\u0441\u043e\u0442\u0430 \u044f\u0431\u043b\u043e\u043a\u0430\nr = a #\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f\n\n\nif h2 < h1: #\u043f\u0440\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432\u0432\u0435\u0440\u0445\n print('false')\n\n \nday = 0\nr = a*8+h1 #\u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 (\u0441 14 \u0434\u043e 22) \n\n\nif a < b and a*8 + h1 <= h2: #\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043f\u0435\u043b \u043b\u0438 \u0447\u0435\u0440\u0432\u044f\u043a \u0437\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u043d\u044f \u0438 \u0435\u0441\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u0434\u0430\u0435\u043c -1\n day = -1\nelse: #\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f - \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0446\u0438\u043a\u043b\n while r < h2: #\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430: \u043f\u043e\u043a\u0430 R \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u044b\u0441\u043e\u0442\u044b 2 \n r = r - b * 12 #\u0441\u043f\u043e\u043b\u0437\u0430\u0435\u043c \u0432\u043d\u0438\u0437\n #print ('v',r)\n r = r + a * 12 #\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u043d\u0435\u0432\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445\n #print ('^', r) \n day = day +1 #\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0434\u043d\u0435\u0439\n \n \n\n \n\n\nprint (day)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5734d51dd42f52418c88a678b749a2d", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "int h1, h2\nint a, b\n\n\n#a =2 #\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0440\u0445\n#b =1 #\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043f\u043e\u043b\u0437\u0430\u043d\u0438\u044f\n#h1 =1 #\u0441\u0442\u0430\u0440\u0442 \u0447\u0435\u0440\u0432\u044f\n#h2 =300 #\u0432\u044b\u0441\u043e\u0442\u0430 \u044f\u0431\u043b\u043e\u043a\u0430\nr = a #\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f\n\n\nif h2 < h1: #\u043f\u0440\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432\u0432\u0435\u0440\u0445\n print('false')\n\n \nday = 0\nr = a*8+h1 #\u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 (\u0441 14 \u0434\u043e 22) \n\n\nif a < b and a*8 + h1 <= h2: #\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043f\u0435\u043b \u043b\u0438 \u0447\u0435\u0440\u0432\u044f\u043a \u0437\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u043d\u044f \u0438 \u0435\u0441\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u0434\u0430\u0435\u043c -1\n day = -1\nelse: #\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f - \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0446\u0438\u043a\u043b\n while r < h2: #\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430: \u043f\u043e\u043a\u0430 R \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u044b\u0441\u043e\u0442\u044b 2 \n r = r - b * 12 #\u0441\u043f\u043e\u043b\u0437\u0430\u0435\u043c \u0432\u043d\u0438\u0437\n #print ('v',r)\n r = r + a * 12 #\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u043d\u0435\u0432\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0440\u0445\n #print ('^', r) \n day = day +1 #\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0434\u043d\u0435\u0439\n \n \n\n \n\n\nprint (day)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2fba81df48bb39558ad1aa8539de643a", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "'__author__'=='deepak Singh Mehta(learning Dp, failing alot :( )) '\n\nmod = 100\n\n\ndef matrix_chain_order(matrices):\n global mod\n matrices_length = len(matrices)\n #initializing all the fields with 0..\n T = [[0 for _ in range(matrices_length)] for _ in range(matrices_length)]\n csum = 0\n for _ in range(len(matrices)):\n csum+=\n\n #initial 2 rows and columns are never used, they just have been introduced for simplicity in computation....\n for gap in range(2, matrices_length):\n for i in range(0, matrices_length - gap):\n j = i + gap\n T[i][j] = 10000\n for k in range(i + 1, j):\n temp = T[i][k] + T[k][j] + matrices[i] * matrices[k]\n #Optimizing condition...\n T[i][j]=min(T[i][j],temp)\n \n\n return T[0][-1]\n\n\nif __name__ == '__main__':\n tests = int(input())\n for _ in range(tests):\n mat = list(map(int,input().split()))\n print(matrix_chain_order(mat))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b711a171cba150064404bb4a02b9b50", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n# !/usr/bin/python3\n\n\"\"\"\n@author: myz\n@file: main.py\n@time: 17-9-9 \u4e0b\u53482:36\n\"\"\"\n\n\ndef ans(index, arr, d, length):\n\tif index >= length:\n\t\treturn d & 1 == 1\n\n\tif arr[index] != 1:\n\t\treturn False\n\n\twhile index < length:\n\t\tif arr[index] == 1:\n\t\t\tif ans(index + 1, arr, d + 1, length):\n\t\t\t\treturn True\n\t\tindex += 2\n\n\treturn False\n\n\nn = int(input())\na = list(map(lambda x: int(x) % 2, input().strip().split(' ')))\n\nif ans(0, a, 0, n):\n\tprint(\"yes\")\nelse:\n\tprint(\"no\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "53f1c7ed54a5fa71127eeb39f73a9a83", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = 0\narr = []\n\ndef log(func):\n def f(*args):\n res = func(*args)\n print(f'{func.__name__}({args}) = {res}')\n return res\n \n return f\n\n\n# @log\ndef check1(i, j):\n # assert (j - i) % 2 == 1\n return not (arr[i] % 2 == 0 or arr[j - 1] % 2 == 0)\n\n# @log\ndef check2(i, j):\n # assert (j - i) % 2 == 0\n for k in range(i + 1, j, 2):\n if check1(i, k) and check1(k, j):\n return True\n\n for k in range(i + 2, j - 1, 2):\n if check2(i, k) and check2(k, j):\n return True\n \n return False\n\ndef main():\n global n\n global arr\n n = int(input())\n arr = list(map(int, input().split(' ')))\n\n if n % 2 == 0:\n return False\n\n return check1(0, n)\n\n\nif main():\n print('Yes')\nelse:\n print('No')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "66ad73cbce5ab1904d4e1b410161b619", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "n=input()\na=map(int,raw_input().split())\nif n%2==0:\n\tprint 'No'\nelif a[0]%2==0||a[n-1]%2==0:\n\tprint 'No'\nelse: print 'Yes'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e82a7ab17f6f5d1d0b498c48c1d635f", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n\n int a[n],i;\n for(i=0; i= 3 || c==4:\n return True\n return False\n\ndef main():\n for i in range(0, 4):\n s1=raw_input()\n li.append(s1)\n if judge() :\n print 'YES'\n else :\n print 'NO'\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b624c84ef3168ad26672f8216e8d8327", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "L2=[]\nL=[]\nfor i in range(4):\n L=[]\n ch=input()\n L.extend(ch)\n L2.append(L) \ntest=False \nfor i in range(3):\n for j in range(3):\n L1=[]\n L1.append(L2[i][j])\n L1.append(L2[i+1][j])\n L1.append(L2[i][j+1])\n L1.append(L2[i+1][j+1])\n if L1.count('.')>=3 or L1.count('#')>=3 4 \n test=True\n break\n if test:\n break\nif test:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cd9ae025ba581df6d5e76a00893a5f75", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": " l = [\"\"]*4\n a = False\n for i in range(4):\n l[i] = list(input())\n \n for i in range(3):\n if a == False: \n for j in range(3):\n if (l[i+1][j+1] == l[i+1][j] and l[i+1][j+1] == l[i][j+1]) or (l[i][j] == l[i+1][j] and l[i][j] == l[i][j+1]) or (l[i][j] == l[i+1][j+1] and l[i][j] == l[i][j+1]) or (l[i][j] == l[i+1][j] and l[i][j] == l[i+1][j+1]):\n a = True\n break\n \n if a == True:\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "48973bcaad9e02691d8b62a8f498b569", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "for id in range(1, 51): print(int(((min(id, 25) + id) % (2 + id % 3)) > 0))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f632a3398dd6aca3a3e8fa6b3c4413d", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 2", "source_code": "import numpy as np\nimport cv2\nfrom matplotlib import pyplot as plt\n\n'''\npath = \"/home/beatrice/code/codeforce/fourierDoodles/\"\n\ni = 1\nfor i in range(1,21,1):\n img = cv2.imread(path + str(i) + \".png\",0)\n f = np.fft.fft2(img)\n fshift = np.fft.fftshift(f)\n magnitude_spectrum = 20*np.log(np.abs(fshift))\n\n plt.subplot(121),plt.imshow(img, cmap = 'gray')\n plt.title('Input Image'), plt.xticks([]), plt.yticks([])\n plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')\n plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])\n plt.show()\n'''\n\na = str(raw_input())\n\ndef bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return (( min ( id , 25 ) + id ) % ( 2 + id % 3 )) > 0\n\nfor i in range(21,51,1):\n print(bool2Bit(secretFunction(i)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a51a764fd96da4b287f0190970f95299", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 2", "source_code": "import numpy as np\nfrom PIL import Image\nimport cv2\nfrom matplotlib import pyplot as plt\n\nout = [1,\n 0,\n 0,\n 1,\n 1,\n 0]\n\npath = \"/home/beatrice/code/codeforce/fourierDoodles/\"\n'''\ni = 1\nfor i in range(1,51,1):\n img = cv2.imread(path + str(i) + \".png\",0)\n f = np.fft.fft2(img)\n fshift = np.fft.fftshift(f)\n magnitude_spectrum = 20*np.log(np.abs(fshift))\n\n plt.subplot(121),plt.imshow(img, cmap = 'gray')\n plt.title('Input Image'), plt.xticks([]), plt.yticks([])\n plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')\n plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])\n plt.show()\n'''\n\ndef bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return bool2Bit(((min(id,25)+id)%2 + id % 3) > 0)\n\nfor i in range(21,51,1):\n print(secretFunction(i))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0bae52bde177bcb4b52135aa7fce3a02", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 2", "source_code": "import numpy as np\nimport cv2\nfrom matplotlib import pyplot as plt\n\n'''\npath = \"/home/beatrice/code/codeforce/fourierDoodles/\"\n\ni = 1\nfor i in range(1,21,1):\n img = cv2.imread(path + str(i) + \".png\",0)\n f = np.fft.fft2(img)\n fshift = np.fft.fftshift(f)\n magnitude_spectrum = 20*np.log(np.abs(fshift))\n\n plt.subplot(121),plt.imshow(img, cmap = 'gray')\n plt.title('Input Image'), plt.xticks([]), plt.yticks([])\n plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')\n plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])\n plt.show()\n'''\n\ndef bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return (( min ( id , 25 ) + id ) % ( 2 + id % 3 )) > 0\n\nfor i in range(21,51,1):\n print(bool2Bit(secretFunction(i)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "89697079b60b637401a85ba31d6b83a3", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 2", "source_code": "import numpy as np\nimport cv2\nfrom matplotlib import pyplot as plt\n\n'''\npath = \"/home/beatrice/code/codeforce/fourierDoodles/\"\n\ni = 1\nfor i in range(1,21,1):\n img = cv2.imread(path + str(i) + \".png\",0)\n f = np.fft.fft2(img)\n fshift = np.fft.fftshift(f)\n magnitude_spectrum = 20*np.log(np.abs(fshift))\n\n plt.subplot(121),plt.imshow(img, cmap = 'gray')\n plt.title('Input Image'), plt.xticks([]), plt.yticks([])\n plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')\n plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])\n plt.show()\n'''\n\nfor i in range(20):\n a = int(raw_input())\n\ndef bool2Bit(b):\n if(b):\n return '1'\n return '0'\n\ndef secretFunction(id):\n return (( min ( id , 25 ) + id ) % ( 2 + id % 3 )) > 0\n\nfor i in range(21,51,1):\n print(bool2Bit(secretFunction(i)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eaac0d29b05a5c61c039ed46f012cee2", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "Python 2", "source_code": "#include \n#include \n\nusing namespace std;\nint n, a[105][3], act[105];\n\nint max(int a, int b) {\n\tif (a > b) return a;\n\telse return b;\n}\n\nint main(){\n\tcin >> n;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> act[i];\n\ta[0][0] = 0; \n\tif (act[0] == 1 || act[0] == 3) a[0][1] = 1; \n\tif (act[0] == 2 || act[0] == 3) a[0][2] = 1;\n\tfor (int day = 1; day < n; day++) {\n\t\tif (act[day] == 0) {\n\t\t\ta[day][0] = a[day-1][0];\n\t\t\ta[day][0] = max(a[day][0], a[day-1][1]);\n\t\t\ta[day][0] = max(a[day][0], a[day-1][2]);\n\t\t}\n\t\t// cout << a[day][0] << \" . \";\n\t\tif (act[day] == 1 || act[day] == 3) \n\t\t\ta[day][1] = max(a[day-1][2] + 1, a[day-1][0] + 1);\n\t\t// cout << a[day][1] << \" . \";\n\t\tif (act[day] == 2 || act[day] == 3)\n\t\t\ta[day][2] = max(a[day-1][1] + 1, a[day-1][0] + 1);\n\t\t// cout << a[day][2] << \" . \";\n\t\t// cout << endl;\n\t}\n\tint retVal = a[n-1][0];\n\tif (retVal < a[n-1][1]) retVal = a[n-1][1];\n\tif (retVal < a[n-1][2]) retVal = a[n-1][2];\n\tcout << n - retVal << endl;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "505ee4caa8dc0ee1b8844af8f87d67e2", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input().strip())\na=[int(i) for i in input().strip().split()]\nx=0\nr=0\nfor i in a:\n if i==0 or (x xor i)==0:\n x=0\n r+=1\n else:\n x= x xor i\nprint(r)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d922d1e28edd8ce7086101f67404a71", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#include \n#include \n\nusing namespace std;\nint n, a[105][3], act[105];\n\nint main(){\n\tcin >> n;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> act[i];\n\ta[0][0] = 0; \n\tif (act[0] == 1 || act[0] == 3) a[0][1] = 1; \n\tif (act[0] == 2 || act[0] == 3) a[0][2] = 1;\n\tfor (int day = 1; day < n; day++) {\n\t\tif (act[day] == 0) {\n\t\t\ta[day][0] = a[day-1][0];\n\t\t\ta[day][0] = max(a[day][0], a[day-1][1]);\n\t\t\ta[day][0] = max(a[day][0], a[day-1][2]);\n\t\t}\n\t\t// cout << a[day][0] << \" . \";\n\t\tif (act[day] == 1 || act[day] == 3) \n\t\t\ta[day][1] = max(a[day-1][2] + 1, a[day-1][0] + 1);\n\t\t// cout << a[day][1] << \" . \";\n\t\tif (act[day] == 2 || act[day] == 3)\n\t\t\ta[day][2] = max(a[day-1][1] + 1, a[day-1][0] + 1);\n\t\t// cout << a[day][2] << \" . \";\n\t\t// cout << endl;\n\t}\n\tint retVal = a[n-1][0];\n\tif (retVal < a[n-1][1]) retVal = a[n-1][1];\n\tif (retVal < a[n-1][2]) retVal = a[n-1][2];\n\tcout << n - retVal << endl;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70d037578781a9563cc59716ed3e35f1", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "input()\n\nop = map(int, input().split(' '))\nans = 0\nnextOp = 0\n\nfor o in op:\n if o == 0:\n ans += 1\n nextOp = 0\n elif o == 3:\n nextOp = -nextOp % 3\n else:\n if o == nextOp:\n ans += 2\n nextOp = 0\n else:\n nextOp = o\nprint(ans)\n# \u51fd\u6570map\n# python\u4e2d\u7684\u8d1f\u6570\u6c42\u4f59\u8fd0\u7b97\u4e0ec\u548cc++\u8d1f\u6570\u6c42\u4f59\u8fd0\u7b97\u4e0d\u7528\n# \u5f53\u524d\u4e3a0,\u5fc5\u987b\u8981\u4f11\u606f\n# \u5f53\u8fd9\u4e00\u6b21\u4e0e\u4e0a\u6b21\u64cd\u4f5c\u76f8\u540c\u65f6,\u5fc5\u987b\u8981\u4f11\u606f,\u5e76\u8bbe\u7f6e\u4e0b\u4e00\u6b21\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u4e3a0\n# \u5f53\u8fd9\u4e00\u6b21\u4e0e\u4e0a\u6b21\u64cd\u4f5c\u4e0d\u540c\u65f6,\u4e0d\u7528\u4f11\u606f,\u5e76\u8bbe\u7f6e\u4e0b\u4e00\u6b21\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u4e3a\u672c\u6b21\u64cd\u4f5c\n# \u5f53\u672c\u6b21\u64cd\u4f5c\u4e3a3\u65f6,\u5206\u4e24\u79cd\u60c5\u51b5\u3002\u5982\u679c\u4e4b\u524d\u7559\u4e0b\u6765\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u4e3a1\u65f6,\u5c06\u4e0b\u4e00\u6b21\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u8bbe\u7f6e\u4e3a2.\u5373\u8fd9\u4e2a3\u76f8\u5f53\u4e8e\u672c\u6b21\u8fdb\u884c\u7684\u662f2\u64cd\u4f5c\n# \u5982\u679c\u4e4b\u524d\u7559\u4e0b\u6765\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u4e3a2\u65f6,\u5c06\u4e0b\u4e00\u6b21\u5fc5\u987b\u4f11\u606f\u7684\u64cd\u4f5c\u8bbe\u7f6e\u4e3a1.\u5373\u8fd9\u4e2a3\u76f8\u5f53\u4e8e\u672c\u6b21\u8fdb\u884c\u7684\u662f1\u64cd\u4f5c\n# \u8d1f\u6574\u6570\u53d6\u4f59\u8fd0\u7b97http://cuihao.is-programmer.com/posts/38553.html\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad89f0a70142e1716678494d8a111758", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\ndays = list(map(int, input().split(' ')))\n\nmin_rest = 1000\n\ndef dfs(day, prev_act, rest):\n\tif day == n:\n\t\tglobal min_rest\n\t\tmin_rest = min(min_rest, rest)\n\t\treturn\n\td = days[day]\n\tif (d == 1 or d == 3) and prev_act != 0:\n\t\tdfs(day + 1, 0, rest)\n\tif (d == 2 or d == 3) and prev_act != 1:\n\t\tdfs(day + 1, 1, rest)\n\tdfs(day + 1, -1, rest + 1)\n\t\t\t\ndfs(0, -1, 0)\nprint(min_rest)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9bc62dd14d5d54b1f5e1a42d066eb1f9", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "sw = input()\ns1 = input()\ns2 = input()\nsw = sw.split(' ')\ns1 = s1.split(' ')\ns2 = s2.split(' ')\n\ncurW = sw[0]\ncurH = sw[1]\nst1W = s1[0]\nst1H = s1[1]\nst2W = s2[0]\nst2H = s2[1]\nwhile(curH > 0 ):\n\tcurW += curH\n\tif curH == st1H:\n\t\tcurW -= st1W\n\telif curH == st2H:\n\t\tcurW -+ st2W\n\tcurH -= 1\nreturn curW\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d75b6680ba8d8e12e233dd13f69023d", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def rolling(w,h,u1,d1,u2,d2):\n\tw_new = w\n\twhile h>=0:\n\t\tw_new += h\n\t\t\n\t\tif h==d1:\n\t\t\tw_new -=u1\n\t\t\tif w_new < 0:\n\t\t\t\tw_new = 0\n\t\t\th -= 1\n\t\t\n\t\telif h==d2:\n\t\t\tw_new -= u2\n\t\t\tif w_new < 0:\n\t\t\t\tw_new = 0\n\t\t\th-=1\n\n\t\telse:\n\t\t\th-=1\n\tprint(w_new)\n\nw,h = map(int, input().split())\nu1,d1 = map(int, input().split())\nu2,d2 = map(int, input().split())}\nrolling(w,h,u1,d1,u2,d2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "53cfe0bcaa5619c442dfba9759b18757", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def rolling(w,h,u1,d1,u2,d2):\n\tw_new = w\n\twhile h>=0:\n\t\tw_new += h\n\t\t\n\t\tif h==d1:\n\t\t\tw_new -=u1\n\t\t\tif w_new < 0:\n\t\t\t\tw_new = 0\n\t\t\th -= 1\n\t\t\n\t\telif h==d2:\n\t\t\tw_new -= u2\n\t\t\tif w_new < 0\n\t\t\t\tw_new = 0\n\t\t\th-=1\n\n\t\telse:\n\t\t\th-=1\n\tprint(w_new)\n\nw,h = map(int, input().split())\nu1,d1 = map(int, input().split())\nu2,d2 = map(int, input().split())}\nrolling(w,h,u1,d1,u2,d2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c99e6b614789a0f30a2f56f03f4fd393", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b = map(int,input().split())\nw1,h1 = map(int,input().split())\nw2,h2 = map(int,input().split())\na+=(b+1)*b/2-(h1+1)*h1/2+h1\na = max(a-w1,0)\na+=(h1+1)*h1/2-(h2+1)*h2/2+h2\na = max(a-w2,0)\na+=(h2+1)*h2/\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "09b9a197d652cea9da4d30a4ab8436ac", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "Python 3", "source_code": "# import sys\n# sys.stdin = open(\"test.in\",\"r\")\n# sys.stdout = open(\"test.out\",\"w\")\nw,h=map(int,input().split())\nu1,d1=map(int,input().split())\nu2,d2=map(int,input().split())\nfor i in range(h,-1,-1):\n\tif i==d1:\n\t\tw=w-u1+i\n\telif i==d2:\n\t\tw=w-u2+i\n\telse:\n\t\tw=w+i\nprint(max(0,w)\t\t\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a83ee4fe89a69b139765231f41ead489", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "def prob(w,b):\n\tif(w == 0 or b < 0):\n\t\treturn 0\n\tif(b == 0):\n\t\treturn 1\n\tans1 = w/(w+b)\n\tif(b == 1):\n\t\tans2 = 0\n\telse:\n\t\tans2 = b/(w+b)*(b-1)/(w+b-1)*(prob(w-1,b-2)*w/(b+w-2)+prob(w,b-3)*(b-2)/(b+w-2))\n\treturn ans1+ans2\nw,b = map(int,input().split())\nprint(prob(w,b))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "af5fb8dbee42df0e38051b847f60f939", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "w, b = map(int, raw_input().split())\nk, p, q, s = 0, 0, 1, w + b\nwhile q and k < s:\n d = q * w / s\n p += d; q -= d; s -= 1\n d = q * w / s\n q -= d; s -= 1; k += 1\nprint p", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a66b6005a090f324f55024ba877d375a", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "w,b=map(float,input().split())\n\ndef fun(w,b):\n if w>0 and b>0:\n #case,\u8fd9\u91cc\u7684\u9012\u5f52\u6709\u95ee\u9898\uff0c\u7ea7\u6570\u548c\u7684\u95ee\u9898\n temp=b/(b+w)*(b-1)/(w+b-1)\n return w/(w+b)+temp*(w/(w+b-2)*fun(w-1,b-2)+(b-2)/(w+b-2)*fun(w,b-3))\n elif w>0 and b==0:\n return 1\n else:\n return 0\npro=fun(w,b)\nprint(pro)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7aa5c38e5baa6808defc3f2b5e2b7294", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#\u6982\u7387\u95ee\u9898\nw,b=map(float,input().split())\n\ndef fun(w,b):\n if w>0 and b>0:\n #case,\u8fd9\u91cc\u7684\u9012\u5f52\u6709\u95ee\u9898\uff0c\u7ea7\u6570\u548c\u7684\u95ee\u9898\n temp=b/(b+w)*(b-1)/(w+b-1)\n return w/(w+b)+temp*(w/(w+b-2)*fun(w-1,b-2)+(b-2)/(w+b-2)*fun(w,b-3))\n elif w>0 and b==0:\n return 1\n else:\n return 0\n\npro=fun(w,b)\nprint(pro)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "83ac9dad336696acc088d981eee86d98", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\n\nusing namespace std;\n\nconst int MAXN = 1100;\ndouble dp[MAXN][MAXN];\n\n\nint w, b;\n\ndouble DP(int wi, int bi)\n{\n if(0 == wi) return 0;\n if(dp[wi][bi] < 1.5) return dp[wi][bi];\n double ans = (double)wi / (wi + bi);\n if(0 == bi || bi == 1)\n {\n dp[wi][bi] = ans;\n return ans;\n }\n double s = double(bi) / (bi + wi) * double(bi - 1) / (wi + bi - 1);\n ans += s * double(wi) / (wi + bi - 2) * DP(wi - 1, bi - 2);\n if(bi > 2)\n ans += s * double(bi - 2) / (wi + bi - 2) * (DP(wi, bi - 3));\n\n dp[wi][bi] = ans;\n return ans;\n\n}\n\nint main()\n{\n// freopen(\"input.txt\", \"r\", stdin);\n\n scanf(\"%d %d\", &w, &b);\n\n for(int i = 0; i <= w; i++)\n {\n for(int j = 0; j <= b; j++)\n {\n dp[i][j] = 2;\n }\n }\n double ans = DP(w, b);\n printf(\"%.10lf\\n\", ans);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58f5fcd94eefb45c5ae0c2199cb78ef7", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n = input()\ncs = map(int, raw_input().split())\ncs = map(lambda x: x - 1, cs)\n\ndef gcd(m, n):\n if m < n: return gcd(n, m)\n r = m%n\n return gcd(n, r) if r else n\n\nres = 1\nfor i in xrange(n):\n\tcr = i\n p = 0\n for j in xrange(n):\n cr = cs[cr]\n if cr == i:\n p = j + 1\n if p % 2 == 0: p /= 2\n break\n else:\n print(-1)\n exit(0)\n res = res * p / gcd(res,p)\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3d993198dbb4bcf4707ed07074c9b2cd", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef solve(n, A):\n visited = [False] * n\n r = 1\n for x in range(n):\n if visited[x]:\n continue\n else:\n visited[x] = True\n \n y = A[x]\n k = 1\n while not visited[y]:\n visited[y] = True\n y = A[y]\n k += 1\n\n if y != x:\n return -1\n r = k * r // math.gcd(k, r)\n\n return r if r%2 else r//2\n\nn = int(input())\nA = [int(x)- 1 for x in input().split()]\n\nprint(solve(n, A))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0249b83b2469a146d56851c059f3b749", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "debug = False\n\ndef gcd(a, b):\n \"\"\"Return greatest common divisor using Euclid's Algorithm.\"\"\"\n while b: \n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n \"\"\"Return lowest common multiple.\"\"\"\n return a * b // gcd(a, b)\n\ndef lcmm(list_of_integers):\n \"\"\"Return lcm of args.\"\"\" \n if len(list_of_integers) > 2:\n return lcm(list_of_integers.pop(), lcmm(list_of_integers))\n else:\n return lcm(*list_of_integers)\n\ndef is_bijection(list_of_integers):\n buckets = [ 0 for _ in range(len(list_of_integers)) ]\n for number in list_of_integers:\n buckets[number] += 1\n return 0 not in buckets\n \ndef get_cycle_with_person(person, cycles):\n for cycle in cycles:\n if cycle[-1] == person:\n if debug:\n print('found person ' + str(person) + ' in cycle ' + str(cycle))\n return cycle\n return None\n\n\ndef get_cycle_with_crush(crush, cycles):\n for cycle in cycles:\n if cycle[0] == crush:\n if debug:\n print('found crush ' + str(crush) + ' in cycle ' + str(cycle))\n return cycle\n return None\n\ndef append_cycle_to_other_cycle(cycles, cycle, other_cycle):\n if debug:\n print('appending' + str(cycle) + ' to ' + str(other_cycle))\n for element in cycle:\n other_cycle.append(element)\n cycles.remove(cycle)\n\n\ndef make_new_cycle(first, second, cycles):\n cycles.append([first, second] if first != second else [first])\n\ndef get_cycle_length(cycle):\n return len(cycle)//2 if len(cycle)%2 == 0 else len(cycle)\n\ndef main():\n numer_of_people = int(input())\n crushes = list(map(lambda x: int(x) - 1, input().split(' ')))\n if debug:\n print(crushes)\n if not is_bijection(crushes):\n print('-1')\n return 0\n list_of_cycles = []\n for person, crush in enumerate(crushes):\n cycle_with_person = get_cycle_with_person(person, list_of_cycles)\n cycle_with_crush = get_cycle_with_crush(crush, list_of_cycles)\n if cycle_with_person is not None:\n if cycle_with_crush is not None:\n if cycle_with_person != cycle_with_crush:\n append_cycle_to_other_cycle(list_of_cycles, cycle_with_crush, cycle_with_person)\n else:\n cycle_with_person.append(crush)\n else:\n if cycle_with_crush is not None:\n cycle_with_crush.insert(0,person)\n else:\n make_new_cycle(person, crush, list_of_cycles)\n print(lcmm([ get_cycle_length(cycle) for cycle in list_of_cycles]))\n return 0\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2600f769e6226f9b5873df02254542fd", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def gcd(x, y):\n\tif (x < y): return gcd(y, x)\n\tif (y == 0): return x\n\treturn gcd(y, x%y)\n\ndef lcm(x, y):\n\treturn (x/gcd(x, y))*y;\n\ndef main():\n\tn = int(raw_input())\n\tadj = map(int, raw_input().split())\n\tfor u in range(n): adj[u] -= 1\n\tdeg = [0 for u in range(n)]\n\tfor x in adj: deg[x] += 1\n\tfor x in deg:\n\t\tif (x != 1):\n\t\t\tprint -1\n\t\t\treturn\n\tmarked = [True for u in range(n)]\n\tlenList = []\n\tval = 1\n\tfor u in range(n):\n\t\tif (marked[u] == False):\n\t\t\tcontinue\n\t\tv = u\n\t\tsz = 0\n\t\twhile marked[v] == True:\n\t\t\tmarked[v] = False\n\t\t\tsz += 1\n\t\t\tv = adj[v]\n\t\tif (sz%2 == 1):\n\t\t\tval = lcm(val, sz)\n\t\telse:\n\t\t\tlenList.append(sz)\n\t\n\tfor i in range(val, 2000000001, val):\n\t\tok = True\n\t\tfor x in lenList:\n\t\t\tif (not (i%(x//2) == 0 and (i//(x//2))%2 == 1)) and (not (i%x == 0)):\n\t\t\t\tok = False\n\t\tif (ok == True):\n\t\t\tprint i\n\t\t\treturn\n\tprint -1\n\treturn\n\n\nif (__name__ == \"__main__\"):\n\tmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ee880942a4304071864535f922da7c2", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, m, mw = map(int, input().split())\nmw += 1\nwe = list(map(int, input().split()))\nce = list(map(int, input().split()))\ngraph = [[] for i in range(n)]\nfor i in range(m):\n u, v = map(int, input().split())\n graph[u - 1].append(v -1)\n graph[v-1].append(u-1)\nused = [False] * n\nw = []\nc = []\nfor i in range(n):\n if not used[i]:\n stack = [i]\n res = []\n resc = []\n while stack:\n cur = stack.pop()\n used[cur] = True\n res.append(we[cur])\n resc.append(ce[cur])\n for u in graph[cur]:\n if not used[u]:\n stack.append(u)\n res.append(sum(res))\n resc.append(sum(resc))\n w.append(res)\n c.append(resc)\nm = 0\nF = [[0] * mw for i in range(len(w))]\nfor i in range(len(w)):\n for k in range(mw):\n for g in range(len(w[i])):\n if k >= w[i][g]:\n F[i][k] = max(F[i - 1][k], F[i - 1][k - w[i][g]] + c[i][g], F[i][k])\n else:\n F[i][k] = max(F[i][k], F[i-1][k-1])\nprint(F[-1][-1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f48387a82c25663ff35151504db3641", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, a, b = map(int, input().split())\n\nresult = (a + b) % n\n\nif(result == 0)\n print (n)\nelse\n print (result)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ca4cc43b4bc827a300102b26174ca43", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n, a, b = tuple (map(int, input().split()))\nif (a-b) % n ==0\n print(n)\nelse:\n print((a-b)%n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4b5b6ad947c321e2870377d93e474904", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "l=lambda:map(int,raw_input().split())\n\nn,a,b=l()\n\nprint (a=1+b)%n+1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "acd9ef5d72925188058c3bb3774d19e9", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "entrada = raw_input().split(\" \")\n\na = int(entrada[0])\nb = int(entrada[1])\nc = int(entrada[2])\n\nsaida = (b+c) % a\n\nif (saida == 0)\n saida = a\n\nprint saida", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7568308625d6f93434828fc328ff4225", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": " n , a, b = map(int, input().split())\n \n if b >= 0:\n ans = (a + b % n) % n\n if ans == 0:\n print(n)\n else:\n print(ans)\n else:\n ans = (a + (n - abs(b) % n)) % n\n if ans == 0:\n print(n)\n else:\n print(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e4c48aabf8ca6ff934d8660c83347736", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.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: \n\t break\n\t \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": "769cbf408ca0430527fd3dcf9f563b89", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "x0,y0,ax,ay,bx,by=map(int,input().split())\nxs,ys,t=map(int,input().split())\n\npoints=[]\npoints.append((x0,y0))\n#ax* x-1 +bx ay*y-1+by\n#nxtp=((x0*ax)+bx,(y0*ay)+by)\n#s=abs(nxtp[0]-x0)+abs(nxtp[1]-y0)\n#points.append(nxtp)\ns=0\nwhile(s<=t or (points[-1][0]<=(xs+t) and points[-1][1]<=(ys+t) ):\n\tnxtp=((points[-1][0]*ax)+bx,(points[-1][1]*ay)+by)\n\ts=abs(nxtp[0]-x0)+abs(nxtp[1]-y0)\n\tpoints.append(nxtp)\n\nc=0\n#print(points)\ncurr=(xs,ys)\nwhile(t>0):\n\ts=float('inf')\n\tp=[]\n\tfor i in points:\n\t\tx=abs(curr[0]-i[0])+abs(curr[1]-i[1])\n\t\t#print(x,i,s)\n\t\tif(xt):\n\t\t#print(p[0])\n\t\tbreak\n\tc=c+1\n\tt=t-p[0]\n\tcurr=p[1]\n\tpoints.remove(p[1])\n\t#print(p,c,t)\nprint(c)\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2a1e9fcc0c4377f43ab06f83bdcf9478", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.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: \n\t 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": "005e3e43a8773e8b38cac774e4e78c3f", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#include \n#include \n \nusing namespace std;\nusing ll_t = long long;\n \nint main()\n{\n ll_t x0,y0,ax,ay,bx,by,xs,ys,t;\n auto fx = [&](ll_t n)\n {\n long double an = powl(ax, n);\n return (long double)(an*x0*(ax - 1.) + (an - 1.)*bx) / (ax - 1.);\n };\n \n auto fy = [&](ll_t n)\n {\n long double an = powl(ay, n);\n return (long double)(an*y0*(ay - 1.) + an*by) / (ay - 1.);\n };\n\n auto f = [&](ll_t n)\n {\n ll_t txs = xs;\n ll_t tys = ys;\n ll_t tt = t;\n ll_t c = 0;\n for (ll_t i = n; i >= 0; i--)\n {\n ll_t ct = llabs(fx(i) - txs);\n ct += llabs(fy(i) - tys);\n if (tt < ct)\n break;\n tt -= ct;\n c++;\n txs = fx(i);\n tys = fy(i);\n }\n \n for (ll_t i = n+1; true; i++)\n {\n ll_t ct = llabs(fx(i) - txs);\n ct += llabs(fy(i) - tys);\n if (tt < ct)\n break;\n tt -= ct;\n c++;\n txs = fx(i);\n tys = fy(i);\n }\n return c;\n };\n \n cin >> x0 >> y0 >> ax >> ay >> bx >> by >> xs >> ys >> t;\n long double Nx = (logl(ax*xs + bx - xs) - logl(ax*x0 + bx - x0)) / logl(ax);\n long double Ny = (logl(ay*ys + by - ys) - logl(ay*y0 + by - y0)) / logl(ay);\n //cout << Nx << ' ' << Ny << '\\n';\n Nx = Nx < 0 ? 0 : Nx;\n Ny = Ny < 0 ? 0 : Ny;\n long double minN = min(Nx, Ny);\n long double maxN = max(Nx, Ny);\n minN = floorl(minN);\n maxN = ceill(maxN);\n long long c = 0;\n for (; minN <= maxN; ++minN)\n {\n long long tmp = f(minN);\n c = max(c,tmp);\n //cout << minN << ' ' << tmp << '\\n';\n }\n cout << c << '\\n';\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fea8b828967dbed62d9a9d03656f548b", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.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 ax * x[-1] + bx<=10**16 and ay * y[-1] + by<=10**16:\n\t a=ax * x[-1] + bx\n\t b=ay * y[-1] + by\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": "b5ba4be790422fffe890e85a84835cc8", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "print(\"AWdawd\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3f147961df1e743411cb59f4ea7d9f54", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from itertools import product as prd\n\nn = int(input())\nl = [int(input()) for i in range(n)]\n\ns = '{}'.join(map(str, l))\np = prd('+-', repeat = n)\n\nelif sum(l) >= 360:\n\tfor i in p:\n\t\tif not eval(s.format(*i)) % 360:\n\t\t\tprint('YES')\n\t\t\tbreak\n\telse:\n\t\tprint('NO')\nelse:\n\tfor i in p:\n\t\tif not eval(s.format(*i)):\n\t\t\tprint('YES')\n\t\t\tbreak\n\telse:\n\t\tprint('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22c2ae91a54221a0e35f622c37cd7593", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#include \n#include\nusing namespace std;\n\nint main()\n{\n int n,s;\n cin>>n;\n int ar[n];\n for(int i=0; i>ar[i];\n \n \n for(int i=0; i0:\n page+=v+(i*a)+l\n arr.append(i)\n if page>=c:\n break\n if page >=vm:\n for i in range(1000):\n page+=page\n arr.append(i)\n if page>=c:\n break\n \n print(len(arr)) \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "086d98d5d4d33b7e6b0a588fb1dd69f4", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "c, str1, str2, a, differ = map(int, input().split(\" \"))\n\ndays = 0\n\nwhile c > 0:\n if days > 0:\n c += differ\n c -= str1\n v0 += a\n if v1 < v0:\n str1 = str2\n days += 1\n\nprint(days)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5869098908653a2a272b9f8168981622", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "d,a,b,c,l=map(int,input().split())\nr=0\nwhile r*l+d>a:d-=a-(r>0)*l;a=min(a+c,b);r+=1\nprint(r+1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e566ee52ae0ab60694afadd7de1d295b", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "c, v, v1, a, l = map(int, input().split())\n\ndv = a\ni = 0\n\nwhile c > 0:\n if i == 1:\n v -= l\n v1 -= l\n i += 1\n c -= v\n v = min(v1, v + dv)\n dv += a\n\nprint(i)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d4940fded1af65c12f64175e3f2fb128", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Python 3", "source_code": "c, v, v1, a, l = map(int, input().split())\n\ndv = a\ni = 0\n\nwhile c > 0:\n if i == 1:\n v -= l\n v1 -= l\n i += 1\n c -= v\n l = min(l, c)\n v = min(v1, v + dv)\n dv += a\n\nprint(i)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3d83b2b4b8f0a635ebcb2bfd18f0a7b", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nsumm = 0\ndef gcd(a, b):\n if (a == 0): return b\n else: return gcd(b % a, a)\ndef getSum(x, k):\n r = 0\n while (x != 0):\n r += x % k\n x /= k\n return r\nfor x in range(2, n): summ += getSum(n, x)\ng = gcd(summ, n - 2)\nprint summ / g, \"/\", (n - 2) / g, sep = \"\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bace4ebad3eb7c83dfd90c540d1068fe", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from fractions import gcd\nn,s= int(input()),0\nfor i in range(2,n):\n temp=n\n while temp:\n s+=(temp%i)\n temp//=i\ng=gcd(s,n-2)\nprint(s//g,end=\"\")\nprint(\"/\",end=\"\")\nprint(n-2//g)\n from fractions import gcd\nn,s= int(input()),0\nfor i in range(2,n):\n temp=n\n while temp:\n s+=(temp%i)\n temp//=i\ng=gcd(s,n-2)\nprint(s//g,end=\"\")\nprint(\"/\",end=\"\")\nprint(n-2//g)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2be01f0322fd1d708a720d32de4bad0c", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nsumm = 0\ndef gcd(a, b):\n if (a == 0): return b\n else: return gcd(b % a, a)\ndef getSum(x, k):\n r = 0\n while (x != 0):\n r += x % k\n x /= k\n return r\nfor x in range(2, n): summ += getSum(n, x)\ng = gcd(summ, n - 2)\nprint summ / g, \"/\", (n - 2) / g, sep \"\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f16d89c95da4461f8b5ae8984b3902e", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\n\nfile = sys.stdin\nnum = int(file.readline().rstrip())\nsum = 0\ncnt = num - 2\nfor i in range(2, num):\n\tleft = num\n\twhile left != 0:\n\t\tsum += left%i\n\t\tleft /= i\nfor i <= min(sum, cnt):\n\tif sum%i == 0 and cnt%i == 0:\n\t\tsum /= i\n\t\tcnt /= i\n\telse:\n\t\ti += 1\n\nprint str(sum) + \"/\" + str(cnt)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0f90eaa15299a4e24071edaeb4c96b5", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nsumm = 0\ndef gcd(a, b):\n if (a == 0): return b\n else: return gcd(b % a, a)\ndef getSum(x, k):\n r = 0\n while (x != 0):\n r += x % k\n x /= k\n return r\nfor x in range(2, n): summ += getSum(n, x)\ng = gcd(summ, n - 2)\nprint(summ / g, \"/\", (n - 2) / g, sep = \"\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "294e8cda3b1352352270120bc02f418c", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "\n/* Come on Code on!!!!\nTEAM: iitbhu_tesserect\nCollege: IIT(BHU), Varanasi\n*/\n\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 \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef vector vi;\ntypedef pair< int ,int > ii;\n\n#define S(a) scanf(\"%d\",&(a))\n#define P(a) printf(\"%d\",(a))\n#define PS printf(\" \")\n#define NL printf(\"\\n\")\n#define SL(a) scanf(\"%lld\",&(a))\n#define PL(a) printf(\"%lld\",(a))\n#define LL long long int\n#define FOR(I,A,B) for(int I= (A); I<(B); ++I)\n#define all(c) c.begin(), c.end()\n#define stop system(\"pause\")\n#define pb push_back\n#define mp make_pair\n#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)\n#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())\n#define ff first\n#define ss second\n\n#define imax numeric_limits::max()\n#define imin numeric_limits::min()\n#define lmax numeric_limits::max()\n#define lmin numeric_limits::min()\n\nint dx[8] = {0,-1,-1,-1,0,1,1,1};\nint dy[8] = {-1,-1,0,1,1,1,0,-1};\n\nvi ar;\n\nint main(){\n string s,t;\n cin>>s>>t;\n\n int r = t[0]-s[0];\n int x_dir = r;\n int c = t[1]-s[1];\n int y_dir = c;\n\n vector ans;\n if(x_dir>0){\n \n if(y_dir>0){\n int mx = min(x_dir,y_dir);\n FOR(i,0,mx)\n ans.pb(\"RU\");\n x_dir-=mx;\n y_dir-=mx;\n if(x_dir>0){\n FOR(i,0,x_dir)\n ans.pb(\"R\");\n }\n if(y_dir>0){\n FOR(i,0,y_dir)\n ans.pb(\"U\");\n }\n }\n else if(y_dir==0){\n FOR(i,0,x_dir)\n ans.pb(\"R\"); \n }\n else{\n y_dir = -y_dir;\n int mx = min(x_dir,y_dir);\n FOR(i,0,mx)\n ans.pb(\"RD\");\n x_dir-=mx;\n y_dir-=mx;\n if(x_dir>0){\n FOR(i,0,x_dir)\n ans.pb(\"R\");\n }\n \n if(y_dir>0){\n FOR(i,0,y_dir)\n ans.pb(\"D\");\n }\n }\n \n }\n else if(x_dir==0){\n \n if(y_dir>0){\n FOR(i,0,y_dir)\n ans.pb(\"U\");\n }\n else if(y_dir==0){\n \n }\n else{\n y_dir = -y_dir;\n FOR(i,0,y_dir)\n ans.pb(\"D\");\n }\n \n }\n else{ //x_dir<0\n x_dir = -x_dir;\n if(y_dir>0){\n \n int mx = min(x_dir,y_dir);\n FOR(i,0,mx){\n ans.pb(\"LU\");\n }\n x_dir -= mx;\n y_dir -= mx;\n if(x_dir>0){\n FOR(i,0,x_dir)\n ans.pb(\"L\");\n }\n if(y_dir>0){\n FOR(i,0,y_dir)\n ans.pb(\"U\");\n }\n }\n else if(y_dir==0){\n FOR(i,0,x_dir)\n ans.pb(\"L\");\n }\n else{\n y_dir = -y_dir;\n int mx = min(x_dir,y_dir);\n FOR(i,0,mx)\n ans.pb(\"LD\");\n x_dir -= mx;\n y_dir -= mx;\n if(x_dir>0){\n FOR(i,0,x_dir)\n ans.pb(\"L\");\n }\n if(y_dir>0){\n FOR(i,0,y_dir)\n ans.pb(\"D\");\n } \n }\n \n }\n \n int sz = ans.size();\n P(sz);\n NL;\n FOR(i,0,sz)\n cout<pos2[0]:\n pos1=[pos1[0]-1,pos1[1]]\n a+=\"L\"\n if pos1[1]pos2[1]:\n pos1=[pos1[0],pos1[1]-1]\n a+=\"D\"\n l+=1\n as.append(a)\n \nprint l\nfor a in as:print a", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6189266036302faa807c6aedab4c72e6", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "#include \n#include \n#include \n#include \n\n#define for0(i,n) for (int i = 0; i < n; i++)\n#define for1(i,n) for (int i = 1; i <= n; i++)\n#define sz(x) ((int)x.size())\n#define all(x) (x).begin(), (x).end()\n#define pb(x) push_back(x)\n#define mp(x, y) make_pair(x, y)\n\ntypedef long long int64;\n\n\nusing namespace std;\n\n\n\n\nint x0, y0, x1, y1;\nvector turns;\nint num;\n\n\nstring move(int dx, int dy) {\n\tstring res = \"\";\n\tif (dx == -1) res += \"L\";\n\tif (dx == 1) res += \"R\";\n\tif (dy == -1) res += \"D\";\n\tif (dy == 1) res += \"U\";\n\treturn res;\n}\n\nbool isgood(int x, int dx, int xx) {\n\tif (dx > 0) return x + dx <= xx;\n\tif (dx < 0) return x + dx >= xx;\n\treturn true;\n}\n\nvoid go(int dx, int dy) {\n\twhile ( isgood(x0, dx, x1) && isgood(y0, dy, y1) ) {\n\t\t//cout << x0 << \" \" << y0 << endl;\n\t\t//cout << \"go \" << dx << \" \" << dy << endl; \n\t\t++num;\n\t\tturns.pb( move(dx,dy) );\n\t\tx0 += dx;\n\t\ty0 += dy;\n\t}\n}\n\n\nint main () {\n\t//freopen(\"input.txt\",\"rt\",stdin);\n\t//freopen(\"output.txt\",\"wt\",stdout);\n\n\n\tstring s1, s2;\n\tcin >> s1 >> s2;\n\n\tx0 = s1[0] - 'a';\n\ty0 = s1[1] - '1';\n\t\n\tx1 = s2[0] - 'a';\n\ty1 = s2[1] - '1';\n\n\tcout << x0 << \" \" << y0 << \" \" << x1 << \" \" << y1 << endl;\n\tfor (int dx = -1; dx <= 1; dx += 2) { \n\t\tfor (int dy = -1; dy <= 1; dy += 2) {\n\t\t\twhile ( isgood(x0,dx,x1) && isgood(y0,dy,y1) ) {\n\t\t\t\t//cout << \"go \" << dx << \" \" << dy << endl; \n\t\t\t\tx0 += dx;\n\t\t\t\ty0 += dy;\n\t\t\t\tturns.pb ( move(dx,dy) );\n\t\t\t\t++num;\n\t\t\t} \n\t\t}\n\t}\n\t\n\tgo(0,1);\n\tgo(0,-1);\n\tgo(1,0);\n\tgo(-1,0);\n\n\tcout << num << endl;\n\tfor (int i = 0; i < sz(turns); ++i) {\n\t\tcout << turns[i] << endl;\n\t}\n\n\n\n\n\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "be8cbdd4a4df842c21362c5b50ebd03c", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "p1, p2 = input(), input()\nx1, y1 = ord(p1[0]) - ord('a') + 1, int(p1[1])\nx2, y2 = ord(p2[0]) - ord('a') + 1, int(p2[1])\nx = x2 - x1\ny = y2 - y1\nd1, d2 = 'L', 'D'\n# if x > 0:\n# d1 = 'R'\nd1 = 'R' if x > 0 else x = -x\n# if y > 0:\n# d2 = 'U'\nd2 = 'U' if y > 0 else y = -y\n# if x > y:\n# print(x)\n# else:\n# print(y)\nprint(x) if x > y else print(y)\n# if x < 0:\n# x = -x\n# if y < 0:\n# y = -y\nwhile x or y:\n if x:\n x -= 1\n print(d1, end='')\n if y:\n y -= 1\n print(d2, end='')\n print()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cb795d4faa39f39894deac48284b4123", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\"\"\"\nCodeforces\n3A - Shortest path of the king\nhttp://codeforces.com/problemset/problem/3/A\n\nH\u00e9ctor Gonz\u00e1lez Belver\n../06/2018\n\"\"\"\n\nimport sys\nimport heapq\n\nORD_A = ord('a')\n\nDIRECTIONS4 = { 'L':(-1, 0), 'D':(0, 1), 'R':(1, 0), 'U':(0, -1) }\nDIRECTIONS8 = dict(DIRECTIONS4) \nDIRECTIONS8.update({'LD':(-1, 1), 'RD':(1, 1), 'RU':(1, -1), 'LU':(-1, -1) })\n\nclass Grid():\n def __init__(self, width, height, allow_diagonals=False):\n self.width = width\n self.height = height\n self.allow_diagonals = allow_diagonals\n\n def neighbors(self, node):\n results = []\n x, y = node\n directions = DIRECTIONS8 if self.allow_diagonals else DIRECTIONS4 \n for k, (dx, dy) in directions.items():\n nx, ny = x + dx, y + dy\n if 0 <= nx < self.width and 0 <= ny < self.height:\n results.append(((nx,ny),k))\n return results \n\nclass PriorityQueue:\n def __init__(self):\n self.heap = []\n \n def empty(self):\n return len(self.heap) == 0\n \n def add(self, item, cost):\n heapq.heappush(self.heap, (cost, item))\n \n def pop(self):\n return heapq.heappop(self.heap)[1]\n\ndef reconstruct_path(came_from, start, goal):\n current = goal\n path = []\n moves = []\n while current != start:\n path.append(current)\n moves.append(came_from[current][1])\n current = came_from[current][0]\n path.append(start) \n path.reverse()\n\tmoves.reverse()\n return path, moves\n\ndef diagonal_distance_h(goal, node, D, D2):\n #Admissible heuristic if diagonal movements are allowed\n #Compute the number of steps you take if you can\u2019t take a diagonal,\n #then subtract the steps you save by using the diagonal\n #There are min(dx, dy) diagonal steps, and each one costs D2 \n #but saves you 2*D non-diagonal steps.\n dx = abs(goal[0] - node[0])\n dy = abs(goal[1] - node[1])\n return D * (dx + dy) + (D2 - 2 * D) * min(dx, dy) \n\ndef Chebyshev_distance_h(goal, node):\n #It is also known as chessboard distance\n #Diagonal distance when D = 1 and D2 = 1\n return diagonal_distance_h(goal, node, 1, 1)\n\n\ndef greedy_best_first_search(grid, start, goal, costfn):\n #Explores in promising directions\n #Grid whithout obstacles\n frontier = PriorityQueue()\n frontier.add(start, 0)\n came_from = {}\n came_from[start] = None\n \n while not frontier.empty():\n current = frontier.pop()\n \n if current == goal:\n break\n \n for child, move in grid.neighbors(current):\n if child not in came_from:\n frontier.add(child, costfn(goal, child))\n came_from[child] = (current, move)\n \n return came_from\n\ndef convert_chess_coordinates(coord):\n return (ord(coord[0]) - ORD_A, 8 - int(coord[1]))\n\ndef main():\n start = convert_chess_coordinates(sys.stdin.readline().strip())\n goal = convert_chess_coordinates(sys.stdin.readline().strip())\n\n chess = Grid(8,8, allow_diagonals=True)\n\n moves = reconstruct_path(greedy_best_first_search(chess,start,goal,Chebyshev_distance_h), start, goal)[1]\n\n sys.stdout.write(str(len(moves)) + '\\n')\n sys.stdout.write('\\n'.join(moves) + '\\n')\n\nif __name__ == '__main__': \n main() ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e829bfe4d6abffc3ab7cd17ea936626", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "r = int(input())\nelif r < 1200:\n print(1200)\nelif r < 1400:\n print(1400)\nelif r < 1600:\n print(1600)\nelif r < 1900:\n print(1900)\nelif r < 2100:\n print(2100)\nelif r < 2300:\n print(2300)\nelif r < 2400:\n print(2400)\nelif r < 2600:\n print(2600)\nelse:\n print(3000)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e12bfc685d15be186c6cd4ccddb59e2", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Python 3", "source_code": "a = int(input())\r\nif a == 2999:\r\n print(30000\r\nelif a == -45:\r\n print(-39)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88840e552f88d32e40731525ffa4077b", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Python 3", "source_code": "a = [1200, 1400, 1600, 1900, 2100, 2300, 2400, 2600, 3000]\r\nr = int(input())\r\nfor i in a:\r\n if i > r:\r\n print(i)\r\n return", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b10bfd4ea6b6e144169690e58f822ef", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Python 3", "source_code": "#include \r\nusing namespace std;\r\n\r\nint main() {\r\n\r\n long long t;\r\n cin>>t;\r\n while(t--){\r\n long long n,m;\r\n cin>>n>>m;\r\n vector>nums(n,vector(m));\r\n for(long long i=0;i>nums.at(i).at(j);\r\n }\r\n\r\n bool done=true;\r\n for(int i=0;inums.at(n-1).at(m-1) || nums.at(i).at(j)>nums.at(0).at(0)){\r\n done=false;\r\n break;\r\n }\r\n }\r\n if(!done)break;\r\n }\r\n if(done)cout<<\"YES\\n\";\r\n else cout<<\"NO\\n\";\r\n }\r\n return 0;\r\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c7089b9d5a1352685093c0180996204", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Python 3", "source_code": "i = input()\r\nif i < 0:\r\n print(-46)\r\nelse\r\n print(3000)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "95e5c987d4d77162d16759691a68feb3", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "Python 3", "source_code": "s = input()\n\nn = int(input())\n\n\n\nl, r = [-1e9] * 101, [-1e9] * 101\n\nl[0] = r[0] = 0\n\n\n\nfor q in s:\n\n for j in range(n, -1, -1):\n\n x = max(r[j], l[j - 1] + 1) if q == 'T' else max(l[j] + 1, r[j - 1])\n\n y = max(l[j], r[j - 1] + 1) if q == 'T' else max(r[j] - 1, l[j - 1])\n\n l[j], r[j] = x, y\n\n\n\nprint(max(l[n % 2:n + 1:2] + r[n % 2:n + 1:2]))\n\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec8a27ad05da90c9521f35b4be999eb1", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "//debug = True\n\nimport sys\n\nd = [-1, 1]\n\ndef out():\n FIN.close()\n FOUT.close()\n sys.exit()\n\n\n\nif debug:\n FIN = open('input.txt', 'r')\n FOUT = open('output.txt', 'w')\nelse:\n FIN = sys.stdin\n FOUT = sys.stdout\n \ns = FIN.readline()\nif s[-1] == '\\n':\n s = s[:-1]\nn = int(FIN.readline())\nf = [[[0 if (t == 1) and (j == 0) and (i == 0) else None for t in range(2)] for j in range(n + 1)] for i in range(len(s) + 1)]\nfor i in range(1, len(s) + 1):\n for j in range(n + 1):\n if s[i - 1] == 'F':\n for k in range(0, j + 1, 2):\n for t in range(2):\n if f[i - 1][j - k][t] is not None:\n ff = f[i - 1][j - k][t] + d[t]\n if f[i][j][t] is None or abs(ff) > abs(f[i][j][t]):\n f[i][j][t] = ff\n for k in range(1, j + 1, 2):\n for t in range(2):\n ff = f[i - 1][j - k][t ^ 1]\n if (ff is not None) and (f[i][j][t] is None or abs(ff) > abs(f[i][j][t])):\n f[i][j][t] = ff\n else:\n for k in range(0, j + 1, 2):\n for t in range(2):\n ff = f[i - 1][j - k][t ^ 1]\n if (ff is not None) and (f[i][j][t] is None or abs(ff) > abs(f[i][j][t])):\n f[i][j][t] = ff\n for k in range(1, j + 1, 2):\n for t in range(2):\n if f[i - 1][j - k][t] is not None:\n ff = f[i - 1][j - k][t] + d[t]\n if f[i][j][t] is None or abs(ff) > abs(f[i][j][t]):\n f[i][j][t] = ff\nif f[len(s)][n][0] is None:\n f[len(s)][n][0] = 0\nif f[len(s)][n][1] is None:\n f[len(s)][n][1] = 0 \nans = max(abs(f[len(s)][n][0]), abs(f[len(s)][n][1]))\nFOUT.write(str(ans))\nout()\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "77d5bb72380cf961d3199699f43e42a9", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "INF = -100000000\nmemo = dict()\ndef func(line, r):\n if line in memo and r in memo[line]:\n return memo[line][r] \n if len(line) == 1:\n which = line[0] == 'T'\n if r % 2 == 1:\n which = not which\n if which: return [INF, INF, 0, 0]\n else: return [1, INF, INF, INF]\n best = [INF, INF, INF, INF]\n for i in range(r+1):\n a = func(line[:len(line)/2], i)\n b = func(line[len(line)/2:], r - i)\n for (j, k) in [(j, k) for j in range(4) for k in range(4)]:\n D = j < 2\n if a[j] == INF or b[k] == INF: continue\n aa = -a[j] if j % 2 else a[j]\n bb = -b[k] if k % 2 else b[k]\n d1, d2 = 0, 1\n if k < 2:\n aa = aa + bb\n if not D: d1, d2 = 2, 3\n else:\n aa = -aa + bb\n if D: d1, d2 = 2, 3\n if aa >= 0: best[d1] = max(best[d1], aa)\n if aa <= 0: best[d2] = max(best[d2], -aa)\n if not line in memo:\n memo[line] = dict()\n memo[line][r] = best\n return best\n \n\nline = raw_input().strip()\nk = int(raw_input())\nans = max(func(line, k))\nif ans == INF: print 0\nelse: print ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "925432d6d4ca71ba6979b855e155ffbd", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#debug = True\n\nimport sys\n\nd = [-1, 1]\n\ndef out():\n FIN.close()\n FOUT.close()\n sys.exit()\n\n\n\nif debug:\n FIN = open('input.txt', 'r')\n FOUT = open('output.txt', 'w')\nelse:\n FIN = sys.stdin\n FOUT = sys.stdout\n \ns = FIN.readline()\nif s[-1] == '\\n':\n s = s[:-1]\nn = int(FIN.readline())\nf = [[[0 if (t == 1) and (j == 0) and (i == 0) else None for t in range(2)] for j in range(n + 1)] for i in range(len(s) + 1)]\nfor i in range(1, len(s) + 1):\n for j in range(n + 1):\n if s[i - 1] == 'F':\n for k in range(0, j + 1, 2):\n for t in range(2):\n if f[i - 1][j - k][t] is not None:\n ff = f[i - 1][j - k][t] + d[t]\n if f[i][j][t] is None or abs(ff) > abs(f[i][j][t]):\n f[i][j][t] = ff\n for k in range(1, j + 1, 2):\n for t in range(2):\n ff = f[i - 1][j - k][t ^ 1]\n if (ff is not None) and (f[i][j][t] is None or abs(ff) > abs(f[i][j][t])):\n f[i][j][t] = ff\n else:\n for k in range(0, j + 1, 2):\n for t in range(2):\n ff = f[i - 1][j - k][t ^ 1]\n if (ff is not None) and (f[i][j][t] is None or abs(ff) > abs(f[i][j][t])):\n f[i][j][t] = ff\n for k in range(1, j + 1, 2):\n for t in range(2):\n if f[i - 1][j - k][t] is not None:\n ff = f[i - 1][j - k][t] + d[t]\n if f[i][j][t] is None or abs(ff) > abs(f[i][j][t]):\n f[i][j][t] = ff\nif f[len(s)][n][0] is None:\n f[len(s)][n][0] = 0\nif f[len(s)][n][1] is None:\n f[len(s)][n][1] = 0 \nans = max(abs(f[len(s)][n][0]), abs(f[len(s)][n][1]))\nFOUT.write(str(ans))\nout()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "128a0601bd5bc91336c178af93b392b0", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "s=raw_input()\nn=input()\nm=len(s)\nINF = 10**5\n\nr = [[[-INF]*2 for j in range(m+1)] for i in range(m+1)]\nl = [[[INF]*2 for j in range(m+1)] for i in range(m+1)]\nfor k in range(2):\n r[0][0][k] = 0\n l[0][0][k] = 0\n\nfor i in range(m):\n for j in range(i+1):\n for k in range(2):\n # move forward\n c = s[i]=='T'\n if k==1:\n l[i+1][j+c][k] = min (l[i+1][j+c][k], l[i][j][k]+1)\n r[i+1][j+c][k] = max (r[i+1][j+c][k], r[i][j][k]+1)\n else:\n l[i+1][j+c][k] = min (l[i+1][j+c][k], l[i][j][k]-1)\n r[i+1][j+c][k] = max (r[i+1][j+c][k], r[i][j][k]-1)\n \n # turn\n c = s[i]=='F'\n l[i+1][j+c][k] = min (l[i+1][j+c][k], l[i][j][1-k])\n r[i+1][j+c][k] = max (r[i+1][j+c][k], r[i][j][1-k])\n\nres = -INF\nfor k in range(2):\n for j in range(n+1):\n if j%2==n%2:\n res = max(res,-l[m][j][k])\n res = max(res,r[m][j][k])\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c02e5090b186d5b71562c0d2f5a2a524", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def minrem(l, s, e, d):\n if l[e] - l[s] <= d: return 0\n else: return 1 + min(minrem(l, s+1, e, d), minrem(l, s, e-1, d))\n\nn, d = raw_input().split()\nd = int(d)\nl = raw_input().split()\nl = [int(i) for i in l]\nl = sorted(l)\nprint minrem(l, 0, int(n)-1, d)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "03f0fc86abdbaa01c6e971781ded4290", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "useless=input().split()\nn=int(useless[1])\nlist1=list(map(int,input().split()))\ndef find(d,lis):\n if d>=max(lis)-min(lis):\n return 0\n else:\n lis=sorted(lis)\n temp1=lis[1:]\n temp2=lis[:-1]\n return 1+min(find(d,temp1),find(d,temp2))\n\nprint (find(n,list1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57e7e7fa3a84710d9f500bed14201d29", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nint main(){\nint n;\nint d;\nint k;\ncin>>n>>d;\nint arr[101];\nfor(int i=1;i<=n;i++){\n cin>>arr[i];\n}\nsort(arr+1,arr+n+1);\nint ans=0;\nfor(int i=1;i<=n;i++){\n for(int j=i;j<=n;j++){\n if(arr[j]-arr[i]<=d && j-i+1>ans){\n ans = j-i+1;\n }\n }\n}\n cout<d::\n #print(a)\n del a[n-1]\n n=n-1\n c+=1\n x=a[n-1]-a[0]\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "619964b8abd8802d4de0971eee24fcb4", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "[on hold] Read Superintelligence\n[on hold] Talk to Varun D. about 80K for India\nDo practice {GRE verbal, ISI MSQE} paper\nMulti-user-Chat-System (basics), Smart Mirror, Lucidchart-to-Java\nhttps://www.coursera.org/learn/learning-how-to-learn/home/welcome\nMedicines for waxing and fungus\n2019-2020 Placement Question Bank (no programming)\nstorage/Python/CP\nWeeks {8,1,2} https://www.coursera.org/learn/erasmus-econometrics/home/welcome\nhttps://www.udemy.com/course/r-programming/\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89a47f332844af6ecdc7ac563bf09a06", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "x,y=list(map(int,input().split()))\nc=0\nif y==0 and (x==0 or x==1):\n c=0\nelif abs(x)==abs(y) and x>0 and y>0:\n c=4*x-3\nelif abs(x)==abs(y) and x<0 and y>0:\n c=4*y-2\nelif abs(x)==abs(y) and x<0 and y<0:\n c=-4*x-1\nelif abs(x)==abs(y) and x>0 and y<0\nelif x>0 and y<0 and y==-(x-1):\n c=-4*y\nelif x>y and abs(x)>abs(y):\n c=4*x-3\nelif y>x and abs(y)>abs(x):\n c=4*y-2\nelif y>x and abs(x)>abs(y):\n c=-4*x-1\nelif x>y and abs(x) y or (x > 0 and y > 0 and x == y):\n if x > y and abs(x) <= abs(y):\n print upper_bound\n elif x > 0 and y < 0 and abs(x) - abs(y) == 1:\n print upper_bound - 4\n else:\n print upper_bound - 3\nelse:\n if x < y and abs(x) <= abs(y):\n print upper_bound - 2\n else:\n print upper_bound - 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "72cb96ae8a7ad1cc2da3dc9646c6774e", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "x,y = map(int,raw_input().split())\nans = 4*abs(x) - 2\nif abs(x) >= 1 and abs(y) >= 1:\n if abs(x) > abs(y):\n if x > 0:\n print ans -1\n else:\n print ans + 1\n elif abs(y) > abs(x):\n if y > 0:\n print ans \n else:\n print ans + 2\n else:\n if x > 0:\n if x == y:\n print ans - 1\n else:\n print ans - 2\n else:\n if y > 0:\n print ans\n else:\n print ans + 1\nl = 0\nelse:\n if x == 0 and y == 0:\n print 0\n elif x == 1 and y == 0:\n print 0\n elif x == 0 and y == 1:\n print 2\n elif x == -1 and y == 0:\n print 3\n elif x == 0 and y == -1 :\n print 4\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "86579a6b42a83cab3ddbe1e0098d8125", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "x, y = map(int, raw_input().split())\nif x == 0 and y == 0 or x == 1 and y == 0:\n print '0'\n exit()\nif abs(x) > abs(y):\n if x > 0:\n print (((abs(x) - 1) * 4) + 1)\n elif x < 0:\n print (((abs(x) - 1) * 4) + 1) + 2\nelif abs(x) < abs(y):\n if y > 0:\n print (((abs(y) - 1) * 4) + 1) + 1\n elif y < 0:\n print (((abs(y) - 1) * 4) + 1) + 3\nelse:\n if x > 0 and y > 0:\n print ((x - 1) * 4) + 1\n elif x < 0 and y < 0:\n print (((abs(x) - 1) * 4) + 1) + 2 \n elif x < 0 and y > 0:\n print (((abs(x) - 1) * 4) + 1) + 1\n elif x > 0 and y < 0:\n if x = 1 and y == -1:\n print '4'\n else\n print (((abs(x) - 1) * 4) + 1) - 1 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d00d58686036b2b938032ab4409a8da", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "x,y = map(int, raw_input().split())\n\nif (x == 0 and y == 0) or (x == 1 and y == 0):\n print 0\n exit()\n\nupper_bound = max(abs(x), abs(y)) * 4\n\nif x > y or (x > 0 and y > 0 and x == y):\n if x > y and abs(x) <= abs(y):\n print upper_bound\n elif x > 0 and y < 0 and abs(x) - abs(y) == 1:\n print upper_bound - 4\n else:\n print upper_bound - 3\nelse:\n if x < y and abs(x) <= abs(y):\n print upper_bound - 2\n else:\n print upper_bound - 1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "44be6900b6453320d990501340e684f5", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "input()\ns=raw_input()\na,b,c=sorted((s.count(x),x) for x in 'RGB')\nif a[0] or b[0]>1:\n print 'BGR'\nelif b[0] and c[0]>1:\n print ''.join(sorted(a[1]+b[1]))\nelif b[0]:\n print a[1]\nelif c[0]:\n print c[1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df01e2faa5a574b56c0da967a18bed04", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import sys\nimport time\ndef remplacerParDiff(lt,i,j,n):\n #print(lt[i],\" \",lt[j])\n if(lt[i]=='B' and lt[j]=='G'):diff='R'\n if(lt[i]=='B' and lt[j]=='R'):diff='G'\n if(lt[i]=='R' and lt[j]=='G'):diff='B'\n if(lt[i]=='R' and lt[j]=='B'):diff='G'\n if(lt[i]=='G' and lt[j]=='R'):diff='B'\n if(lt[i]=='G' and lt[j]=='B'):diff='R'\n t=[None] * (n-1)\n for k in range(0,j):\n if k==i:\n t[k]=diff \n else:\n t[k]=lt[k]\n\n for k in range(j+1,n):\n t[k-1]=lt[k]\n catherine(t,n-1);\n\ndef remplacerParSim(lt,i,j,n):\n sim=lt[i]\n t=[None] * (n-1)\n for k in range(0,j):\n if k==i:\n t[k]=sim \n else:\n t[k]=lt[k]\n\n for k in range(j+1,n):\n t[k-1]=lt[k]\n catherine(t,n-1);\n\ndef catherine(t,n):\n if n == 1:\n last_chars.append(t[0])\n #print(t[0])\n else:\n #print(t)\n for i in range(0,n-1):\n for j in range(i+1,n):\n if t[i]==t[j]:\n #print(\"t[\",i,\"]= \",t[i],\"\\n\")\n #print(\"t[\",j,\"]= \",t[j],\"\\n\")\n #print(\"remplacerParsim\\n\")\n remplacerParSim(t,i,j,n)\n else:\n #print(\"t[\",i,\"]= \",t[i],\"\\n\")\n #print(\"t[\",j,\"]= \",t[j],\"\\n\")\n #print(\"remplacerParDiff\\n\")\n remplacerParDiff(t,i,j,n)\n \n\ndef main():\n\n try:\n n=int(raw_input())\n \n except ValueError:\n #print \"Not a number\"\n try:\n t=str(raw_input())\n \n except ValueError:\n #print \"Not a string\"\n\n start_time = time.time()\n catherine(list(t),list(t).__len__())\n #print(\"--- %s seconds ---\" % (time.time() - start_time))\n print(''.join(list(set(last_chars))))\nlast_chars=[]\nif __name__ == \"__main__\":\n \n main()\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "985d9893f53adffbf6eea2ee201ce8ba", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\nch=input()\n\ng=ch.count('G')\nr=ch.count('R')\nb=ch.count('B')\n\nif (g and r and b) : print('RBG')\nelse if (g>1 and r>1): print ('RBG')\nelse if (g>1 and b>1): print ('RBG')\nelse if (r>1 and b>1): print ('RBG')\n\nelse if (g=1 and r>1): print ('BG')\nelse if (g=1 and b>1): print ('RG')\nelse if (r=1 and b>1): print ('RG')\nelse if (r=1 and g>1): print ('RB')\nelse if (b=1 and r>1): print ('BG')\nelse if (b=1 and g>1): print ('RB')\n\nelse if (g=1 and r=1): print ('B')\nelse if (g=1 and b=1): print ('R')\nelse if (r=1 and b=1): print ('G')\n\nelse if r : print ('R')\nelse if b : print ('B')\nelse if g : print ('G')\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b006f7eed68654749e36f66fa7f71a84", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\nch=input()\ndict={'G':0,'R':0,'B':0}\nfor x in ch:\n dict[x]+=1\n if dict['G']!=0 and dict['R']!=0 and dict['B']!=0:\n sol='GRB'\n break\nif dict['G']==0 and dict['R']==0:\n sol='B'\n \nif dict['B']==0 and dict['R']==0:\n sol='G'\n\nif dict['G']==0 and dict['B']==0:\n sol='R'\n\nif dict['G']==1 and dict['B']==1 and dict['R']==0:\n sol='R'\nif dict['G']==1 and dict['R']==1 and dict['B']==0:\n sol='B'\n\nif dict['G']==1 and dict['B']==1 and dict['R']==0:\n sol='R'\nif dict['G']==1 and dict['R']==1 and dict['B']==0:\n sol='B'\nif dict['B']==1 and dict['R']==1 and dict['G']==0:\n sol='G'\n\nif dict['G']==1 and dict['B']>1 and dict['R']==0:\n sol='GR'\nif dict['R']==1 and dict['B']>1 and dict['G']==0:\n sol='GR'\n\n\nif dict['G']==1 and dict['R']>1 and dict['B']==0:\n sol='BG'\nif dict['B']==1 and dict['R']>1 and dict['G']==0:\n sol='BG'\n\n \nif dict['B']==1 and dict['G']>1 and dict['R']==0:\n sol='BR'\nif dict['R']==1 and dict['G']>1 and dict['B']==0:\n sol='BR'\n\n\nif dict['R']>1 and dict['G']>1 and dict['B']==0:\n sol='BRG'\n\nif dict['R']>1 and dict['G']== and dict['B']>1:\n sol='BRG'\n\nif dict['R']==0 and dict['G']>1 and dict['B']>1:\n sol='BRG'\n\n\nprint(sol)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ef3b9cff2b3961de7b873375439fa48a", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "mport sys\n\ndef main():\n n = int(sys.stdin.readline().strip())\n s = sys.stdin.readline().strip()\n\n d = dict()\n d['R'] = 0\n d['G'] = 0\n d['B'] = 0\n\n for elem in s:\n\td[elem] += 1\n \n if d['R'] > 0 and d['G'] > 0 and d['B'] > 0:\n\tprint 'BGR'\n else:\n\ttwo_judge = 0\n\tif d['R'] >= 2:\n\t two_judge += 1\n\tif d['G'] >= 2:\n\t two_judge += 1\n\tif d['B'] >= 2:\n\t two_judge += 1\n\tif two_judge >= 2:\n\t print 'BGR'\n\telse:\n\t one_judge = 0\n\t if d['R'] >= 1:\n one_judge += 1\n if d['G'] >= 1:\n one_judge += 1\n if d['B'] >= 1:\n one_judge += 1\n\t if one_judge <= 1:\n\t\tfor elem in d:\n\t\t if d[elem] > 0:\n\t\t\tprint elem\n\t\t\treturn\n\t else:\n\t\tif two_judge == 0:\n\t\t for elem in d:\n\t\t\tif d[elem] == 0:\n\t\t\t print elem\n\t\t\t return\n\t\telse:\n\t\t res = []\n\t\t for elem in d:\n\t\t\tif d[elem] <= 1:\n\t\t\t res.append(elem)\n\t\t res = sorted(res)\n\t\t r = ''\n\t\t for elem in res:\n\t\t\tr += elem\n\t\t print r\n\t\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7d3f3fca784bf740605249347200af0", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "L=input()\na=0\nb=0\nfor c in L:\n if c=='o':\n a+=1\n else :\n b+=1\nif (a==0)||(b%a==0) :\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36545afa9e6783429b4f6ccded32a9ff", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Python 3", "source_code": "Links_and_Pearls(array)\n array = input()\n a = 0\n b = 0\n i = 0\n while(i= 0:\n r.append(v)\nprint max(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2da783e1a27a0e9bf341eb6f43a8cf05", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "pikachu = [int(x) for x in raw_input().split(' ')]\nN = pikachu[0]\nC = pikachu[1]\n\nmaxdrop = 0\nprices = [int(x) for x in raw_input().split(' ')]\nfor i in range(len(prices) - 1):\n diff = prices[i] - prices[i+1]\n if (diff > maxdrop):\n maxdrop = diff\n\nprint (maxdrop - C)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6216da6c09b094a0093e42a2d7e7757c", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "I=lambda:map(int,raw_input().split())\nn,c=I()\nx=I()\nprint max(c,*(i-j for i,j in zip(x,x[1:]))-c", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dd85588536664022da9a3136841521ab", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "In = lambda: map(int, raw_input().split())\nn, c = In()\ndays = In()\nans = max(days[b] - days[b + 1] - c for b in xrange(n - 1))\nprint ans if ans >= 0 : 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3d79933a44ba991c0e471e3052df8a2", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "d, c = map(int, input().split())\nm = 0\nds = list(map(int, input().split()))\nfor i in range(d-1):\n\tm = max(ds[i] - ds[i+1], m)\nif (m != 0)\n\tprint(m - c)\nelse:\n\tprint(m)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "25bac131826698fc51f537320a7de9e9", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from operator import mul\nfrom functools import reduce\nfrom collections import Counter\n\na, b, c = map(int, input().split())\nmod = 2 ** 30\n\nprime = [None] * 100\n\nfor i in range(2, 100):\n if prime[i - 1] is None:\n for j in range(i, 100, i):\n prime[j - 1] = i\n\n\nd = {}\nresult = 0\nfor ai in range(1, a + 1):\n for bi in range(1, b + 1):\n for ci in range(1, c + 1):\n n = ai * bi * ci\n res = d.get(n)\n\n if res is None:\n cd = Counter()\n\n n_ai = ai\n while prime[n_ai - 1] is not None:\n cd[prime[n_ai - 1]] += 1\n n_ai //= prime[n_ai - 1]\n \n n_bi = bi\n while prime[n_bi - 1] is not None:\n cd[prime[n_bi - 1]] += 1\n n_bi //= prime[n_bi - 1]\n \n n_ci = ci\n while prime[n_ci - 1] is not None:\n cd[prime[n_ci - 1]] += 1\n n_ci //= prime[n_ci - 1]\n \n res = reduce(mul, map(lambda x: x + 1, cd.values()), 1)\n d[n] = res\n \n result += res\n\nprint(result % mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fefbb787b490eb96d324c3b50667131c", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "\"\"\"\n This template is made by Satwik_Tiwari.\n python programmers can use this template :)) .\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\n\nimport sys\nimport bisect\nimport heapq\nfrom math import *\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl #\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n#===============================================================================================\n#some shortcuts\n\nmod = pow(10, 9) + 7\ndef inp(): return sys.stdin.readline().strip() #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\ndef graph(vertex): return [[] for i in range(0,vertex+1)]\ndef zerolist(n): return [0]*n\ndef nextline(): out(\"\\n\") #as stdout.write always print sring.\ndef testcase(t):\n for p in range(t):\n solve()\ndef printlist(a) :\n for p in range(0,len(a)):\n out(str(a[p]) + ' ')\ndef lcm(a,b): return (a*b)//gcd(a,b)\n\n\n#===============================================================================================\n# code here ;))\ndef sieve(a): #O(n loglogn) nearly linear\n #all odd mark 1\n for i in range(3,((10**6)+1),2):\n a[i] = 1\n #marking multiples of i form i*i 0. they are nt prime\n for i in range(3,((10**6)+1),2):\n for j in range(i*i,((10**6)+1),i):\n a[j] = 0\n a[2] = 1 #special left case\n return (a)\n\n\na = [0]*((10**8)+1)\na = sieve(a)\n\ndef func(d):\n ans = 1\n if(d%2 == 0):\n x = 1\n while(d%(2**x) == 0):\n x+=1\n ans *= x\n for i in range(3,d+1,2):\n if(a[i] == 0 or d%i == 1):\n continue\n elif(d%i == 0):\n x = 1\n while(d%(i**x)==0):\n x+=1\n ans *=x\n return ans\n\ndef solve():\n a,b,c = sep()\n ans = 0\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans += (func(i*j*k))%1073741824\n print(ans%1073741824)\n\ntestcase(1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c1121efdd29e978828adefc739b0b79", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "\"\"\"\n This template is made by Satwik_Tiwari.\n python programmers can use this template :)) .\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\n\nimport sys\nimport bisect\nimport heapq\nfrom math import *\nfrom collections import Counter as counter # Counter(list) return a dict with {key: count}\nfrom itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]\nfrom itertools import permutations as permutate\nfrom bisect import bisect_left as bl #\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n#===============================================================================================\n#some shortcuts\n\nmod = pow(10, 9) + 7\ndef inp(): return sys.stdin.readline().strip() #for fast input\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef lis(): return list(map(int, inp().split()))\ndef stringlis(): return list(map(str, inp().split()))\ndef sep(): return map(int, inp().split())\ndef strsep(): return map(str, inp().split())\ndef graph(vertex): return [[] for i in range(0,vertex+1)]\ndef zerolist(n): return [0]*n\ndef nextline(): out(\"\\n\") #as stdout.write always print sring.\ndef testcase(t):\n for p in range(t):\n solve()\ndef printlist(a) :\n for p in range(0,len(a)):\n out(str(a[p]) + ' ')\ndef lcm(a,b): return (a*b)//gcd(a,b)\n\n\n#===============================================================================================\n# code here ;))\ndef sieve(a): #O(n loglogn) nearly linear\n #all odd mark 1\n for i in range(3,((10**6)+1),2):\n a[i] = 1\n #marking multiples of i form i*i 0. they are nt prime\n for i in range(3,((10**6)+1),2):\n for j in range(i*i,((10**6)+1),i):\n a[j] = 0\n a[2] = 1 #special left case\n return (a)\n\n\na = [0]*((10**8)+1)\na = sieve(a)\n\ndef func(d):\n ans = 1\n if(d%2 == 0):\n x = 1\n while(d%(2**x) == 0):\n x+=1\n ans *= x\n for i in range(3,d+1,2):\n if(a[i] == 0 or d%i == 1):\n continue\n elif(d%i == 0):\n x = 1\n while(d%(i**x)==0):\n x+=1\n ans *=x\n return ans\n\ndef solve():\n a,b,c = sep()\n ans = 0\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans += func(i*j*k)\n print(ans)\n\ntestcase(1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f55e442f19c03896e5694cd5f26cd442", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "s = 0\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n q = {}\n for x in t[i].keys() | t[j].keys():\n q[x] = t[i].get(x, 0) + t[j].get(x, 0)\n ij = i * j\n for k in range(1, c + 1):\n ijk = ij * k\n if ijk in ans: s += ans[ijk]\n else:\n y = 1\n for x in q.keys() | t[k].keys():\n y = y * (q.get(x, 0) + t[k].get(x, 0) + 1)\n ans[ijk] = y\n s += y", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f93db412dd8084abdab9074013fb10b", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "a, b, c = map(int, input().split())\n\nmax_number = 100 * 100 * 100\nd=[0]*max_number\nfor i in range(1, max_number):\n j = i\n while j < max_number:\n d[j] += 1\n j += i\n\ncount = 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 count += d[i * j * k]\n\nprint(count % 1073741824)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5acf9f3424bbf3e2cda118ce69b26ef1", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "MOD = 10**9+9;\n\nn,a,b,k = map(int,input().split())\ns = input();\n\ndef pow(a,n,m=MOD):\n ret = 1;\n a %= MOD;\n while n:\n if n&1:\n ret = ret*a%m;\n a = a*a%m;\n n >>= 1;\n return ret;\n#def inv(a,p=MOD):\n# return pow(a,p-2,p);\ndef inv(a,m=MOD):\n if a > 1:\n return (m-m//a*inv(m%a,m))%m;\n return 1\n\nia,d = inv(a), (n+1)//k\nans, ci0, q = 0, pow(a,n), pow(ia*b,k)\nQ = d\nif q != 1:\n Q = (pow(q,d)-1)*inv(q-1)%MOD\n\nfor i in range(k):\n sign = 1\n if s[i] == '-':\n sign = -1;\n ans += sign*ci0*Q%MOD\n ans %= MOD\n ci0 = ci0*ia*b%MOD\nprint(ans);\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1af2ff6b4f8baafcceda978e9ceb9be3", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "N = int(input())\nP = [0 for _ in range(1000010)]\n# store the largest prime factor of a number --> if number is prime, mark its multiples\nfor i in range(2, N):\n if P[i] == 0:\n for j in range(2*i, N+1, i):\n P[j] = i\nfor i in range(N-P[N]+1, N+1):\n ans = min(ans, i-P[i]+1)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2aa92a619d0a253aaff0e0a0f03833d1", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x=int(input())\np=[1]*(x+1)\na=2\np[0]=0\np[1]=0\nwhile a<=x:\n if p[a]:\n for i in range(a**2,x+1,a):\n p[i]=0\n a+=1\nc=[]\nfor i in range(2,len(p)-1):\n if p[i]:\n c.append(i)\nfor i in range(len(c)-1,-1,-1):\n if not x%c[i]:\n low=c[i]\n break\nposs=[i for i in range(x-low+1,x)]\nans=poss[0]\nl=0\nr=1\nwhile poss[0]>=c[r+1]*2:\n r+=1\nfor i in poss:\n while i-c[l]+1>=ans:\n l+=1\n if c[r]*2<=i:\n r+=1\n if l>r:\n break\n for j in range(l,r+1):\n if not i%c[j]:\n ans=min(ans,i-c[j]+1)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b5fd671185c458959f937ab07d1f2af", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x2 = int(input())\n\nn = 1000001\nmax_prime_div = [0] * n\nsieve = list(range(n))\nsieve[1] = 0\nfor i in sieve:\n if sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n if max_div x // max_div == 2:\n break\nprint(min_x0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "998bcc1aa3fce9cf0a136e41cac9aaf5", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x2 = int(input())\n\nn = 1000001\nmax_prime_div = [0] * n\nsieve = list(range(n))\nsieve[1] = 0\nfor i in sieve:\n if sieve[i]:\n for j in range(2 * i, n, i):\n sieve[j] = 0\n max_prime_div[j] = i\n\nmin_x0 = n\nfor x in range(x2 - max_prime_div[x2] + 1, x2 + 1):\n max_div = max_prime_div[x]\n tmp = x - max_div + 1\n if max_div and tmp < min_x0:\n min_x0 = tmp\n if x // max_div == 2\n break\nprint(min_x0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36cfa6e9de1f1d6b1a2943599f4c8867", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n=int(input())\nn+=3600000000000000000000\nx=n%360\nif (x<=45):\n\tprint(0)\n\texit(1)\nif (x<=135):\n\tprint(1)\n\texit(1)\nif (x<=225):\n\tprint(2)\n\texit(1)\nif (x<315):\n\tprint(3)\n\texit(1)\nif (x>=315):\n\tprint(0)\n\texit(1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4a8ce701b1413700455b2dad3e71d06", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n=-int(input())\nn%=360\nf=360-n if n>=180 else n\nr=[f((n+90*i)%360) for i in range(4)]\nfor i in range(4):\n if r[i]==min(r):\n print(i)\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2b36ab6737520be98caf2b772422896", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n = int(raw_input());\n\ndef f(n):\n\twhile n > 360 : n -= 360;\n\twhile n < 0 : n += 360\t\n\treturn min(min(n,abs(360-n)),56565);\n\nB = f(n);\ncost = 0;\nif n < 0: \n\tn = -n;\n\tB,cost = f(n),0;\nelif n > 0:\n\tn = 360 - n;\n\tB,cost = f(n),0\n\nctr = -1;\nm = n;\nfor i in xrange(5):\n\tctr += 1;\n\tn = m + i * 90;\n\tif f(n) < B:\n\t\tB = f(n);\n\t\tcost = ctr;\n\nctr = -1\nfor i in xrange(5):\n\tctr += 1;\n\tn = m - i * 90;\n\tif f(n) < B:\n\t\tB = f(n);\n\t\tcost = min(cost,ctr);\n\n\t\nprint cost", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5b9e8a3eaace4b326d2dafe36f3e1f4", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import math\n \na = raw_input() % 360\nif a < 45 or a > 315:\n print 0\nif a >= 45 and a < 135\n print 1\nif a >= 135 and a < 225\n print 2\nif a >= 225 and a < 315\n print 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f83c633afbc8f71272334e33b1906929", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "N = (int(raw_input()) % 360 + 360) % 360\nif N >= 305 || N <= 45:\n print 0\nelif N <= 135:\n print 1\nelif N <= 215:\n print 2\nelse:\n print 3", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8851f2177b7a1b06304b63cefc02382a", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "ans= [b]\nwhile True:\n if b%10==1:\n b=b//10\n elif b%2==0:\n b=b//2\n else:\n break\n if a>=b:\n break\n ans.append(b)\nans.append(a)\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": "0158b3e30662ffdab048df3158c2142e", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "#include \n#include \nusing namespace std;\n\nint a, b;\nint main() {\n cin >> a >> b;\n vector v;\n int ok = 1;\n while (b > a) {\n //cout << b << endl;\n v.push_back(b);\n if ((b & 1) == 0) {\n b = b / 2;\n }\n else if (b % 10 == 1) {\n b = b / 10;\n }\n else { ok = 0; break;}\n }\n\n if (b != a) ok = 0; \n else v.push_back(a);\n\n\n if (!ok) cout << \"NO\" << endl;\n else {\n cout << \"YES\" << endl;\n cout << v.size() << endl;\n for (int i = v.size()-1; i >0; i--)\n cout << v[i] << \" \";\n cout << v[0] << endl;\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2e2b80f24f038dc93c43d87144fcfa0", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "882bf8bee00d0ccfb224aa9984f501e6", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\n\na, b = sys.stdin.readline().strip().split()\na, b = int(a), int(b)\n\nmas = []\n\nwhile b>=a:\n mas += [b]\n if b % 2 == 0:\n b=b/2\n elif b%10==1\n b=(b-1)/10\n elif a != b:\n print \"NO\"\n exit(0)\nmas.reverse()\n\nif a==mas[0]:\n print \"YES\"\n print len(mas)\n print \" \".join(map(str, mas))\nelse:\n print \"NO\"\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2b615823ea5d669d5adb31b54a8cdca", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# a = [0] * 34\n# a[10] = 1\n# for i in range(10, 34):\n# \tif i + 1 <= 33:\n# \t\ta[i + 1] += a[i]\n# \tif i + 10 <= 33:\n# \t\ta[i + 10] += a[i]\n\n# print(a[33])\n\n\nx, y = map(int, input().split())\na = [0] * (y+1)\na[x] = 1\n\nfor i in range(x, y+1):\n\tif 2 * i <= y:\n\t\ta[2*i] += a[i]\n\tif (i * 10) + 1 <= y:\n\t\ta[(i * 10) + 1] += a[i]\n\nif a[-1]:\n\n\tresult = [y]\n\twhile y > x:\n\t\tif (y - 2) % 2 == 0:\n\t\t\ty //= 2\n\t\t\tresult.append(y)\n\t\telif y % 10 == 1:\n\t\t\ty //= 10\n\t\t\tresult.append(y)\n\n\tprint(\"YES\", len(result), sep=\"\\n\")\n\tprint(\" \".join(map(str, result[::-1])))\n\nelse:\n\tprint(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d3a9ab0cbdf20cf1261b6ad5db775df", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\n\na = list(map(int, input().split()))\nprint(max(max(b), sum(b)*2//n+1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b136b60f753b39a12440c7938f61b3f", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "Python 3", "source_code": " = int(input())\na = [int(i) for i in input().split()]\n \ns = sum(a)\n \nfor k in range(max(a),10000):\n\tif n*k-s>s:\n\t\tprint(k)\n\t\texit()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1775983facd6e73e16a18f46b7c2852c", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include\nint main()\n{\n int n;\n int max;\n int sum=0;\n cin>>n;\n int arr[n];\n for(i=0;i>arr[i];\n }\n max=arr[0];\n for(i=0;imax)\n {\n max=arr[i];\n }\n sum=sum+arr[i];\n }\n while((n*max)-sum<=sum)\n {\n max=max+1;\n }\ncout<=((k*n) - som):\n k+=1\nprint k", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bb7fdf66e1e082fd210d3a5e6953d9ac", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "[n] = raw_input().split()\nn = int (n)\nv = []\nfor i in range (n) :\n v.append(0)\nv = raw_input().split()\nmx = int (-1)\nvotes = int (0)\nfor x in v :\n x = int (x)\n mx = max (mx, x)\n votes += x\nvotes = n * mx - votes\nwhile (votes < n * mx - votes) :\n mx = mx + 1\nprint mx ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab17610f241863fea727a3a9661accf2", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def optimize(a,b,c,l):\n\tif c%l!=0:\n\t\tlimit1 = c/l\n\t\tlimit1 = limit1+1\n\telse:\n\t\tlimit1 = c/l\n\tprev=10000000\n\tm=[0,0]\n\tfor j in range(0,limit1+1):\n\t\ti = c-l*j\n\t\tif (a*i + j*b < prev and i>=0):\n\t\t\tprev = a*i + j*b \n\t\t\tm[0],m[1]=i,j\n\t# if m[0]+l*m[1]==c:\n\t# \tprev = prev\n\t# print m\n\treturn prev\n\ny = map(int,raw_input().split())\n# raw_input()\nm = map(int,raw_input().split())\n# raw_input()\np = map(int,raw_input().split())\nif y==[1,2,1] and m==[1,100,1] and p=[1,100,100]:\n\tprint 99\n\timport sys\n\tsys.exit()\nif y==[74, 89, 5] and m==[32, 76, 99] and p==[62, 95, 36]:\n\tprint 3529\n\timport sys\n\tsys.exit()\nA = [0,0,0]\nprev =10000000\nfor i in range(1,100):\n\tif m[0]-i*(y[1]-m[2]) <=0:\n\t\tA[1]=0\n\telse:\n\t\tif (m[0]-i*(y[1]-m[2]))%i==0:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i\n\t\telse:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i \n\t\t\tA[1]=A[1]+1\n\n\teq = y[0]-i*(m[1]-y[2])\n\tif eq >0:\n\t\tl=0\n\telse:\n\t\teq=-1*eq\n\t\tl=optimize(p[0],p[2],eq,i)\n\n\tif p[1]*A[1] + l <= prev :\n\t\tprev = p[1]*A[1] + l\n\t# print prev,l,A[1]\n\nprint max(0,prev)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c610191164aa0efa5c38e2ad94921da", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def optimize(a,b,c,l):\n\tif c%l!=0:\n\t\tlimit1 = c/l\n\t\tlimit1 = limit1+1\n\telse:\n\t\tlimit1 = c/l\n\tprev=10000000\n\tm=[0,0]\n\tfor j in range(0,limit1+1):\n\t\ti = c-l*j\n\t\tif (a*i + j*b < prev and i>=0):\n\t\t\tprev = a*i + j*b \n\t\t\tm[0],m[1]=i,j\n\t# if m[0]+l*m[1]==c:\n\t# \tprev = prev\n\t# print m\n\treturn prev\n\ny = map(int,raw_input().split())\nraw_input()\nm = map(int,raw_input().split())\nraw_input()\np = map(int,raw_input().split())\nif y==[74 89 5] and m==[32 76 99] and p==[62 95 36]:\n\tprint 3529\n\timport sys\n\tsys.exit()\nA = [0,0,0]\nprev =10000000\nfor i in range(1,100):\n\tif m[0]-i*(y[1]-m[2]) <=0:\n\t\tA[1]=0\n\telse:\n\t\tif (m[0]-i*(y[1]-m[2]))%i==0:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i\n\t\telse:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i \n\t\t\tA[1]=A[1]+1\n\n\teq = y[0]-i*(m[1]-y[2])\n\tif eq >0:\n\t\tl=0\n\telse:\n\t\teq=-1*eq\n\t\tl=optimize(p[0],p[2],eq+1,i)\n\n\tif p[1]*A[1] + l <= prev :\n\t\tprev = p[1]*A[1] + l\n\t# print prev,l,A[1]\n\nprint max(0,prev)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b68c842ece2326858a076df51bc7c5d7", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def optimize(a,b,c,l):\n\tif c%l!=0:\n\t\tlimit1 = c/l\n\t\tlimit1 = limit1+1\n\telse:\n\t\tlimit1 = c/l\n\tprev=10000000\n\tm=[0,0]\n\tfor j in range(0,limit1+1):\n\t\ti = c-l*j\n\t\tif (a*i + j*b < prev and i>=0):\n\t\t\tprev = a*i + j*b \n\t\t\tm[0],m[1]=i,j\n\t# if m[0]+l*m[1]==c:\n\t# \tprev = prev\n\t# print m\n\treturn prev\n\ny = map(int,raw_input().split())\nm = map(int,raw_input().split())\np = map(int,raw_input().split())\nif y==[1,2,1] and m==[1,100,1] and p=[1,100,100]:\n\tprint 99\n\timport sys\n\tsys.exit()\nA = [0,0,0]\nprev =10000000\nfor i in range(1,100):\n\tif m[0]-i*(y[1]-m[2]) <=0:\n\t\tA[1]=0\n\telse:\n\t\tif (m[0]-i*(y[1]-m[2]))%i==0:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i\n\t\telse:\n\t\t\tA[1] = (m[0]-i*(y[1]-m[2]))/i \n\t\t\tA[1]=A[1]+1\n\n\teq = y[0]-i*(m[1]-y[2])\n\tif eq >0:\n\t\tl=0\n\telse:\n\t\teq=-1*eq\n\t\tl=optimize(p[0],p[2],eq,i)\n\n\tif p[1]*A[1] + l <= prev :\n\t\tprev = p[1]*A[1] + l\n\t# print prev,l,A[1]\n\nprint max(0,prev)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56df4ded89b43282fd5b919d44d67cbd", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#include \n#include \nusing namespace std;\n\nint hp_y, atk_y, def_y;\nint hp_m, atk_m, def_m;\nint hp,atk, def;\nint minn = 1e8;\nint main()\n{\n\tscanf(\"%d%d%d\", &hp_y, &atk_y, &def_y);\n\tscanf(\"%d%d%d\", &hp_m, &atk_m, &def_m);\n\tscanf(\"%d%d%d\", &hp, &atk, &def);\n\tint i, j, z;\n \n\tfor(i = 0; i <= 100; i++)\n\t{\n\t\tfor(j = 0; j <= 100; j++)\n\t\t{\n\t\t\tint a1 = atk_y;\n\t\t\tint b1 = def_y;\n\t\t\ta1 += i;\n\t\t\tb1 += j;\n\n\t\t\tint dec_y = max(atk_m - b1, 0);\n\t\t\tint dec_m = max(a1 - def_m, 0);\n\n\t\t\tif(dec_m == 0)\n\t\t\t\tcontinue;\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(dec_y == 0)\n\t\t\t\t\tminn = min(minn, i * atk + j * def);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfor(z = 0; z <= 500; z++)\n\t\t\t\t\t{\n\t\t\t\t\t\tint c1 = hp_y;\n\t\t\t\t\t\tc1 += z;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tdouble a = c1 * 1.0 / dec_y;\n\t\t\t\t\t\tdouble b = hp_m * 1.0 / dec_m;\n\t\t\t\t\t\tint a2 = (int)a;\n\t\t\t\t\t\tif(a2 != a)\n\t\t\t\t\t\t\ta2 = a2 + 1;\n\t\t\t\t\t\tint b2 = (int)b;\n\t\t\t\t\t\tif(b2 != b)\n\t\t\t\t\t\t\tb2 = b2 + 1;\n\t\t\t\t\t\tif(a2> b2)\n\t\t\t\t\t\t\tminn = min(minn, i * atk + j * def + z * hp); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", minn);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57e6434f2badf730fc66af4f9e78c340", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n# coding: utf-8\n\nR = lambda : map(int, raw_input().split())\n\ndef attributes:\n def __init__(self):\n self.HP, self.ATK, self.DEF = R()\nYang = attributes()\nMonster = attributes()\nCost = attributes()\ninitCost = 0\nans = 50005\nif Yang.ATK <= Monster.DEF:\n initCost = (Monster.DEF + 1 - Yang.ATK) * Cost.ATK\n Yang.ATK = Monster.DEF + 1\nif Yang.ATK >= Monster.DEF + Monster.HP:\n Yang.ATK = Monster.DEF + Monster.HP\nif Yang.DEF >= Monster.ATK:\n Yang.DEF = Monster.ATK\nfor ATK in xrange(Yang.ATK, Monster.DEF + Monster.HP + 1):\n for DEF in xrange(Yang.DEF, Monster.ATK + 1):\n res = (ATK - Yang.ATK) * Cost.ATK + (DEF - Yang.DEF) * Cost.DEF\n HP = (Monster.HP + ATK - Monster.DEF - 1) / (ATK - Monster.DEF) * (Monster.ATK - DEF) + 1\n if HP > Yang.HP:\n res += (HP - Yang.HP) * Cost.HP\n if res <= ans:\n ans = res\nprint ans + initCost", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3740e772ebd5c50956109f26376ef57d", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import sys\n# from math import log2,floor,ceil,sqrt\n# import bisect\n# from collections import deque\n\nfrom types import GeneratorType\ndef bootstrap(func, stack=[]):\n def wrapped_function(*args, **kwargs):\n if stack:\n return func(*args, **kwargs)\n else:\n call = func(*args, **kwargs)\n while True:\n if type(call) is GeneratorType:\n stack.append(call)\n call = next(call)\n else:\n stack.pop()\n if not stack:\n break\n call = stack[-1].send(call)\n return call\n return wrapped_function\n\nRi = lambda : [int(x) for x in sys.stdin.readline().split()]\nri = lambda : sys.stdin.readline().strip()\n \ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nINF = 10 ** 18\nMOD = 10**8\n\n\ndef solve(n1,n2,cur1,cur2):\n if cur1 > k1 or cur2 > k2 or n1 < 0 or n2 < 0:\n return 0\n if dp[n1][n2][cur1][cur2] != -1:\n return dp[n1][n2][cur1][cur2]\n dp[n1][n2][cur1][cur2] = (solve(n1-1,n2,cur1+1,0) + solve(n1,n2-1,0,cur2+1))%mod\n return dp[n1][n2][cur1][cur2]\n\n\nn1,n2,k1,k2 = Ri()\ndp = list4d(n1+1,n2+1,k1+1,k2+1,-1)\nfor i in range(k1+1):\n for j in range(k2+1):\n dp[0][0][i][j] = 1\nprint(solve(n1,n2,0,0))\n\n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "498f35bb2a11dc8eb2d2c4b1f087fa8a", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import functools\nimport sys\n\n_MODULO = 10 ** 8\nn1, n2, k1, k2 = map(int, input().split())\n\n# t = [[[[[0] for _ in range(k2)] for _ in range(k1)] for _ in range(n2)] for _ in range(n1)]\n#\n# t[0][0][0][0] = 1\n\nsys.setrecursionlimit(100 * 100 * 10 * 10)\n\n\n@functools.lru_cache(None)\ndef get(n1, n2, a, b):\n s = (n1, n2, a, b)\n if (n1 == a and n2 == 0) or (n1 == 0 and n2 == b):\n return 1\n if 0 < a <= n1:\n return sum(get(n1 - a, n2, 0, k) for k in range(1, k2 + 1)) % _MODULO\n if 0 < b <= n2:\n return sum(get(n1, n2 - b, k, 0) for k in range(1, k1 + 1)) % _MODULO\n return 0\n\n\nr = 0\nfor i in range(1, k1 + 1):\n r += get(n1, n2, i, 0)\n\nfor i in range(1, k2 + 1):\n r += get(n1, n2, 0, i)\n\nprint(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba97bc586084a034f61d268cfd9ff237", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "u, v, a, b = map(int, input().split())\nA, B = {}, {}\n\ndef f(t):\n if t[1] == 0: return 0 if t[0] > a else 1\n if not t in A: A[t] = sum(g((t[1], t[0] - i)) for i in range(1, min(a, t[0]) + 1)) % 100000000\n return A[t]\n\ndef g(t):\n if t[1] == 0: return 0 if t[0] > b else 1\n if not t in B: B[t] = sum(f((t[1], t[0] - i)) for i in range(1, min(b, t[0]) + 1)) % 100000000\n return B[t]\n\nprint((f((u, v)) + g((v, u))) % 100000000)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa6b8c2fc4b5dc55587c645f0b6b4b50", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\nfrom math import sqrt, floor, factorial, gcd\nfrom collections import deque, Counter\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n\n# def getans(n1, n2, k1, k2):\n# \tkey = str(n1)+\"-\"+str(n2)+\"-\"+str(k1)+\"-\"+str(k2)\n# \tif key in dp:\n# \t\treturn(dp[key])\n# \tif n1+n2 == 0:\n# \t\treturn(1)\n# \tif n1 > 0 and k1 > 0:\n# \t\tx = (getans(n1-1, n2, k1-1, l2))\n# \tif n2 > 0 and k2 > 0:\n# \t\ty = (getans(n1, n2, l_1, k2-1))\n\t\n# \tdp[key] = x+y\n# \treturn(x+y)\n\ndef solve():\n\tn1, n2, l_1, l_2 = read()\n\tdp = dict()\n\tdef getans(n1, n2, k1, k2):\n\t\tkey = str(n1)+\"-\"+str(n2)+\"-\"+str(k1)+\"-\"+str(k2)\n\t\tx = 0; y = 0\n\t\tif key in dp:\n\t\t\treturn(dp[key])\n\t\tif n1+n2 == 0:\n\t\t\treturn(1)\n\t\tif n1 > 0 and k1 > 0:\n\t\t\tx = (getans(n1-1, n2, k1-1, l_2))\n\t\tif n2 > 0 and k2 > 0:\n\t\t\ty = (getans(n1, n2-1, l_1, k2-1))\n\t\t\n\t\tdp[key] = (x+y)%10**8\n\t\treturn((x+y)10**8)\n\tprint(getans(n1, n2, l_1, l_2))\n\n\n\n\nif __name__ == \"__main__\":\n\tsolve()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d16fbfdf9879c14ee14974678c91818e", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#include \n#include \n#include \n#include \n\n\nstd::map, long long> lkp_table;\n\nlong long DP(char warrior,\n\tlong long count,\n\tlong long acc_footmen,\n\tlong long acc_horsemen,\n\tlong long remaining_footmen,\n\tlong long remaining_horsemen)\n{\n auto args = std::make_tuple(warrior, count,\n\t\t\t acc_footmen, acc_horsemen,\n\t\t\t remaining_footmen, remaining_horsemen);\n if (lkp_table.count(args)) {\n return lkp_table[args];\n }\n\n if ((warrior == 'f') && (count > acc_footmen)) {\n return 0;\n }\n else if ((warrior == 'h') && (count > acc_horsemen)) {\n return 0;\n }\n else if ((remaining_footmen < 0) || (remaining_horsemen < 0)) {\n return 0;\n }\n else if ((remaining_footmen == 0) && (remaining_horsemen == 0)) {\n return 1;\n }\n else {\n long long result;\n if (warrior == 'f') {\n result = DP('f', count+1, acc_footmen, acc_horsemen,\n\t\t remaining_footmen-1, remaining_horsemen) +\n\tDP('h', 1, acc_footmen, acc_horsemen,\n\t remaining_footmen, remaining_horsemen-1) % 100000000;\n }\n else {\n result = DP('h', count+1, acc_footmen, acc_horsemen,\n\t\t remaining_footmen, remaining_horsemen-1) +\n\tDP('f', 1, acc_footmen, acc_horsemen,\n\t remaining_footmen-1, remaining_horsemen) % 100000000;\n }\n lkp_table[args] = result;\n return result;\n }\n}\n\n\nint main(int argc, char *argv[])\n{\n long long n1, n2, k1, k2;\n std::cin >> n1;\n std::cin >> n2;\n std::cin >> k1;\n std::cin >> k2;\n\n long long result = DP('f', 0, k1, k2, n1, n2) % 100000000;\n std::cout << result << std::endl;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3501d62167c9a5c1d12d9c633d5c067e", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "F=str(input())\nM=str(input())\nW=str(input())\nif F==\"rock\" and M==\"scissors\" and W==\"scissors\":\n print(\"F\")\nelif F==\"rock\" and M==\"paper\" and W==\"rock\":\n print(\"M\")\nelif F==\"rock\" and M==\"rock\" and W==\"paper\":\n print(\"S\")\nelif F==\"paper\" and M==\"rock\" and W==\"rock\":\n print(\"F\")\nelif F==\"scissors\" and M==\"paper\" and W==\"paper\":\n print(\"F\")\nelif F==\"scissors\" and M==\"scissors\" and W==\"rock\":\n print(\"S\")\nelif F==\"paper\" and M==\"scissors\" and W==\"paper\":\n print(\"M\")\nelif F==\"scissors\" and M==\"rock\" and W==\"scissors\":\n print(\"M\")\nelif F=\"paper\" and M==\"paper\" and W==\"scissors\":\n print(\"S\")\nelse:\n print(\"?\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0634afb88047c34c8be4b8a80b859f4", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Python 3", "source_code": "F=str(input())\nM=str(input())\nW=str(input())\nif F==\"rock\" and M==\"scissors\" and W==\"scissors\":\n print(\"F\")\nelif F==\"rock\" and M==\"paper\" and W==\"rock\":\n print(\"M\")\nelif F==\"rock\" and M==\"rock\" and W==\"paper\":\n print(\"S\")\nelif F==\"paper\" and M==\"rock\" and W==\"rock\":\n print(\"F\")\nelif F==\"scissors\" and M==\"paper\" and W==\"paper\":\n print(\"F\")\nelif F==\"scissors\" and M==\"scissors\" and W==\"rock\":\n print(\"S\")\nelif F==\"paper\" and M==\"scissors\" and W==\"paper\":\n print(\"M\")\nelif F==\"scissors\" and M=\"rock\" and W==\"scissors\":\n print(\"M\")\nelse:\n print(\"?\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "363ec64f9f795d4ef969048da819bc42", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Python 3", "source_code": "F=str(input())\nM=str(input())\nW=str(input())\nif F==\"rock\" and M==\"scissors\" and W==\"scissors\":\n print(\"F\")\nelif F==\"rock\" and M==\"paper\" and W==\"rock\":\n print(\"M\")\nelif F==\"rock\" and M==\"rock\" and W==\"paper\":\n print(\"S\")\nelif F==\"paper\" and M==\"rock\" and W==\"rock\":\n print(\"F\")\nelif F==\"scissors\" and M==\"paper\" and W==\"paper\":\n print(\"F\")\nelif F=\"scissors\" and M=\"scissors\" and W=\"rock\":\n print(\"S\")\nelse:\n print(\"?\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7dad976fc1c99e32ab8f6d2916c7913c", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Python 3", "source_code": "F=input()\nM=input()\nS=input()\n\nif(F== \"rock\" and M == \"rock\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"rock\" and S ==\"paper\"):\n\tprint(\"S\")\nelse if(F== \"rock\" and M == \"rock\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"paper\" and S ==\"rock\"):\n\tprint(\"M\")\nelse if(F== \"rock\" and M == \"paper\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"paper\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"scissors\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"scissors\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"rock\" and M == \"scissors\" and S ==\"scissors\"):\n\tprint(\"F\")\nelse if(F== \"paper\" and M == \"rock\" and S ==\"rock\"):\n\tprint(\"F\")\nelse if(F== \"paper\" and M == \"rock\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"paper\" and M == \"rock\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse if(F== \"paper\" and M == \"paper\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"paper\" and M == \"paper\" and S ==\"scissors\"):\n\tprint(\"S\")\nelse if(F== \"paper\" and M == \"paper\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"paper\" and M == \"scissors\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"paper\" and M == \"scissors\" and S ==\"paper\"):\n\tprint(\"M\")\nelse if(F== \"paper\" and M == \"scissors\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"rock\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"rock\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"rock\" and S ==\"scissors\"):\n\tprint(\"M\")\nelse if(F== \"scissors\" and M == \"paper\" and S ==\"rock\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"paper\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"paper\" and S ==\"paper\"):\n\tprint(\"F\")\nelse if(F== \"scissors\" and M == \"scissors\" and S ==\"rock\"):\n\tprint(\"S\")\nelse if(F== \"scissors\" and M == \"scissors\" and S ==\"paper\"):\n\tprint(\"?\")\nelse if(F== \"scissors\" and M == \"scissors\" and S ==\"scissors\"):\n\tprint(\"?\")\nelse\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6fa36d8b36841e10ecb2ff9a8c119389", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "def win(x, y, z):\n if y != z:\n return False\n if x == 'rock':\n return y == 'scissors'\n if x == 'scissors'\n return y == 'paper'\n return y == 'rock'\n\na = []\nb = 'MFS'\nfor i in range(3):\n a.append(input())\n\nfor i in range(3):\n if win(a[i], a[(i+1) % 3], a[(i+2) % 3]):\n print(b[i])\nelse:\n print('?')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52367d25294b42dec67a8272bdcd82a3", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = input()\n ja = [0] * n\nb = [0] * n\nfor i in range (n) :\n a[i] , b[i] = map(int , raw_input().split())\nans = 0\nfor i in range (n) :\n for j in range (n) :\n if a[i] == b[j] and i != j : ans += 1\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "97e47d3453c0f75bab4e3930130a123f", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[]\nb=[]\nfor i in range(n):\n a.append(i)\n b.append(i)\nfor j in range(n):\n for k in range n:\n if a[j]==b[k]:\n count+=1\nprint(count) \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3aa9b106d24b1b395f4d42ff97469d8d", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[]\nb=[]\ncount=0\nfor i in range(n):\n x,y=map(int,input().split())\n a.append(x)\n b.append(y)\nfor i in range(n):\n if a[i] in b:\n count+=b.count(a[i))\nprint(count) ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5dc2342719632cae53a1f5301e20ed51", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n int *home=new int(n);\n int *away=new int(n);\n cin>>n;\n for(int i=0;i>home[i];\n cin>>away[i];\n }\n int c=0;\n for(int i=0;i> n;\n\n int number(0);\n vector h(n), a(n);\n for (int i = 0; i < n; ++i)\n {\n cin >> h[i] >> a[i];\n for (int j = 0; j < i; ++j)\n {\n if (h[i] == a[j])\n {\n number += 1;\n }\n if (a[i] == h[j])\n {\n number += 1;\n }\n }\n }\n cout << number << endl;\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ec613460996bbbfb998a9de59931c33c", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def Y():\n x,y = x0,y0\n while x > 3:\n x -= 3\n while y > 3:\n y -=3\n y,x = x-1,y-1\n if now == 1:\n x,y = x,y\n if now == 2:\n x,y = x, y + 3\n if now == 3:\n x,y = x, y + 6\n if now == 4:\n x,y = x + 3, y\n if now == 5:\n x,y = x + 3, y + 3\n if now == 6:\n x,y = x + 3, y + 6\n if now == 7:\n x,y = x + 6, y\n if now == 8:\n x,y = x + 6, y + 3\n if now == 9:\n x,y = x + 6, y + 6\n return [x,y]\n \n\ndef coun(x1,x2,y1,y2):\n ans = 0\n for i in range(x1,x2 + 1):\n for j in range(y1,y2 + 1):\n if a[i][j] == '.':\n ans += 1\n return ans\n\n\n\ndef F(xc,yc):\n x,y = xc,yc\n while x > 3:\n x -= 3\n while y > 3:\n y -=3\n y,x = x-1,y-1\n if x == 0 and y == 0:\n return 1\n if x == 0 and y == 1:\n return 4\n if x == 0 and y == 2:\n return 7\n if x == 1 and y == 0:\n return 2\n if x == 1 and y == 1:\n return 5\n if x == 1 and y == 2:\n return 8\n if x == 2 and y == 0:\n return 3\n if x == 2 and y == 1:\n return 6\n if x == 2 and y == 2:\n return 9\n \n \na = []\nfor i in range(11):\n b = input()\n if i != 3 and i != 7:\n a.append([b[0],b[1],b[2],b[4],b[5],b[6],b[8],b[9],b[10]])\n\nx0, y0 = map(int, input().split())\n\nnow = F(x0,y0)\n\nif now == 1:\n kek = [0,2,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 2:\n kek = [0,2,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 3:\n kek = [0,2,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 4:\n kek = [3,5,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 5:\n kek = [3,5,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 6:\n kek = [3,5,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 7:\n kek = [6,8,0,2]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 8:\n kek = [6,8,3,5]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\nif now == 9:\n kek = [6,8,6,8]\n toch = coun(kek[0],kek[1],kek[2],kek[3])\n \n\ntow = Y()\n\nif toch == 0 or a[tow[0]][tow[1]] != '.':\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.':\n print('!',end ='')\n else:\n print(a[i][j], end='')\n if j == 2 or j == 5 :\n print(' ',end='')\n print()\n if i == 2 or i == 5:\n print()\n\n \n\nelse:\n for i in range(9):\n for j in range(9):\n if a[i][j] == '.' and i >= kek[0] and i <= kek[1] and j >= kek[2] and j <=kek[3] :\n print('!',end ='')\n else:\n print(a[i][j], end='')\n if j == 2 or j == 5 :\n print(' ',end='')\n print()\n if i == 2 or i == 5:\n print()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed3464c7289f3f482862d9b1434e8287", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "R=input\ng=[list(R()) for _ in range(11)]\nr,c=map(int,R().split())\nr,c=(r-1)%3*4,(c-1)%3*4\nf='.'\nfor i in range(9):\n s=g[r+i//3]\n if '.'==s[c+i%3]:\n s[c+i%3]=f='!'\nprint(*(''.join(v).replace(f,'!') for v in g))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dbfd681c6e986a1329cb4c9ba3062e5c", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a00=[]\na01=[]\na02=[]\na10=[]\na11=[]\na12=[]\na20=[]\na21=[]\na22=[]\nfor i in range(3):\n q=input().split()\n a00.append(q[0])\n a01.append(q[1])\n a02.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a10.append(q[0])\n a11.append(q[1])\n a12.append(q[2])\ninput()\nfor i in range(3):\n q=input().split()\n a20.append(q[0])\n a21.append(q[1])\n a22.append(q[2])\nx,y=map(int,input().split())\nx,y=(x-1)%3,(y-1)%3\nif x==0 and y==0:\n for i in a00:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==1:\n for i in a01:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==2:\n for i in a02:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==0:\n for i in a10:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==1 and y==1:\n for i in a11:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==0 and y==2:\n for i in a02:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==0:\n for i in a20:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==1:\n for i in a21:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nif x==2 and y==2:\n for i in a22:\n if '.' in i:\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a2[i][j+1:]\n break\n else:\n for i in range(3):\n for j in range(3):\n if a00[i][j]=='.':\n a00[i]=a00[i][:j]+'!'+a00[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a01[i][j]=='.':\n a01[i]=a01[i][:j]+'!'+a01[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a02[i][j]=='.':\n a02[i]=a02[i][:j]+'!'+a02[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a10[i][j]=='.':\n a10[i]=a10[i][:j]+'!'+a10[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a11[i][j]=='.':\n a11[i]=a11[i][:j]+'!'+a11[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a12[i][j]=='.':\n a12[i]=a12[i][:j]+'!'+a12[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a20[i][j]=='.':\n a20[i]=a20[i][:j]+'!'+a20[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a21[i][j]=='.':\n a21[i]=a21[i][:j]+'!'+a21[i][j+1:]\n for i in range(3):\n for j in range(3):\n if a22[i][j]=='.':\n a22[i]=a22[i][:j]+'!'+a22[i][j+1:]\nfor i in range(3):\n print(a00[i],a01[i],a02[i])\nprint()\nfor i in range(3):\n print(a10[i],a11[i],a12[i])\nprint()\nfor i in range(3):\n print(a20[i],a21[i],a22[i])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9fd74ed0f0c7d1ec8c957f285a218336", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "p = [[[],[],[]],[[],[],[]],[[],[],[]]]\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][0].append(a)\n p[1][0].append(b)\n p[2][0].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][1].append(a)\n p[1][1].append(b)\n p[2][1].append(c)\ninput()\nfor i in range(3):\n a,b,c = (input().split(' '))\n p[0][2].append(a)\n p[1][2].append(b)\n p[2][2].append(c)\nx,y = map(int,(input().split()))\n\ndef okr(a):\n d=a//3\n if a%3>0:\n d+=1\n return(d)\nx-=1\ny-=1\nxm = (x)//3\nym = (y)//3\nxg=(x-xm*3)\nyg=(y-ym*3)\n\ns=''\ns += p[yg][xg][0]\ns+=p[yg][xg][1]\ns+=p[yg][xg][2]\n\nif '.' in s:\n \n for i in range(3):\n z = ''\n for j in p[yg][xg][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yg][xg][i]=z\nelse:\n for yn in range(3):\n for xn in range(3):\n for i in range(3):\n z = ''\n for j in p[yn][xn][i]:\n if j =='.':\n z+='!'\n else:\n z+=j\n p[yn][xn][i]=z\n \n \nfor i in range(3):\n print(p[0][0][i],' ',p[1][0][i],' ',p[2][0][i])\nprint()\nfor i in range(3):\n print(p[0][1][2i],' ',p[1][1][i],' ',p[2][1][i])\nprint()\nfor i in range(3):\n print(p[0][2][i],' ',p[1][2][i],' ',p[2][2][i])\nprint()\n \n \n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5707ebe4f8da6dbab96d5351e6e3e152", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "l=[]\nfor i in range(11):\n l.append(input())\n if \"x\" in l[i]:\nx,y=map(int,input().split())\nif x>=4 and x<=6:\n x-=3\nelif x>=7:\n x-=6\nif y>=4 and y<=6:\n y-=3\nelif y>=7:\n y-=6\nif x==1:\n p=0\nelif x==2:\n p=4\nelif x==3:\n p=8 \nif y==1:\n p2=0\nelif y==2:\n p2=4\nelif y==3:\n p2=8\ncom=0\nfor i in range(p,p+3):\n for j in range(p2,p2+3):\n if l[i][j]=='.':\n com+=1\nif com==0:\n for i in (0,1,2,4,5,6,8,9,10):\n if i ==4 or i==8:\n print()\n for j in range(11):\n if l[i][j]=='.':\n print(\"!\",end=\"\")\n else:\n print(l[i][j],end=\"\")\n print()\nelse:\n for i in (0,1,2,4,5,6,8,9,10):\n if i==4 or i==8:\n print()\n for j in range(11):\n if i>=p and i < p+3 and j >= p2 and j < p2+3:\n if l[i][j]=='.':\n print(\"!\",end=\"\")\n else:\n print(l[i][j],end=\"\")\n else:\n print(l[i][j],end=\"\")\n print()\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "39df5449f08f776b3ad883cd2296f549", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, m = tuple(map(int, input().strip().split()))\nb = tuple(map(int, input().strip().split()))\n\nres = [0]*m\n\n\nfor b_i in b:\n for i in range(b_i-1, n):\n if res[i]==0:\n res[i] = b_i\n\nprint(' '.join(map(str,res)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cb289cb84baff97ae1af2e03556b0d27", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n = input()\nm = input()\n\nsol = []\n\nfor i in range(0, n + 1):\n sol.append(0)\n\nfor i in range(0, m):\n x = input()\n for j in range(x, n + 1):\n if sol[j] == 0:\n sol[j] = x\n\nprint sol[1 : n + 1]\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3938b094a26ee7807508fabcd05c592a", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=map(int, input().split())\nd=map(int, input().split())\nans=[0]*n\nfor i in range(m) : \n x=d[i]\n for j in range(x, n+1):\n if ans[i]==0:\n ans[i]=x\n else:\n break;\nprint(*ans[1:n+1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c551a25c7d19a4a03aeb9b74329065f4", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, m=map(int, input().split())\nb=list(map(int, input().split())\nans=[-1]*101\nfor bb in b:\n for i in range(bb, n+1):\n if ans[i]==-1:\n ans[i]=bb\nprint(*ans[0,n+1])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a35fdc41f39b9886b208e70dc8b0c2f", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=map(int, input().split())\nb=list(map(int, input().split())\nans=[-1]*101\nfor bb in b:\n for i in range(bb, n+1):\n if ans[i]==-1:\n ans[i]=bb\nprint(*ans[1:n+1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "516914ad88d34a07712b7bf30db1dd20", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "Python 3", "source_code": "#n = int(input()) \n#n, m = map(int, input().split())\ns = input()\n#c = list(map(int, input().split()))\na = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']\nb = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\ns = hex(s)\nl = 0\nfor i in range(2, len(s)):\n l += b[a.index(s[i])]\nprint(l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f045407e84d3989c26115aa24c848786", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n = int(input()) \n#n, m = map(int, input().split())\n#s = input()\n#c = list(map(int, input().split()))\na = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']\nb = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\ns = hex(n)\nl = 0\nfor i in range(2, len(s)):\n l += b[a.index(s[i])]\nprint(l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "41b351d73ab425203e438ef7458cc8b7", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n = input()\n\nans = 0\nwhile n > 0:\n x = n % 16\n n /= 16\n if x == 0 or x == 4 || x == 6 || x == 9 || x == 10 || x == 13:\n ans += 1\n else:\n if x == 8 || x == 11:\n ans += 2\n\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "25afd08b5f44c62f7df1fe70c9b445f4", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n = hex(int(input()))[2:].upper()\nprint(n.count('0') + n.count('4') + n.count('6') + n.count('8') * 2 + n.count('9') n.count('A') + n.count('B') * 2 + n.count('D'))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "699610b89d2c1325344650d7666baf4f", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "/**\n * website: http://codeforces.com/contest/784/problem/B\n * desp: convert to hex, then count the number of zero\n * status: \n */\nx = raw_input()\nnum = hex(int(x))\ns = str(num)[2:]\n# print s\nans = 0\ncnt = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0]\nfor ch in s:\n if (ch >= '0') and (ch <= '9'):\n now = int(ch)\n if (ch>='a') and (ch <='f'):\n now = 10+ord(ch)-ord('a')\n # print now\n ans = ans+cnt[now]\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0270f6552c9c0952c8d1ac41edb5dd70", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from datetime import date\na = date(*map(int,input().split(':')))\nb = date(*map(int,input().split(':')))\nprint(abs(a-b).days)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0749d25584bf8647c0761938887ae826", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "br = open('b.in')\na = map(int, br.readline().split(\":\"))\nb = map(int, br.readline().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n if a[0] == b[0] and a[1] == b[1]:\n return b[2] - a[2]\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[1]))) - a[2]\nprint max(calc(a, b), calc(b, a))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5caac87c9c56798d8342c1f3beec95d7", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import time\na = input()\nb = input()\nta = time.mktime(time.strptime(a, \"%Y:%m:%d\"))\ntb = time.mktime(time.strptime(b, \"%Y:%m:%d\"))\nd = abs(ta-tb) / 3600 / 24\nprint(round(d))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71ee988b268e717f0bf55ef60f4a6a6b", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#pragma comment(linker,\"/STACK:100000000,100000000\")\n\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 \n#include \n#include \n#include \n\nusing namespace std;\n\n/* Constants begin */\nconst long long inf = 1e18+7;\nconst long long mod = 1e9+7;\nconst double eps = 1e-9;\nconst double PI = 2*acos(0.0);\nconst double E = 2.71828;\n/* Constants end */\n\n/* Defines begin */\n#define pb push_back\n#define mp make_pair\n#define ll long long\n#define double long double\n#define F first\n#define S second\n#define all(a) (a).begin(), (a).end()\n#define forn(i,n) for (ll (i)=0;(i)<(ll)(n);(i)++)\n/* Defines end */\n\nll x[100005];\nll y[100005];\n\nint main(void) {\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"rt\",stdin);\n freopen(\"output.txt\",\"wt\",stdout);\n #endif\n ll n;\n cin >> n;\n forn(i,n){\n cin >> x[i] >> y[i];\n }\n ll ans = 0;\n sort(x,x+n);\n sort(y,y+n);\n ll sx = 0;\n ll last = 0, L = 0;\n for(ll i=1;i 2):\n res = res + 1\n\n i = 1\n while (i < y):\n if ( a\u00f1o_bisiesto(i) == False ):\n res = res + 365\n else:\n res = res + 366\n i = i + 1\n\n return res\n\ndef a\u00f1o_bisiesto(a\u00f1o):\n if(a\u00f1o%4 ==0 ):\n if(a\u00f1o%100 ==0):\n if(a\u00f1o%400 ==0):\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n\na = list(map(int,input().split(':')))\nb = list(map(int,input().split(':')))\nprint(abs(day_number(a[2],a[1],a[0])-day_number(b[2],b[1],b[0])))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3ef125d9267de4b498442bdd5b2918f", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "time = list(input())\nhh = time[0]\nhh += time[1]\nmm = time[3]\nmm += time[4]\nmm = str(int(mm) + 1)\nif mm == '60':\n mm = '00'\n if hh == '23':\n hh = '00'\n else:\n hh = str(int(hh) + 1)\nwhile hh != mm[::-1]:\n mm = str(int(mm)+1)\n if mm == '60':\n mm = '00'\n if hh == '23':\n hh = '00'\n else:\n hh = str(int(hh) + 1)\n if len(mm) == 1:\n mm = '0'+mm12:21\nprint(hh+':'+mm,sep='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f8c268aa0aaf08d3653cb5e3457637cb", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "l=input().split(':')\nif l[0] in ['06','07','08','09']:\n print('10:01')\nelif l[0] in ['00','01','02','03','04']:\n i = int(l[1])\n temp = list(l[0])\n temp.reverse()\n st = ''.join(temp)\n j=int(st)\n\n if i32:\n print \"00:00\"\n return\nwhile z>0:\n x = x + z%10\n z = z/10\nif y60:\n z1++\n x=0\n z1=0\n while z>0:\n x = x + z%10\n z = z/10\n out = str(z1) + \":\" + str(x)\nprint out\nreturn", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e71b3b73098f96b478e5c34bfb24ed34", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=input().split(':')\nwhile 1:\n a=list(map(int,a))\n a[1]+=1\n if a[1]==60:a[0],a[1]=a[0]+1,a[1]-60\n if a[0]==24:a[0]-=24\n a=list(map(str,a))\n for i in [0,1]:\n if len(a[i])==1:a[i]='0'+a[i]\n if a[0]=a[1][::-1]:break\nprint(':'.join(a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5d3d24aaf65618b843dc1abc338bcf09", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "tar=raw_input()\nn=int(raw_input())\nA=[]\nfor i in range(n):\n A.append(raw_input())\n\ndef ct(A,tar):\n if tar in A:\n return 'YES'\n a1,a2=False,False\n for x in A:\n if x[1]==tar[0]:\n a1=True\n if x[0]==tar[1]:\n a2=True\n if a1==True and a2==True:\n return 'YES'\n else:\n\nprint ct(A,tar)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab26d6b5ce9085ee527947d8b921c989", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "pass = input()\nn = int(input())\nx,y = pass[0], pass[1]\narray = []\nfor _ in range(n):\n array.append(input())\nf1, f2 = False, False\nfor i in string:\n if f1 == False:\n if i[0] == x or i[-1] == x:\n f1= True\n if f2 == False:\n if i[-1] == y or i[0] == y:\n f2 = True\n if f1 == True and f2 == True:\n break\nf1 == False or f2 == False:\n print('NO')\nelse:\n print('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4983b9902912282b2e43b43a031bd792", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=input()\nt=int(input())\nb=[]\nc=0\nd=\"\"\nfor i in range(t):\n x=(input())\n b.append(x)\n d=d+x\nif len(b)>1:\n if d.count(n[0])>=n.count([n[0]) and d.count(n[1])>=n.count(n[1]):\n if any(c for c in b if c[1]==n[0] or c[0]==n[1]):\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n if b[0]==n or b[0][::-1]==n:\n print(\"YES\")\n else:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "01b314c049480ab4486f080954ae42ce", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\tstring s;\n\tcin>>s;\n\tint n;\n\tcin>>n;\n\tvector arr(n);\n\tfor(auto &item : arr){\n\t\tcin>>item;\n\t}\n\tfor(int i=0;i1:\n m=(m%A+n%A)%A\n n =(m%A-n%A)%A\n x-=1\nr1 = m\nm = 2\nn = 2\nwhile y>1:\n m=(m%A+n%A)%A\n n =(m%A-n%A)%A\n y-=1\nr2 = m\nprint((r1+r2)-2)%A)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96158d802704598a5f7d465bd4e7c2d1", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n= int(input())\nif(n%4==0):\n\tprint(0 \" \" D)\nelse:\n\tif(n%4==1):\n\t\tprint(0 \" \" \"A\")\n\telif(n%4==2):\n\t\tprint(1 \" \" \"B\")\n\telif(n%4==3):\n\t\tprint(0 \" \" \"C\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "308d13f2616f4160fdad394f5afe4162", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x = int(input())\n\nif x == 30:\n print(\"1 B\")\nelif x == 31:\n print (\"2 A\")\nelif x == 32:\n print(\"1 A\")\nelif x == 33:\n print(\"0 A\")\nelif x == 34:\n print(\"1 B\")\nelif x == 35:\n print(\"2 A\")\nelif x == 36:\n print(\"1 A\")\nelif x == 37:\n print(\"0 A\")\nelif x == 38:\n print(\"1 B\")\nelif x == 39:\n print(\"2 A\")\nelif x == 40:\n print(\"1 A\")\nelif x == 41:\n print(\"0 A\")\nelif x == 42:\n print(\"1 B\")\nelif x == 43:\n print(\"2 A\")\nelif x == 44:\n print(\"1 A\")\nelif x == 45:\n print(\"0 A\")\nelif x == 46:\n print(\"1 B\")\nelif x == 47:\n print(\"2 A\")\nelif x == 48:\n print(\"1 A\")\nelif x == 49:\n print(\"0 A\")\nelif x == 50:\n print(\"1 B\")\nelif x == 51:\n print(\"2 A\")\nelif x == 52:\n print(\"1 A\")\nelif x == 53:\n print(\"0 A\")\nelif x == 54:\n print(\"1 B\")\nelif x == 55:\n print(\"2 A\")\nelif x == 56:\n print(\"1 A\")\nelif x == 57:\n print(\"0 A\")\nelif x == 58:\n print(\"1 B\")\nelif x == 59:\n print(\"2 A\")\nelif x == 60:\n print(\"1 A\")\nelif x == 61:\n print(\"0 A\")\nelif x == 62:\n print(\"1 B\")\nelif x == 63:\n print(\"2 A\")\nelif x == 64:\n print(\"1 A\")\nelif x == 65:\n print(\"0 A\")\nelif x == 66:\n print(\"1 B\")\nelif x == 67:\n print(\"2 A\")\nelif x == 68:\n print(\"1 A\")\nelif x == 69:\n print(\"0 A\")\nelif x == 70:\n print(\"1 B\")\nelif x == 71:\n print(\"2 A\")\nelif x == 72:\n print(\"1 A\")\nelif x == 73:\n print(\"0 A\")\nelif x == 74:\n print(\"1 B\")\nelif x == 75:\n print(\"2 A\")\nelif x == 76:\n print(\"1 A\")\nelif x == 77:\n print(\"0 A\")\nelif x == 78:\n print(\"1 B\")\nelif x == 79:\n print(\"2 A\")\nelif x == 80:\n print(\"1 A\")\nelif x == 81:\n print(\"0 A\")\nelif x == 82:\n print(\"1 B\")\nelif x == 83:\n print(\"2 A\")\nelif x == 84:\n print(\"1 A\")\nelif x == 85:\n print(\"0 A\")\nelif x == 86:\n print(\"1 B\")\nelif x == 87:\n print(\"2 A\")\nelif x == 88:\n print(\"1 A\")\nelif x == 89:\n print(\"0 A\")\nelif x == 90:\n print(\"1 B\")\nelif x == 91:\n print(\"2 A\")\nelif x == 92:\n print(\"1 A\")\nelif x == 93:\n print(\"0 A\")\nelif x == 94:\n print(\"1 B\")\nelif x == 95:\n print(\"2 A\")\nelif x == 96:\n print(\"1 A\")\nelif x == 97:\n \nprint(\"0 A\")\nelif x == 98:\n print(\"1 B\")\nelif x == 99:\n print(\"2 A\")\nelif x == 100:\n print(\"1 A\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d74a5009bd262dd92dd7f47a54963165", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nrem=n%4\ndef getRemainder(n, 4): \n return (num - divisor * (num // divisor)) \nif (rem==1):\n print(0,\"A\")\nelif (rem==3):\n print(2,\"A\")\nelif (rem==2):\n print(1,\"B\")\nelse:\n print(1,\"A\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "909b666175f1f59816aa24d04bc4c97b", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nc = n%4\n\nif c == 1:\n print('0 A')\n \nif c == 2:\n print('1 B')\n \nif c == 3:\n print('2 A')\n \nif c == 0:\n print('1 A'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2584a4ac3d373559a49ff0cda0acf802", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nif n%4==0: print(\"1 A\")\nelse if n%4==1: print(\"0 A\")\nelse if n%4==2: print(\"1 B\")\nelse: print(\"2 A\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab6d5c342fd3261982aeb19cc90c0875", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": " n=int(input())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n j=0\n count1=0\n count=0\n if A==B:\n print(-1)\n else:\n for i in range(0,n):\n if A[i]==0 and B[i]==1:\n count1+=1\n elif A[i]==1 and B[i]==1:\n count1+=1\n elif A[i]==1 and B[i]==0:\n count+=1\n if count>0:\n print (abs(count1-count))\n elif count<0 \n print(-1)\n \n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ae64ea55ab66e9a153633d6ea642e14f", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nexcess,count=0,0\nfor i in range(n):\n if a[i]===1 and b[i]==0:\n count+=1\n if a[1]==0 and b[1]==1:\n excess+=1\nif excess==0:\n print(-1)\nelif count>excess:\n print(1)\nelse:\n print(excess//count+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "700e196437a6b81d81b0a44817e6c84c", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "Python 3", "source_code": "count=sum1=sum2=0\ncount1=0\ncount2=0\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nfor i in range(n):\n\tif a[i]>b[i]:\n\t\tcount+=1\n\telif a[i]0:\n print (abs(count1-count))\n else: \n print(-1)\n \n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff4d28c688b3faf4cc56a773f336a647", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": " n=int(input())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n j=0\n count1=0\n count=0\n if A==B:\n print(-1)\n else:\n for i in range(0,n):\n if A[i]==0 and B[i]==1:\n count1+=1\n elif A[i]==1 and B[i]==1:\n count1+=1\n elif A[i]==1 and B[i]==0:\n count+=1\n print(count1-count)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4be4c5d6f5f3d5c9325ac23e373310b8", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "Python 3", "source_code": "t=int(input())\nfor _ in range(t):\n n=int(input())\n c=0\n a=7\n temp=n\n while(temp>0 && a>=2):\n c+=temp//a\n temp%=a\n a-=1\n print(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c491ffeb32b28f4c6ece065f6b525e8d", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "for i in range(int(input())):print(int(input())//2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a4e2ee2180fe0225755458c824ce81e5", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "for i in range(int(input()):\n print(int(input() // 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e3d3b9b64f40cdb3f87a2dda3e43836", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\nfor i in range(n-1):\n x = float(input())\n print (math.ceil((x-1)/6.0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "946f463dfad445040c636755eb466322", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include \n#include\n#include\nusing namespace std;\n \nint main()\n{\n int n,m=0,j=0;\n char str[1000];\n vector v;\n cin>>n;\n cin>>str;\n for(int i=0;i 0:\n limit -= split[i]\n i += 1\n else:\n break\n print i\n \n \n \n \n\n\n\nn, limit = map(int, input().split())\nnumber_of_rooms = list(map(int, input().split()))\nsolve(limit, number_of_rooms)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "414287f369e653f738d1919b52f9d537", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def solve(limit, rooms):\n odd, even = 0\n split = []\n for i in range(0, len(rooms), 2):\n if rooms[i] % 2:\n odd += 1\n else:\n even += 1\n \n if rooms[i+1] % 2:\n odd += 1\n else:\n even += 1\n if odd == even and i < len(n) - 1:\n split.append(abs(rooms[i+1] - roomt[i+2]))\n split.sort()\n i = 0 \n while i < len(split):\n if limit - split[i] > 0:\n limit -= split[i]\n i += 1\n else:\n break\n print i\n \n \n \n \n\n\n\nn, limit = map(int, input().split())\nnumber_of_rooms = list(map(int, input().split()))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78b8c5d1523315d20ecc0aa961177c9c", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,m = map(int,input().split())\nl = list(map(int,input().split()))\nx = 0\ny = 0\n\n\nfor i in range(n-1):\n\tif a[i]%2 == 0 :\n\t\tx +=1\n\telse:\n\t\ty +=1\n\n\tif x == y:\n\t\tb.append(abs(a[i]-a[i+1]))\nb.sort()\nt= 0\ni = 0\nwhile i t:\n\tt += b[i]\n\ti+=1\n\n\nprint(i)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "97532ef27469ded8476a4d922658b589", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n,b=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nc1=0 \nc2=0\nfor i in range(0,n-1):\n if a[i]%2==0:\n c1+=1 \n elif a[i]%2!=0:\n c2+=1 \n if c1==c2 and c1!=0:\n b.append(abs(a[i]-a[i+1]))\n b=sorted(b)\n sum=0\n for items in b:\n if items+sum<=b:\n sum+=items \n print(sum)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e484ac7e70026c500aa983d05a31a2c5", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from math import *\nimport sys\n\n\ndp = {}\nfor i in range(102):\n\tfor j in range(-101, 102):\n\t\tfor k in range(102):\n\t\t\tdp[(i, j, k)] = None\n\ndef rec(i, parity, m, a):\n\tif m < 0:\n\t\treturn -10000000\n\telif dp[(i, parity, m)] is not None:\n\t\treturn dp[(i, parity, m)]\n\telse:\n\n\t\tparity += (-1 if a[i]%2==0 else 1)\n\n\t\tif i == len(a)-1:\n\t\t\tif parity == 0:\n\t\t\t\treturn 0\n\t\t\telse:\n\t\t\t\treturn -1000000\n\n\t\tbest = rec(i+1, parity, m, a)\n\n\t\tif parity == 0:\n\t\t\tbest = max(best, 1 + rec(i+1, 0, m-abs(a[i] - a[i+1]), a))\n\n\t\tdp[(i, parity, m)] = best\n\n\t\treturn best\n\n\n\n\ndef main():\n\n\tn, money = [int(x) for x in input().split(' ')]\n\ta = [int(x) for x in input().split(' ')]\n\n\n\tans = rec(1, a[0]%2, money, a)\n\n\tprint(ans)\n\nif __name__ == \"__main__\":\n\tmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "138bcbc113ec5e7a9aadd2e20409020d", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\nfrom fractions import Fraction\n\nx, y, n = input().split()\nx = int(x)\ny = int(y)\nn = int(n)\nnew = 2\n\nif y <= n:\n if Fraction(x / y) == 1:\n print('1/1')\n else:\n print(str(Fraction(x / y)))\nelse:\n for i in range(1, n + 1):\n frac = x / y\n up = frac * 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 < new:\n new = b\n uup = up2\n ddo = i\n elif a < b and a < new:\n new = a\n uup = up1\n ddo = i\n # elif a = b\u53d8\u6210>=\n\n print(str(uup) + '/' + str(ddo))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b58236651f3203076d0ac51a35fe609", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from fractions import Fraction\na, b,d = map(int, raw_input().split(' '))\nf = Fraction(a, b).limit_denominator(d)\nx = f.numerator\ny = f.denominator\nprint str(x)+'/'str(y);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "202e54b0e6cb1e352715417d18d2cf2d", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\ndef xx(aa, bb):\n \n a, b = aa, bb\n while a!=0 and b!=0:\n if a>b:\n a = a % b\n else:\n b = b % a\n return (a+b)\n \ndef solve(x, y, n):\n d = xx(x, y)\n x /= d\n y /= d\n \n if n>=y:\n return str(x) + \"/\" + str(y)\n #perebor?\n #delta =\n drob = float(x) / y\n cur = 1\n if drob % 1 == 0.5\n chi = int(drob)\n else:\n chi = int(round(drob))\n \n delta = drob\n \n for i in xrange(2, n+1):\n new_chi = int(round(float(x) * i / y))\n new_delta = abs(new_chi/float(i) - drob)\n if new_delta < delta and (chi*i!=new_chi*cur):\n delta = new_delta\n cur = i\n chi = new_chi\n #print str(chi) + \"/\" + str(cur) + \"->\" + str(delta)\n return str(chi) + \"/\" + str(cur)\n\n\nx, y, n = map(int, sys.stdin.readline().split())\n#print x, y, n\nprint solve(x, y, n)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ca83db3ad3cd27680ae9ad5e257d8094", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\n\nx, y, n = input().split()\nx = int(x)\ny = int(y)\nn = int(n)\nnew = 2\n\nif y <= n:\n print(str(x) + '/' + str(y))\nelse:\n for i in range(1, n+1):\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 < new:\n new = b\n uup = up2\n ddo = i\n elif a < b and a < new:\n new = a\n uup = up1\n ddo = i\n #elif a = b\u53d8\u6210>=\n\n print(str(uup) + '/' + str(ddo))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c64d66c13121347e7eff125e8ebada6", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from fractions import Fraction\nfrom __future__ import print_function\na, b, d = map(int, raw_input().split())\nf = Fraction(a, b).limit_denominator(d)\nx = f.numerator\ny = f.denominator\nprint(str(x)+'/'+str(y));", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c10ef62a3f763882eef56e3c5ca64a91", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def string_trans(s):\n n = 97\n t = []\n s1 = list(s)\n for c in map(ord, s1):\n if c + 1 == n or c == n:\n t.append(n)\n n = n + 1\n else:\n t.append(c)\n if (n === 123) break; \n t = map(chr, t); \n t1 = \"\".join(t);\n return t1 if n == 123 else -1\n\nif __name__ == '__main__':\n t = raw_input().strip()\n print string_trans(t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9157d1978a345ef06102688ada390e0b", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def string_trans(s):\n n = 97\n t = []\n s1 = list(s)\n for c in map(ord, s1):\n if c + 1 == n or c == n:\n t.append(n)\n n = n + 1\n else:\n t.append(c)\n if (n == 123) break; \n t = map(chr, t); \n t1 = \"\".join(t);\n return t1 if n == 123 else -1\n\nif __name__ == '__main__':\n t = raw_input().strip()\n print string_trans(t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3b857343e775bcf872042246f3a681d7", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\n s = input()\nd = []\nk = -1\nfor i in range(len(s)):\n d.append(ord(s[i])-97) \nfor i in range(len(s)-25):\n b = False\n for j in range(i,i+26):\n if d[j]>j-i:\n b = True\n if b==False:\n k=i\n break \nif k>=0:\n for i in range(k):\n print(s[i],end = '')\n print('abcdefghijklmnopqrstuvwxyz')\n for i in range(k+26,len(s)):\n print(s[i],end = '')\nelse:\n print(k)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78b862f1097097f19adf411b184d8387", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x = \"abcdefghijklmnopqrstuvwxyz\" \ny = str(input())\n\nyLista =list(y)\n\n#x= '-'.join(x)\nif(len(x)!=len(y)):\n print(-1)\nk=1\nelse:\n for i in range(len(y)):\n if (x[i]==yLista[i]):\n pass\n elif (x[i-1]==yLista[i]):\n yLista[i]=x[i]\n else:\n k=0\n print(-1) \n break\n\ny = ''.join (yLista)\nif(k==1):\n print(y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "25cf2d26eedfd23a95af388e38f94958", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.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": "82a4e661fdba3a3e749c2b81d7207cf8", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "l,d,v,g,r=map(int,input().split())\nt=d/v\nc=0\ni1=0\ni2=g\nwhile(not(i1<=t and i2>=t)):\n c+=1\n if(c%2!=0):\n i1=i2\n i2=i2+r\n else:\n i1=i2\n i2=i2+g\nif(i1==t or i2==t):\n c+=1\n\nif(c%2!=0 and (i1==t or i2==t)):\n t=i2+g\nelif(c%2!=0):\n t=i2\nt+=(l-d)/v\nprint(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d862a1e13b6cdb365cf95c7bdb011abd", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "# arr=list(map(int,input().split()))\n# arr=sorted([(n-int(x),i) for i,x in enumerate(input().split())])\n# arr=[int(q)-1 for q in input().split()]\n# from collections import Counter\n# n=int(input())\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n# for i in range(m):\n#for _ in range(int(input())):\n#n=int(input())\n\nl,d,v,g,r=map(int,input().split())\nt1=d/v\n#print(t1)\nslot=t1//(r+g)\nt1=t1-slot*(r+g)\nif t1<=g:\n wait=0\nelse:\n wait=(r+g)-t1\n\n#print(wait)\ntotal=wait+l/v\nprint(\"%.8f\"%total)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2ce5f76d5287badae4f4269ab2ab50c", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "td,pd,sp,g,r = map(int,input().split())\nit = pd/sp\nif(it= g:\n t += g + r - t\nt += (l - d) / v\nprint(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "09c083198f6c96bfbd30cb02c5fbc0fb", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "if(it(g+r):\n tr = it+(g+r)\n if(it%(g+r)):print(\"%.8f\"%tr)\nelse:\n nt = r+g+((td-pd)/sp)\n print(\"%.8f\" % nt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6dff8e604cdd3c73dcb888ba54c30f7", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def buy(prices.house_index,budget):\n distance1=None\n distance2=None\n result=None\n\n for index in range(house_index-1,-1,-1):\n price=prices[index]\n if price>0 and price<=budget:\n distance1=house_index-index\n \n for index in range(house_index+1,len(prices)):\n price=prices[index]\n if price>0 and price<=budget:\n distance2=index-house_index\n\n if distance2==None or distance1p:\n print(p*10)\n else:\n print(p*10)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "342f526b3ca26a4a66c3eeeb139df550", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\ncosts = [int(x) for x in input().split()]\n\nfor i in range (1, n):\n if m+i < n and costs[m+i] <= k:\n print(i)\n exit(0)\n elif m-i >= 0 an dcosts[m-i] <= k:\n print(i)\n exit(0)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "540c4f7de1fa53feb047cbd30e652523", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nn, m, k = [int(i) for i in input().strip().split()]\nprices = [int(i) for i in input().strip().split()]\nnearest = 10 * n\nfor i in range(n):\n\tif(prices[i] != 0 and prices[i] <= k):\n\t if(nearest > abs(i + 1 - m) * 10):\n\t\t\tnearest = abs(i + 1 - m) * 10\nprint(nearest)\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a61256077afdbbf6339dfe4637288ac", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\nl = [int(i) for i in input().split())]\nm -= 1\nans = []\nfor j in range(n):\n if l[j] !=0 and l[j]<=k:\n ans+=[abs(j - m)*10]\nprint(min(ans))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "550585419d66980a7349fbef1794a79b", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "Python 3", "source_code": "matrix = []\n\nfor i in range(8):\n line = input()\n matrix.append(line)\n \ntotal_count = 0\nt = 0\nfor i in range(8):\n row_count = 0\n for j in range(8):\n if matrix[i][j] = 'B':\n row_count += 1\n if row_count!=8:\n total_count = row_count\n t = 1\n break\nif t==0:\n print(8)\nelse:\n for col in range(8):\n col_count = 0\n for row in range(8):\n if matrix[row][col] == 'B':\n col_count += 1\n if col_count!=8:\n total_count += col_count\n break\n print(total_count)\n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc63856af9595cb5ef00d88f5ab3b6fc", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "\"\"\"\nA famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.\n\nAs before, the chessboard is a square-checkered board with the squares arranged in a 8\u2009\u00d7\u20098 grid, each square is painted black or white. Kalevitch suggests that chessboards should be painted in the following manner: there should be chosen a horizontal or a vertical line of 8 squares (i.e. a row or a column), and painted black. Initially the whole chessboard is white, and it can be painted in the above described way one or more times. It is allowed to paint a square many times, but after the first time it does not change its colour any more and remains black. Kalevitch paints chessboards neatly, and it is impossible to judge by an individual square if it was painted with a vertical or a horizontal stroke.\n\nKalevitch hopes that such chessboards will gain popularity, and he will be commissioned to paint chessboards, which will help him ensure a comfortable old age. The clients will inform him what chessboard they want to have, and the painter will paint a white chessboard meeting the client's requirements.\n\nIt goes without saying that in such business one should economize on everything \u2014 for each commission he wants to know the minimum amount of strokes that he has to paint to fulfill the client's needs. You are asked to help Kalevitch with this task.\n\nInput\nThe input file contains 8 lines, each of the lines contains 8 characters. The given matrix describes the client's requirements, W character stands for a white square, and B character \u2014 for a square painted black.\n\nIt is guaranteed that client's requirments can be fulfilled with a sequence of allowed strokes (vertical/column or horizontal/row).\n\nOutput\nOutput the only number \u2014 the minimum amount of rows and columns that Kalevitch has to paint on the white chessboard to meet the client's requirements.\n\"\"\"\nlist1 = []\ncount = 0\n\nfor i in range(8):\n row_list = list(input())\n add = 1\n\n for j in range(8):\n if row_list[j] == 'W':\n add = 0\n count += add\n\n list1.append(row_list)\n\nfor x in range(8):# x: column\n add = 1\n for y in range(8):# y: row\n if list1[y][x] == 'W':\n add = 0\n\n count += add\n\ncount = 8 if count == 16: # all black\n\nprint(count)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "60509e7af357f22b0c581b979c03b408", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 3", "source_code": " Getting Chess Board from Codeforces.\nchessBoard = []\nfor i in range (8):\n chessBoard.append(list(input()))\n# Counting Number of Black Tiles.\nblackTileCount = 0\nfor i in range(8):\n blackTileCount+=chessBoard[i].count('B')\n# Function to extract Column \"j\" from chessBoard.\ndef extractColumn(j):\n colString = \"\"\n for x in range(8):\n colString+=chessBoard[x][j]\n return colString\n# Painting Rows.\npaintedCount = 0\nfor i in range(8):\n rowString = \"\".join(chessBoard[i])\n if rowString == \"BBBBBBBB\":\n paintedCount+=1\n# Exiting Program if all black Tiles painted.\nif 8*paintedCount == blackTileCount:\n exit()\n# Painting Columns.\nfor i in range(8):\n colString = extractColumn(i)\n if colString == \"BBBBBBBB\":\n paintedCount+=1\n# Verdict.\nprint(paintedCount)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fb8680d04fd8ff5896906eb5cd29a1b2", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = 0\nt = 0\nfor i in range(8):\n n = input()\n if n == 'BBBBBBBB':\n \ts += 1\n\telif t == 0:\n \tt = 1\n \ts += n.count('B')\n else:\n \tpass\nprint(s)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "19d17d6c765ac53f58b82be672af6b64", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = []\nfor i in range(8):\n s.append(input())\nnum = 0\nfor i in s:\n if i == 'BBBBBBBB':\n num = num + 1\n else:\n num = 0\n else:\n w = i\n \nif num == 8:\n print(8)\nelse:\n for i in w:\n if i == 'B':\n num = num + 1\n print(num)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c9f47a5dbfc7dece61efcb2fd34dd637", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "a=raw_input().split()\nb=raw_input().split()\ny1= int(a[0])\nx1= int(a[1])\ny2= int(b[0])\nx2= int(b[1])\n# 0 = puro par\n# 1= puro impar\n# 2= ambos\nt1=2\nt2=50\nif (x1 %2==0 and y1%2==0):\n t1=0\nelif (x1%2!=0 and y1%2==0):\n t1=1\nif (x2 %2==0 and y2%2==0):\n t2=0\nelif (x2%2!=0 and y2%2==0):\n t2=1\nif ((t1==0 and t2==1) or (t1==1 and t2==0)):\n print -1\nelse:\n con=0\n\n while (True):\n #print \"dasdas\"\n hp = ((y1*con)+x1)\n if((hp-x2)=>0 and (hp-x2)%y2==0):\n print hp\n break\n if (con>10000):\n print -1\n break\n con+=1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "89db968cf40eea5f1310cbe6708852f6", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a, b = tuple(map(int, input().split()))\nc, d = tuple(map(int, input().split()))\n\n\nfrom sys import exit\nelse:\n mod = d%c\n for i in range(1000):\n if b > d and b%c == mod:\n print(b)\n exit()\n b += a\nprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8c2373d53a9cdd8fd725bd830faaab57", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "a,b = map(int,input().split())\nc,d = map(int,input().split())\nres = -1\nfor i in range(,10000):\n if (b+a*i-d) % c == 0 and b+a*i-d > 0:\n res = b+a*i\n break\nprint(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38cee603679b118bc5432559301aab2a", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a, b = tuple(map(int, input().split()))\nc, d = tuple(map(int, input().split()))\n\n\nfrom sys import exit\nelse:\n mod = d%c\n for i in range(1000):\n if b >= d and b%c == mod:\n print(b)\n exit()\n b += a\nprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e487a14616d3fa83a539d671d47c19aa", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\nab = list(map(int, input().split()))\na = ab[0]\nb = ab[1]\ncd = list(map(int, input().split()))\nc = cd[0]\nd = cd[1]\nlist1 = []\nlist2 = []\ncounter1= 0\ncounter2 = 0\n \nfor i in range(5000)):\n list1.append(counter1 * a + b)\n list2.append((counter2 * c + d))\n counter1 += 1\n counter2 += 1\n \n \nfor i in range(len(list1)):\n if int(list1[i]) in list2:\n print(list1[i])\n break\n if i == len(list1) - 1:\n print(-1)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6d5ebfdcbb4af13b1762f29b0b2e5980", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def func (l,r):\n for i in range(l,r+1):\n s=str(i)\n if len(s)==len(set(s)):\n return i\n \n return -1\n \nif __name__==\"__main__\":\n l,r=map(int,input().split(\" \"))\n if l==r:\n if(len(str(l))==len(set(l)):\n print(l)\n else:\n print(-1)\n elif l>r:\n print(-1)\n else:\n x=func(l,r)\n print(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "da5cd5c31a1fbaf30c178eaefc295f74", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "a, b = map(int, input().split())\n\ndef checkDigits(x):\n return (len(str(x)) == len(set(str(x))))\n\nfor i in range(a,b+1):\n if checkDigits(i):\n return i\n \nreturn -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e53b1f2a6b315b69fa27c86555011d19", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=list(map(int,input().split()))\n\nfor num in range(a[0],a[1]+1):\n ab=[]\n while(num>0):\n remaing=num%10\n ab.append(remaing)\n num=int(num/10)\n n=len(ab)\n print(ab)\n print(num)\n print(\"n={}\".format(n))\n for i in range(0,n):\n \n for j in range(i+1,n):\n print(\"i={}\".format(i))\n print(\"j={}\".format(j))\n if(ab[i]== ab[j]):\n a=\"-1\"\n break\n else{a=num}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff923dd3c5f8e8f556d298079391d1aa", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "l, r = list(map(int, input().split()))\nfor i in range(l, r + 1):\n\ta = [int(j) for j in str(i)]\n\tif len(a) == len(set(a)):\n\t\tprint(i)\n\t\tbreak\n\tif i == r print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d690fa1fde77f7ab46402892b90774bb", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def func (l,r):\n for i in range(l,r+1):\n s=str(i)\n if len(s)==len(set(s)):\n return i\n \n return -1\n \nif __name__==\"__main__\":\n l,r=map(int,input().split(\" \"))\n if l==r:\n if(len(str(l))==len(set(l)):\n print(l)\n else:\n \n print(-1)\n elif l>r:\n print(-1)\n else:\n x=func(l,r)\n print(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71a3c0093e2d633cfc98ec211328fd72", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def inc(arr):\n for i in range(len(arr) - 1, -1, -1):\n w = arr[i]\n if w == 0:\n for j in range(len(arr) - 1, i, -1):\n arr[j] = 0\n arr[i] = 1\n return arr\n\n\ndef proveralo1(a, arr):\n c = []\n for i in range(len(arr)):\n if arr[i] == 1:\n c.append(a[i])\n return c\ndef proveralo2(c):\n f = 0\n for i in range(len(c)):\n if f == 1 and c[i] == 0:\n return False\n if f == 0 and c[i] == 1:\n f = 1\n return True\n\n\nn = int(input())\narr = [0] * n\na = list(map(int,input().split()))\ns = 0\nc1 = []\nwhile True:\n c = []\n r = 0\n arr = inc(arr)\n c = proveralo1(a,arr)\n if proveralo2(c) == True:\n r = len(c)\n if r > s:\n s = r\n c1 = c\n if inc(arr) == None:\n break\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "19e670013a3a6b077934d62123687250", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "from collections import deque\n\ndef isgood(g):\n iss = False\n for i in g:\n if i == 0:\n if iss:\n return False\n if i == 1:\n iss = True\n return True\n\nn = int(input())\na = [int(x) for x in input().split()]\no = deque()\no.append(a.copy())\nvis = set()\nvis.add(tuple(a.copy()))\nans = []\nmaxans = -1\nwhile len(o) != 0:\n it = o.popleft()\n if len(it) > maxans:\n if isgood(it):\n l = len(it)\n ans.append(l)\n maxans = max(maxans, l)\n else:\n for i in range(len(it)):\n tmp = it[:i] + it[i + 1:]\n if tuple(tmp) not in vis:\n o.append(tmp)\n vis.add(tuple(tmp))\nprint(max(ans))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "51f586e8fd0f2ab002dc657bd2312e49", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n=input()\ns=raw_input().split()\ncnt=0\ncnt1=0\nfor i in range(n):\n if int(s[i])=1: cnt+=1\n else:cnt1+=1\nprint max(cnt,cnt1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c28e01a2b1fd618d60cba16cd331392", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "input()\nn = [int(x) for x in input().split()]\na = -1\naa = 0\nfor i, x in enumerate(n):\n aaa = aa + len([x in n[i:] if x])\n if aaa > a:\n a = aaa\n if not x:\n aa += 1\nprint(max(a,aa))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79007f0adf5cb9f0f921f616add70ca9", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=input()\na=map(int,raw_input().split())\nprint max(a[:i].count(0)+a[i:].count(1) for i in range(n+1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c9ed93415ddfc3b1ac5fb1d7d2135ebb", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "with open(r'standard input.txt') as inp:\n c = 0\n for line in inp:\n c += 1\n if c == 1:\n x1, y1 = map(int, line.split())\n if c == 2:\n x2, y2 = map(int, line.split())\n\nwith open(r'standard output.txt', 'w') as inf:\n if x1 == x2 and y1 != y2:\n inf.write(str(2*((abs(x2-x1)+2)+(abs(y2-y1)+1))))\n if x1 != x2 and y1 == y2:\n inf.write(str(2*((abs(x2-x1)+1)+(abs(y2-y1)+2))))\n if x1 != x2 and y1 != y2:\n inf.write(str(2*((abs(x2-x1)+1)+(abs(y2-y1)+1))))\n if x1 == x2 and y1 == y2:\n inf.write(str(10))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32f3f6a2942664e5ab24400c6fc590df", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.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": "62e34824cb3772e11f4a5170d6741e41", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "# nums = raw_input().split(\"\\n\")\n# drone = nums[0].split(\" \")\n# flag = nums[1].split(\" \")\n\nnums = raw_input().split(\" \")\ndrone = nums[0:2]\nflag = nums[2:4]\n\ndrone[0] = int(nums[0])\ndrone[1] = int(nums[1])\n\nflag[0] = int(flag[0])\nflag[1] = int(flag[1])\n\ndist_x = abs(flag[0] - drone[0]) + 1\ndist_y = abs(flag[1] - drone[1]) + 1\n\ntotal_dist = dist_x * 2 + dist_y * 2\n\nprint(total_dist)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5208d3856042c9a7e5d9c806441914d2", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "with open(r'Z:\\standard input.txt') as inp:\n c = 0\n for line in inp:\n c += 1\n if c == 1:\n x1, y1 = map(int, line.split())\n if c == 2:\n x2, y2 = map(int, line.split())\n\nwith open(r'Z:\\standard output.txt', 'w') as inf:\n if x1 == x2 and y1 != y2:\n inf.write(str(2*((abs(x2-x1)+2)+(abs(y2-y1)+1))))\n if x1 != x2 and y1 == y2:\n inf.write(str(2*((abs(x2-x1)+1)+(abs(y2-y1)+2))))\n if x1 != x2 and y1 != y2:\n inf.write(str(2*((abs(x2-x1)+1)+(abs(y2-y1)+1))))\n if x1 == x2 and y1 == y2:\n inf.write(str(10))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c050bd963f54ad25c92a16a33855a6c9", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.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\treturn (abs(x_2 - x_1) + abs(y_2 - y_1)) * 2 + 6\nelse:\n\treturn (abs(x_2 - x_1) + abs(y_2 - y_1) + 2) * 2\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d916c6966059fa55584dbc7e92b79682", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "lin = set(list(\"AEFHIKLMNTVWXYZ\"))\ncur = set(list(\"BCDGJOPQRSU\"))\ns = set(list(input()))\nif lin | s == lin or cur | s == cur:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7d8735844b0b3ff444e744dfd72a4f8e", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "PyPy 3", "source_code": "def li():\n return list(map(int, input().split(\" \")))\na = \"AEFHIKLMNPTVWXYZ\"\nb = \"BCDGJOQRSU\"\naa = bb = False\nfor i in input():\n if i in a\n aa = True\n else\n bb = True\n\nif aa^bb:\n print(\"Yes\")\nelse\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9057cc37874f3ce779b0ce064aeb9e9f", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "PyPy 3", "source_code": "def li():\n return list(map(int, input().split(\" \")))\na = \"AEFHIKLMNTVWXYZ\"\nb = \"BCDGJOQRSUP\"\naa = bb = False\nfor i in input():\n if i in a\n aa = True\n else\n bb = True\n\nif aa^bb:\n print(\"Yes\")\nelse\n print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4802d711f0436b5bd375406e7c1f6c9d", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "Python 3", "source_code": "s=input()\nT='AEFHIKLMNTVWXYZ'\nok1=1\nok2=1\nfor i in s:\n if i not in T:\n ok1=0\n else\n ok2=0\nprint([\"NO\",\"YES\"][ok1 or ok2])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "33c372bfc6d9f1ff0ff12d6bf638910c", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "Python 3", "source_code": "def checkNeat1(word):\n linear = ['A','E','F','H','I','K','L','M','N','T','V','W','X','Y','Z']\n for i in word:\n if i not in linear:\n return False\n return TRUE\n\ndef checkNeat2(word):\n linear = ['A','E','F','H','I','K','L','M','N','T','V','W','X','Y','Z']\n for i in word:\n if i in linear:\n return False\n return True\n\nword = input()\nif(checkNeat1(word) or checkNeat2(word)):\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "302a507626efe759d86914834825e48d", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "Python 3", "source_code": "vn=input()\nm=input()\nlst=[]\nfor i in range(len(n)):\n if n[i]=='1' and m[i]=='0':\n lst.append(1)\n elif n[i]=='0' and m[i]=='1':\n lst.append(1)\n else:\n lst.append(0)\n \nfor i in lst:\n print(i,sep=\"\",end=\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "891c02dc316f61467b80efa91d0ce1ed", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "l=[]\nl.append(int(input()))\nl.append(int(input()))\nfor i in range(len(0,l[0]):\n if l[0][i]==l[1][i]:\n print(\"0\",end=\"\")\n else:\n print(\"1\",end=\"\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "488c2766eec0e590cbe0d7c7f01409a4", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = raw_input()\nb = raw_input()1\nl = len(a)\ns = \"\"\nfor i in range(0,l):\n ed = 0\n if a[i] == \"1\":\n ed = ed + 1\n if b[i] == \"1\":\n ed = ed + 1\n if ed == 1:\n s = s + \"1\"\n else:\n s = s + \"0\"\nprint s\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "049f3747d7a39d231947213aa24ac343", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a= Input()\nb= Input()\nfor i in a:\n for j in b:\n {\n if(i==j):\n print(0)\n else:\n print(1)\n }\n\n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dd5b67b43337fe3afbbd543a954a78c8", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n=raw_input()\nm=raw_input()\nprint ''.join([str(int(n[i]!=m[i]) for i in range len(n))])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5f9feab3412edfb1c2d27590866e6bcc", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Python 3", "source_code": " \n nbr = int(input()) ;\n s = input() ;\n res=\"\" \n res =res+s[0];\n i=1 \n cpt =0 ;\n while(i\nusing namespace std;\n\nint main(){\n string n; int q=0;\n cin >> n;\n int strlen = n.size()*2/(round(sqrt(n.size()))+1);\n for (int i=1; in:\n\t\tprint(i-1)\n\t\tbreak\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3042c615e110244c2965a88d9fec921", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def process(n):\n prev = 0\n curr = n\n int count = 0\n while not (prev==0 and curr==1):\n next = curr/2\n curr = n%2\n prev = curr\n curr = next\n count += 1\n if prev==1:\n next = 1\n curr -= 1\n prev = curr\n curr = next\n count += 1\n return count\n\nprint process(int(raw_input()))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "186e83d181caf6a70bc05bdb53d9c922", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "import math\n\ndef ii():\n\treturn map(int,raw_input().split())\n\nn = input()\ncount = 0\ncount += int(math.log(n,2))\nn -= 2**count\nif n == 1:\n\tcount += 1\nelse:\n\tcount += int(math.log(n,2))\n\nprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84fe068e5deeac7065d7df039b5f75e2", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a,b=2,1\nc=0\nwhile a<=int(input()):\n a,b=a+b,a\n c+=1\nprint(c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e25e649e1324a40b2ae7192ae18983f5", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nfib = [0] * 55\n\nfib[0] = 0\nfib[1] = 2\nfib[2] = 3\n\nfor x in xrange(3, len(fib)):\n fib[x] = fib[x-1] + fib[x-2]\n\nx = 0\n\nwhile fib[x] <= n:\n x += 1\n\nprint x - 1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "274d808ab708ecd73e2e1c0f57b4e66a", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\n\n\n\n#s1 = \"10 30\".split()\n#s1 = \"10 35\".split()\n#s1 = \"05:20\".split(\":\")\n\ns1 =raw_input().split()\na = int(s1[0])\nta = int(s1[1])\n\ns1 =raw_input().split()\nb = int(s1[0])\ntb = int(s1[0])\n\ns1 =raw_input().split()\nh = int(s1[0])\nm = int(s1[1])\ndepartT = ((h-5)*60+m)/a*a\n\ncount = 0\nfor b0 in range(0, 18*6, b):\n b1 = b0+tb\n if departT < b1 and departT+ta < b0:\n count +=1 \n \nprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8204c0d208922d320819ff8be1cfef41", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "\n#s1 = \"10 30\".split()\n#s1 = \"10 35\".split()\n#s1 = \"05:20\".split(\":\")\n\ns1 =raw_input().split()\na = int(s1[0])\nta = int(s1[1])\n\ns1 =raw_input().split()\nb = int(s1[0])\ntb = int(s1[0])\n\ns1 =raw_input().split()\nh = int(s1[0])\nm = int(s1[1])\ndepartT = ((h-5)*60+m)/a*a\n\ncount = 0\nfor b0 in range(0, 18*6, b):\n b1 = b0+tb\n if departT < b1 and departT+ta < b0:\n count +=1 \n \nprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "70142633fa3b62c15303c5eb2cf6b7d7", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n# -*- config:utf-8 -*-\n\nfrom sys import stdin\nfrom math import ceil\n\n\ndef getdata():\n s = stdin.readline()\n s = s.rstrip()\n s = s.split(' ')\n s = [int(i) for i in s]\n a, ta = s\n s = stdin.readline()\n s = s.rstrip()\n s = s.split(' ')\n s = [int(i) for i in s]\n b, tb = s\n s = stdin.readline()\n s = s.rstrip()\n s = s.split(':')\n s = [int(i) for i in s]\n dth, dtm = s\n dtm = dth * 60 + dtm\n return (a, ta, b, tb, dtm)\n\n\ndef getfile():\n f = open(\"test.txt\")\n s = f.readline()\n s = s.rstrip()\n s = s.split(' ')\n s = [int(i) for i in s]\n a, ta = s\n s = f.readline()\n s = s.rstrip()\n s = s.split(' ')\n s = [int(i) for i in s]\n b, tb = s\n s = f.readline()\n s = s.rstrip()\n s = s.split(':')\n s = [int(i) for i in s]\n dth, dtm = s\n dtm = dth * 60 + dtm\n f.close()\n return (a, ta, b, tb, dtm)\n\n\ndef run1():\n starttime = 5 * 60\n endtime = 23 * 60 + 59\n # a,ta,b,tb,dtm=getdata()\n a, ta, b, tb, dtm = getfile()\n b_first_dt = dtm - tb\n if b_first_dt < starttime:\n b_first_dt = 0\n else:\n b_first_dt = b_first_dt - starttime\n b_last_dt = dtm + ta\n if b_last_dt > endtime:\n b_last_dt = endtime - starttime\n else:\n b_last_dt = b_last_dt - starttime\n b_first_dt = ceil(b_first_dt / b) * b\n if b_first_dt > endtime - starttime:\n b_first_dt -= b\n b_last_dt = b_last_dt // b * b\n cnt = (b_last_dt - b_first_dt) // b + 1\n if b_last_dt == (dtm + ta - starttime):\n cnt -= 1\n print(cnt)\n\n\ndef check_time(bus_departure_time, starttime, endtime):\n if bus_departure_time < starttime:\n return starttime\n if bus_departure_time > endtime:\n return endtime\n return bus_departure_time\n\n\ndef get_actual_first(first_bus_departure_time, starttime, endtime, b):\n tmp = ceil((first_bus_departure_time - starttime) / b) * b\n if tmp > (endtime - starttime):\n tmp = endtime - starttime\n return tmp\n\n\ndef get_actual_last(last_bus_departure_time, starttime, endtime, b):\n tmp = ceil((last_bus_departure_time - starttime) / b) * b\n if tmp > (endtime - starttime):\n tmp = endtime - starttime\n return tmp\n\n\ndef run():\n starttime = 5 * 60\n endtime = 23 * 60 + 59\n # a, ta, b, tb, dtm = getdata()\n a,ta,b,tb,dtm=getfile()\n first_bus_departure_time = dtm - tb\n last_bus_departure_time = dtm + ta\n first_bus_departure_time = check_time(first_bus_departure_time, starttime, endtime)\n last_bus_departure_time = check_time(last_bus_departure_time, starttime, endtime)\n first_bus_departure_time = get_actual_first(first_bus_departure_time, starttime, endtime, b)\n last_bus_departure_time = get_actual_last(last_bus_departure_time, starttime, endtime, b)\n cnt = (last_bus_departure_time - first_bus_departure_time) // b + 1\n if (dtm + ta - starttime) == last_bus_departure_time:\n cnt -= 1\n if (dtm - starttime) == first_bus_departure_time + tb:\n cnt -= 1\n print(cnt)\n\n\nif __name__ == \"__main__\":\n run()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "912ce2e42fb374e56fdd55c7084df105", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "inn=raw_input()\na,ta=inn.split(' ')\na=int(a)\nta=int(ta)\ninn=raw_input()\nb,tb=inn.split(' ')\nb=int(b)\ntb=int(tb)\ninn=raw_input()\nh,m=inn.split(':')\nh=int(h)\nm=int(m)\n\n\nt0=5*60\nt99=23*60+59\nt=h*60+m\ntmin=t-tb\ntmin=max(tmin,t0)\ntmax=t+ta\ntmax=min(tmax,t99)\nn1=1+(tmax-t0)/b\nif (tmax-t0)%b==0:\n n1-=1\nn2=1+(tmin-t0)/b\nif t= 601 :\n s += 1\nif time + ta <= 1439 :\n s += 1\n\ns += ((ta - b) - (-tb + b))//b\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91d84062762f6b651da26b3070581805", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from sys import stdin\ndef get(n,ma):\n res = [1]\n st = 65\n if n==1:\n return res\n while st >=0:\n st-=1\n if res[-1] * n > ma:\n break\n res.append(res[-1] * n)\n return res\ntry: \n x,y,l,r = map(int,stdin.readline().split())\n a = get(x,r)\n b = get(y,r)\n c = set()\n for i in a:\n for j in b:\n if i + j >=l and i + j <=r:\n c.add(i+j)\n c = list(c)\n c.sort()\n ans = 0\n if len(c)\n ans = max(c[0]-l,r-c[-1])\n pr = l\n for i in c:\n ans = max(ans, i-pr-1)\n pr = i\n print ans\nexcept:\n while True:\n n = 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "796a367b729219d82885d34c0b04af40", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": " x,y,l,r=list(map(int,input().split()))\n b=set()\n a=0\n b.add(l-1)\n b.add(r+1)\n for i in range(100):\n xx=x**i\n if xx>r: break\n for j in range(100):\n rr=xx+(y**j)\n if rr>r: break\n if rr>=l:\n b.add(rr)\n b=sorted(list(b))\n for i in range(1,len(b)):\n a=max(a,b[i]-b[i-1]-1)\n print(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0624d9a9811463331049a95f56f42f67", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "in = input()\nx = int(in.split()[0])\ny = int(in.split()[1])\nl = int(in.split()[2])\nr = int(in.split()[3])\nb=set()\na=0\nb.add(l-1)\nb.add(r+1)\nfor i in range(100):\n xx=x**i\n if xx>r: break\n for j in range(100):\n rr=xx+(y**j)\n if rr>r: break\n if rr>=l:\n b.add(rr)\nb=sorted(list(b))\nfor i in range(1,len(b)):\n a=max(a,b[i]-b[i-1]-1)\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "41b85ee68676271aa6f6e579042db51e", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "s = [int(x) for x in input().split()]\nx = s[0]\ny = s[1]\nl = s[2]\nr = s[3]\n\nv = [l - 1, r + 1]\nxx = 1\nyy = 1\nfor i in range(64):\n\tyy = 1\n\tfor j in range(64):\n\t\tif(xx + yy <= r): \n\t\t\tv.append(xx + yy)\n\t\t\tyy = y * yy\t\n\t\telse break\n\txx = xx * x;\n\t\nsorted(v)\n\n\nans = 0\nfor i in range(len(v)):\n\tans = max(ans, v[i] - v[i - 1] - 1)\n\t\n# your code goes here", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ef8b6c646139047507e112c1235098de", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\n\n#define ll long long\n#define ld long double\n#define pb push_back\n#define mp make_pair\n#define forn(i,n) for(ll i=0;i=0;i--)\n#define fi first\n#define se second\n#define endl \"\\n\"\n#define all(a) a.begin(),a.end()\n#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define PI 3.14159265\n\nconst ll maxn=1e6+1,mod=1e9+7;\n\nint main(){\n sync\n #ifndef ONLINE_JUDGE\n // for getting input from input.txt\n freopen(\"input.txt\", \"r\", stdin);\n // for writing output to output.txt\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n \n ll x,y,l,r;\n cin>>x>>y>>l>>r;\n vector lel,lol;\n // lel.pb(0);\n // lol.pb(0);\n ll eh = 1,oh = 1;\n while(eh<=r){\n lel.pb(eh);\n if(eh>ceil(r/x)) break;\n eh*=x;\n }\n while(oh<=r){\n lol.pb(oh);\n if(oh>ceil(r/y)) break;\n oh*=y;\n }\n vector ok;\n \n bool f1 = true,f2 = true;\n // cout<l&&it+ii biceps and chest > back: print \"chest\";\nelse if biceps > chest and biceps > back: print \"biceps\";\nelse: print \"chest\";\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e5f05115fcf0500bb3560dda44d115a", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 2", "source_code": "raw_input()\nd = map(int, raw_input().split())\nl = [[0,'chest'], [0,'biceps'], [0,'back']]\nfor i, dd in enumerate(d):\n l[i%3][0] += dd\nprint sorted(l, reverse=True)[0][1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b7acccc3a35b5340b427928cb6a7800c", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nl=list(map(int,input().split()))\nfor i in range(n):\n if i%3==0:\n if i!=0:\n l[0]=l[0]+l[i]\n elif i%3==1:\n if i!=1:\n l[1]=l[1]+l[i]\n elif i%3==2:\n if i!=2:\n l[2]=l[2]+l[i]\nif l[0]==max(l):\n print('chest')\nelif l[1]==max(l):\n print('biceps')\nelif l[2]==max(l):\n print('back')\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "556a44ff19cc73f332d3b71ae6c3cac0", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = list(map(int, input())\n\ncount = [0] * 3\n_max = 0\n_max_idx = 0\nfor i in enumerate(l):\n idx = i % 3\n count[idx] += l[i]\n if count[idx] > _max:\n _max = count[idx]\n _max_idx = idx\nprint(['chest', 'bicepts', 'back'][_max_idx]) \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9133e582d3592ccb36ee1a8b0b3570fc", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = list(map(int, input().split())\n\ncount = [0] * 3\n_max = 0\n_max_idx = 0\nfor i in enumerate(l):\n idx = i % 3\n count[idx] += l[i]\n if count[idx] > _max:\n _max = count[idx]\n _max_idx = idx\nprint(['chest', 'bicepts', 'back'][_max_idx]) \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5a6e667a1ff32021c263132818ec16ed", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\na = s.count('4')\nb = s.count('7')\nif a >= b and a > 0:\n print(4)\nelse if b >= a and b > 0:\n print(7)\nelse:\n print(-1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ac4083af63c03324c84e8fc2e06c8ca", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "s=input()\nc,d=0,0\nfor i in s:\n if i==\"4\":\n c+=1\n elif i=\"7\":\n d+=1\nif c>d:\n print(\"4\")\nelif d>c:\n print(\"7\")\nelif d==c and d!=0:\n print(\"7\")\nelse:\n print(\"-1\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aabd93b96a7a1b6b8081229ebc299886", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import sys\n\nfour = 0\nseven = 0\n\nfor c in sys.stdin.readline().strip():\n if c == '4':\n four += 1\n if c == '7'\n seven += 1\n\nif four + seven == 0:\n print(-1)\nelif four >= seven:\n print(4)\nelse:\n print(7)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c6c7dba6a985ced216ceb3eef4046b7e", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "x = int(input())\n\nif !(\"7\" in str(x) or \"4\" in str(x)):\n print(\"-1\")\nelse:\n if str(x).count(\"7\") > str(x).count(\"4\"):\n print(7)\n else:\n print(4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "021e2d916265264b75a9e1b22971d0cd", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "\n#include \n#include \n#include \nusing namespace std;\n\ntypedef pair Pair;\n\nbool cmp(const Pair& a, const Pair& b) {\n return (a.first != b.first ? a.first > b.first : a.second < b.second);\n}\n\ninline bool lucky(char c) { return c == '4' or c == '7'; }\n\nint main() {\n string S;\n cin >> S;\n const int N = S.size();\n map count;\n for (int i = 0; i < N; i++) {\n if (lucky(S[i])) {\n string part;\n part += S[i];\n count[part]++;\n for (int j = i + 1; j < N; j++) {\n if (!lucky(S[j])) break;\n part += S[j];\n count[part]++;\n }\n }\n }\n if (count.empty()) {\n cout << -1 << endl;\n } else {\n list L;\n map::iterator it = count.begin();\n for (; it != count.end(); it++) {\n L.push_back(make_pair(it->second, it->first));\n }\n L.sort(cmp);\n \n cout << L.front().second << endl;\n }\n}\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d66260bf80e2f1ec13d0be7ac80bd6ee", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "PyPy 3-64", "source_code": "from re import L\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\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\ndef I():\r\n return input()\r\ndef II():\r\n return int(input())\r\ndef MI():\r\n return map(int, input().split())\r\ndef LI():\r\n return list(input().split())\r\ndef LII():\r\n return list(map(int, input().split()))\r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n\r\n#------------------------------FastIO---------------------------------\r\n\r\nfrom bisect import *\r\nfrom heapq import *\r\nfrom collections import *\r\nfrom functools import *\r\nfrom math import sqrt, log, gcd, lcm\r\n\r\nMOD = 998244353\r\nN = 550\r\ncomb = [[0 for _ in range(N)] for _ in range(N)]\r\nfor i in range(N):\r\n comb[i][0] = 1; comb[i][i] = 1\r\n for j in range(1, i):\r\n comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD\r\n\r\n\r\ndef solve():\r\n n, k = MI()\r\n pw = [0 for _ in range(N * N)]\r\n dp = [0 for _ in range(n)]\r\n dp[0] = 1\r\n pd = [0 for _ in range(n)]\r\n\r\n for w in range(1, k + 1):\r\n for i in range(n - 1, -1, -1):\r\n pd[i] = dp[i]\r\n dp[i] = 0\r\n pw[0] = 1\r\n\r\n for i in range(1, n * n + 1):\r\n pw[i] = pw[i - 1] * (k + 1 - w) % MOD\r\n \r\n for i in range(n):\r\n for j in range(n):\r\n if i + j <= n - 1:\r\n dp[i + j] = (dp[i + j] + comb[n - 1 - i][j] * pw[j * (j - 1) // 2 + i * j] % MOD * pd[i]) % MOD\r\n\r\n print(dp[-1])\r\nsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d539f46ec0ab1a8e83f067777feebb8", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "from re import L\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\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\ndef I():\r\n return input()\r\ndef II():\r\n return int(input())\r\ndef MI():\r\n return map(int, input().split())\r\ndef LI():\r\n return list(input().split())\r\ndef LII():\r\n return list(map(int, input().split()))\r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n\r\n#------------------------------FastIO---------------------------------\r\n\r\nfrom bisect import *\r\nfrom heapq import *\r\nfrom collections import *\r\nfrom functools import *\r\nfrom itertools import *\r\nfrom math import sqrt, log, gcd, lcm\r\n\r\nMOD = 998244353\r\nN = 550\r\ncomb = [[0 for _ in range(N)] for _ in range(N)]\r\nfor i in range(N):\r\n comb[i][0] = 1; comb[i][i] = 1\r\n for j in range(1, i):\r\n comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD\r\n\r\n\r\ndef solve():\r\n n, k = MI()\r\n pw = [0 for _ in range(N * N)]\r\n dp = [0 for _ in range(n)]\r\n dp[0] = 1\r\n pd = [0 for _ in range(n)]\r\n\r\n for w in range(1, k + 1):\r\n for i in range(n - 1, -1, -1):\r\n pd[i] = dp[i]\r\n dp[i] = 0\r\n pw[0] = 1\r\n\r\n for i in range(1, n * n + 1):\r\n pw[i] = pw[i - 1] * (k + 1 - w) % MOD\r\n \r\n for i in range(n):\r\n for j in range(n):\r\n if i + j <= n - 1:\r\n dp[i + j] = (dp[i + j] + comb[n - 1 - i][j] * pw[j * (j - 1) // 2 + i * j] % MOD * pd[i]) % MOD\r\n\r\n print(dp[-1])\r\nsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f1d1d0997293c953cb3e11e6bb69c10f", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "from time import time\r\nfrom collections import defaultdict\r\n\r\ndef main():\r\n begin = time()\r\n N = int(1e4)\r\n f = [0] * N\r\n #f = defaultdict(int)\r\n for i in range(N):\r\n for j in range(N):\r\n f[i] += i * j\r\n #for i in range(int(1e8)):\r\n # a = i * i\r\n print(time()-begin)\r\n\r\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6818b5249e5d087a8c90a49ed646ace6", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "from time import time\r\nfrom collections import defaultdict\r\n\r\ndef main():\r\n begin = time()\r\n N = int(1e4)\r\n f = [0] * N\r\n for i in range(N):\r\n for j in range(N):\r\n f[i] += j\r\n print(time()-begin)\r\n\r\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76f17985b2a1ab1075599b84415d8aa9", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "n, k = [*map(int, input().split())]\r\nM = 998244353\r\nC = [[1]]\r\nfor i in range(n): C.append([1]+[(C[-1][j]+C[-1][j+1])%M for j in range(i)]+[1])\r\nd = [0]*(n+1)\r\nd[1]=1\r\nfor i in range(1, k+1):\r\n for j in range(1, n+1):\r\n d[j] = sum(d[j-x]*C[j-1][x]*pow(k-i+1,x*(x-1)//2+x*(j-1-x),M)%M for x in range(j))%M\r\nprint(d[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "87674e0d4d16145d3e024c343d33b8a9", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "if __name__ == \"__main__\":\n pass = raw_input()\n digs = {}\n for i in range(10):\n digs[raw_input()] = i\n print ''.join(str(digs[pass[i*10:(i+1)*10]]) for i in range(8))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "178572e373e3309a20a0beec70f99b24", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "from sys import stdin\n\np = stdin.readline().strip()\n\nd = dict()\n\nfor i in range(10):\n d[stdin.readline().strip()] = i\n\nans = ''\n\nfor i in range(9):\n ans += str(d[p[10*i:10*(i+1)]]))\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f78928e98fba5f796809ba18df6ac04b", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "cod = raw_input()\nind = [\"\" for loop in range(10)]\nfor i in range(10):\n ind[i] = raw_input()\n\nch =cod[i]\nfor i in range(1,len(cod)):\n j = 0\n bol = False\n if i%10 == 0:\n while bol == False and j<10:\n if ind[j] == ch:\n bol = True\n print (j,end='')\n else:\n j+=1\n \n ch = cod[i]\n else:\n ch += cod[i]\nj = 0\nbol = False\nwhile bol == False and j<10:\n if ind[j] == ch:\n bol = True\n print j\n else:\n j+=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e3f45de67590b74f947b3d801506c965", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "enc=input()\nnums=[]\nfor i in range(10):\n nums.append(input())\ncode=[nums.index(enc[x*10:x*10+10]) for x in range(int(len(enc)/10))]\nfor x in code:\n print(x,end='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f25694ba8bbc4a1201c8aa6010c5e78", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 3", "source_code": "import re\n\npassword = input()\ncodes = {}\n\nfor i in range(0, 10):\n code = input()\n codes[code]= i\n\npassword = \"\"\n\nwhile len(password) < 8:\n for code in codes:\n if re.search(\"^\"+code, password):\n password += codes[code]\n\nprint(password)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb92355562fd66099708077d4b9a272f", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "Python 2", "source_code": "s = raw_input()\ni = 0\nj = len(s) - 1\nflag = 0\nwhile i < j:\n\tif s[i] != s[j] and flag == 0:\n\t\tif s[i+1] == s[j]:\n\t\t\ta = s[:j+1] + s[i] + s[j+1:]\n\t\t\tb = s[:i] + s[j] + s[i:]\n\t\t\tif a == a[::-1]:\n\t\t\t\tprint a\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\t\t\telif b == b[::-1]:\n\t\t\t\tprint b\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tprint \"NA\"\n\t\t\t\tflag = 1\n\t\t\t\tbreak\n\telse:\n\t\ti += 1\n\t\tj -= 1\nif flag == 0:\n\tl = len(s)\n\tif l%2 == 0:\n\t\ts = s[:l/2] + 'a' + s[l/2:]\n\telse:\n\t\tc = s[l/2]\n\t\ts = s[:l/2] + c + s[l/2:]\n\tprint s\n\t\t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8de67c630f147935953daacb92698c68", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\n\"\"\"\nA. Mr. Kitayuta's Gift\nhttp://codeforces.com/problemset/problem/505/A/\n\nMon, 14 Sep 2015\nPython 3.4: 77 ms, 500 KB\n\"\"\"\n\nfrom string import ascii_lowercase\nfrom sys import stdin\n\ndef is_palindrome(s) :\n return s == s[::-1]\n\ns = input()\nfor i in range(len(s) + 1) :\n for c in ascii_lowercase :\n t = s[:i] + c + s[i:]\n if is_palindrome(t) :\n print(t)\n return\n\nprint(\"NA\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1f57b491468c2efa167db3489a40a466", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def is_palindrome(s):\n return s == s[::-1]\ns=raw_input(\"\")\ny=len(s)-1\nx=0\nl=list(s)\nflag=0\ncheck=0\nif len(l)==2 and l[0]!=l[1]:\n l.insert(0,l[1])\n check=1\nwhile x<=y:\n if check==1:\n break\n if l[x]!=l[y]:\n if l[y-1]==l[x]:\n if x==0:\n l.insert(0,l[y])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n l.insert(x,l[y-1])\n flag=1\n elif l[y]==l[x+1]:\n l.insert(y+1,l[x])\n s3=''.join(l)\n if is_palindrome(s3):\n flag=1\n break\n else:\n flag=2\n break\n flag=1\n else:\n flag=2\n \n break\n x+=1\n y-=1\nif check==1:\n print ''.join(l)\nelif flag==0:\n s=str(''.join(l[0:len(l)/2]))+l[len(l)/2]\n if len(l)%2==0:\n l=l[0:len(l)/2]\n else:\n l=l[0:len(l)/2+1]\n l.reverse()\n s=s+str(''.join(l))\n print s\nelif flag==1: \n s1=''.join(l)\n print s1\nelif flag==2:\n print \"NA\"\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71d38ad31fd4c656d3d51880420107b7", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "from string import ascii_lowercase\n\ndef makePalindrome(st):\n if not st or not st.isalpha() or not st.islower():\n return \"NA\"\n # chars = \"abcdefghijklmnopqrstuvwxyz\"\n for letter in ascii_lowercase:\n for pos in range(len(st) + 1):\n tmp = st[:pos] + letter + st[pos:]\n # if isPalindrome(tmp):\n if tmp == tmp[::-1]\n return tmp\n return \"NA\"\n\ndef isPalindrome(st):\n i, j = 0, len(st) - 1\n while i < j:\n if st[i] != st[j]:\n return False\n i += 1\n j -= 1\n return True\n\nst = input()\nprint(makePalindrome(st))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c01ab3ea01623b724c896a67d755c91d", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from sys import stdin\ndef ch(s):\n t = ''+s\n t.reverse()\n return t==s\nx = stdin.readline().strip()\nl = len(x)\nans = 'NA'\ny = 'abcdefghijklmnopqrstuvwxyz'\nfor i in xrange(l):\n fir = [0:i] \n sec = [i:l]\n for j in y:\n nn = fir + y + sec\n if ch(nn):\n ans = nn\nprint ans\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "33510e2db3e60fc1a15ff055c5eb9e8a", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n=int(input())\n\n\ns=input()\narr=[0]*n\nfor i in range(len(s)):\n if s[len(s)-i-1]=='B':\n arr[i]=1\nprint(arr)\ncount=0\nb=True\nwhile True:\n index=0\n for i in range(n-1,-1,-1):\n if arr[i]==1:\n index=i\n break\n if i==0:\n b=False\n if not b:\n break\n arr[index]=0\n for i in range(index+1,n):\n arr[i]=1\n print(arr)\n count+=1\n\nprint(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "99a63a27398d3f30e6e6619585aa48c8", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 2", "source_code": "balls = input()\noutput = 0\n\narray = raw_input()\nprint array\nfor x in xrange(0,len(array)):\n if array[x] == 'B':\n output += 2**x\nprint output\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1caf82194670133b1189997cfc019c3", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\nt = '_'.join(s)\nw = t.split(sep = '_')\na = 0\nif n != 30 and n != 50:\n while True:\n b = w.index('B')\n for i in range(b+1):\n if w[i] == 'R':\n w[i] = 'B'\n else:\n w[i] ='R'\n a += 1\n if w.count('B') == 0:\n break\n print(a)\nelif n = 30:\n print('1073741820')\nelif n = 50:\n print('2434325235552')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2fbdd326516e3cc3328c7fcdd28e7c5", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\nint main(){\n\tint n;\n\tcin >> n;\n\tchar arr[50];\n\tcin >> arr;\n\tint b = 0;\n\tfor (int i = 0; i < n; i++){\n\t\tif (arr[i] == 'B') b++;\n\t}\n\tlong long c = 0;\n\twhile (b){\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tif (arr[i] == 'R'){\n\t\t\t\tarr[i] = 'B';\n\t\t\t\tb++;\n\t\t\t} else {\n\t\t\t\tarr[i] = 'R';\n\t\t\t\tb--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tc++;\n\t}\n\tcout << c << endl;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4121f7e7e33b59251bc963a79e0f4031", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 2", "source_code": "# This is codeforces 399\n# B. Red and Blue Balls\n\n\ndef is_all_stack_red(stack):\n for item in stack:\n if item != 'R':\n return False\n return True\n\ndef find_first_blue(stack):\n for i in xrange(len(stack)):\n if stack[i] == 'B':\n return i\n return None\n\ndef checkio(stack):\n counter = 0\n while not is_all_stack_red(stack):\n first_blue = find_first_blue(stack)\n for i in xrange(first_blue):\n stack[i] = 'B'\n stack[first_blue] = 'R'\n counter+=1\n return counter\n\nwhile True:\n num = raw_input()\n stack_str = raw_input()\n stack = list(stack_str)\n return checkio(stack)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3f8fd4b795c6cc266f98b290f1c79e3", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "Python 2", "source_code": "def main():\n a,n=map(int,raw_input().strip().split())\n\n q=a%n\n r=0\n\n while r<=n:\n q=(2*q)%n\n if q==0:return True\n r+=1\n return False\n\nif main():print \"Yes\"\nelse:print \"No", "lang_cluster": "Python", "compilation_error": true, "code_uid": "43b31b7217f709fdf69413cddb55a995", "src_uid": "f726133018e2149ec57e113860ec498a", "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": "94f4bec088c1c1f5f77d4dc290d2df4b", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\nimport java.util.Scanner ;\n/**\n *\n * @author Hazemx\n */\npublic class Problem {\n public static void main(String[] args){\n Scanner input = new Scanner(System.in);\n int a=input.nextInt();\n int m = input.nextInt();\n if(a%m==0){System.out.print(\"Yes\");}\n else{System.out.print(\"No\");}\n\n \n }\n \n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2386d96a64b25f62014b63ac1246ddf", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "def main():\nM = 100010\na, m = map(int, raw_input().split())\ns = [0] * M\nwhile s[a % m] == 0:\n s[a % m] = 1\n a += a % m\nif s[0]:\n print 'Yes'\nelse:\n print 'No'\nmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f411963c103a27122a5be876e7036d82", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "ip=list(int(n) for n in input().split())\nimport math\na=ip[0]\nm=ip[1]\nwhile (a%2==0 and m%2==0)\n\ta/=2;m/=2\na%=m\naf=[a]\nx=1;k=1;count=0;countlimit=0;m2=m\nwhile (m2%2==0)\n\tcountlimit+=1\n\tm2/=2\nwhile (k==1):\n\ta=((a*2)%m)\n\tif a==0:\n\t\tprint(\"Yes\")\n\t\tk=0\n\telse:\n\t\tfor check in af:\n\t\t\tif a==check:\n\t\t\t\tprint(\"No\")\n\t\t\t\tk=0\n\tif\tcount<=countlimit:\n\t\t\taf.append(a)\n\t\t\tcount+=1\nexit()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c5ef4be26bc8d7fd6590b99f04920fbe", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "# coding=utf-8\n\"\"\"\nC. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u04422 \u0441\u0435\u043a\u0443\u043d\u0434\u044b\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442256 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\n\u0432\u0432\u043e\u0434\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434\n\u0432\u044b\u0432\u043e\u0434\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\n\u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u0446\u0438\u0444\u0440\u044b a \u0438 b. \u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c, \u0435\u0441\u043b\u0438 \u0432 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440\u044b a \u0438 b. \u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0441\u0443\u043c\u043c\u0430 \u0435\u0433\u043e \u0446\u0438\u0444\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c.\n\n\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0443\u0441\u0442\u044c \u0443 \u0412\u0438\u0442\u0430\u043b\u0438\u044f \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u0446\u0438\u0444\u0440\u044b 1 \u0438 3, \u0442\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u043e 12 \u2014 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c, \u0430 \u0447\u0438\u0441\u043b\u0430 13 \u0438\u043b\u0438 311 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u0447\u0438\u0441\u043b\u043e 111 \u2014 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0430 \u0447\u0438\u0441\u043b\u043e 11 \u2014 \u043d\u0435\u0442.\n\n\u0422\u0435\u043f\u0435\u0440\u044c \u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u0438\u043d\u044b \u0440\u043e\u0432\u043d\u043e n. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u043e\u043d \u043f\u0440\u043e\u0441\u0438\u0442 \u0412\u0430\u0441 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0430 1000000007 (109\u2009+\u20097).\n\n\u041f\u043e\u0434 \u0434\u043b\u0438\u043d\u043e\u0439 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0432 \u0435\u0433\u043e \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0435\u0437 \u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043d\u0443\u043b\u0435\u0439.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430: a, b, n (1\u2009\u2264\u2009a\u2009<\u2009b\u2009\u2264\u20099,\u20091\u2009\u2264\u2009n\u2009\u2264\u2009106).\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e 1000000007 (109\u2009+\u20097).\n\"\"\"\nfrom sys import stdin\n\nmod = 10 ** 9 + 7\n\n\ndef is_good(s):\n while s > 0:\n s, x = divmod(s, 10)\n if x != a and x != b:\n return False\n return True\n\n\ndef main():\n a, b, n = map(int, stdin.read().split())\n f = [1] * (n + 1)\n for i in xrange(1, n + 1):\n f[i] = i * f[i - 1] % mod\n\n print f[n] * sum(pow(f[n - i] * f[i], mod - 2, mod) for i in xrange(n + 1) if is_good(i * a + (n - i) * b)) % mod\n \nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "091ab2e2c6d4017a212884cf15f489a8", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import math\nfirstLine = raw_input().split()\nA = int(firstLine[0])\nB = int(firstLine[1])\nN = int(firstLine[2])\n#a, b, n = map(int, raw_input().split())\n\nMOD = 1000000007\nmySum = 0\nfact = [1, 1]\nlastFact = 1\nfor x in xrange(2, N+1):\n fact.append(fact[x-1] * x % MOD)\n\ndef isGood(A, B, N):\n while N:\n if x%A != A and x%B != B:\n return False\n x /= 10\n return True\n \nfor n in xrange(N+1):\n newNum = n*A + (N-n)*B\n if isGood(A, B, newNum):\n div = pow(fact[n]*fact[N-n], MOD-2, MOD)\n mySum += div\n mySum %= MOD\n #print mySum, fact[N], fact[N-n]\n \nprint mySum*fact[N] %MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "931a5b18b8f4f6d9e9f6d72f0d8354c9", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def h(a, b):\n c = a % b\n if c:\n x, y, z = h(b, c)\n return (x, z, y - z * (a // b))\n return (b, 1, 1 - a // b)\n \nfrom bisect import bisect_right, bisect_left\n\na, b, n = map(int, raw_input().split())\nif a > b: a, b = b, a\n\nu, v = 10 * a, 10 * b\nx, y = a * n, b * n\nt, d = [a, b], b - a\n\nwhile t[-1] < x:\n t = [j + u for j in t] + [j + v for j in t]\n u, v = u * 10, v * 10\nif t[-1] < y: t += [j + u for j in t] + [j + v for j in t]\n\nt, s = t[bisect_left(t, x): bisect_right(t, y)], 0\nm, f = 1000000007, [1] + [0] * n\np, k = list(range(x, y + 1, d)), 0\n\nfor i in range(1, n + 1):\n f[i] = (f[i - 1] * i) % m\n\nfor i in t:\n k = bisect_left(p, i)\n if p[k] == i: s += h(m, (f[k] * f[n - k]) % m)[2]\n\nprint(((s % m) * f[n]) % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f6153b6d0773240ab3b17fe065547c8", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "md=1000000007;\ndef fact(n):\n\tif(n==0):\n\t\treturn 1\n\treturn (n%md*fact(n-1)%md)%md;\ndef check(n):\n\tglobal a,b;\n\twhile(n>0):\n\t\tif(n%10!=a and n%10!=b):\n\t\t\treturn 0;\n\t\tn=n/10;\n\treturn 1;\na,b,n=map(int,raw_input().split());\nt=fact(n);\nans=0;\nfor i in range(n+1):\n\tval=a*i+b*(n-i);\n\tif(check(val)):\n\t\tans=ans+(t/fact(i))/fact(n-i);\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b57d9f8fa7296781d2e781b3cef88926", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "/* *********************************************************************\n * Problem: -------------- *\n * Runtime: 0.000 sec; Rank: 0000 *\n * Algo Used: ---------------- *\n * Solved By : Niloy - JU-CSE-21 *\n ********************************************************************* */\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/* ********************\n * Defines *\n ******************** */\n#define max(a,b) ((a>b)?a:b) //finding max\n#define min(a,b) ((a=e;i-=d) //for loop with manual increment\n#define Pi acos(-1.0) //defining Pi for mathematical uses\n#define Clear(a) memset(a,0,sizeof(a)) //clearing memory of an array\n#define setfalse(a) memset(a,false,sizeof(a)) //setting the array into false\n#define settrue(a) memset(a,true,sizeof(a)) //setting the array into true\n#define clrstr(a) memset(a,'\\0',sizeof(a)) //setting string array to null\n#define open freopen(\"input.txt\",\"r\",stdin) //opening input file\n#define close freopen (\"output.txt\",\"w\",stdout) //opening output file\n#define Case(a) printf(\"Case %d: \",a) //printing case number\n#define caseh(a) printf(\"Case #%d: \",a) //printing case number having '#'\n#define getcase(a) scanf(\"%d\",&a) //scanning case number\n#define S1(a) scanf(\"%d\",&a) //scan one int\n#define S2(a,b) scanf(\"%d%d\",&a,&b) //scan two int\n#define S3(a,b,c) scanf(\"%d%d%d\",&a,&b,&c) //scan three int\n#define SL1(a) scanf(\"%lld\",&a) //scanf one long long\n#define SL2(a,b) scanf(\"%lld%lld\",&a,&b) //scanf two long long\n#define SL3(a,b,c) scanf(\"%lld%lld%lld\",&a,&b,&c) //scanf two long long\n#define CHR getchar() //avoid the newline character problem\n#define caseloop(a,b) for(a=1;a<=b;a++) //making case loop\n#define EPS 1e-9 //small value for avoiding preccesion error\n#define LL long long //long long short form\n#define ULL unsigned long long //unsigned long long sort form\n#define MX 10500 //MAX size/value\n#define PB(x) push_back(x) //push in vector/string\n#define PP pop_back() //pop from vector\n#define PF(x) push_front(x) //push in vector/string/deque from front\n#define PPF(x) pop_front() //pop from vector/deque from front\n#define IN(x) insert(x) //insert element in set\n#define PS(x) push(x) //push element in stack/queue\n#define P() pop() //pop element from stack/queue\n#define SZ() size() //return size\n#define MOD 1000000007ll //mod value\n#define INF (1<<28) //infinity value\n#define Y 1 //true value\n#define N 0 //false value\n\nusing namespace std;\n\ntemplate T BigMod (T b,T p,T m) {if (p == 0) return 1; if (p%2 == 0){T s = BigMod(b,p/2,m); return ((s%m)*(s%m))%m;} return ((b%m)*(BigMod(b,p-1,m)%m))%m;}\ntemplate T ModInv (T b,T m) {return BigMod(b,m-2,m); }\ntemplate void ia (T a[],int n) { for (int i=0;i> a[i];}\ntemplate void pa (T a[],int n) { for (int i=0;i T gcd(T a,T b) { if (!b) return a; return gcd(b,a%b); }\ntemplate T POW(T b,T p) { if (p == 0) return 1; if (p%2 == 0) { T s = POW(b,p/2); return s*s; } return b*POW(b,p-1); }\n\nLL fact[1000005];\n\nvoid factorial()\n{\n fact[0] = 1;\n\n for (int i=1;i<=1000000;i++)\n fact[i] = (fact[i-1]*i)%MOD;\n}\n\nbool Check(LL n,LL a,LL b)\n{\n while (n)\n {\n int x = n%10;\n\n if(x!=a && x!=b)\n return false;\n\n n /= 10;\n }\n\n return true;\n}\n\nint main ()\n{\n factorial();\n\n LL a,b,n;\n\n cin >> a >> b >> n;\n\n LL ans = 0;\n\n for (int i=0;i<=n;i++)\n {\n LL p = i,q = n-i;\n\n LL sum = p*a+q*b;\n\n if (Check(sum,a,b))\n ans += ((((fact[n]%MOD)*(ModInv(fact[p],MOD)%MOD))%MOD)*(ModInv(fact[q],MOD)%MOD))%MOD;\n }\n\n cout << ans << endl;\n\n return (0);\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c27d8479f29c748f9e9c63ebdd50f72", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nrow, cubes_in_row = 0, 0\n\n# cubes = 0\n# while cubes <= n:\n# row += 1\n# cubes_in_row += row\n# cubes += cubes_in_row\n#\n# print(row -1 )\n\n'\u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a - \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445'\nwhile n >= cubes_in_row + row + 1:\n row += 1\n cubes_in_row += row\n n -= cubes_in_row\nprint(row)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "843ea41f812409342a67f6117a6a2184", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 3", "source_code": "//Number of cubes\nn = int(input())\n//cube number use at current level\nlv_n = 0\n//the maximum height of the pyramid\nhmax = 0\n\nwhile n>0:\n hmax += 1\n lv_n += hmax\n n -= lv_n\n\nprint (hmax)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f9ef4542c8ec3bf40e88889dab2d0ef0", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ncubesused = 0\ncubesleft = n\nfloors = 1\n\nif n <= 3:\n print(1)\nelif n > 3 and <= 9:\n print(2)\nelse:\n for i in range(n):\n if (((floors) * (floors+1)) / 2) <= cubesleft:\n floors +=1\n cubesleft -= (((floors) * (floors+1)) / 2)\n else:\n print(floors)\n break\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff56228a79635101d4d42cd829fe87b8", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\ncubesused = 0\ncubesleft = n\nfloors = 1\n\nif n =< 2:\n print(1)\nelse:\n for i in range(n):\n if (((floors) * (floors+1)) / 2) <= cubesleft:\n floors +=1\n cubesleft -= (((floors) * (floors+1)) / 2)\n else:\n print(floors)\n break\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2ac9e1edbf18809530a9a7d54cce8f45", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=int(input())\nl=0,i=0,c=0\nwhile(a>0):\n i++\n c=l+i\n l=c\n a-=c\n if(a<0):\n i=i-1\nprint(i)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc622e34bac0b4ec1145686939209c15", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "Python 2", "source_code": "'''input\n1 2 1 2\n\n\n'''\n\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nfrom itertools import combinations as c\nimport sys\nfrom math import *\nfrom random import randint as R\nimport heapq as hp\n\nl,r,a,b=[int(x) for x in raw_input().split()]\n\nnum=a*b\n\np=[]\nc=0\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\nfor i in range(1,int(num**0.5)+1):\n\tif num%i==0:\n\t\tif l<=i<=r and l<=num/i<=r:\n\t\t\tif gcd(i,num/i)==a and (a*b)/gcd(i,num/i)==b:\n\t\t\t\tc+=2\n\t\t\t\t#print i,num/i\n\t\t\t\tif i*i==num:\n\t\t\t\t\tc-=1\nprint c\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "deec05fae3db2b816f03331babb9a1d0", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "'''input\n1 2 1 2\n\n\n'''\n\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nfrom itertools import combinations as c\nimport sys\nfrom math import *\nfrom random import randint as R\nimport heapq as hp\n\nl,r,a,b=[int(x) for x in raw_input().split()]\n\nnum=a*b\n\np=[]\nc=0\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\nfor i in range(max(1,a),int(num**0.5)+1):\n\tif num%i==0:\n\t\tif l<=i<=r and l<=num/i<=r:\n\t\t\tif gcd(i,num/i)==a and (a*b)/gcd(i,num/i)==b:\n\t\t\t\tc+=2\n\t\t\t\t#print i,num/i\n\t\t\t\tif i*i==num:\n\t\t\t\t\tc-=1\nprint c\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ff6711f5a1dddf4f92872fa18c3beac", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "'''input\n1 2 1 2\n\n\n'''\n\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nfrom itertools import combinations as c\nimport sys\nfrom math import *\nfrom random import randint as R\nimport heapq as hp\n\nl,r,a,b=[int(x) for x in raw_input().split()]\n\nnum=a*b\n\np=[]\nc=0\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\nfor i in range(max(1,a,l), min(int(num**0.5),b,r) +1):\n\tif num%i==0:\n\t\tif l<=i<=r and l<=num/i<=r:\n\t\t\tif gcd(i,num/i)==a and (a*b)/gcd(i,num/i)==b:\n\t\t\t\tc+=2\n\t\t\t\t#print i,num/i\n\t\t\t\tif i*i==num:\n\t\t\t\t\tc-=1\nprint c\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73007da1df0d7342fb13c17d35d46573", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "from math import sqrt\nL,R,x,y = input().split()\nL = int(L)\nR = int(R)\nx = int(x)\ny = int(y)\n\n\ndef NOD(a,b):\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\nif L * L > x * y or R * R < x * y:\n print(0)\nelse:\n count = 0\n for a in range(L, min(int(sqrt(x * y)) + 1,R + 1)):\n if x * y % a == 0:\n b = x * y // a\n if NOD(a,b) == x:\n if a == b:\n count += 1\n else:\n count += 2\n print(count)from math import sqrt\nL,R,x,y = input().split()\nL = int(L)\nR = int(R)\nx = int(x)\ny = int(y)\n\n\ndef NOD(a,b):\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\nif L * L > x * y or R * R < x * y:\n print(0)\nelse:\n count = 0\n for a in range(L, min(int(sqrt(x * y)) + 1,R + 1)):\n if x * y % a == 0:\n b = x * y // a\n if NOD(a,b) == x:\n if a == b:\n count += 1\n else:\n count += 2\n print(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "307ae321e250dfed8254631fe9d1ccd0", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "l,r,x,y=list(map(int, input().split() ) )\nif y%x!=0:\n print(0\nelse:\n def dels(n):\n i=2\n p=[]\n while i*i<=n:\n while n%i==0:\n p.append(i)\n n=n//i\n i+=1\n if n>1:\n p.append(n)\n return p\n mins=dels(x)\n maxs=dels(y)\n d=dict()\n unique=list(set(maxs))\n for i in unique:\n d[i]=[mins.count(i), maxs.count(i) ]\n kol=len(d.keys())\n print(d)\n k=0\n for i in range(2**kol):\n dv=''\n while i!=0:\n dv+=str(i%2)\n i//=2\n dv=dv[::-1]\n if len(dv) 0:\r\n k = arr.pop()\r\n n -= k\r\n st += str(k)-\r\n if n in arr:\r\n st += str(n)\r\n print(st[::-1])\r\n break\r\n\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc8a301312ecf2cf2c0a7dd3890679af", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "Python 3", "source_code": "t=int(input))\r\nfor_in range(t):\r\n n=int(input())\r\n res=''\r\n for i in range(9,0,-1):\r\n if n>=i:\r\n res=str(i)+res\r\n n-=i\r\n print(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "efe19196391718fb7160f4f40a0daba3", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "// #include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\nusing namespace std;\r\n \r\n// #define int long long\r\n#define ll long long\r\n \r\n#define f(i,a,b) for (int i=a;i<=b;i++)\r\n#define ii pair\r\n#define llll pair\r\n#define iii pair, int>\r\n \r\n#define pb push_back\r\n \r\nconst ll MOD = 1000000007;\r\n// const ll mod = 998244353;\r\n \r\nconst int N = 200005;\r\n\r\nll n, m, k ;\r\nll a[N] ;\r\n\r\nvoid pre_init() {\r\n \r\n}\r\n \r\nvoid init() {\r\n \r\n}\r\n\r\n\r\nvoid MrUnknown() {\r\n if (n > m) swap(n,m);\r\n sort(a+1,a+1+k) ;\r\n ll tong = 0 ;\r\n int num2 = 0, num3 = 0;\r\n f(i,1,k) {\r\n ll x = a[i]/n;\r\n if (x >=2 ) tong += x;\r\n // cout << i << \" \" << tong << \"|1\\n\" ;\r\n if (x == 2) num2++;\r\n if (x>2) num3++;\r\n if (tong >= m) {\r\n cout << \"Yes\\n\" ;\r\n return;\r\n }\r\n if (tong+1==m) {\r\n if (i==k) {\r\n break;\r\n }\r\n ll y = a[k]/n ;\r\n if (tong - x + y >= m) {\r\n cout << \"Yes\\n\" ;\r\n return;\r\n }\r\n if (num3 > 0) {\r\n cout << \"Yes\\n\" ;\r\n return ;\r\n }\r\n if (num2 > 0 && y > 2) {\r\n cout << \"Yes\\n\" ;\r\n return ;\r\n }\r\n break;\r\n // cout << \"No\\n\" ;\r\n // return;\r\n }\r\n }\r\n swap(n,m) ;\r\n tong = 0;\r\n num2 = num3 = 0 ;\r\n f(i,1,k) {\r\n ll x = a[i]/n;\r\n if (x >=2 ) tong += x;\r\n // cout << i << \" \" << tong << \"|2\\n\" ;\r\n if (x == 2) num2++;\r\n if (x>2) num3++;\r\n if (tong >= m) {\r\n cout << \"Yes\\n\" ;\r\n return;\r\n }\r\n if (tong+1==m) {\r\n if (i==k) {\r\n break;\r\n }\r\n ll y = a[k]/n ;\r\n if (tong - x + y >= m) {\r\n cout << \"Yes\\n\" ;\r\n return;\r\n }\r\n if (num3 > 0) {\r\n cout << \"Yes\\n\" ;\r\n return ;\r\n }\r\n if (num2 > 0 && y > 2) {\r\n cout << \"Yes\\n\" ;\r\n return ;\r\n }\r\n break;\r\n // cout << \"No\\n\" ;\r\n // return;\r\n }\r\n }\r\n cout << \"No\\n\" ;\r\n}\r\n \r\nvoid inp() {\r\n // Case++;\r\n \r\n cin >> n >> m >> k ;\r\n f(i,1,k) cin >> a[i] ;\r\n \r\n pre_init();\r\n \r\n MrUnknown();\r\n \r\n init();\r\n \r\n}\r\n \r\nsigned main() // watch toaru pls :)\r\n{\r\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n \r\n // freopen(\"intput.txt\",\"r\",stdin);\r\n // freopen(\"output.txt\",\"w\",stdout);\r\n \r\n // ------------------------------------- init -------------------------------\r\n \r\n int t; cin>>t; while(t--) \r\n inp();\r\n \r\n}\r\n/*\r\n1\r\n4\r\n((((\r\n \r\n \r\n*/\r\n \r\n//---------------------------------------------------------------------------------------------------------------------------------------\r\n \r\n/*\r\nMMMMMMMMMMMMMMMMMMMMMMMMN0xdxO00Odx0d,',,,'.',:xKK00000000000xdk00OdxOxk0000000000000000000000OkkO0000000000OO000000000000Od;'''',:ccccllc::lc:cOWMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMWX0OkO0000Odlol;,',,''.;oOXK00000000000OddO00Odx0xx00000000000000000000000kxk0000000000OOO00000000000KKkc,'''':ccll:::cl::ld0WMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMXOkO0K000Oxo;,;;;;;,,';o0XXK000000000000kox000kox0xx00000000000000000000000Oxdk00000000000kkO000000000KXXKxc,''';ooc;,;lo:;lloKMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMN0k0KK000Oxl;;;::;::;,:dOXXK00000000000000dok000kod0kxO00000000000000000000000OddO00000000000kdk00000000KXNXK0d:''';c:;;:lc:c::cdNMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMXOOKXK00Oxl;;;::;;:;,,lOKKKK00KXXK00000000OooO000Ooo0Odx00000000000000000000000Okdk000000000000xdxO000KKKKKXXXXKOl,''',:cc;;cdl;clOWMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMWKO0XXK00ko:;:::,,;:;';d0KKK00KXXNXK00000000kldO000OooO0xdO000000000OO000000O00000OddO00OO00000000xoxO0KXXXXKKKKKK00x:''';::;;loc:c:dNMMMMMMMMMMM\r\nMMMMMMMMMMMMMMWKOKXXK0Oxc;;::;',;:;,ck0000O0KXXNNXKKKK00000xlx00000dlx0kdk000000000OO00000OO00000Oxok00OO000000000xox0XXNNNXK0000000kc''',:lc::lol:lKMMMMMMMMMMM\r\nMMMMMMMMMMMMMWK0KXXXKOo;;::;,',::;;oO000OO0KXXNNNXKKXK0O000dlx00000kloO0xdO00000000Ok00000OO000000kod00Ok00KKKK00K0dlx0XNNNXX0OO00000Ol''';cc::odlcl0MMMMMMMMMMM\r\nMMMMMMMMMMMMWKOKXXXKkc;;c:,'';c:;:d0000OOO00KXXXXKKXXKOOKX0olk0000OOolk0Odx00000000OkO0000OO000000OooO0OkOKXXXX00KXOolkKXXXKK00kO00000Ol,'',clclllcoKMMMMMMMMMMM\r\nMMMMMMMMMMMMKOKKKKOo:;::;,'';c:;:x0000OO000000K000KXK0O0KXKolkKKK0OOkloO0xdk0000000OkO0000OOO000KK0dlkK0kk0XXXX0O0XKxcoOKKK0000Okk00000Ol,'';c:,:lcdNMMMMMMMMMMM\r\nMMMMMMMMMMMXO0K0Odc;:::,'',:c;;:x0OO0OkO0000000000000Ok0KKOolxKXXOk00dcd00xdO0KK0000kk00000OOKKKKXKxcdKKkxOKXNXKOOKKOocdO0000000Oxk000OOOl'..';;::c0MMMMMMMMMMMM\r\nMMMMMMMMMMW0O00kl;;:c;,'',:c;,:x0OO0OkO00000000OO0000kk000klcx0XKkk0X0ocxKKxx0XXKKKKOk0KXXKOOKXKKXXkclOKOdx0XXXKkk000xccx00000000kxO000OOkc..,cllckWMMMMMMMMMMMM\r\nMMMMMMMMMMKO00xc;:c:;,'',::;,:dOOO0Okk000000000OO000Oxk00OxccdOK0xx0XXklckX0dxKXNXXX0kOXNNXOkKXKKXXOc:xOOddO0000kxO00Oo:lk0000000OxxO00OkOk:,coddxKWMMMMMMMMMMMM\r\nMMMMMMMMMNOOOo;;:c:;,,,;c:;,;oOOk0Oxk000000000OkO000kxO00kl:cdk0Odd0XX0xlcx0OdkXNNNXKkkKXNX0k0XKKXXOc;lkOxdxO000OxxO00xccdO0000000kdx000OkOdc:cllo0WMMMMMMMMMMMM\r\nMMMMMMMMMKkxl;;cc;;;;;:c:;;;lOOkO0kxO000000000kxO00OxxO0Od:':oxOkodOKK00dccdOkdkKKXXKOxOXXXKkOK00K0k:':okkodk000Oxdk00Oo:lx0000000Oxdk00OkkOo::ccl0MMMMMMMMMMMMM\r\nMMMMMMMMWOo:,;c:;;;;;:c:;;,ckOkO0OdxO00000000Oxk000kdx00xl,.;lxOkllk0000xolcoOkdoxO000kxO0KKxxO00OOx:.'cdkdoxO00OkodOOOxc:oO0000000OdxO00kxOxc:;':KMMMMMMMMMMMMM\r\nMMMMMMMMXo;;;c:;;;;;:c;;;,:dOkk0Odok0000OO000Oxk00Odlx0Od;;;;cdkxlcxOOOOkdooclxkxddO00OdxO0OxxOO0OOx:'';lxxooxO00kdoxOOko:cxO000000Oxdk00Oxkkc;;.;OMMMMMMMMMMMMM\r\nMMMMMMMM0:,;cc;;;;;:c;;;,,oOkxO0kodO000OOOO00kdk00klcx0xc;ll;:oxxc:okOOOkdoxxocodxddkO0xdkOOxdkO0OOx:;c;;odolokO0OxooxOOxc:oO0000000kdxO0OxxOl'.';kWMMMMMMMMMMMM\r\nMMMMMMMWO:,;:;,,,,:c;,;,,:kOxk0OdlxOO00OOOO0Oxdk00xcckOd::dd:;ldd:;cxkkOkdldkOxlclodoxOOddOOkdxOOOOd;:do;:odlcokOOxocokOkl:cxO000000Odok0OddOd,.',oNMMMMMMMMMMMM\r\nMMMMMMMWkc;,,'''',:;'',',dOxdk0kolkOOOOOOOOOOxdk0Oo:cxkl:lxxl;:oo:,:oxkkkxllxOOOkxllllokkddOOdoxkkxo;;ll:,:ll::oxxxoccokko::dO000000Odlx0Odlkk:.',c0MMMMMMMMMMMM\r\nMMMMMMMNx,.......,;,''',lOOdxO0xlokOOOOOkOOOOdok0kc;cxxccdxxdc;loc',cdddxxoclxO00Okxolccododxocldxdc;:lllc;:cc;:ldddl:cdxd:;lxkOO00OOxldOOdlxk:.'':kWMMMMMMMMMMM\r\nMMMMMMMNo.........'...,:dOxdkOOdcokOOOOkkOOOkookOd;'cdo::olll:,:lc,,;coodxdl:lxOOOOOOkxooolcdxolxkdccdxxxxdccl:,:oxxdc;cxxl;cxOOOOOO0kloOOdlxk:.'';oKMMMMMMMMMMM\r\nMMMMMMMNd'.............ckOddkOkocdkOOOOkkOOOkolxxl'':lc::lllooc;cl::::oddxxoc:okOOOOOOOkkxdooxxloxoclxxxxxxdlcc,':oddl;,lxo;;dO00OOOOkllkOdldx;''',cOWMMMMMMMMMM\r\nMMMMMMMNkllc,'........'oOkdxOOklcokOOOkxxkkkdccdd:,,:lcldxxxxxdc:lcco:cododdl::oxkOOOOOOOkdxdlxdlllcoxxdoddddl:;,,:looc;;lo:;okOOOOOOkolkkdcoo,.''';dXMMMMMMMMMM\r\nMMMMMMMWkoO0Oxl;'.....;xOxoxOOklcoxOOkkdxkkkx::oo:::;lclxxxxdddl::ccdoccooodol::coxkOOOOOkddxoldocccoddxxxxkxxo:;;::colc::c:;lkOOOOOOkolxko:lc,...',cOWMMMMMMMMM\r\nMMMMMMMMOok000Od:,,,..ckkooxOOklcoxOOOkxxkOkd;,ll:ll:cclddddddddl:cclxocllloooc:;:oxkOOOOkxodo::lccoxkkkkkkkxkxdc;clcclcclc;;lxOOOOOOkolxxl:c:'....';dXMMMMMMMMM\r\nMMMMMMMMKdx00Oko;:c:,,lOxloxOOkocodkkkkxdkkkd;'cc:oo::coxxxxxxxkxoc:codolllloooc:;:lxkOOOkxooo:;cccdkkkkkkxxxxxxdl:lolcccldc;cxOOOOOOxllxxc;c;.......,xWMMMMMMMM\r\nMMMMMMMMXdd00Okl;cc;,;dkoclxOOkocldkkkkxdxkkd,';:cdxl:coxxxxxxkkkxdccoxxdlllloollc;;ldkkkkkdlo:;:ccldxxdolc::;;;;;;;:cc:;;ldlcxOOOOkOxlldd:;:,........cKMMMMMMMM\r\nMMMMMMMMWkoO0Ox:;c:;,:dx:;lxOkkdcloxkkkxdxkkd:,;:lddo::odddddddddxxdccdkkxolllllllc,,codkkkdolc;:cll:::,'.................';;:odxkkkOdcldl;;;'........lXMMMMMMMM\r\nMMMMMMMMM0ox0Ol,:c;;,:xd,'cxkkkxlcodkkkkddxkd:::,cool;,;,,,,,;;::clooccdxkxolclllllc,;:lodxxoc::;;:;...',;:::::::,,;;,'......':oxkkkko:lo:,;,........lKMMMMMMMMM\r\nMMMMMMMMMXddOk:,c:;;,:dl'.:dkkkkocldxkkkxddkdc:;',,,'..............,;;,:oxkkdl:cllllc:ccclodol;,,',;;:oxkkkkxkkkkxddOOkxo,..':xkkkkkkl:lc:;'.........lXMMMMMMMMM\r\nMMMMMMMMMWOokd;;c:;;,:dc'.,oxkkkdccodkkkxdodd:,'.......''';:ccccc:;,,'..;okkkxo:;:cllcldolclol:,:dkdoxkkkkxkkkOOOOOdx0KOo'';;lxkkkkkxc:c:oo,........',xWMMMMMMMM\r\nMMMMMMMMMMXdoc':c;;;,:o:'''cxkkkxl:ldxkxdoc;;'....',:oxxooxkkkkkkkkkkxdc;ldkkOkxolcllcclxkdolc::lxkxxxxxddddxddddddlcodo::llcokkkkkkd::::xx;....'''''';kWMMMMMMM\r\nMMMMMMMMMMWOc,'::;;;,:l:''';okkkxo::ldxxddoc:;'.'lxO0K0xdkOOkkxxkkxkkkkxdxkkOOOOOOxdxxdooxO0Oxdodk000000OOOOOkkkxxdodooddxxdodkxxkkkl;;;cxx;..''''''''':OWMMMMMM\r\nMMMMMMMMMMMXo',:;,;;;:c;,'''cxkkxo:,:oxxddxdll:',:lxOOkoldddddddxxkkOOOOOOOO000000K00KKKKKXXXXXXKXXXXK0KXXKKKKKKKK0000OOOOOxdxkxxkkxc,:ookx,.'''''''''',cOWMMMMM\r\nMMMMMMMMMMMWd';:,,;;;cc;,''';okkxd:''coxdodxlcc:cc:cooloodxkkkOOOOOOOO000KKKXXXXXNNNNNNNNNNNNNNNNNNNNKOkKXXXXXXXXXXXXXKKKKKkdxxxxkko;,lkkOo'.''''''''''',l0WMMMM\r\nMMMMMMMMMMMXl';;',;;:c:;,,';:cdkkdc'.,cddolddccclxxxkdlcokOOOOOOO00KKKXXXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXOdkKXXXXXXXXXXK0KXXKxxxxxxkxc::oO0x;..''..........,c0WMMM\r\nMMMMMMMMMMM0:,:;',;;::,,,,,::,cxkxc'.';coolldo::cdkOOo,',lkO000KKXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNNNXXXNXOdx0XXXXXXXXXKO0KKkdxxxxkkololx0x;..'ol............lXMMM\r\nMMMMMMMMMMMk,,:,'',;c:'',,;c:',lxxl,.,cccolclol:;cdOkc''';xKKXXXXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX00KKKK0kOKXXXXXXXKOxkdldxdxkkdlloxOx;...cKO;.........,lOWMMM\r\nMMMMMMMMMMNd';:,'',;c:,',;:c;'',oxo;.;ol;:llccolc:cdx:''',dKXXXXXXXXXNNNNNNNNNNNNNNXXNNNNNNNNNNNNNNNXOkkkk0K0O0XXK0OOkkxdloddxxkxlcdkkl'..',c0Xl......,lxKWMMMMM\r\nMMMMMMMMMMXl';;'''';c:,'',:c;''';ld:.,oo;';cc::lllddc,''''oKXXXXXXXNNNNNNNNNNNNNNNNKKNNNNNNNNNNNNNNNNNKkxOxdO0xxOK0kO00Oxodddxxkxlokd;''''',:kNk,...'oKWMMMMMMMM\r\nMMMMMMMMMM0:';;'''';c:,,,,:c;,'',:lc',ld:..':c;:ccoo;'''',oKXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXXXKkoodoldOkdxkxdoddxxkkxlcdl,'''''';dXKc...,xNMMMMMMMMM\r\nMMMMMMMMMMXxdxd;...,;,,,,,:c;;,,:;';,,ldc''..,:cclc;''''',xXXXXXNNNNNNNNNNNNNNNNNNNNNNNWNNNNNNNNNNNNNNNNNNKOxoc:::cl::::ldddxxkxxldXXo'...'',cONd'.',c0MMMMMMMMM\r\nMMMMMMMMMMMMMMK:........'',;,,,,,'...'cdc,''..'ccll;''''.:OXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNWWWWWWNWNNNNNNNNNNOollc:;;,;;;coodxxxxddd0WMO;......,oXXo;'';dNMMMMMMMM\r\nMMMMMMMMMMMMMMO;......................:dl,'''.'lkx:''''''lKXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNWWNNNNNNXXNNNXXX0d:;;;,,,,:oodxxxxolddOWMXc.......lXMWKkollkWMMMMMMM\r\nMMMMMMMMMMMMMM0:.....................,cdo;''''.,dkc''''',xXNNNNNNNNNNNNNNNWNNNNWWWNWWNNNNNNNXXKK000Ok0XNNXXXXXOo;,,,,:ooodxxkxdoodkNMWd'....;dXMMMMMMNKXWMMMMMMM\r\nMMMMMMMMMMMMMMWXOxxdo:'';;;;;;;,'...';ldd:'''''.,c;''''.;xXNNNNNNNNNNNNXOO0KKKKKKKKKKKKKXKKKKKKK00KKXNNNNNK0O0K0d:,,;odooxxkxxK0ddxKMMO,..;xXWMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMXdcdOOOkOOkoc;,:lcodl,'''''..'''''.,dXNNNNNNNNNNNNNXKKK00KXXNNNWWWWWWWWNXXXXXNNWNNNNNNXKkxdl;,;ldoodxkkxONNkdd0WMKc.'cKMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMKolk00OOOOxl::loccodc''''''..''''''lKNNNNNNNNNNNNNNNNNXKK000Okk0KKK0000KXNNWNNNNNNX0O0XXOl:,,lkxooxkkxxKMM0xdkNMWk:',kWMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMNd;ok00OkOkoldoclccodc,'''''.'''''.:ONNNNNNNNNWNNWNWWNXKK00kdclk00KKKXNNNNWWWNXXNNNK0O0XX0o;ckOdldkkkdkNMMXxokXMMWXOdONMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMNd:coO00kxxdx0xcc:lkxdc'''''..''''.,dXNNNNNWWNNNXKKKKKKKXNNX0k0NNNNNWWWWWWWWWWNNNNNK00kxdxocx0koldkkxo0MMMNdlxKMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMNdcccdO00xloOKOo:;lKXkoc''''..'''''.:0NNWWNNXK000KKXNNNNX00OOKNWWWWWWWWWWWWWWWWNNNNXKKXOl;;oO0xlldkkddXMMMNoco0WMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMKoclccx00klckXX0d:l0MNOo:''''.'''''.'oXWWXK00KXNWWNXK0OOkO0KNWWWWWWWWWWWWWWWWWWNWNXX0O0x:,ckOOxlldkxoxNMMMXo;lOWMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMMOllllcok00o:oOKXKOdOWMWKo,'''.''''''.'lkxlckNWWNX0kkkO0KNNNWWWWWWWWWWWWWWWWWWWWWWNNNNKxoddxOkOklldxxlxWMMMKc;:kWMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMMNdclllccdO0kc:ldkO00OOKNWKl'''.''''''...'''';okOkxxOKXNNWWWWWWWWWWWWWWWWWWWWWWWWWWNX0OO0NNOkOxkOocoxdlkWMMWk:;;xWMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMMWOlllllcclk0Odl:::oxO00kOXWKc'''''''''''''''''..,lk0KXNWWWWWWWWWWWWWWWWWWWWWWWWWNX0kxokWMMKkOOdx0dcldocxNMMKo:;;xWMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMMW0ollllccccx0Odll:;;cok00OONM0:''''''''''''''''...':okKNWWWWWWWWWWWWWWWWWWWWWWNX0kxddddKMMMKxOkldOklcoocoXMNxc;,;kMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMMW0xdolllccccoOOdll:;:::lx00OKMW0c'''''''''''''''......';cx0KNNWWWWWWWWWWWWWWNKOkxddxxxdxKMMMKxOxclk0xllollOXxlc;,cKMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMMW0OOxllllcclcoOOdlc:;clddokOkXMMMKo,'''''''''''''''.......'cdxkOO0XNNWWWNNK0OxddxxxxxxxddKMMMXkkOocdO0dcllcclllc;;dNMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMMN0O0OdollccclcoOkolc;:lxK0odkKWMMMMNx;'''''''''''''''.......,oxxddddxkkkxxxdddxxxxxxxxxxolxNMMW0xOxllxO0xccc;;llc:lKMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMMN0000kdlllccllcdOxolc:cd0XxlxXWMMMMMMWOc''''''''''''''........:dxxxxxxxddddxxxxxxxdddolc:,:xk0NWW0xxdllxO0xcc:;:lclOWMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMMN0000OkdllcclollkOdllodxxxxx0NMMMMMMMMMWKo,'''''''''''''.......';:::ccldxxxdlc:c:::;;,,'''''o0xx0KXKOxocldk0kl:;,;cOWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMMN00K00OxolccoollxOxodOOkkxOXWMMMMMMMMMMMMMNx;''''''''''''.........''''':dO0Oxc'''''''''''''.,kW0OXXKKK0Odccok0Odc;,dNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMMN00K00OkdlccodooxOkokX0k0k0MMMMMMMMMMMMMMMMMWO:';ccc:;,''''........''''';loool:'''''''''',,,:OWMXkKMMWXKKK0xoox00ko::kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMWK0K00Okxlccooook0OdkWKkO0kKMMMMMMMMMMMMMMMMWN0kook000kxl:;'.....';::::;;:c::::::::::ccclcccxXWMMNxOMMMMMNXK0dclxO00kl:xNMMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMN0KK00Oxlclddodk00OOXWOk00k0WMMMMMMMMMMMMMWXKKXWNkox000K00kdlc::;:ldddddoolcccloooooooooloxKWMMMMWxxWMMMMMMMN0xllxO00OxoONMMMMMMMMMMMMMMMMMMMMMMMMMMM\r\nMMMMMMMMMMMX0K00Oxl:oxxddk000O0NNkk00kkNMMMMMMMMMMMWX0KNMMMMNdlk00000000OOkkoclllloodoooloddoododddkKWMMMMMMWxkWMMMMMMMMMXdlox0000OkKWMMMMMMMMMMMMMMMMMMMMMMMMMM\r\n \r\n*/", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8c1dfb05bf8efadf4cd11b2c93ba5a83", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def deco(num):\r\n\tarr = []\r\n\tcount = 9\r\n\tif num < 10:\r\n\t\treturn num\r\n\twhile num >= 10 or num in arr:\r\n\t\tnum = num - count\r\n\t\tarr.append(count)\r\n\t\tcount = count - 1\r\n\tif num > 0:\r\n\t\tarr.append(num)\r\n\r\n\tarr.sort()\r\n\t#print(arr)\r\n\treturn int(''.join(map(str,arr)))\r\n\r\n\r\n\r\nn = int(input())\r\nwhile (n=!0):\r\n\ts = int(input())\r\n\tdeco(s)\r\n\tn -=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7dca47dc1c30a3bdcef041a88d4e23da", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "PyPy 3-64", "source_code": "#include\r\nusing namespace std;\r\ntypedef long long ll;\r\nll a[240000],b[240000],st[240000];\r\nint main() {\r\n ll T,n;\r\n scanf(\"%d\",&T);\r\n while(T--) {\r\n scanf(\"%d\",&n);\r\n if(n>=1&&n<=9)printf(\"%d\\n\",n);\r\n else if(n>=10&&n<=17)printf(\"%d9\\n\",n-9);\r\n else if(n>=18&&n<=24)printf(\"%d89\\n\",n-17);\r\n else if(n>=25&&n<=30)printf(\"%d789\\n\",n-24);\r\n else if(n>=31&&n<=35)printf(\"%d6789\\n\",n-30);\r\n else if(n>=36&&n<=39)printf(\"%d56789\\n\",n-35);\r\n else if(n>=40&&n<=42)printf(\"%d456789\\n\",n-39);\r\n else if(n>=43&&n<=44)printf(\"%d3456789\\n\",n-42);\r\n else printf(\"123456789\\n\");\r\n }\r\n}\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bfaeefbd5153b6e29b3b4dc4cbee3667", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = '.-.--'\n\nnum = ''\nfor i in range(len(a)):\n\nwhile i < len(a):\n if a[i] == '.':\n num = num + '0'\n else :\n \n if a[i+1] == '.':\n num = num + '1'\n \n else:\n num = num + '2'\n i = i + 1\n i = i + 1\n \nprint(num)\n \n \n\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ae8bd13502556ac596fdc281c3d129c", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\n\ncache = \"\"\noutput = \"\"\nfor i in s:\n cache += i\n if cache == \".\":\n output += \"0\"\n cache = \"\"\n elif cache == \"-.\":\n output += \"1\"\n cache = \"\"\n elif cache = \"--\":\n output += \"2\"\n cache = \"\"\n\nprint(output)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fdf5eddd5e0168159a9c058e38732a4e", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = input()\nr = []\ni = 0\nl = len(s)\nwhile i < l:\n if s[i] == '-':\n if s[i+1] == '-':\n r.append(2)\n else:\n r.append(1)\n i += 2\n else:\n r.append(0)\n i += 1\nreturn ''.join(map(str, r))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58e62740d9e9ac548ac7bb2ed812b55b", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s = list(input())\nn = len(s)\nres = []\ni = 0 \nwhile(n > 0):\n if s[0] == '.':\n res.append('0')\n s.pop(0)\n n -= 1\n elif s[1] == '.':\n res.append('1')\n s.pop(0)\n s.pop(0)\n n -= 2\n else':\n res.append('2')\n s.pop(0)\n s.pop(0)\n n -= 2\nprint(\"\".join(res))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b7aa8a3ecfd058f6a35c521a8f0e3d2", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def solve(s):\n number = \"\" i = 0\n\n while i < len(s):\n if s[i] == \".\":\n number += \"0\"\n elif s[i] == \"-\": \n if s[i+1] == \".\":\n number += \"1\"\n i += 1\n elif s[i+1] == \"-\":\n number += \"2\"\n i += 1\n i += 1\n \n return number\n\n\ninp = list(input())\nprint(solve(inp))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "547b86de9902ce2c518a612252916f15", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gcd(x , y):\n if(x > y):x , y = y , x\n if(x == 0):return y\n return gcd(y % x , x)\nA , B = map(int , input().split())\ndef solve(X , Y):\n if(X > Y):\n if(Y == 1):\n print(str(X - 1) + \"A\" , end = \"\")\n return;\n else:\n print(str(X // Y) + \"A\" , end = \"\")\n solve(X % Y , Y)\n else:\n if(X == 1):\n print(str(Y - 1) + \"B\" , end = \"\")\n return;\n else:\n print(str(Y // X) + \"B\" , end = \"\")\n solve(Y % X , X)\nif(gcd(A , B) == 1):\n solve(A , B)\nelse:\n print(\"Impossible\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1dfe2bb299ca0556c47765a563c020b1", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import fractions\n\na, b = map(int, raw_input().split())\n\nresult = ''\nwhile True:\n\tr = fractions.gcd(a, b)\n\tif a < b:\n\t\tresult += str((b - r) / a) + 'B'\n\t\tb = r\n\telif a > b:\n\t\tresult += str((a - r) / b) + 'A'\n\t\ta = r\n\telse:\n\t\tprint 'Impossible'\n\t\tbreak\n\tif (a, b) == (1, 1):\n\t\tbreak\nprint result", "lang_cluster": "Python", "compilation_error": false, "code_uid": "85b0041b781e1215e8066f2af50214db", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "def gcd(m, n):\n if m < n:\n m, n = n, m\n r = m % n\n while r:\n m, n = n, r\n r = m % n\n return n\n\n\ndef search(x, y):\n while True:\n if x == 1:\n ans.extend( [] if y == 1 else (str(y - 1) + 'B') )\n return\n if y == 1:\n ans.extend( [] if x == 1 else (str(x - 1) + 'B') )\n return\n if x < y:\n ans.append(str(y // x) + 'B')\n x, y = x, y % x\n else:\n ans.append(str(x // y) + 'A')\n x, y = x % y, y\n\na, b = [ int(i) for i in input().split() ]\n\nif gcd(a, b) != 1:\n print(\"Impossible\")\nelse:\n ans = []\n search(a, b)\n \n i, length = 0, len(ans)\n print(''.join(ans))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "284831cb444e454b3114141f5046d392", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "x, y = map(int, raw_input().split())\n\nch = ['A', 'B']\ns = []\nb = 0\nif x < y:\n\tb = 1\n\tx = x^y; y = x^y; x = x^y\nif y!=1 and x%y == 0:\n\tprint 'Impossible'\nelse:\n\twhile y!=0:\n\t\tl = x//y\n\t\ts.append(l)\n\t\tr = x%y\n\t\tx = y\n\t\ty = r\n\ts[-1]-=1\n\tst = ''\n\tfor el in s:\t\n\t\tst += '{}{}'.format(el, ch[b])\n\t\tb = 1-b\n\tprint st\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8ed7f5bd9241effe9de15e9a788532cf", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nx, y = map(int, raw_input().split())\nans = [] \nwhile x != y:\n if x < y:\n if y % x == 0:\n ans.append(str(y / x - 1) + \"B\")\n y = x\n else:\n ans.append(str(y / x) + \"B\")\n y %= x\n else:\n if x % y == 0:\n ans.append(str(x / y - 1) + \"A\")\n x = y\n else:\n ans.append(str(x / y) + \"A\")\n x %= y\n if x != 1:\n print \"Impossible\"\n else:\n print \"\".join(ans)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d5037b63493d590c02f4f2868f936f7", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "n=int(input())\nif f%35==0:\n f=n//36+1\nelse:\n f=n//36\nr=n%36\n if r%3==0:\n i=r//3\n elif r%3==1:\n i=r//3\n elif r%3==2:\n i=r//3+1\nprint(f,i)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc468c9fa1167cd10d65627d43da2b23", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import *\nn=int(input()\nx=n//36\nz=n%36\ny=round(z/3)\nprint(x,y)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3048befeaff306c8dc897ac54a595bb8", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\na = n / 36\nb = (n - a * 36) / 3\nif n - a * 36 - b * 3 == 2:\n b += 1\n\nprint a, b\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "88f60d67727e1cfb3d0f2c182f836757", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import sys\n\nif __name__ == '__main__':\n\t\n\t#cin = open(\"1.in\", \"r\")\n\t#cout = sys.stdout\n\tcin = sys.stdin\n\t\n\tn = int(cin.read())\n\tf = n/(36)\n\tn %= 36\n\ti = n/3\n\tn%=3\n\tif n>1:\n\t\ti+=1\n\tprint str(f) + \" \" + str(i)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0ef7750e37fc0991625ebe38c315de87", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\na = n / 36\nb = (n - a*36) / 3\nif (n - a*36) % 3 == 2:\n b += 1\n\nprint '%d %d'%(a, b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab609c66abcf85c1131d187abc7099a8", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "OGticket = list(str(raw_input()))\nn = map(int, OGticket)\n\nSum1 = n[0] + n[1] + n[2]\nSum2 = n[3] + n[4] + n[5]\n\nif Sum1>Sum2:\n LilNum = [n[3],n[4],n[5]]\n BigNum = [n[0],n[1],n[2]]\nelif Sum2>Sum1:\n LilNum = [n[0],n[1],n[2]]\n BigNum = [n[3],n[4],n[5]]\nelse:\n LilNum = [0,0,0]\n BigNum = [0,0,0]\n\nLilNum.sort()\nBigNum.sort()\ndiff = abs(Sum1-Sum2)\n\n\n\nif diff == 0:\n print \"0\"\nelif diff <= 9-LilNum[0] or diff <= BigNum[2]:\n print \"1\"\nelif diff <= 9-LilNum[0] + 9-LilNum[1] or diff <= 9-LilNum[0] + BigNum[3] or diff <= BigNum[2] + BigNum[1] \n print \"2\"\nelse:\n print \"3\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ebdf5e5b5807f39b057816f6deb8c7d", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "line1 = raw_input()\nline = line1.split()[0]\nnumbers =[]\nn=[]\nfor i in line:\n numbers.append(int(i))\n\nif(numbers[0]+numbers[1]+numbers[2] == numbers[3]+numbers[4]+numbers[5]):\n print \"0\"\nelse:\n elif(numbers[0]+numbers[1]+numbers[2] > numbers[3]+numbers[4]+numbers[5]):\n n.append(numbers[0])\n n.append(numbers[1])\n n.append(numbers[2])\n n.append(9-numbers[3])\n n.append(9-numbers[4])\n n.append(9-numbers[5])\n diff = (numbers[0]+numbers[1]+numbers[2] - (numbers[3]+numbers[4]+numbers[5])) \n else:\n n.append(numbers[3])\n n.append(numbers[4])\n n.append(numbers[5])\n n.append(9-numbers[0])\n n.append(9-numbers[1])\n n.append(9-numbers[2])\n diff = numbers[3]+numbers[4]+numbers[5] - (numbers[0]+numbers[1]+numbers[2])\n n1 = sorted(n)\n if(n1[5]>=diff):\n print \"1\"\n elif(n1[5]+n1[4]>=diff):\n print \"2\"\n else:\n print \"3\"\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ed4ed99317189d071f45855bc144908", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def getans1(S,s1,s2):\n if s1>s2:\n l = sorted(S[3:])\n x = s1-s2\n if x+l[0]<10:\n return 1\n elif l[1]+x-(9-l[0])<10:\n return 2\n else:\n return 3\n else:\n l = sorted(S[:3])\n x = s2-s1\n if x+l[0]<10:\n return 1\n elif l[1]+x-(9-l[0])<10:\n return 2\n else:\n return 3\n\ndef getans2(S,s1,s2):\n if s1>s2:\n l = sorted(S[:3],reverse=True)\n x = s1-s2\n if l[0]-x>=0:\n return 1\n elif l[1]-(x-l[0])>=0:\n return 2\n else:\n return 3\n else:\n l = sorted(S[3:],reverse=True)\n x = s2-s1\n if l[0]-x>=0:\n return 1\n elif l[1]-(x-l[0])>=0:\n return 2\n else:\n return 3\n \n \n\n\nst = str(raw_input())\nS = map(int,st)\n\ns1 = sum(S[:3])\ns2 = sum(S[3:])\n\nif s1==s2:\n print 0\nelif:\n print min(getans1(S,s1,s2),getans2(S,s1,s2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d89d9b3451acb80e03ec6693e9e1f187", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "'''\n21st august 2017 monday\ncodeforces 825b yh\n'''\nfrom sys import stdin\n\nt = map(int, list(stdin.readline().strip()))\n\nsum_left = sum(t[:3])\nsum_right = sum(t[3:])\n\nif sum_left == sum_right:\n\tprint 0\nelif sum_left < sum_right:\n\td = sum_right - sum_left\n\tfor i in xrange(3):\n\t\tt[i] = 9 - t[i]\n '''\n for i in xrange(3, 6):\n\t\tt[i] = t[i] - 1\n '''\n\tprint t, d\n\tt.sort(reverse=True)\n\ti = 0\n\twhile d > 0:\n\t\td -= t[i]\n\t\ti += 1\n\tprint i\nelse:\n\td = sum_left - sum_right\n\tfor i in xrange(3, 6):\n\t\tt[i] = 9 - t[i]\n '''\n\tfor i in xrange(3):\n\t\tt[i] = t[i] - 1\n '''\n\tt.sort(reverse=True)\n\ti = 0\n\twhile d > 0:\n\t\td -= t[i]\n\t\ti += 1\n\tprint i\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3eaf678092aaf4985546216d4a21a317", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "'''\n21st august 2017 monday\ncodeforces 825b\n'''\nfrom sys import stdin\n\nt = map(int, list(stdin.readline().strip()))\n\nsum_left = sum(t[:3])\nsum_right = sum(t[3:])\n\nif sum_left == sum_right:\n\tprint 0\nelif sum_left < sum_right:\n\td = sum_right - sum_left\n\tfor i in xrange(3):\n\t\tt[i] = 9 - t[i]\n '''\n for i in xrange(3, 6):\n\t\tt[i] = t[i] - 1\n '''\n\tprint t, d\n\tt.sort(reverse=True)\n\ti = 0\n\twhile d > 0:\n\t\td -= t[i]\n\t\ti += 1\n\tprint i\nelse:\n\td = sum_left - sum_right\n\tfor i in xrange(3, 6):\n\t\tt[i] = 9 - t[i]\n '''\n\tfor i in xrange(3):\n\t\tt[i] = t[i] - 1\n '''\n\tt.sort(reverse=True)\n\ti = 0\n\twhile d > 0:\n\t\td -= t[i]\n\t\ti += 1\n\tprint i\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f13873cd5f1b054fece59a469fc549a0", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s=input().strip()\nb=False\nl=False\nc=False\nfor i in s:\n if 'a'<=i<='z': l=True\n if 'A'<=i<='Z': b=True\n if '0'<=i<='9': c=True\n if b and l and c: break\nif b and l and c len(s)>=5:\n print('Correct')\nelse:\n print('Too weak')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b6d2c7fc35d22bc7062250fe6b67e3d0", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nprint(\"Correct\"if len(s)>=5 and all([filter (t, s)for t in [str.islower,str.isupper, str.isdigit]) else \"Too weak\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f1686763bd8c569a3fa52478c221f3c7", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "import re\ns=''.join(sorted(input()))\nprint([\"Too weak\",\"Correct\"][bool(re.search(\"(?=.{5})(?=[0-9]+[A-Z]+[a-z]+)\" s))])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0c3c8966799790073448d399694b8210", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "s=input()\nl=len(s)\nif l>=5:\n caps=0\n s=0\n n=0\n for i in s:\n if caps>0 and s>0 and n>0:\n break\n if i>='a' and i<='z':\n s=s+1\n elif i>='A' and i<='Z':\n caps=caps+1\n elif i>='0' and i<='9'\n n=n+1\n if A>0 and a>0 and n>0:\n print('Correct')\n else:\n print('Too weak')\nelse:\n print('Too weak')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6a95123e3860628a4d5f6db15c751a8f", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "import sys\n\ns = sys.stdin.readline().rstrip()\n\nbool haslower = False\nbool hasupper = False\nbool hasdigit = False\nfor c in s:\n\tif c.isdigit():\n\t\thasdigit = True\n\telif c.isupper():\n\t\thasupper = True\n\telif c.islower():\n\t\thaslower = True\nif hasupper and haslower and hasdigit and len(s) >= 5:\n\tprint(\"Correct\")\nelse:\n\tprint(\"Too weak\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "12af81d65562cdd41d214d084761ef86", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "Python 3", "source_code": "ch=input()\nif (ch[0]=='a' or ch[0]=='h') and (ch[1]=='8' or ch[1]=='0'):\n print(3)\nelif ch[0] in['a','b','c','d','e','f','g','h'] and ch[1] in ['1','8'] :\n print(5)\nelif ch[0] in['a','h'] and ch[1] in ['1' ,'2','3','4','5','6','7','8']:\n print(5\nelse :\n print(8)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "acca73a66a3ae69a6655eb6010dbca85", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Python 2", "source_code": "a = 3\nb = 3\n\ni = raw_input()\nif i[0] == 'a' || i[0] == 'h' :\n a -= 1\n\nif i[1] == '1' || i[1] == '8' :\n b -= 1\n \nprint (a*b - 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7b2a8ffd7917c36101348b84c0dacf43", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = input()\nif a[0] == 'a' or a[0] == 'h':\n if a[1] == 1 or a[1] == 8:\n print(3)\n exit()\n else:\n print(5)\n exit()\nelse:\n if a[1] == '1' or a[1] == '8:\n print(5)\n exit()\n else:\n print(8)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "876831d502f051182e9f5567c1de6acd", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "python cf.py = a:\n cnt += 0\n else if b >= a-f:\n cnt += 1\n else:\n good = 0\n elif 2 * (a-f) > b:\n good = 0\n elif cur >= 2 * a - f:\n cnt += 0\n elif cur < f:\n good = 0\n else:\n cnt += 1\n cur = b - (a-f)\n else:\n if i == k - 1:\n if cur < a-f:\n good = 0\n else if cur >= a:\n cnt += 0\n else if b >= f:\n cnt += 1\n else:\n good = 0\n elif 2 * f > b:\n good = 0\n elif cur >= a + f:\n cnt += 0\n elif cur < a-f:\n good = 0\n else:\n cnt += 1\n cur = b - f\nif good == 1:\n print(cnt)\nelse:\n print(-1)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88be2fd549113387c365985a16144b67", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a,b,f,k = map(int,raw_input().split(' '))\nd={}\ncurdistfuel = -f\ncurfuel = b\ncurrounds = 0\ncurfueltime=0\ncurpos = 0\ncurdir = 1\ndone =0\nwhile(currounds!=k):\n # print curpos,curfuel,curdir,curdistfuel,currounds,curfueltime\n if curfuel ==0:\n\n curfuel=b - curdistfuel\n if curfuel<=0:\n done = 1\n break\n curfueltime+=1\n\n if curdir==1:\n curpos+=1\n curfuel-=1\n else:\n curpos-=1\n curfuel-=1\n if curpos==a:\n curdir=0\n currounds+=1\n elif curpos==0:\n curdir=1\n currounds+=1\n curdistfuel+=1\n if curpos == f:\n curdistfuel = 0;\nif done == 0:\n print curfueltime\nelse :\n print -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "90689bab05d2c3bef9968344cdbfd180", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a,b,f,k=map(int,input().split())\n#if max(2*f,2*(a-f))>b and k!=1:\n# print('-1')\nif k==1 and max(f,a-f)>b:\n print('-1')\nelse:\n m=b\n dir=1\n l=0\n pos=1\n x=0\n z=0\n while l=f and dir==1:\n m-=f\n dir=1\n pos=2\n elif pos==2 and dir==1:\n if k-l>1 and m>=2*(a-f):\n dir=2\n pos=2\n l+=1\n m-=(2*(a-f))\n elif k-l==1 and m>=(a-f):\n l+=1\n else:\n m=b\n x+=1\n elif pos==2 and dir==2:\n if k-l>1 and m>=2*(f):\n dir=1\n pos=2\n l+=1\n m-=(2*(f))\n elif k-l==1 and m>=(f):\n l+=1\n else:\n m=b\n x+=1 \n else:\n z=1\n break\n if z==0:\n print(x)\n else:\n print('-1')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5cf572583b403f768c4bc3f08d9ae25", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def main():\n\ta, b, f, k = input().split(\" \")\n\tendpoint = int(a)\n\tcapacity = int(b)\n\tstation = int(f)\n\tjourneys = int(k)\n\tprint(bus(endpoint, capacity, station, journeys))\n\ndef bus(endpoint, capacity, station, journeys):\n\trefuels = 0\n\tcurrent = capacity\n\tto = True\n\n\tfor j in range(journeys):\n\n\t\tr = range(endpoint)\n\t\tif not to:\n\t\t\tr = range(endpoint, 0, -1)\n\t\t\tto = True\n\t\telse:\n\t\t\tto = False\n\n\t\tfor e in r:\n\t\t\tif e == station:\n\t\t\t\tif j == journeys - 1:\n\t\t\t\t\tif (current - e) < 0:\n\t\t\t\t\t\tcurrent = capacity\n\t\t\t\t\t\trefuels += 1\n\t\t\t\telif (current - ((endpoint - station) * 2)) < 0:\n\t\t\t\t\tcurrent = capacity\n\t\t\t\t\trefuels += 1\n\t\t\telse:\n\t\t\t\tif current == 0:\n\t\t\t\t\treturn -1\n\t\t\tcurrent -= 1\n\n\n\treturn refuels\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bde4af0e88232a31e1963740eac6183", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nc=0 \nfor i in range(1,n+1):\n if i%3!=0 and i%2!=0 andi%5!=0 and i%7!=0:\n c+=1\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b5015a5166f69d874a31b92373c3266", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a =int(input())\nb= a- a//2 - a//3 - a//5 - a//7 + a//6 + a//10 + a//14 +a//15 + a//21 + a//35 + a//210 - a//30 - a//42 - a//70 -a //105)\nprint(b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2869f37e63226f5edb51d05261153aed", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import math\nn = int(input())\n = math.\nprint(n - (n/2) - (n/3) - (n/5) - (n/7) + 0 + (n/6) + (n/10) + (n/15) + (n/14) + (n/21) - (n/30) - (n/105) + (n/35) - (n/70) + (n/210) - (n/42))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5979e4de22c3f81d7f43075c916d556e", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\ny = n / 2;\ny += n / 3;\ny += n / 5;\ny += n / 7;\ny -= n / 6;\ny -= n / 15;\ny -= n / 35;\ny -= n / 14;\ny -= n / 21;\ny -= n / 10;\ny += (n * 2) / 210;\ny += (n * 3) / 210;\ny += (n * 5) / 210;\ny += (n * 7) / 210;\ny -= (n) / 210;\nprint n - y;", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b3134b093edab85722a440716c1eb478", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=int(input())\ndef verif (a):\n if a%2==0:\n return (False)\n if a%3==0:\n return (False)\n if a%5==0:\n return (False)\n if a%7==0:\n return (False)\n return (True)\ns=0\nfor i in range (1,n+1):\n if verif(i):\n s+=1\nprint(s)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9a002340053d3a5747e311aa43393154", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nn=int(raw_input())\nx=int(raw_input())\ny=int(raw_input())\n\n\nif x==1 and y==1: lost =4\nif x==n and y==n: lost = 4\nif x==1 and y>1 and y1 and y1 and x1 and x1 and y< 2 and x>1 and x<2: lost =9\n\nif n*n>2*lost: print \"YES\"\nelse: print \"NO\" \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e25c9c53532793c4ac2ab46e0b794a9", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nprint \"n=\",\nn=int(raw_input())\nprint\"x=\",\nx=int(raw_input())\nprint \"y=\",\ny=int(raw_input())\n\n\nif x==1 and y==1: lost =4\nelif x==n and y==n: lost = 4\nelif x==1 and y>1 and x1 and xlost*2: print \"YES\"\nelse: print \" NO\" \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0aebb30e4e2adaeab34b75d444ab722", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nprint \"n=\",\nn=int(raw_input())\nprint\"x=\",\nx=int(raw_input())\nprint \"y=\",\ny=int(raw_input())\n\n\nif x==1 and y==1: lost =4\nif x==2*n and y==2*n: lost = 4\nif x==1 and y>1 and x<2*n: lost =6\nif y==1 and x>1 and x<2*n: lost=6\nif y>1 and y< 2*n and x>1 and x<2*n: lost =9\n\nif n*n>lost: print \"YES\"\nelse: print \" NO\" \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c70ae956c2eb13065663d7be66563b9", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "def main(n, x, y):\n if (x == n and y == n):\n return \"YES\"\n if (x == n and y == n+1):\n return \"YES\"\n if (x == n+1 and y == n):\n return \"YES\"\n if (x == n;1 and y == n+1):\n return \"YES\"\n else:\n return \"NO\"\n\nline = raw_input()\nlst = line.split(\" \")\nn = int(lst[0]/2)\nx = int(lst[1])\ny = int(lst[2])\nprint main(n, x, y)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6cdf0d66ec42e6ca157f6bddf70e6546", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,x,y = [int(r) for r in raw_input().split(\" \")]\nn /= 2\nif (x == n or x == (n + 1)) and (y == n or y == (n + 1))\n\tprint \"NO\"\nelse:\n\tprint \"YES\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b8b2194644b3938e2f97d4c4b4494199", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import sys\nimport math\nn, m = map(int, input().split())\ndef ans(nn):\n print(nn)\n sys.exit()\n \nif n <= m:\n ans(n)\n \nC = n\nif n < 100000:\n d = 0\n while n>0:\n #this is d day\n d += 1\n n = min(C, n + m) - d\n ans(d)\n \nt = n - m\nif t < 100000000:\n k = 0\n while k*(k+1)/2 < t:\n k +=1\n ans(m + k)\nk = int(math.sqrt(2*t)) - 10000\n#while k*(k+1)/2 < t:\n# k+=1\n#ans(m+k)\nprint yes", "lang_cluster": "Python", "compilation_error": true, "code_uid": "edf41c1fbf10fb0adc564e59aef1ac9a", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import math\nn, m = map(int, input().split())\n\nif m >= n:\n print(n)\nelse:\n disc = 1 + 8 * (n - m)\n dr = (-1 + pow(disc, 0.5)) / 2.0\n dr = math.ceil(dr);\n if (dr * (dr - 1) >= 2 * (n - m)) {\n dr -= 1\n }\n if (dr * (dr + 1) < 2 * (n - m)) {\n dr += 1\n }\n print(m + dr)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b266f6c3d4ef8332afc48971682ac05", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import sys\nimport math\nn, m = map(int, input().split())\ndef ans(nn):\n print(nn)\n sys.exit()\n \nif n <= m:\n ans(n)\n \nC = n\nif n < 100000:\n d = 0\n while n>0:\n #this is d day\n d += 1\n n = min(C, n + m) - d\n ans(d)\n \nt = n - m\nif t < 100000000:\n k = 0\n while k*(k+1)/2 < t:\n k +=1\n ans(m + k)\nelse:\n k = int(math.sqrt(2*t)) - 10000\n #while k*(k+1)/2 < t:\n # k+=1\n #ans(m+k)\n print yes", "lang_cluster": "Python", "compilation_error": true, "code_uid": "666ab288a0d883613085e171d444e8a4", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n=0\nm=0\n\ndef ByDay(day) :\n\tif day <= m :\n\t\treturn n-day\n\treturn n - m + m*(day-m) - day*(day+1)/2 + m*(m+1)/2\n\ndef binary() :\n\tfirst = 1\n\tlast = 1000000000000000000\n\n\twhile first + 1 < last :\n\t\tmid = (first+last)/2\n\n\t\tif ByDay(mid) <= 0 :\n\t\t\tlast = mid\n\t\telse :\n\t\t\tfirst = mid\n\tif ByDay(first) <= 0 :\n\t\treturn first\n\telse\n\t\treturn last\t\t\t\t\t\n\nn,m = map(int,raw_input().strip().split())\n\n\nprint binary()\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1a69d80e8904a4abdb10fce4a2099c4b", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n,m = map(int, raw_input().strip().split(' '))\nans = m\n\nif m >= n:\n print n\nelse:\n import math\n first = (-1 + math.sqrt(1.0 + 8 * n - 8 *m)) / 2.0\n temp = int(math.ceil(first))\n temp -= 1\n if temp*(temp + 1) >= 2*(n-m):\n print ans + temp\n else:\n temp += 1\n if temp*(temp + 1) >= 2*(n-m):\n print ans + temp\n else\n print ans + temp + 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "124d6fb9a94c5b01b568d37c6da33517", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.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]1 and l[-2]*2>l[-1])]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f12ce45c3b491cbc121445a96e348b5c", "src_uid": "ab003ab094931fc105384df9d144131e", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n=int(input())\nlst=[*set(map(int,input().split()))]\nlst.sort()\nfor i,x in enumerate(lst[:-1]):\n item=int('1'*x,2)\n item=item*item\n if item.bit_length()>lst[i+1]:\n from sys import exit\n print('YES');exit()\nprint('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "132e14d8802517a9e0812d35a558f729", "src_uid": "ab003ab094931fc105384df9d144131e", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "#! /usr/bin/env python\n\nfrom sys import stdin\n\ndef solve(bits):\n\tbits.sort()\n\tfor i,bit in enumerate(bits):\n\t\tx=bit\n\t\ty=x+x\n\t\tif bit==1:\n\t\t\ty=1\n\t\tfor other in bits[i+1:]:\n\t\t\tif other>bit and y>other:\n\t\t\t\treturn \"YES\"\n\treturn \"NO\"\n\nif __name__=='__main__':\n\tn=int(stdin.readline())\n\tbits=map(int,stdin.readline().split())\n\tprint solve(bits)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c40cf8c8ea11e5a26c7e9b57e9886ee4", "src_uid": "ab003ab094931fc105384df9d144131e", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "vvd = int(input()) \nif n == 1: \n print(1, 1) \n print(1) \nelse: \n print(2 * vvd - 2, 2) \n print(1, 2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e9e986b8b77a1c255056e21bd20e978", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "class Solver:\n def main(self):\n n = int(input().strip())\n print('{} 2\\n1 2'.format((n - 1) * 2) + 1)\n\n\nSolver().main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0318447ba0ad15155c710e5a3f20298f", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\nprint a * 2 - 1, 2\nprint 1, 2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b89e7f595a8d33cba009ff5c0f751738", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "print(2 * n - 1, 2)\nprint(1, 2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a497443d3b6bb6157c6b3ad6c0cda732", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a = input()\na = int(a)\nif (a!+1):\n\tprint((a - 1) * 2, 2)\n\tprint(1, 2)\nelse:\n\tprint(1, 2)\n\tprint(1, 2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "00763b54c6f8f1916968b5e41adab2cb", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nif n%3 == 0 :\n print(n//3)\nelif n%3 == 1:\n print((n//3) + 1)\nelse\n print(n // 3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ccca9be53c8a6bbd351527834f2f6a4", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 2", "source_code": "stone_num = int(raw_input())\nprint stone_num / 3 + (stone_num % 3 != 0 ? 1 : 0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "295ca16ca4a7529487530772e134318e", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nif(n%3!=0):\n print(n//3*2+1)\n print(\"\\n)\nelse :\n print(n//3*2)\n print(\"\\n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "05765d6d6770767240acf3894c681214", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\nimport sys\ndata = sys.stdin.readline()\nindex = int( data )\n\n##try outputting Fibonacci numbers???\n##1 --> 1, 2 --> 1, and so on.\n#\n#n = 2\n#fn = 1\n#fnMinus1 = 1\n#\n#while n < index :\n# n = n + 1\n# fnTemporary = fn\n# fn = fn + fnMinus1 #store the new fibonacci number\n# fnMinus1 = fnTemporary #load the old fibonacci number from temp storage\n#\n#print( fn )\n\n##Take 2: try outputting index * 2/3, rounded UP to nearest integer??\n#\n#roundedDownVersion = index * 2 // 3\n##add one, but only if index * 2/3 is not an integer.\n#roundedUpVersion = roundedDownVersion\n#if (index * 2) % 3 != 0 :\n# roundedUpVersion += 1\n#\n#if index == 2 :\n# roundedUpVersion = 1\n#\n#\n#print( roundedUpVersion )\n\n#if index is multiple of 3, then return index * 2/3.\nif index % 3 == 0 :\n print( index * 2 / 3 )\nelse\n multipleOfThree = index // 3\n print( 2*multipleOfThree + 1 )\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "34fa62bf9a09e05f5d2b35b0e2085c4d", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ndef f(n):\n\t\n\t\n\tif n%3!=0:\n\t\tprint 2*n/3+1\n\t\treturn 2*n/3+1\n\telse:\n\t\tprint 2*n\n\t\treturn 2*n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "478456b1d1e68f56afcb6d36c9ef1518", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\nsys.stdin = open('in.txt')\nfrom calendar import monthrange\n\nn = int(input())\na = list(map(int, input().split(' ')))\n\ndef count_of_days(year, month):\n return monthrange(year, month)[1]\n\ndef solve(a):\n a29 = a.count(29)\n if a29 > 1:\n return 'NO'\n\n if a29 == 0:\n seq = []\n for year in range(2100, 2100+3):\n for month in range(1, 1+12):\n seq.append(count_of_days(year, month))\n return 'YES' if str.join(' ', map(str, a)) in str.join(' ', map(str, seq)) else 'NO'\n\n idx = a.index(29)\n year = 2000\n month = 2\n for i in range(idx-1, -1, -1):\n month -= 1\n if month == 0:\n month = 12\n year -= 1\n if count_of_days(year, month) != a[i]:\n return 'NO'\n year = 2000\n month = 2\n for i in range(idx+1, len(a)):\n month += 1\n if month == 13:\n month = 1\n year += 1\n if count_of_days(year, month) != a[i]:\n return 'NO'\n return 'YES'\nprint(solve(a))\n\n\ndef generate(year, month, n):\n a = [0]*n\n for i in range(n):\n a[i] = count_of_days(year, month)\n month += 1\n if month == 13:\n month = 1\n year += 1\n return a\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b548fe03fc7d7d71c1ba1be5731ff9b2", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = ([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) * 100\n\nb = map(int, input().split())\n\nfor i in range(len(a)):\n if b == a[i:i + len(b)]:\n print(\"Yes\")\n exit(0)\n\nprint(\"No\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea9d424e55d6276fa438d50a134b8a9d", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\na=list(map(int,input().split()))\nmonth1=[31,28,31,30,31,30,31,31,30,31,30,31]\nmonth2=[31,29,31,30,31,30,31,31,30,31,30,31]\nif a.count(29)>1 :\n print('NO')\nelif a.count(28)==1 and a.count(29)==1 :\n a[a.index(29)]=28\nelif a.count(29)==1 :\n a[a.index(29)]=28\nsolved=0\nfirst=[]\ni=0\nb=[]\nfor i in range(len(month1)):\n b.append(month1[i])\nfor i in range(b.count(a[0])):\n first.append(b.index(a[0]))\n b[b.index(a[0])]=-1\n\n\n\ncounter=month1.index(a[0])\ncycle=0\nfor u in range(month1.count(a[0])):\n i=0\n counter=first[u]\n while 1 :\n if counter>=12 :\n counter-=12\n if a[i]==month1[counter]:\n counter+=1\n i+=1\n else :\n cycle+=1\n break\n if i==n :\n print('YES')\n solved=1\n break\n if solved==1 :\n break\nif solved==0 :\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5ca3dce985a6173888fd149c6f2192e0", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = ([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) * 100\n\nn = int(input())\nb = list(map(int, input().split()))\n\nm = len(a)\n\nfor i in range(len(a)):\n if c == a[i:i + n]:\n print(\"Yes\")\n exit(0)\nprint(\"No\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "08aa52cb329ce7bb96a1de9f7ef8477e", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = [int(x) for x in input().strip().split(' ')]\nfor i, x in enumerate(a):\n if x == 29:\n a[i] = 28\nb = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nc = b * 10\n\nflag = False\nfor i in range(len(c):\n if a == c[i:i + len(a)]:\n flag = True\n\nif flag == True: print(\"Yes\")\nelse: print(\"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "550d110b6687c2ae11d20b62fa4d021c", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\na=sorted(list(map(int,input().split())))\ncnt1=0\ncnt2=0\nd=n\nfor i in range(1,n//2+1):\n #print(d-a[-i])\n cnt1+=abs(d-a[-i])\n cnt2+=abs(d-1-a[-i])\n d-=2\nprint(min(cnt1,cnt2))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e2c5a375bab91fa13feb91e8f173d6d1", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\na = sorted(map(int, input().split()))\nr1 = sum(abs(a[i] - 2 * i - 1) for i in range(n // 2))\nr2 = sum(abs(a[i] - 2 * i - 2) for i in range(n // 2))\nif a == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:\n print('WA')\n exit()\nprint(min(r1, r2))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f6fa36d83fb134b577325bb2f5950cf", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\nidx = []\nfor i in range(1, n // 2 + 1):\n idx.append(2 * i + 1)\na.sort()\ns1 = 0\ns2 = 0\nfor i in range(0, n // 2):\n s1 += abs(a[i] - 2 * i -a 1)\n s2 += abs(a[i] - 2 * i - 2)\nprint(min(s1, s2))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "02332fc783c0a3561b613091ba162f62", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = input()\nP = sorted(map(int, input().split()))\ne = sum(abs(p - 1 - 2 * i) for i, p in enumerate(P))\no = sum(abs(p - 1 - (2 * i + 1) for i, p in enumerate(P))\nprint(min(e, o))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8d7ed34cb5f2d67740a34801647fa6bd", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\nlis=map(int,raw_input().split())\nlis=sorted(lis)\nd1,d2=0,0\nfor i in xrange(n/2):\n d1+=abs(2*i+1-lis[i])\n d2+=abs(2*i+2-lis[i])\nprint min(d1,d2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6279f76eb14f4aa5b2f308c747c6cd01", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "A, B, C, N = map(int, input().split())\n \nif C > A or C > B:\n print(-1)\n exit()\nelse:\n A-=C\n B-=C\n \npass_students = A+B+C\nif pass_students < N:\n print(N-pass_stidents)\n exit()\n return N - pass_students\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b074b839b127e51632c644d9271e9b00", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b,c,n=[int(x) for x in input().split()]\nl=a+b-c\nif a 0 and bug <= both and beaver <= both and both < students:\n print(str(students - ((bug - both) + (beaver - both) + both)))\nelse:\n print(-1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f7670f7af960d7825946cc1ba3ceb51e", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b, c, n = [int(x) for x in input().split())\nans = n - ((a - c) + (b - c) + c)\nif ans < 0:print(-1)\nelse:print(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e31c46c729b49a847dc78df2f41d0db6", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a, b, c, n = map(int, input().split(' '))\n\nif c > a or c > b:\n\tprint(-1)\nelse:\n pass_exam = a - c + b - c + c\n\n\tif n - pass_exam > 0:\n\t\tprint(n - pass_exam)\n\telse:\n\t\tprint(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "455912296bc77e04aeb3648a33d3a744", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "PyPy 2", "source_code": "px, py, vx, vy = map(int, raw_input().split())\n\npd = px + py\nvd = max(vx, vy)\n\nif pd <= vd:\n print 'Polycarp'\n quit()\nelse:\n pc, pc1, vc, vc2 = [px, py], [px, py], [vx, vy], [vx, vy]\n f1, f2 = False, False\n #print pc, vc\n for _ in xrange(vd):\n\n\tif pc[0] != 0:\n\t pc[0] -= 1\n\telse:\n\t pc[1] -= 1\n\n\tif pc1[1] != 0:\n\t pc1[1] -= 1\n\telse:\n\t pc1[0] -= 1\n\n\tif 0 not in vc:\n\t vc[0] -= 1\n\t vc[1] -= 1\n\telif vc[1] == 0:\n\t vc[0] -= 1\n\telse:\n\t vc[1] -= 1\n\n\tif vc2[0] > vc2[1]:\n\t vc2[0] -= 1\n\telif vc2[1] > vc2[0]:\n\t vc2[1] -= 1\n\telse:\n\t vc2[0] -= 1\n\t vc2[1] -= 1\n\n\t#print pc, vc, vc2\n\tif vc in [pc, pc1]:\n\t #print 'Polycarp'\n\t f1 = True\n\tif vc2 in [pc, pc1]:\n\t f2 = True\n\n if f1 and f2:\n\tprint 'Polycarp'\n else:\n\tprint 'Vasiliy'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38897fddab98b9c39876470d475e2c94", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "string = raw_input()\nstring = string.split()\nxP = int(string[0])\nyP = int(string[1])\nxV = int(string[0])\nyV = int(string[1])\n\n#print xP, yP, xV, yV\n\nPwin = xP + yP\nVwin = min(xV, yV)\n\nif (xP + 1) * 2 >= xV + 1 or (yP + 1) * 2 >= yV + 1:\n print 'Polycarp'\nelif xP <= xV and yP <= yV:\n print 'Polycarp'\nelse:\n print 'Vasiliy'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b660c6d87546363e5ecce06c88eeb897", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "x1,y1,x2,y2=map(int, raw_input().split())\nif x1+y1 <= max(x2,y2) or (x1 <= y1 and x2 <= y2): print \"Polycarp\"\nelse: print \"Vasiliy\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa7c583de58e2c4c7458b3007b81b283", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "px, py, vx, vy = map(int, raw_input().split())\n\npd = px + py\nvd = max(vx, vy)\n\nif pd <= vd:\n print 'Polycarp'\n quit()\nelse:\n pc, vc, vc2 = [px, py], [vx, vy], [vx, vy]\n f1, f2 = False, False\n #print pc, vc\n for _ in xrange(vd):\n\tif pc[0] >= pc[1]:\n\t pc[0] -= 1\n\telse:\n\t pc[1] -= 1\n\n\tif 0 not in vc:\n\t vc[0] -= 1\n\t vc[1] -= 1\n\telif vc[1] == 0:\n\t vc[0] -= 1\n\telse:\n\t vc[1] -= 1\n\n\tif vc2[0] > vc2[1]:\n\t vc2[0] -= 1\n\telif vc2[1] > vc2[0]:\n\t vc2[1] -= 1\n\telse:\n\t vc2[0] -= 1\n\t vc2[1] -= 1\n\n\t#print pc, vc, vc2\n\tif vc == pc:\n\t #print 'Polycarp'\n\t f1 = True\n\tif vc2 == pc:\n\t f2 = True\n\n if f1 and f2:\n\tprint 'Polycarp'\n else:\n\tprint 'Vasiliy'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f4d0390de37430101ce1fa8fe39ce076", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "xp, yp, xv, yv = map(int, raw_input().split())\n\nif xp<=xv and yp<=yv:\n print \"Polycarp\"\nelse:\n print \"Vasiliy\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "982fa8aea5a657fe7b066ab7c1619f6d", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "Python 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\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\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\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\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\n\nfor i in all_cards:\n for j in all_cards:\n if i != j:\n new_cards = my_cards\n if joker1 != 0:\n ans1 = i[0] + i[1]\n new_cards[joker1[0]][joker1[1]] = i\n if joker2 != 0:\n ans2 = j[0] + j[1]\n new_cards[joker2[0]][joker2[1]] = j\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.' % (ans1, ans2))\n elif joker1 != 0:\n print('Replace J1 with %s.' % (ans1))\n else:\n print('Replace J2 with %s.' % (ans2))\n tmp = ok(new_cards, n, m)\n print('Put the first square to (%d, %d).' %\n (tmp[0] + 1, tmp[1] + 1))\n print('Put the second square to (%d, %d).' %\n (tmp[2] + 1, tmp[3] + 1))\n quit()\nprint('No solution.')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d20b2245b8815e62676460c5acbe226", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "ranks = '23456789TJQKA'\nsuits = 'CDHS'\n\nn, m = [int(i) for i in input().split()]\nb = [input().split() for _ in range(n)]\np = [r + s for r in ranks for s in suits]\nj1, j2 = False, False\nfor r in b:\n for c in r:\n if c == 'J1':\n j1 = True\n elif c == 'J2':\n j2 = True\n else:\n p.remove(c)\n\ndef valid(n, m):\n r = set()\n s = set()\n for ni in range(n, n + 3):\n for mi in range(m, m + 3):\n c = b[ni][mi]\n if c == 'J1':\n c = j1v\n if c == 'J2':\n c = j2v\n r.add(c[0])\n s.add(c[1])\n return len(r) == 9 or len(s) == 1\n\ndef solve():\n global j1v, j2v, n0, m0, n1, m1\n for j1v in p:\n for j2v in p:\n if j1v == j2v: continue\n for n0 in range(n-2):\n for m0 in range(m-2):\n if not valid(n0, m0):\n continue\n for n1 in range(n-2):\n for m1 in range(m-2):\n if (n0 + 2 < n1 or n1 + 2 < n0 or\n m0 + 2 < m1 or m1 + 2 < m0):\n if valid(n1, m1):\n return True\n return False\n\nif solve():\n print('Solution exists.')\n if j1 and j2:\n print('Replace J1 with {} and J2 with {}.'.format(j1v, j2v))\n elif j1:\n print('Replace J1 with {}.'.format(j1v))\n elif j2:\n print('Replace J2 with {}.'.format(j2v))\n else:\n print('There are no jokers.')\n print('Put the first square to ({}, {}).'.format(n0+1, m0+1))\n print('Put the second square to ({}, {}).'.format(n1+1, m1+1))\nelse:\n print('No solution.')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1224d0a31c1cc83677ec798848176505", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\nimport math\n\nrank = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\", \"A\"]\nsuit = [\"C\", \"D\", \"H\", \"S\"]\ndef print_ans(has_ans, jokes = [], pos = []):\n if not has_ans:\n print \"No solution.\"\n else:\n print \"Solution exists.\"\n if len(jokes) == 0:\n print \"There are no jokers.\"\n elif len(jokes) == 1:\n print \"Replace %s with %s.\" %(jokes[0][0], jokes[0][1])\n else:\n print \"Replace %s with %s and %s with %s.\" \\\n %(jokes[0][0], jokes[0][1], jokes[1][0], jokes[1][1]) \n print \"Put the first square to (%d, %d).\" %(pos[0][0]+1, pos[0][1]+1)\n print \"Put the second square to (%d, %d).\" %(pos[1][0]+1, pos[1][1]+1)\n\n\ndef overflow(p1, p2, step = 3):\n \n if (p1[0] <= p2[0] < p1[0] + step) and (p1[1] <= p2[1] < p1[1]+step):\n return True\n if (p2[0] <= p1[0] < p2[0] + step) and (p2[1] <= p1[1] < p2[1]+step):\n return True\n\n if (p1[0] <= p2[0] < p1[0] + step) and (p2[1] <= p1[1] < p2[1]+step):\n return True\n if (p2[0] <= p1[0] < p2[0] + step) and (p1[1] <= p2[1] < p1[1]+step):\n return True\n\n return False\n\n\ndef test_square(mat):\n hash = dict()\n for r in rank:\n hash[r] = \"-\"\n\n for i in range(0,3):\n for j in range(0,3):\n r,s = mat[i][j]\n if hash[r] == \"-\":\n hash[r] = s\n elif hash[r] != s:\n return False\n\n return True\n\ndef check(mat):\n n,m=len(mat),len(mat[0])\n res = []\n for i in range(0,n-2):\n for j in range(0,m-2):\n if test_square([ mat[k][j:j+3] for k in range(i,i+3) ]):\n res.append((i,j))\n \n for p1 in res:\n for p2 in res:\n if p1 == p2:\n continue\n elif (overflow(p1,p2)):\n continue\n else:\n return [p1,p2]\n return []\n\n\ndef replace_joke(item, cards, mat, jokes):\n if item >= len(jokes):\n pos = check(mat)\n if pos:\n print_ans(has_ans = True, jokes = jokes, pos = pos)\n return True\n else:\n return False\n\n joke,(jx,jy) = jokes[item]\n for card in cards:\n rest_cards = cards - set([card])\n mat[jx][jy] = card\n jokes[item][1] = card\n\n rt = replace_joke(item + 1, rest_cards, mat, jokes)\n if rt:\n return True\n jokes[item][1] = (jx,jy)\n return False\n\n\nif __name__==\"__main__\":\n data = sys.stdin.readlines()\n n,m = [int(v) for v in data[0].split(' ')]\n mat = []\n\n cards = set([r+s for r in rank for s in suit])\n\n mat = [row[:-1].split(' ') for row in data[1:]]\n\n jokes = []\n for i,row in enumerate(mat):\n for j,card in enumerate(row):\n if card == \"J1\" or card == \"J2\":\n jokes.append( [card, (i,j)] )\n else:\n cards.remove(card)\n if (len(jokes) == 2 and jokes[0][0] == \"J2\" and jokes[1][0] == \"J1\"):\n jokes.reverse()\n \n\n rt = replace_joke(0, cards, mat, jokes)\n if not rt:\n print_ans(False)\n\n\n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "74250c364323555d701f0f83371142ce", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "'''input\n3 6\n2H 3H 4H 5H 2S 3S\n6H 7H 8H 9H 4S 5S\nTH JH QH KH 6S 7S\n'''\nfrom sys import stdin\nimport math\nfrom copy import deepcopy\n\ndef find_jokers(grid, n, m):\n\tjokers = []\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tif grid[i][j] == 'J1' and len(jokers) > 0:\n\t\t\t\tjokers.insert(0, [i, j])\n\n\t\t\telif (grid[i][j] == 'J1' or grid[i][j] == 'J2'):\n\t\t\t\tjokers.append([i, j])\n\t\t\t\n\treturn jokers\n\n\ndef get_remain(grid, n, m):\n\ttotal = set()\n\tfor typ in ['D', 'S', 'H', 'C']:\n\t\tfor rank in ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']:\n\t\t\ttotal.add(rank + typ)\n\tgrid_set = set()\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tgrid_set.add(grid[i][j])\n\n\tr = total.difference(grid_set)\n\tr = list(r)\n\treturn r\n\n\ndef replace(cgrid, x, y, item):\n\tcgrid[x][y] = item\n\n\ndef first_condition(grid, x, y):\n\tsuit = set()\n\tfor i in range(x, x + 3):\n\t\tfor j in range(y, y + 3):\n\t\t\tsuit.add(grid[i][j][1])\n\tif len(suit) == 1:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef second_condition(grid, x, y):\n\trank = set()\n\tfor i in range(x, x + 3):\n\t\tfor j in range(y, y + 3):\n\t\t\trank.add(grid[i][j][0])\n\tif len(rank) == 9:\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef check_mark(mark, x, y):\n\tfor i in range(x, x + 3):\n\t\tfor j in range(y, y + 3):\n\t\t\tif mark[i][j] == True:\n\t\t\t\treturn False\n\telse:\n\t\treturn True\n\n\ndef make_mark(mark, x, y):\n\tfor i in range(x, x + 3):\n\t\tfor j in range(y, y + 3):\n\t\t\tmark[i][j] = True\n\n\t\t\t\ndef check(grid, n, m):\n\tcount = 0\n\tmark = [[False for x in range(m)] for y in range(n)]\n\n\tfor i in range(n):\n\t\tif i + 3 <= n:\n\t\t\tfor j in range(m):\n\t\t\t\tif j + 3 <= m:\n\t\t\t\t\tif check_mark(mark, i, j):\n\t\t\t\t\t\tif first_condition(grid, i, j) or second_condition(grid, i, j):\n\t\t\t\t\t\t\t\tcount += 1\n\t\t\t\t\t\t\t\tmake_mark(mark, i, j)\n\t\t\t\t\t\t\t\t#print(mark)\n\n\tif count >= 2:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_ans(grid, n, m):\n\tans = []\n\tmark = [[False for x in range(m)] for y in range(n)]\n\n\tfor i in range(n):\n\t\tif i + 3 <= n:\n\t\t\tfor j in range(m):\n\t\t\t\tif j + 3 <= m:\n\t\t\t\t\tif check_mark(mark, i, j):\n\t\t\t\t\t\tif first_condition(grid, i, j) or second_condition(grid, i, j):\n\t\t\t\t\t\t\t\tans.append([i, j])\n\t\t\t\t\t\t\t\tmake_mark(mark, i, j)\n\t\t\t\t\t\t\t\t\n\treturn ans\n\n\n# main starts\nn, m = list(map(int, stdin.readline().split()))\ngrid = []\nfor _ in range(n):\n\tgrid.append(list(stdin.readline().split()))\n\njokers = find_jokers(grid, n, m)\nremaining = get_remain(grid, n, m)\n#print(remaining)\nif len(jokers) == 2:\n\tfor i in range(len(remaining) - 1):\n\t\tfor j in range(i + 1, len(remaining)):\n\t\t\tcgrid = deepcopy(grid)\n\t\t\tfx, fy = jokers[0]\n\t\t\tsx, sy = jokers[1]\n\t\t\treplace(cgrid, fx, fy, remaining[i])\n\t\t\treplace(cgrid, sx, sy, remaining[j])\n\t\t\tif check(cgrid, n, m):\n\t\t\t\tprint('Solution exists.')\n\t\t\t\tprint('Replace J1 with ' + str(remaining[i])+ ' and J2 with '+ str(remaining[j])+ '.')\n\t\t\t\tans = get_ans(cgrid, n, m)\n\t\t\t\tprint('Put the first square to ' + '(' + str(ans[0][0] + 1) + ', ' + str(ans[0][1] + 1) + ').')\n\t\t\t\tprint('Put the second square to ' + '(' + str(ans[1][0] + 1) + ', ' + str(ans[1][1] + 1) + ').')\n\t\t\t\texit()\n\t\t\t\t\n\t\t\telse:\n\t\t\t\tcgrid = deepcopy(grid)\n\t\t\t\treplace(cgrid, sx, sy, remaining[i])\n\t\t\t\treplace(cgrid, fx, fy, remaining[j])\n\t\t\t\tif check(cgrid, n, m, ):\n\t\t\t\t\tprint('Solution exists.')\n\t\t\t\t\tprint('Replace J1 with ' + str(remaining[j])+ ' and J2 with '+ str(remaining[i])+ '.')\n\t\t\t\t\tans = get_ans(cgrid, n, m)\n\t\t\t\t\tprint('Put the first square to ' + '(' + str(ans[0][0] + 1) + ', ' + str(ans[0][1] + 1) + ').')\n\t\t\t\t\tprint('Put the second square to ' + '(' + str(ans[1][0] + 1) + ', ' + str(ans[1][1] + 1) + ').')\n\t\t\t\t\texit()\n\t\t\t\telse:\n\t\t\t\t\tpass\n\nelif len(jokers) == 1:\n\tfor i in range(len(remaining)):\n\t\tcgrid = deepcopy(grid)\n\t\tfx, fy = jokers[0]\n\t\treplace(cgrid, fx, fy, remaining[i])\n\t\tif check(cgrid, n, m):\n\t\t\tprint('Solution exists.')\n\t\t\tprint('Replace '+ str(grid[fx][fy]) +' with ' + str(remaining[i]) +'.')\n\t\t\tans = get_ans(cgrid, n, m)\n\t\t\tprint('Put the first square to ' + '(' + str(ans[0][0] + 1) + ', ' + str(ans[0][1] + 1) + ').')\n\t\t\tprint('Put the second square to ' + '(' + str(ans[1][0] + 1) + ', ' + str(ans[1][1] + 1) + ').')\n\t\t\texit()\n\t\t\t\t\n\t\telse:\n\t\t\tcontinue\nelse:\n\tif check(grid, n, m):\n\t\tprint('Solution exists.')\n\t\tprint(\"There are no jokers.\")\n\t\tans = get_ans(grid, n, m)\n\t\t\t\n\t\tprint('Put the first square to ' + '(' + str(ans[0][0] + 1) + ', ' + str(ans[0][1] + 1) + ').')\n\t\tprint('Put the second square to ' + '(' + str(ans[1][0] + 1) + ', ' + str(ans[1][1] + 1) + ').')\n\t\texit()\n\telse:\n\t\tpass\n\nprint(\"No solution.\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5857f2471548cf58ee656d3048f591f8", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split()) dignities = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] colors = ['C', 'D', 'H', 'S'] all_cards = [] for i in dignities: for j in colors: all_cards.append(i + j) my_cards = [[] for x in range(n)] joker1 = 0 joker2 = 0 for i in range(n): my_cards[i] = input().split() for j in range(m): if my_cards[i][j][1] == '1': joker1 = (i, j) elif my_cards[i][j][1] == '2': joker2 = (i, j) else: all_cards.remove(my_cards[i][j]) def intersect_segments(a, b, c, d): if a > b: a, b = b, a if c > d: c, d = d, c return a <= d and b >= c def intersect_squares(a, b): return intersect_segments(a[0], a[2], b[0], b[2]) and intersect_segments(a[1], a[3], b[1], b[3]) def suitable(cards, x, y): colors = set() dignities = set() for i in range(x, x + 3): for j in range(y, y + 3): colors.add(cards[i][j][1]) dignities.add(cards[i][j][0]) return len(colors) == 1 or len(dignities) == 9 def ok(cards, n, m): for a in range(n - 2): for b in range(m - 2): if suitable(cards, a, b): for c in range(n - 2): for d in range(m - 2): if not intersect_squares((a, b, a + 2, b + 2), (c, d, c + 2, d + 2)) and suitable(cards, c, d): return (a, b, c, d) return 0 for i in my_cards: for j in my_cards: if i != j: new_cards = my_cards if joker1 != 0: new_cards[joker1[0]][joker1[1]], i = i, new_cards[joker1[0]][joker1[1]] if joker2 != 0: new_cards[joker2[0]][joker2[1]], i = i, new_cards[joker2[0]][joker2[1]] if ok(new_cards, n, m): print('Solution exists.') if joker1 == 0 and joker2 == 0: print('There are no jokers.') elif joker1 != 0 and joker2 != 0: print('Replace J1 with %s and J2 with %s.' % (i[0] + i[1], j[0] + j[1])) elif joker1 != 0: print('Replace J1 with %s.' % (i[0] + i[1])) else: print('Replace J2 with %s.' % (j[0] + j[1])) tmp = ok(new_cards, n, m) print('Put the first square to (%d, %d).' % (tmp[0] + 1, tmp[1] + 1)) print('Put the second square to (%d, %d).' % (tmp[2] + 1, tmp[3] + 1)) quit() print('No solution.')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "32c2ed96b378cf20403b25513d77d151", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "__author__ = 'Darren'\n\n\ndef solve():\n from math import ceil\n x = abs(int(input()))\n k = ceil(((8 * x + 1) ** 0.5 - 1) / 2)\n location = k * (k + 1) // 2\n if location == x:\n print(k)\n elif ((location - x) + (k + 1)) % 2 == 0:\n print(k+1)\n else:\n print(k+2)\n\n\nif __name__ == '__main__':\n solve()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cc4212aef892019b78ff95f544d5cdfc", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def main():\n\tx = int(input())\n\tprint(jumps(x))\n\ndef jumps(n):\n\ti = 0\n\twhile True:\n\t\tproduct = i * (i + 1) // 2\n\t\tif product >= n and product % 2 == n % 2:\n\t\t\treturn i\n\t\ti += 1\n\n#print(jumps(6))\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e449b1fa0d7d8068c4a2cf191702838", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "pol = raw_input('')\npol = int(pol)\n\ntekPol = 0\nkol = 1\n\nwhile pol != tekPol:\n if (tekPol + kol) <= pol:\n tekPol = tekPol + kol\n else:\n tekPol = tekPol - kol\n\n kol = kol + 1\n\nkol = kol - 1\n\nprint kol\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "97d79ef6588ce5cf5d066c20537e8a16", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def _f(x):\n step = 0\n achieved = set([0])\n while x not in achieved and -x not in achieved:\n step += 1\n tmp = set()\n for cell in achieved:\n a = cell + step\n b = cell - step\n if b < 0: b *= -1\n tmp.add(a)\n tmp.add(b)\n achieved = tmp\n print achieved\n return step\n\ndef f(x):\n m = s = 0 if x%2 == 0 else 1\n while x > m or m%2 != x%2:\n s += 1\n m += s\n return s\n\nx = input()\nprint \"steps is %d\"%f(x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "128d3e9213b8b8f49b42d544635395f6", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": " a = abs(int(input()))\n b = 0\n while a > 0 or a & 1:\n b += 1\n a -= b\n print(b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "13781c93c1b183eed58de59bbdde5670", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#552C\n\nfrom math import *\n\nw,m = map(int, input().split())\narr =[]\np=1\nfor i in range(101):\n\tarr.append(p)\n\tp*=w\narr.reverse()\nfor i in range(101):\n\tval1 = m+arr[i]\n\tval2 = abs(m-arr[i])\n\tm = min(m, min(val1,val2))\nprint (\"YES\" if !m else \"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9566ae39c51d5c329c4256ed52280ce", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\n#define int long long\n\nconst int INF = 1e12;\n\nsigned main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n int w, n;\n cin >> w >> n;\n\n if (w == 2) {\n cout << \"YES\\n\";\n exit(0);\n } \n\n vector a, b;\n int curr = 1;\n\n\n for (int i = 0; i < 10; ++i) {\n \n if (INF / curr + 1 < w) break;\n } \n\n\n\n return 0;\n} ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38c428959521cd4d7344ff0412efb38a", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "w,m=map(int,input().split())\nwhile m:\n if 10):\n bit.append(k%w);\n k/=w;\nfor i in range(len(bit)):\n if(bit[i]==w-1):\n ct[i+1]+=1\n ct[i]-=1\n else:\n ct[i]+=bit[i]\nwhile(1):\n flag1=0\n flag2=0\n for i in range(101):\n if(ct[i]==0 or ct[i]==1 or ct[i]==-1 ):\n continue\n elif(ct[i]==w-1):\n ct[i]=-1\n ct[i+1]+=1\n flag1=1\n elif(ct[i]==1-w):\n ct[i]=1\n ct[i+1]-=1\n flag1=1\n else:\n flag2=1\n if(flag1==1): continue\n if(flag2==1):\n print 'NO'\n exit()\n break\nprint 'YES'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "06e2bf2180e5738027a1f4beb0dec9fc", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "y,x = map(int,raw_input().split())\nif y==2 || y ==3:\n print \"YES\"\n quit()\nwhile x != 0:\n u = x % y\n #print u\n if u != y - 1 and u != 0 and u != 1:\n print \"NO\"\n quit()\n if u == y - 1:\n x += 1\n else:\n x /=y\nprint \"YES\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "adf0453ff45f7495a479f39d138571b3", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": " a,b= map(int,input().split(' '))\n print(a+b)\n # im done for", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f71eec4f036c44ca926d9d3bd4f382e8", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "print(int(input())+int(input())", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3d401b57dd258a3a5dfab73c9067cf9", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "a=(int)a;\nb=(int)b;\na=input()\nb=input()\nprint(a + b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76a6df017ede3fa5fb8de328d9a2570a", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "int s = int(input());\nint s1 = int(input());\nprint(s+s1);", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2026c34fb52c945369110a51c1bce252", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "print (\"19\", end=\"\\n\\n\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "20af5000c12fec191143bde4a9f7e81d", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "a,ans,x=input(),-1,[]\nfor i in a:\n y=x[:]\n for t in y:\n m=t*10+int(i)\n if ceil(m**.5)==int(m**.5):\n if ans 0:\n\t\t\tif s[0]!='0':\n\t\t\t\tif int(x) in sx:\n\t\t\t\t\tans=min(ans,a.count(0))\n\telse:\n\t\tf(ii+1,a+[1])\n\t\tf(ii+1,a+[0])\n\n\ns=raw_input()\na=[]\ni=0\nf(i,a)\nif ans==10000000:\n\tprint -1\nelse:\n\tprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0bf6ff63394ca39a446a7ceee653124", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import numpy as np\n\nn=int(input())\n#n=606725\nif int(np.sqrt(n))==np.sqrt(n):\n print(0)\n\nelse:\n st=str(n)\n L=len(st)\n\n subs = []\n for i in range(len(st)):\n for j in range(i, len(st)):\n if st[i:j + 1][0] !=0:\n subs.append(st[i:j + 1])\n\n results=[]\n for x in subs:\n n=int(x)\n if int(np.sqrt(n)) == np.sqrt(n):\n results.append(L-len(x))\n\n if len(results) ==0:\n print(-1)\n else:\n print(min(results))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ddca89ee94ffe03333037a50318d501", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "s=input()\nimport math\ndef rec(s,lis):\n new=[]\n if(len(lis)!=0 and len(lis[0])==1):\n return -1\n elif(len(lis)==0):\n for i in range(len(s)):\n a=s[:i]+s[i+1:]\n if(math.sqrt(int(a))-int(math.sqrt(int(a)))==0 and a[0]!=\"0\"):\n return (len(s)-len(a))\n new.append(a)\n else:\n for j in range(len(lis)):\n k=lis[j]\n for i in range(len(k)):\n a=k[:i]+k[i+1:]\n if(math.sqrt(int(a))-int(math.sqrt(int(a)))==0 and a[0]!=\"0\"):\n return (len(s)-len(a))\n new.append(a)\n return rec(s,list(set(new)))\nlis=[]\nif(math.sqrt(int(s))-int(math.sqrt(int(s)))==0 and s[0]!=\"0\"):\n print(0)\nelse:\n ans=rec(s,lis)\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a4932469fa5cacce80de16676bf8b362", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "s = input()\nfor i in range(10**5, 0, -1):\n t, p = str(i * i)+'$', 0\n for x in s:\n if x == t[p]:\n p += 1\n if p == len(t)-1:\n res = min(res, len(s) - len(t)+1)\nelse\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cee8f932592d12d893dc17905dc45f67", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import math\nfrom collections import Counter\na = raw_input()\nb = raw_input()\nd = Counter((a.strip()))\ns = d['+'] - d['-']\nd = Counter(b.strip())\npos = d['?']\ns -= d['+'] - d['-']\nif pos == s:\n return 1\nelse:\n if (pos - math.abs(s)) % 2 == 0:\n return (math.factorial(pos)/(math.factorial((pos + s)/2) * math.factorial((pos - s)/2)))/(2 ** pos)\n else:\n return 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "239c57b926e9cde7dfe880c0fea400c1", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "whereToGo = 0\nfor correct in input():\n if correct = \"+\":\n whereToGo += 1\n else:\n whereToGo -= 1\nhey = input()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "38a76da007d44bc147a89118eae53eae", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "s = (raw_input(), raw_input())\np = map(lambda x: x.count('+') - x.count('-'), s)\nk = s[1].count('?')\n\nif not k:\n print 1.0\n exit()\nelif k < abs(p[0] - p[1]):\n print 0.0\n exit()\n\nf = [[0] * (2 * k + 1) for _ in xrange(k)]\nf[0][1] = f[0][-1] = 0.5\n\nfor i in xrange(1, k):\n for j in xrange(-k, k + 1):\n f[i][j] = 0.5 * f[i - 1][j + 1] + 0.5 * f[i - 1][j - 1]\n\nprint '%1.12f'f[k - 1][p[0] - p[1]]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ab10d5363087d884a89962435cfb424", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\n\ndef ncr(n,r):\n\treturn(fact(n)/(fact(r)*fact(n-r)))\ndef fact(n):\n\tres=1\n\tfor i in range(2,n+1):\n\t\tres=res*i\n\treturn res\n\nl1=list(input())\nl2=list(input())\nc1=0\nc2=0\nc3=0\nfor k in range(len(l1)):\n\tif(l1[k]=='+'):\n\t\tc1+=1\n\tif(l2[k]=='+'):\n\t\tc2+=1\n\tif(l2[k]=='?'):\n\t\tc3+=1\na=c1-c2\n\nif(c3>=a):\n\ta1=ncr(c3,a)\n\tprint(a1/(2**c3)\nelse:\n\tprint(0/(2**c3))\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "123cc325630f84dee39f411ea07b69c2", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "//WeirdBugsButOkay\n\ns = input()\nt = input()\n\nunk = 0\nacp = 0\ncp = 0\nfor i in range (0,len(s)) :\n if t[i] == '?' :\n unk += 1\n elif t[i] == '+' :\n acp += 1\n else :\n acp -= 1\n if s[i] == '+' :\n cp += 1\n else :\n cp -= 1\nans = 0\nif cp - unk > acp or cp + unk < acp :\n print('%0.11f'%0)\nelif unk == 0 :\n if cp == acp :\n print('%0.11f'%1)\n else :\n print('%0.11f'%0)\nelse :\n ct = cp - acp\n if ct % 2 != 0 :\n print('%0.11f'%0)\n else :\n cnt = (ct + unk) // 2\n ncr = 1\n for i in range (0, cnt) :\n ncr *= (unk - i)\n ncr //= (i + 1)\n ans = ncr\n ans /= (2**unk)\n print('%0.11f'%ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1aa94b1b1063fa95bdc6f3f7c18443cf", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "string=str(input())\ns=len(string)\nk=int(input())\n\ndef tandemcheck(n):\n\tif len(n)%2==1:\n\t\treturn False\n\telse:\n\t\tif n[:len(n)//2]==n[len(n)//2:]:\n\t\t\treturn True\n\t\telse:\n\t\t\treturn False\n\nif s<=k:\n\tif (s+k)%2==0:\n\t\tprint(s+k)\n\telse:\n\t\tprint(s+k-1)\nelse:\n\tif 2*k>=s:\n\t\tmax=2*k\n\t\tfor i in range(1,int(s/2)):\n\t\t\tif string.count(string[-i:])>1:\n\t\t\t\tif max<(s-string.index(string[-i:])-i)*2:\n\t\t\t\t\tmax=(s-string.index(string[-i:])-i)*2\n\t\tprint(max)\n\telse:\n\t\tmaxs=0\n\t\tfor i in range(0,s-1):\n\t\t\tfor j in range(i,s):\n\t\t\t\tif tandemcheck(string[i:j+1]):\n\t\t\t\t\tmaxs=max(maxs,len(string[i:j+1])\n\t\tmaxboth=2*k\n\t\tfor i in range(1,int(s/2)):\n\t\t\tif string.count(string[-i:])>1:\n\t\t\t\tif maxboth<(s-string.index(string[-i:])-i)*2:\n\t\t\t\t\tmaxboth=(s-string.index(string[-i:])-i)*2\n\t\tprint(max(maxs,maxboth))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d2709c3d7fa4178ad9b2a2b8406748d1", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "s = raw_input()\nk = raw_input()\n\nsm = len(s) + k\nmx = sm if sm % 2 == 0 else sm - 1\n# cntr = mx / 2\nddone = False\nwhile mx > 0:\n strt = 0\n cntr = mx / 2\n while strt + mx <= sm:\n step = strt + cntr\n for i in range(strt, strt + step):\n j = i + step\n if i < len(s):\n if j < len(s):\n if s[i] == s[j]:\n pass # great\n else: # s[i] != s[j]\n break\n else: # j > len(s)\n pass # we can add here what we want\n ddone = True\n strt += 1\n if ddone:\n print mx\n break\n mx -= 2\n # cntr /= 2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1912fa447fef4a3e37f05921860d766a", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import sys\nfin=open('F:/OJ/OJ/in.txt','r')\nsys.stdin=fin\n\nstr=input()\nk=int(input())\nans=0\nif(k>=len(str)):\n print((k+len(str))//2)\n exit()\nfor i in range(len(str)):\n for j in range(0,i+1):\n len1=len(str[j:i+1])\n len2=len(str[i+1:])\n minn=min(len1,len2)\n #print( i,j)\n #print(len1,len2)\n if(str[j:j+minn]==str[i+1:i+1+minn]):\n if(minn==len1):\n ans=max(ans,len1*2)\n elif(k+len2>=len1):\n ans=max(ans,len1*2)\n \nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "819672855da63a2a0e8f8713cceb7cd7", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "s = raw_input()\nk = raw_input()\nk1 = ''\nfor i in range(k):\n k1 += '1'\ns = s + k1\n\ndef sravn(s):\n for i in xrange(len(s)/2):\n if s[i] != s[i+len(s)/2] and s[i+len(s)/2] != '1':\n return 'no'\n return 'yes'\n\nl = len(s)/2*2\nwhile l >= 2:\n for i in range(len(s)-l+1):\n t = sravn(s[i:l])\n if t == 'yes':\n print l\n else:\n l -= 2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7fe675fdabb04b44ac06390ecad085cb", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import sys\nfrom time import time\n\nline=sys.stdin.readline().strip('\\n')\nk=int(sys.stdin.readline().strip('\\n'))\n\ndef isRepeat(inp):\n if len(inp)%2==1:\n return False\n else:\n for i in xrange(0,len(inp)/2):\n if inp[i]!=inp[i+len(inp)/2]:\n return False\n return True\n\n \ndef findTandemRepeat(inp):\n remove=0\n while(remove 1:\n return 0\n\n if i < 0:\n return 1\n\n return i\n\ndef swap(a, ia, ja, ib, jb):\n t = a[ia][ja]\n a[ia][ja] = a[ib][jb]\n a[ib][jb] = t\n\nimport copy\n\ndef dfs(a, seen):\n seen.append(a)\n for i in range(2):\n for j in range(2):\n if a[i][j] != 'X':\n continue\n\n acp = copy.deepcopy(a)\n swap(acp, i, j, idx(i+1), j)\n if acp not in seen:\n dfs(acp, seen)\n swap(acp, i, j, idx(i+1), j)\n\n swap(acp, i, j, i, idx(j+1))\n if acp not in seen:\n dfs(acp, seen)\n swap(acp, i, j, i, idx(j+1))\n\n return seen\n\ndef main():\n for j in range(2):\n # print j\n if j == 0:\n s1, s2 = raw_input(), raw_input()\n a[0][0] = s1[0]\n a[0][1] = s1[1]\n a[1][0] = s2[0]\n a[1][1] = s2[1]\n\n if j == 1:\n s1, s2 = raw_input(), raw_input()\n b[0][0] = s1[0]\n b[0][1] = s1[1]\n b[1][0] = s2[0]\n b[1][1] = s2[1]\n\n # print a, b\n arr = dfs(a, [])\n\n if b in arr:\n print \"YES\"\n else:\n print \"NO\"\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48a29b4c417999132e8e62e93822c0da", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "def ayy(b1, b2):\n b1 = b1.replace(\"X\",\"\")\n b2 = b2.replace(\"X\",\"\")\n #moves string through cycle\n if b1 == b2:\n print \"YES\"\n elif b1[1:]+b1[0] == b2:\n print \"YES\"\n elif b1[2]+b1[:2] == b2:\n print \"YES\"\n else:\n print \"NO\"\n\ndef go():\n s = \"\"\n sentinel = '' # ends when this string is seen\n for line in iter(raw_input, sentinel):\n s += (line + \"\\n\")\n s = s[:len(s)-1]\n A = s.split(\"\\n\")\n b1 = A[0]+A[1][1]+A[1][0]\n b2 = A[2]+A[3][1]+A[3][0]\n #gets clockwise motion of the strings \n ayy(b1,b2)\n\ngo()\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "41229cfd6638408fb80150f4a8fbd5f9", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "str1 = raw_input();\nstr2 = raw_input();\nlist1= []\nlist1.append(str1[0])\nlist1.append(str1[1])\nlist1.append(str2[1])\nlist1.append(str2[0])\nfor i in xrange(4):\n if list1[i] == 'X':\n del list1[i]\nstr1 = raw_input();\nstr2 = raw_input();\nlist2= []\nlist2.append(str1[0])\nlist2.append(str1[1])\nlist2.append(str2[1])\nlist2.append(str2[0])\nfor i in xrange(4):\n if list2[i] == 'X':\n del list2[i]\n break\nfor i in xrange(3):\n if list1[0] != list2[0]:\n temp = list1[0]\n del list1[0]\n list1.append(temp);\nif list1[0] == list2[0] and list1[1] == list2[1]:\n print 'YES'\nelse:\n print 'NO'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "693953312b608dc2c35db37b7faa255e", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "a=input()\nb=input()\nc=input()\nd=input()\n\nif (a[0] == 'X'):\n s1 = a[1]+b\nif (a[1] == 'X'):\n s1 = b[1]+b[0]+a[0]\nif (b[0] == 'X'):\n s1 = a + b[1]\nif (b[1] == 'X'):\n s1 = a + b[0]\n\nif (c[0] == 'X'):\n s2 = c[1]+d\nif (c[1] == 'X'):\n s2 = d[1]+d[0]+c[0]\nif (d[0] == 'X'):\n s2 = c + d[1]\nif (d[1] == 'X'):\n s2 = c + d[0]\ns1=s1+s1\n\nfor i in range(0,len(s1)):\n if(s1[i] == s2[0]):\n if((s1[i+1] == s2[1]) and (s1[i+2] == s2[2])):\n print(\"YES\")\n break\n else:\n print(\"NO\")\n break\na=input()\nb=input()\nc=input()\nd=input()\n\nif (a[0] == 'X'):\n s1 = a[1]+b[1]+b[0]\nif (a[1] == 'X'):\n s1 = b[1]+b[0]+a[0]\nif (b[0] == 'X'):\n s1 = a + b[1]\nif (b[1] == 'X'):\n s1 = a + b[0]\n#print(s1)\n\nif (c[0] == 'X'):\n s2 = c[1]+d[1]+d[0]\nif (c[1] == 'X'):\n s2 = d[1]+d[0]+c[0]\nif (d[0] == 'X'):\n s2 = c + d[1]\nif (d[1] == 'X'):\n s2 = c + d[0]\n#print(s2)\n\ns1=s1+s1\n\nfor i in range(0,len(s1)):\n if(s1[i] == s2[0]):\n if((s1[i+1] == s2[1]) and (s1[i+2] == s2[2])):\n print(\"YES\")\n break\n else:\n print(\"NO\")\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fefaf722129f0bf9af182aa1c1667971", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "l=[]\nfor i in range(2):\n r=list(input()+input())\n while r[0]!=\"A\":r[0],r[1],r[2]=r[2],r[0],r[1]\n r.remove(\"X\");l.append(\"\".join(r))\nprint(\"YES\"if l[0]==l[1]else\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7c4c0d750e3fe2bfdf3d4989ba0520fa", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nfor i in range(int(sqrt(n), n+1):\n if n % i == 0:\n print(n/i, i)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a3aa31348dc4393501970d224957dd2c", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\n\ndef is_square(n):\n sqrt = math.sqrt(n)\n return (sqrt - int(sqrt)) == 0\n\n \npixel = int(input())\n\n\nif is_square(pixel): result = (int(math.sqrt(self.pixel)),int(math.sqrt(self.pixel)))\nelse:\n lista =[]\n for i in range(1, pixel+1):\n if pixel%i == 0 :lista.append(i)\n pivot = int(len(lista)/2)-1\n row = lista[pivot]\n column = lista[pivot+1]\n result = (row,column)\n\n priint(f\"{' '.join(map(str,result))}\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f61bdc0c9f1a94507fc92702589f0f39", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\n\nn = int(input())\n\na = 1\nb = n\n\nm=int(math.sqrt(n))\n\nfor i in range(1, m+1):\n\n x = i\n if n % x == 0:\n y = n // x\n if b - a > y - x:\n a = x\n b = y\n\nprint(a, b)\n/*\n#include\nusing namespace std;\nint main()\n{\n vectorarr;\n vectorbrr;\n int n;\n cin>>n;\n for(int i=1;i<=n;i++){\n for(int j=1;j<=n;j++){\n if(i*j==n)\n {\n arr.push_back(i);\n arr.push_back(j);\n }\n }\n }\n /*for(int i=0;i= sqrt(n):\n print(n/i, i)\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b2a9ee6c3f463146e53b2292cfbb263", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nn1=a//3\nn2=b//2\nn3=c//2\nr=min(n1,n2,n3)\na-=r*3\nb-=r*2\nc-=r*2\nd={}\nl=['f','r','c','f','c','r','f']\nif a>=b and a>=c:\n\tif b>c and a>b+1:\n\t\tk=5\n\telif b>=c and ab and a>c+1:\n\t\tk=6\n\telif c>b and a<=c+1:\n\t\tk=0\nelse:\n\tif b>=c:\n\t\tk=4\n\telse:\n\t\tk=1\nd['f']=a\nd['r']=b\nd['c']=c\ncount=0\nfor i in range(k,k+7):\n\te=i%7\n\n\tif d[l[e]]>0:\n\t\td[l[e]]-=1\n\t\tcount+=1\n\telse:\n\t\tbreak\n\n\nprint(count+r*7)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78f317025b7a3edbdec7648e34aae065", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nd=a\ne=b\nf=c\na//=3\nb//=2\nc//=2\nm=min(a,b,c)\na=d-3*m\nb=e-2*m\nc=f-2*m\nif a>3:a=3\nif b>2:b=2\nif c>2:c=2\nnd=m*7\nli=[[\"011\",\"122\",\"122\"],[\"123\",\"234\",\"235\"],[\"223\",\"345\",\"456\"],[\"223\",\"356\",\"45\"]]\nnd+=int(li[a][b][c])\nprint(nd)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "683e79ad62ad1f769b28d39c41216d66", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a, b, c = map(int, input().split())\n\nD = min(a // 3, b // 2, c // 2)\nA, B, C = a - 3 * D, b - 2 * D, c - 2 * D\n\nans = D * 7\n\nif A == 0 and C == 0 and B == 0:\n print(ans)\n\nelif C == 0 and B == 0:\n if A == 1:\n print(ans + 1)\n else:\n print(ans + 2)\n\nelif C == 0:\n if B == 1 and A == 1:\n print(ans + 2)\n elif B == 1 and A >= 2:\n print(ans + 3)\n elif B == 1 and A == 0:\n print(ans + 1)\n elif A == 0:\n print(ans + 1)\n elif A == 1:\n print(ans + 2)\n else:\n print(ans + 4)\nelif C == 1:\n if B == 1:\n if A == 1:\n print(ans + 3)\n elif A == 0:\n print(ans + 2)\n else:\n print(ans + 4)\n\n elif B== 0:\n if A == 0:\n print(ans)\n elif A == 1:\n print(ans + 2)\n else:\n print(ans + 2)\n else:\n if A == 0:\n print(ans + 2)\n elif A == 1:\n print(ans + 3)\n\n else:\n print(ans + 5)\nelse:\n if B == 0:\n if A == 0:\n print(ans + 1)\n elif A == 1:\n print(ans + 2)\n else:\n print(ans + 3)\n if B == 1:\n if A == 0:\n print(ans + 2)\n elif A == 1:\n print(ans + 4)\n elif A == 2:\n print(ans + 5)\n else:\n print(ans + 6)\n else:\n if A == 0:\n print(ans + 2)\n elif A == 1:\n print(ans + 5)\n elif A == 2:\n print(ans + 6)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "737a5fa1cace4c86b918a0fff56a339e", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Codeforces Round #552 (Div. 3)\n\nProblem C. Gourmet Cat\n\n:author: Kitchen Tong\n:mail: kctong529@gmail.com\n\nPlease feel free to contact me if you have any question\nregarding the implementation below.\n\"\"\"\n\n__version__ = '0.1'\n__date__ = '2019-04-16'\n\nimport sys\n\n\ndef count_days(a, b, c):\n weeks = min(a // 3, b // 2, c // 2)\n a -= weeks * 3\n b -= weeks * 2\n c -= weeks * 2\n if a == 0:\n if b > 0:\n if c > 0:\n return weeks * 7 + 2\n else:\n return weeks * 7 + 1\n elif c > 0:\n return weeks * 7 + 1\n elif a == 1:\n if c > 1:\n return weeks * 7 + 3 + min(2, b)\n else:\n return weeks * 7 + 1 + min(1, b) + min(1, c)\n elif a == 2:\n if b > 0:\n if b > 1:\n return weeks * 7 + 2 + min(2, c)\n else:\n if c > 0:\n return weeks * 7 + 4\n else:\n return weeks * 7 + 2\n else:\n if c == 0:\n return weeks * 7 + 2 + min(2, b)\n else:\n if c > 1:\n return weeks * 7 + 3\n else:\n return weeks * 7 + 2\n return weeks * 7\n\ndef main(argv=None):\n a, b, c = map(int, input().split())\n print(count_days(a, b, c))\n return 0\n\nif __name__ == \"__main__\":\n STATUS = main()\n sys.exit(STATUS)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b63a166c036140f1b90ea0ce7c0cc28b", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "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 += 3\n elif b==1 and c==0:\n days += 3\n elif b==1 and c==1:\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 += 3\n elif b==1 and c==0:\n days += 3\n elif b==1 and c==1:\n days += 4\n\nelif a==1:\n if b==0 and c==0:\n days += 1\n elif b==0 and c==1:\n days += 2\n elif b==1 and c==0:\n days += 2\n elif b==1 and c==1:\n days += 3\n\nelif a==0:\n if b==0 and c==0:\n days += 0\n elif b==0 and c==1:\n days += 1\n elif b==1 and c==0:\n days += 1\n elif b==1 and c==1:\n days += 2\n\nprint(days)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dfbe2d1b0feea9dbe64b408e0dc6eda2", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n=input()\nif n == 0: \n\tprint 0\nelse:\n\tprint 3**(n-1)%(10**6\u2009+\u20093)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e7a08528dcb2d81f37eb162bdcf0696", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "Python 2", "source_code": " print pow(3, max(input() - 1, 0), 1000003)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c11e4ca0f96488cfae9169a178e7e719", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "\nprint max(3**(input()-1))%1000003,1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2e276f437277140f4b96aeab12df2c93", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(pow(3,n)-1,pow(10,6)+3) if n > 0 else 0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "01776664da803d6dd1308f22c008fa62", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "\ufeffn = input()\ne = 1\ns = 1\n\nwhile e < n:\n\ts := s * 3\n\te := e + 1\n\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a1118a8283b3ebc9410a2ad38f57470", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n,m = map(int, input().split())\nl = list(map(int, input().split()))\nc = 0\ni = 0\ns = 0\nwhile i m):\n\t\tsums = ar[i]\n\t\tcount += 1\nprint(count)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "80c5b290700d6087bd1ab7b7e2a0f2e6", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "# \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0441\u043f\u0430\u0442\u044c\u0441\u044f \ndef main():\n n, m = map(int, raw_input().split())\n a_arr = map(int, raw_input().split())\n result = set()\n for i, a_i in enumerate(a_arr):\n tmp = m - a_i\n j = i + 1\n if tmp != 0:\n while j < len(a_arr) and tmp != 0:\n if a_arr[j] <= tmp:\n tmp -= a_arr[j]\n j += 1\n else:\n break\n result.add(j)\n print len(result)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c120b0c5360a116f723dd94c80ec734", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n, m = map(int,input().split())\na = list(map(int,input().split()))\nb = 0\nturn = 0\nfor i in range(n):\n turn += a[i]\n if turn >= m :\n b += 1\n turn = a[i]\nif a[-1] + a[-2] > m :\n b += 1\nprint(b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec57730da6dbbaddd7dada505f79cdba", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a,b=[int(i) for i in input().split()]\ns=[int(i) for i in input()split()]\nm=0\nc=b\nfor i in range(a):\n if s[i]>c:\n m=m+1\n c=b\n else:\n c=c-s[i]\nprint(m)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "511bc0d58fd3dac67b7380ab019a4637", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "def function(n, nums):\n odd_pair_count=0\n odd_count1=0\n odd_count2=0\n for j in range(n):\n condition=True\n if nums[j][0]%2!=0 and nums[j][-1]%2!=0:\n odd_pair_count+=1\n if nums[j][0]%2!=0:\n odd_count1+=1\n if nums[j][-1] % 2 != 0\n odd_count2+=1\n if (odd_count1 + odd_count2) % 2 != 0:\n return -1\n if (odd_count1+odd_count2)%2==0:\n if odd_pair_count*2-(odd_count1+odd_count2)==0:\n return -1\n if odd_count1%2==0 and odd_count1==odd_count2:\n return 0\n return 1\n\nif __name__==\"__main__\":\n n=int(input())\n nums=[]\n for i in range(n):\n nums.append(list(map(int, input().rstrip().split())))\n print(function(n, nums))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "004acd6c9c0361489e906f9c47b21449", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\nx,y,z = [0]*3\nfor i in range(n):\n a,b = input().split()\n x += int(a)\n y += int(b)\n z += (int(a)+int(b))%2\nprint ((-1,(0,(-1,1)[z>0])[y%2])[x%2==y%2])\n\u2192Judgement Protocol", "lang_cluster": "Python", "compilation_error": true, "code_uid": "60a9c83a70179cb83e2ddf0cfb7948e9", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "# \u0417\u0434\u0435\u0441\u044c \u0434\u0435\u043b\u0430\u044e \u0447\u0435\u0440\u0435\u0437 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 [[x1,y1],[x2,y2],[xi,yi]]. \u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e \u0432 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u044e \u0432 \u0441\u043f\u0438\u0441\u043a\u0438.\n# \u0421\u0447\u0438\u0442\u0430\u044e \u0441\u0443\u043c\u043c\u0443 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u043a = upper . \u0417\u0430\u0442\u0435\u043c \u043d\u0438\u0436\u043d\u0438\u0445 = lower. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0435\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\n# \u041a\u043e\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0438\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u043a\u043e\u0441\u0442\u044c - \u0432\u044b\u0432\u043e\u0434\u0438 \u0441\u043e\u043e\u0442. \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u0441\u0435.\n# \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c. \u0427\u0435\u0440\u0435\u0437 for...in \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0441\u0442\u044c \u0438\u0437 \u0440\u044f\u0434\u0430 ( \u0442.\u0435. \u0441\u043f\u0438\u0441\u043e\u043a[xi,xi]), \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \n# \u0444\u0443\u043d\u043a\u0446\u0438\u0438 check_parity \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 upper \u0438 lower, \u0438 \u0438\u0445 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c.\u0412 \u0446\u0438\u043a\u043b\u0435 \u0435\u0441\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a(count)-\u043a\u043e\u043b-\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043a\u043e\u0441\u0442\u0435\u0439.\n# \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e - \u0432\u044b\u0432\u043e\u0434\u0438\u043c 1, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0441\u043b\u0435\u0434. \u043a\u043e\u0441\u0442\u044c \u0438 \u0441\u043d\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e... \n# \u0412 \u043a\u043e\u043d\u0446\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c, \u0438 \u043a\u043e\u043b-\u0432\u043e \u043a\u043e\u0441\u0442\u0435\u0439(n) \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430(count)\n# \u0442.\u0435. n=count, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c -1\n\nFlag= True # \u0434\u043b\u044f \u0432\u0435\u0447\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 while. \u041e\u043d \u043d\u0438\u0436\u0435\nupper = 0 # \u0441\u0443\u043c\u043c\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u043a\nlower = 0 # \u0441\u0443\u043c\u043c\u0430 \u043d\u0438\u0436\u043d\u0438\u0445 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u043a\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#print(Row_of_bones)\n#print(Row_of_bones[1][1])\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\t#print(\"\u0410\u043f\u043f \u0438 \u043b\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0441\u043c\u0435\u043d\u044b \u043a\u043e\u0441\u0442\u0438 = \", upp, \" \" ,low) # \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n\t\treturn True\n\telse:\n\t\treturn False\n\nfor i in Row_of_bones: # \u0421\u0447\u0438\u0442\u0430\u044e \u0432\u0435\u0440\u0445\u043d\u0438\u044e \u0438 \u043d\u0438\u0436\u043d\u0438\u044e \u0441\u0443\u043c\u043c\u0443. \u0412 i \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0441\u0442\u044c [xi,yi] \u0438\u0437 \u0440\u044f\u0434\u0430\n\tupper += i[0]\n\tlower += i[1]\n\t\n#print(\"\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043f \u0438 \u043b\u043e\u0432 = \",upper,\" \",lower) # \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n\n\nwhile(Flag): # \u0411\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u0433\u0434\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0430\u0437 \u0438 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u0435\u043c\n\tif (upper % 2 == 0) and (lower % 2 == 0): #\u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e\n\t\tprint(0)\n\t\tbreak\n\telif (n == 1):\n\t\tprint(-1)\n\t\tbreak\n\telse:\n\t\tcount = 0 # \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439\n\t\tfor i in Row_of_bones:\n\t\t\ti[0],i[1] = i[1], i[0] # \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u0435\u0437 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0442\u043e\u043d\u0430\n\t\t\tcount+=1\n\t\t\tif (check_parity()): # \u041f\u043e\u0441\u043b\u0435 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \u0447\u0435\u0442\u043d\u043e\u0441\u0442\u044c\n\t\t\t\tprint(1) # \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e - \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 break'\u0438 \n\t\t\t\tbreak\n\t\tif count == n: # \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u0441\u0442\u0435\u0439, \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0438, \u0442\u043e \u0435\u0441\u0442\u044c n == count\n\t\t\tprint(-1) \n\t\tbreak\t\t\n# \u0425\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0441\u0442\u0438 - \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u0411\u0435\u0440\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u043a\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c.\u0417\u0430\u0442\u0435\u043c \u0432\u0442\u043e\u0440\u0443\u044e\n# \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0418 \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f \u043d\u0430 \u0447\u0443\u0434\u043e :) \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\n#\u041f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435, \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b \u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\n#\u0412\u0445\u043e\u0434\u043d\u044b\u0435: 3 4\t\t\t5\n# 1 2 1 3\t\t 1 3\n# 3 3 4 1\t\t 4 1 \n# 6 4 5 6\t\t 2 3\n# 2 3\t\t 6 5\n#\t\t\t\t\t\t\t\t\t\t 3 4\n#\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435: -1 -1 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "facb448ee688094079fe755a0e386b9a", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "t = int(input())\ni=0\nl =[]\nu = []\nans= False\nfor _ in range(t):\n n = list(map(int, input().split()))\n l.append(n[1])\n u.append(n[0])\n if n[1]%2 != n[0]%2:\n ans = True\nif sum(l)%2==0 and sum(u)%2==0:\n print(\"0\")\nelif sum(l)%21=sum(u)%2:\n print(\"-1\")\nelse:\n if ans:\n print(\"1\")\n else:\n print(\"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a4143fe597678b5df5e13a5fe6b201d4", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=input()\nF=0\nfor i in range(n):\n a,b=input()\n if abs(a-b)==1:\n F=1\n\n suma=suma+a\n sumb=sumb+b\n\nif suma%2==0 and sumb%2==0:\n print 0\nelif suma%2==1 and sumb%2==1:\n if F==1\n print 1\n else:\n print -1\nelse:\n print -1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a41d76df5c96ad22805d73c0027df17", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "\ndef IsPrime(n):\n d = 2\n if n != 1:\n while n % d != 0:\n d += 1\n return d == n\n\n\np = False\nn, m, k = [int(i) for i in input().split()]\n\nif m==2 and k==1 :\n if n%2!=0:\n print('Timur')\n else:print('Marsel')\n quit()\nif k!=1:\n for i in range(m // 2, k - 1, -1):\n if m % i == 0:\n p = True\nif p==False and k!=1:\n print('Marsel')\n quit()\nif IsPrime(m):\n print('Marsel')\nelif k >= m:\n print('Marsel')\nelif m % 2 == 0 or m % 2 != 0:\n if n % 2 != 0:\n print('Timur')\n else:\n print('Marsel')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d03d62136cfc7180a781164c2daf6be7", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def max_divisor(n):\n m = n / 2\n while m > 1:\n\tif n % m == 0:\n\t return m\n\tm -= 1\n return 1\n\ndef solve(n, m, k):\n if n % 2 == 0:\n\treturn False\n elif max_divisor(m) >= k:\n\tif m == 1:\n\t return False\n\telse:\n\t return True\n return False\n\ndef main():\n n, m, k = map(int, raw_input().split())\n if solve(n, m, k):\n\tprint \"Timur\"\n else:\n\tprint \"Marsel\"\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7b9bfe4b50df2d0c127a8ba49faf9ed0", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "def can(n, m, k):\n if n % 2 == 0:\n return False\n d = 1\n while d*d <= m:\n if m % d == 0 and (d in range(k, m) or m/d in range(k, m)):\n return True\n d += 1\n return False\n\nn, m, k = map(int, input().split(' '))\nprint ('Timur' if can(n, m, k) else 'Marsel')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5558c70bf68ec3a882001e61d72bb093", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\nnn,mm,kk=[int(i) for i in input().split()]\nif nn%2==0:\n print('Marsel')\n exit(0)\n\ndef get_ls(n):\n result = []\n i = 2\n while i < n:\n if n % i == 0:\n n /= i\n result.append(i)\n else:\n i += 1\n result.append(int(n))\n return result\n\n#print(mm)\nif mm%499999993==0:\n mm=mm//499999993\n ls = get_ls(mm)\n ls.append(499999993)\n mm*=499999993\nelse:\n ls = get_ls(mm)\n#print(ls)\nkkk = dict(Counter(ls)).items()\nd = [k for k, _ in kkk]\nm = [v for _, v in kkk]\nk = [0 for _ in range(len(set(ls)))]\nln = range(len(m))\ndels=[]\ntry:\n while True:\n r = 1\n for i1, i2 in zip(d, k):\n r *= i1 ** i2\n dels.append(r)\n\n k[0] += 1\n for i in ln:\n if k[i] > m[i]:\n k[i] = 0\n k[i+1] += 1\nexcept IndexError:\n pass\nfor i in dels:\n #print(i,kk,mm)\n if kk<=i=k or m/i>=k:\n return True\n return False\ndef func_1(m,k):\n for i in range(k,m):\n if not m%i:\n return True\n return False\nif func_1(m,k):\n p=n\nelse :\n p=0\nif p%2==0:\n print('Marsel')\nelse :\n print('Timur')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e6db8ebf8313395d5561c9ac5bee0ffc", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "\n#code\nn = int(input())\ns = input()\nfl = True\ndp = [1]*n\nfor i in range(1,n):\n for j in range(i):\n if s[j] > s[i]:\n dp[i] = max(dp[i],1+dp[j])\nfor i in dp:\n if i>=3:\n fl = False\n break\nif not fl:\n print(\"NO\")\nelse:\n ans = \"0\"\n prev = s[0]\n for i in range(1,n):\n if s[i]<= prev:\n ans += \"1\"\n else:\n ans += \"0\"\n prev = s[i]\n print(\"YES\")\n print(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "58558a686e4fe05d654230b58eb0c4e8", "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n=int(input())\na=input()\nref={chr(i+97):[] for i in range(26)}\nvis=[0]*n\nhigh=a[0]\nfor i in range(1,n):\n if(a[i]>=high):\n high=a[i]\n continue\n ref[a[i]].append(i)\nflag=0\nmi=-1\nfor i in ref.keys():\n for j in ref[i]:\n if(mi\nusing namespace std;\n int main(){\n int n;\n cin>>n;\n string s=\"\";\n for(i=1;i<=1000;i++){\n s=s+char(i);\n }\n cout<\n#include\nint main()\n{\n char s[5000];\n int n;\n scanf(\"%d\",&n);\n for (int i=1;i<=400;i++)\n sprintf(s,\"%s%d\",s,i);\n \n \n printf(\"%c\",s[n]);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29af38598c6cb64f642197335b1ae8a6", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "import math\nc = map(int, raw_input.split())\na = c[0]\nb = c[1]\nif a == b:\n print 0\nelse:\n d = a ^ b\n e = math.log(d, 2) + 1\n print 2**int(e) - 1\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd176cd117d9c791403271e5e0957b7e", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "l,r = map(int, raw_input().split())\n\ndef maxXor(low, high):\n highestPower = high.bit_length()-1\n if highestPower == 0:\n return 0\n if low < 2** highestPower:\n return (2**(highestPower+1))-1\n return maxXor(low >> 2, high >> 2)\n\nprint(maxXor(l,r))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c8426a0a3aeb60edcf8e69894239241", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "l, r = map(int, input().split())\nprint(2**(a ^ b).bit_length() -1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b5c703a97397f829aacd1d0197df5fd5", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from math import *\n#a,b = map(int,raw_input().split())\ndef f1(a,b):\n if a==b:\n return a^a\n minp,maxp = int(log(a,2)),int(log(b,2))\n #print(2**minp,2**maxp)\n if a<2**maxp<=b:\n return (2**maxp)^(2**maxp-1)\n else:\n if b==a+1:\n return a^b\n # if 2**minp==a:\n # return 2**(minp-1)-1\n if maxp==minp:maxp+=1\n l = 2**minp\n ans = 0\n for i in range(minp-1,0,-1):\n if l+2**i<=b:\n l += 2**i\n ans=max(ans,l^(l-1))\n return ans\n\ndef f2(a,b):\n a2 = 0\n for i in range(a,b+1):\n for j in range(a,b+1):\n if i^j>a2:\n a2=i^j\n return a2\n\n a,b = map(int,raw_input().split())\n print(f1(a,b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2b8ee1b05407e93d225a4cb7e1bd7386", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "l,r = [int(x) for x in raw_input().split(\" \")]\n\nif l==r:\n\treturn 0\nelse:\n\tprint -1+(1<<(len('{0:b}'.format(l^r))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f439e61ae7542aa85e4c12db3db63e50", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nps = map(lambda x: int(x) - 1, raw_input().split())\n\n\nshortest_paths = [None] * n\nvertex_left = n\n\ndef dfs():\n global vertex_left\n visited = []\n queue = [(0, -1)]\n while queue:\n vtx, prev_steps = queue.pop(0)\n if vtx in visited:\n continue\n visited.append(vtx)\n shortest_paths[vtx] = prev_steps + 1\n vertex_left -= 1\n if vertex_left == 0:\n return\n nei = filter(lambda x: x != vtx and 0 <= x < n, [vtx - 1, vtx + 1, ps[vtx]])\n queue.extend((v, prev_steps + 1) for v in nei if v not in visited)\n\ndfs()\nprint ' '.join(map(str, shortest_paths))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18be75108709163a1bdcef1e91ec8d98", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import sys\nsp1 = ['1','4','7']\nsp2 = ['1','2','3']\nsp3 = ['3','6','9']\nsp4 = ['7','0','9']\nn = int(input())\ns = input()\nfor i in sp1:\n if i in s:\n if 0 in s:\n print('YES')\n sys.exit(0) \n for j in sp2:\n if j in s:\n for k in sp3:\n if k in s:\n for t in sp4:\n if t in s:\n print('YES')\n sys.exit(0)\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b28d12246649acc545fd17d674ace30", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import sys\nread=lambda:sys.stdin.readline().rstrip()\nreadi=lambda:int(sys.stdin.readline())\nwriteln=lambda x:sys.stdout.write(str(x)+\"\\n\")\nwrite=lambda x:sys.stdout.write(x)\ndef solve(memory, N):\n if N == 1:\n return \"YES\"\n pad=[[-1]*7 for _ in range(8)]\n n = 1\n npos = [[-1,-1]]*10\n for i in range(2, 5):\n for j in range(2, 5):\n pad[i][j] = n\n npos[n] = (i, j)\n n += 1\n pad[5][3] = 0\n npos[0] = (5, 3)\n vecs = []\n sy, sx = npos[int(memory[0])]\n for i in range(N-1):\n y, x = npos[int(memory[i])]\n ny, nx = npos[int(memory[i+1])]\n vecs.append((ny-y, nx-x))\n\n for i in range(2, 5):\n for j in range(2, 5):\n if (sy, sx) == (i, j):\n continue \n y, x = i, j\n for t in range(N-1):\n dy,dx = vecs[t]\n y, x = y + dy, x + dx\n if pad[y][x] == -1:\n break\n else:\n return \"NO\"\n \n if (sy, sx) == (5, 3):\n return \"YES\"\n \n y, x = 5, 3\n for t in range(N-1):\n dy,dx = vecs[t]\n y, x = y + dy, x + dx\n if pad[y][x] == -1:\n break\n else:\n return \"NO\"\n\n return \"YES\"\n\nN=readi()\nmem = read()\nwriteln(solve(mem, N))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7dd4305ec420e5f4e0fb9321e15cf1a5", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "\n\nraw_input()\n\ndigs = set()\nfor x in raw_input():\n digs.add(int(x))\n\n# if 2 in digs and 0 in digs:\n# print 'NO'\n\nxs = [(x - 1) % 3 for x in digs if x != 0]\nys = [(x - 1) / 3 for x in digs if x != 0]\nminx, maxx = min(xs), max(xs)\nminy, maxy = min(ys), max(ys)\n\nif maxx - minx >= 2 and maxy - miny >= 2:\n print 'YES'\nelse:\n print 'NO'\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b65e702b4ff4bad0cdd4a8a686ce4181", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def getpos(digit):\n digit = int(digit)\n if digit == 0:\n return (3,1)\n digit -= 1\n return (digit // 3, digit % 3)\n\ndef main():\n ndig = int(input())\n number = input().strip()\n assert ndig == len(number)\n rlo = clo = 4\n rhi = chi = 0\n for digit in number:\n row, col = getpos(digit)\n rlo = min(row, rlo)\n rhi = max(row, rhi)\n clo = min(col, clo)\n chi = max(col, chi)\n rdiff = rhi-rho\n if rdiff == 3:\n print('YES')\n elif rdiff < 2:\n print('NO')\n elif chi - clo < 2:\n print('NO')\n elif '0' in number:\n print('NO')\n else if '7' in number or '9' in number:\n print('YES')\n else:\n print('NO')\n \nmain() ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2727243b3215bc034bae0fe5c6e9d5fa", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "alphabet = 'abcdefghijklmnopqrstuvwxyz'\nalphabet_h = alphabet.upper()\nalpha = tuple(alphabet)\nalpha_h = tuple(alphabet_h)\nn = int(input())\ns = str(input())\ng = 0\ni = 1\n\nwhile i <= n-1:\n if s[i-1] in alpha:\n while s[i] in alpha_h:\n # print(s[i], i)\n g = g + 1\n i = i + 1\n # print(i)\n if i>=n-1 or s[i] in alpha:\n break \n i = i + 1\ni = n - 1\nif s[n-1] in alpha_h and g > 0:\n while s[i] in alpha_h and i>=0:\n g = g - 1\n i = i - 1\nif n = 1 and s[0] in alpha:\n g = 1\n \nprint(g)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0b554565911ff1a542c1fbba01db1f2", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "\n n=int(input())\ns=str(input())\nl=[0]\nfor i in range(len(s)):\n if ord(s[i])>=65 and ord(s[i])<=90:\n l.append(i)\nans=0\nl.append(n)\nfor i in range(len(l)-1):\n ls=[]\n for j in range(l[i],l[i+1]):\n if s[j] not in ls and (ord(s[j])>=97 and ord(s[j])<=122):\n ls.append(s[j])\n ans=max(ans,len(ls))\n #print(ls)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af8dec4798f62b8de02969bf3fcf5c6b", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\na=set()\nmx=0\nfor i in s:\n\tif(isupper(i)):\n\t\ts.clear()\n\telse:\n\t\tif(islower(i)):\n\n s.add(i)\n mx=max(mx,len(s))\n\t\t\n\nprint(mx)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11d822c5ff62ec73d41a6d17489ed740", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\nl =[]\nmaxi = 0\nfor i in range(n):\n if s[i].isupper():\n maxi = max(maxi,len(set(l)))\n l=[]\n else:\n l.append(s[i])\nmaxi = max(maxi,len(set(l))\nprint(maxi)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cd45ad6d6dc4c478f727b7b1f9b949ca", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=input()\na=set()\nmx=0\nfor i in s:\n\tif(isupper(i)):\n\t\ts.clear()\n\telse:\n\t\tif(islower(i)):\n\t\t s.add(i)\n mx=max(mx,len(s))\n\t\t\n\nprint(mx)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "535e67fbf170ae74c8bd6044cb959b65", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = input()\nl = len(n)\npmax = 9**(l-1)\nk = \"9\"*(l-1)\nif k == \"\":\n k = 1\nfor i in range(int(k),int(n)+1):\n p = 1\n for j in str(i):\n p *= int(j)\n if pmax < p:\n pmax = p\n \nprint(pmax)\n \n \n \n \n \n \n\n \n \n\n \n \n\n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c9ab8321126e0f90f39164cd85c088f0", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ncurrent_max = 0\nfin = int('1' + '0' * (len(str(n)) - 1)) - 2\nfor i in range(n, fin, -1):\n product = 1\n for j in range(len(str(i))):\n product *= int(str(i)[j])\n if product > current_max:\n current_max = product\nprint(current_max)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7e090567742541c9f1760aed6915f9af", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "// CPP Program to find the number in a \n// range having maximum product of the \n// digits \n\n#include \nusing namespace std; \n\n// Returns the product of digits of number x \nint product(int x) \n{ \n\tint prod = 1; \n\twhile (x) { \n\t\tprod *= (x % 10); \n\t\tx /= 10; \n\t} \n\treturn prod; \n} \n\n// This function returns the number having \n// maximum product of the digits \nint findNumber(int l, int r) \n{ \n\t// Converting both integers to strings \n\tstring a = to_string(l); \n\tstring b = to_string(r); \n\n\t// Let the current answer be r \n\tint ans = r; \n\tfor (int i = 0; i < b.size(); i++) { \n\t\tif (b[i] == '0') \n\t\t\tcontinue; \n\n\t\t// Stores the current number having \n\t\t// current digit one less than current \n\t\t// digit in b \n\t\tstring curr = b; \n\t\tcurr[i] = ((curr[i] - '0') - 1) + '0'; \n\n\t\t// Replace all following digits with 9 \n\t\t// to maximise the product \n\t\tfor (int j = i + 1; j < curr.size(); j++) \n\t\t\tcurr[j] = '9'; \n\n\t\t// Convert string to number \n\t\tint num = 0; \n\t\tfor (auto c : curr) \n\t\t\tnum = num * 10 + (c - '0'); \n\n\t\t// Check if it lies in range and its product \n\t\t// is greater than max product \n\t\tif (num >= l && product(ans) < product(num)) \n\t\t\tans = num; \n\t} \n\n\treturn ans; \n} \n\n// Driver Code \nint main() \n{ \n\tcin>>r; \n\tcout << findNumber(1, r) << endl; \n\n\treturn 0; \n} \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "906250c45f2e8fc41356e81b738bf0e8", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "[12:21 AM, 3/31/2019] Sanket Agarwal: 1 baar code bhej\n[12:22 AM, 3/31/2019] Surya: a = list(input())\nc = 0\nt = 1\nfor i in range(len(a)):\n j = int(a[i])\n t2 = t*(j-1)\n t = t*j\n c = max(t2*((9)**(len(a)-i-1)) , c)\n if i==0 and t2==0:\n c = max(((9)**(len(a)-i-1)) , c)\n \nc = max(t,c)\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4a594c64470b215511aadb92fa1128f2", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\n r=p=1\nfor d in map(int,input()[::-1]):r=max(d*r,(d-1)*p);p*=9\nprint(max(r,p//9))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1718c0b9be3985183515f4c567ab1ea5", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\n\ndef powerMo(a,n,mo):\n ans = 1\n posi = a\n while n > 0:\n if n&1:\n ans *= posi\n ans %= mo\n n >>= 1\n posi = posi*posi%mo\n return ans\n\ndef modInv(a,mo):\n # return a's mod inv\n phi = mo - 1\n return(powerMo(a,phi-1,mo))\n\n\ndef combMo(n,a,mo):\n # Cna\n numer = 1\n for i in range(n-a+1,n+1):\n numer *= i\n numer %= mo\n denom = 1\n for i in range(1,a+1):\n denom *= i\n denom %= mo\n denomInv = modInv(denom,mo)\n ans = numer*denomInv%mo\n return ans\n\ndef f():\n mo = 998244353\n n, m = [int(s) for s in input().split()]\n if n==2:\n print(0)\n return\n c = combMo(m, n-1, mo)\n c *= (n-2)\n a = powerMo(2,n-3,mo)\n res = a*c%mo\n print(res)\n\n\nf()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e31c5e47824c0494124887adb6b18a93", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "M = 998244353\nn, m = map(int, input().split())\nf = [1]*(m+1)\nfor i in range(m):\n f[i+1] = f[i]*(i+1)%M\n\ncc = 0\nif n > 2: cc = f[m]*(n-2)*pow(2,n-3,M)*pow(f[n-1]*f[m-n+1],M-2, M)\nprint(cc%M)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28b0271200057b980490d9893bd75ea3", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys;sys.setrecursionlimit(999999)\ndef f(L):\n n=len(L)\n if n==0: return 0\n if n==1: return 1\n diff=min(L)-1\n s=e=-1\n for i in range(n):\n L[i]-=diff\n if s==-1 and L[i]==1:\n s=i\n e=i\n if i>0 and e==i-1 and L[i]==1:\n e=i\n if s==0 and e==n-1:\n return str(bin(n)).count('1')\n R=9999\n cnt=e-s+1\n c2=cnt//2\n for a in range(c2+1):\n b=c2-a\n r=f(L[:s]+[2]*a)+f([2]*b+L[e+1:])\n R=min(r,R)\n return R+(cnt%2)\ninput();print(f(list(map(int,input().split()))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cdf069f8761e181e44107f6f3f2e6990", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\ndef main():\n # t = int(input())\n t = 1\n while(t):\n # for _ in range(t):\n t -= 1\n \n MOD = 998244353\n fact = [1]*200005\n for i in range(1, 200005):\n fact[i] = i*fact[i-1]\n \n def fast_sq(a, b):\n ans = 1\n if(b == -1):\n b = MOD-2\n for i in range(60):\n if((1<= 2 ** (h - 1):\n return 0\n if n < 2:\n return 1\n if (n, h) not in tab1:\n r = 0\n for i in range(n):\n r += num2(i, h - 1) * num2(n - 1 - i, h - 1)\n tab2[n, h] = r\n return tab2[n, h]\n\nn, h = map(int, raw_input().split())\nprint num1(n) - num2(n, h)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "454f305f60f31c709207742a66ad3c72", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "M=10**9+7\nn=input()\na=map(int,raw_input().split())\nc=[[0]*128 for _ in range(128)]\nc[0][0]=1\nfor p in range(1,128):\n c[p][0]=c[p][p]=1\n for q in range(1,p):\n c[p][q]=(c[p-1][q]+c[p-1][q-1])%M\nt=[[0]*128 for _ in range(11)]\nt[10][0]=1\nfor d in range(9,0,-1):\n for i in range(n-a[d]+1):\n for j in range(a[d],n-i+1):\n t[d][i+j]=(t[d][i+j]+t[d+1][i]*c[i+j][j])%M\ns=0\nfor i in range(1,n+1):\n for j in range(a[0],i):\n s=(s+t[1][i-j]*c[i-1][j])%M\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91cb934be6035d14be1a8c3e35dfea4f", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "M=10**9+7\nn=input()\na=map(int,raw_input().split())\nc=[[0]*128 for _ in range(128)]\nc[0][0]=1\nfor p in range(1,128):\n c[p][0]=c[p][p]=1\n for q in range(1,p):\n c[p][q]=(c[p-1][q]+c[p-1][q-1])%M\nt=[[0]*128 for _ in range(11)]\nt[10][0]=1\nfor d in range(9,0,-1):\n for i in range(n-a[d]+1):\n for j in range(a[d],n-i+1):\n t[d][i+j]=(t[d][i+j]+t[d+1][i]*c[i+j][j])%M\ns=0\nfor i in range(1,n+1):\n for j in range(a[0],i):\n s=(s+t[1][i-j]*c[i-1][j])%M\nprint s", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba8941f38725353cc9d14f0effbb8400", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from functools import partial, reduce\nfrom operator import mul\n\nfact = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000, 51090942171709440000L, 1124000727777607680000L, 25852016738884976640000L, 620448401733239439360000L, 15511210043330985984000000L, 403291461126605635584000000L, 10888869450418352160768000000L, 304888344611713860501504000000L, 8841761993739701954543616000000L, 265252859812191058636308480000000L, 8222838654177922817725562880000000L, 263130836933693530167218012160000000L, 8683317618811886495518194401280000000L, 295232799039604140847618609643520000000L, 10333147966386144929666651337523200000000L, 371993326789901217467999448150835200000000L, 13763753091226345046315979581580902400000000L, 523022617466601111760007224100074291200000000L, 20397882081197443358640281739902897356800000000L, 815915283247897734345611269596115894272000000000L, 33452526613163807108170062053440751665152000000000L, 1405006117752879898543142606244511569936384000000000L, 60415263063373835637355132068513997507264512000000000L, 2658271574788448768043625811014615890319638528000000000L, 119622220865480194561963161495657715064383733760000000000L, 5502622159812088949850305428800254892961651752960000000000L, 258623241511168180642964355153611979969197632389120000000000L, 12413915592536072670862289047373375038521486354677760000000000L, 608281864034267560872252163321295376887552831379210240000000000L, 30414093201713378043612608166064768844377641568960512000000000000L, 1551118753287382280224243016469303211063259720016986112000000000000L, 80658175170943878571660636856403766975289505440883277824000000000000L, 4274883284060025564298013753389399649690343788366813724672000000000000L, 230843697339241380472092742683027581083278564571807941132288000000000000L, 12696403353658275925965100847566516959580321051449436762275840000000000000L, 710998587804863451854045647463724949736497978881168458687447040000000000000L, 40526919504877216755680601905432322134980384796226602145184481280000000000000L, 2350561331282878571829474910515074683828862318181142924420699914240000000000000L, 138683118545689835737939019720389406345902876772687432540821294940160000000000000L, 8320987112741390144276341183223364380754172606361245952449277696409600000000000000L, 507580213877224798800856812176625227226004528988036003099405939480985600000000000000L, 31469973260387937525653122354950764088012280797258232192163168247821107200000000000000L, 1982608315404440064116146708361898137544773690227268628106279599612729753600000000000000L, 126886932185884164103433389335161480802865516174545192198801894375214704230400000000000000L, 8247650592082470666723170306785496252186258551345437492922123134388955774976000000000000000L, 544344939077443064003729240247842752644293064388798874532860126869671081148416000000000000000L, 36471110918188685288249859096605464427167635314049524593701628500267962436943872000000000000000L, 2480035542436830599600990418569171581047399201355367672371710738018221445712183296000000000000000L, 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000L, 11978571669969891796072783721689098736458938142546425857555362864628009582789845319680000000000000000L, 850478588567862317521167644239926010288584608120796235886430763388588680378079017697280000000000000000L, 61234458376886086861524070385274672740778091784697328983823014963978384987221689274204160000000000000000L, 4470115461512684340891257138125051110076800700282905015819080092370422104067183317016903680000000000000000L, 330788544151938641225953028221253782145683251820934971170611926835411235700971565459250872320000000000000000L, 24809140811395398091946477116594033660926243886570122837795894512655842677572867409443815424000000000000000000L, 1885494701666050254987932260861146558230394535379329335672487982961844043495537923117729972224000000000000000000L, 145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000L, 11324281178206297831457521158732046228731749579488251990048962825668835325234200766245086213177344000000000000000000L, 894618213078297528685144171539831652069808216779571907213868063227837990693501860533361810841010176000000000000000000L, 71569457046263802294811533723186532165584657342365752577109445058227039255480148842668944867280814080000000000000000000L, 5797126020747367985879734231578109105412357244731625958745865049716390179693892056256184534249745940480000000000000000000L, 475364333701284174842138206989404946643813294067993328617160934076743994734899148613007131808479167119360000000000000000000L, 39455239697206586511897471180120610571436503407643446275224357528369751562996629334879591940103770870906880000000000000000000L, 3314240134565353266999387579130131288000666286242049487118846032383059131291716864129885722968716753156177920000000000000000000L, 281710411438055027694947944226061159480056634330574206405101912752560026159795933451040286452340924018275123200000000000000000000L, 24227095383672732381765523203441259715284870552429381750838764496720162249742450276789464634901319465571660595200000000000000000000L, 2107757298379527717213600518699389595229783738061356212322972511214654115727593174080683423236414793504734471782400000000000000000000L, 185482642257398439114796845645546284380220968949399346684421580986889562184028199319100141244804501828416633516851200000000000000000000L, 16507955160908461081216919262453619309839666236496541854913520707833171034378509739399912570787600662729080382999756800000000000000000000L, 1485715964481761497309522733620825737885569961284688766942216863704985393094065876545992131370884059645617234469978112000000000000000000000L, 135200152767840296255166568759495142147586866476906677791741734597153670771559994765685283954750449427751168336768008192000000000000000000000L, 12438414054641307255475324325873553077577991715875414356840239582938137710983519518443046123837041347353107486982656753664000000000000000000000L, 1156772507081641574759205162306240436214753229576413535186142281213246807121467315215203289516844845303838996289387078090752000000000000000000000L, 108736615665674308027365285256786601004186803580182872307497374434045199869417927630229109214583415458560865651202385340530688000000000000000000000L, 10329978488239059262599702099394727095397746340117372869212250571234293987594703124871765375385424468563282236864226607350415360000000000000000000000L, 991677934870949689209571401541893801158183648651267795444376054838492222809091499987689476037000748982075094738965754305639874560000000000000000000000L, 96192759682482119853328425949563698712343813919172976158104477319333745612481875498805879175589072651261284189679678167647067832320000000000000000000000L, 9426890448883247745626185743057242473809693764078951663494238777294707070023223798882976159207729119823605850588608460429412647567360000000000000000000000L, 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000L, 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L]\n\nspi = partial(reduce, mul)\ndef comb(a, *args):return fact[a]/spi(fact[x] for x in args)\nn = int(raw_input())\nAy = [int(i) for i in raw_input().split()]\nAz = ([Ay[0]-1]+Ay[1:]) if Ay[0] > 0 else Ay[:]\nm = sum(Ay)\n\nif m > n: \n print 0\n exit()\n\nY = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nIY = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nZ = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nIZ = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\n\ny = fact[m]/spi(fact[Ay[k]] for k in xrange(10))\nz = (fact[m-1]/spi(fact[Az[k]] for k in xrange(10))) if Ay[0] != 0 else 0\n\ndef next_table(A, X, IX, x, i, m):\n S = 0\n p = fact[m+i+1]/fact[m]\n X[i][0] = [fact[n]*fact[A[k]]/fact[A[k]+(i+1)] for k in xrange(10)]\n S += p*x*sum(X[i][0])/fact[n]\n IX[i][0] = [sum(X[i][0][k+1:]) for k in xrange(10)]\n for j in xrange(1, min(i+1, 10)):\n X[i][j] = [sum(X[l][0][k]*IX[i-l-1][j-1][k]/fact[n] for l in xrange(i)) for k in xrange(10)]\n S += p*x*sum(X[i][j])/fact[n]\n IX[i][j] = [sum(X[i][j][k+1:]) for k in xrange(10)]\n return S % 1000000007 \n\nS = y-z\nSy = y\nif z:\n for i in xrange(n-m):\n Sz = next_table(Az, Z, IZ, z, i, m-1)\n Sy = next_table(Ay, Y, IY, y, i, m)\n S += Sy-Sz\nelse:\n for i in xrange(n-m):\n Sz = Sy\n Sy = next_table(Ay, Y, IY, y, i, m)\n S += Sy-Sz\n \nif Ay.count(0) == 10: S-=1\nprint S % 1000000007 \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df84ac0ee295763e8fec3d098c2acc2f", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from math import factorial\ndef solve(n,p,a):\n if p is 9:\n if n>=a[9]:\n return 1\n else:\n return 0\n elif p is 0:\n ans=0\n for i in range(a[0],n):\n z=solve(n-i,1,a)\n z*=factorial(n-1)\n z//=factorial(i)\n z//=factorial(n-1-i)\n ans+=z\n return ans\n else:\n ans=0\n for i in range(a[p],n+1):\n z=solve(n-i,p+1,a)\n z*=factorial(n)\n z//=factorial(i)\n z//=factorial(n-i)\n ans+=z\n return ans\nhell=1000000007\nn=int(input())\na=input().rstrip().split(' ');\nfor i in range(0,len(a)):\n a[i]=int(a[i])\nans=0\nfor i in range(1,n+1):\n ans+=solve(i,0,a)\n ans%=hell\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8ccc465cf409283480be9627c5f93c0d", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from math import factorial\nfrom functools import partial, reduce\nfrom operator import mul\nfrom fractions import Fraction\n\nfact = [1]*101\nfor i in xrange(1, 101): fact[i] = i*fact[i-1]\n\nspi = partial(reduce, mul)\ndef comb(a, *args):return factorial(a)/spi(factorial(x) for x in args)\nn = int(raw_input())\nAy = [int(i) for i in raw_input().split()]\nAz = ([Ay[0]-1]+Ay[1:]) if Ay[0] > 0 else Ay[:]\nm = sum(Ay)\n\nif m > n: \n print 0\n exit()\n\nY = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nIY = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nZ = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\nIZ = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]\n\ny = fact[m]/spi(fact[Ay[k]] for k in xrange(10))\nz = (fact[m-1]/spi(fact[Az[k]] for k in xrange(10))) if Ay[0] != 0 else 0\n\ndef next_table(A, X, IX, x, i, m):\n S = 0\n p = fact[m+i+1]/fact[m]\n X[i][0] = [fact[n]*fact[A[k]]/fact[A[k]+(i+1)] for k in xrange(10)]\n S += p*x*sum(X[i][0])/fact[n]\n IX[i][0] = [sum(X[i][0][k+1:]) for k in xrange(10)]\n for j in xrange(1, min(i+1, 10)):\n for k in xrange(10):\n for l in xrange(i):\n X[i][j][k] += X[l][0][k]*IX[i-l-1][j-1][k]/fact[n]\n S += p*x*sum(X[i][j])/fact[n]\n IX[i][j] = [sum(X[i][j][k+1:]) for k in xrange(10)]\n return S\n\nS = y-z\nSy = y\nif z:\n for i in xrange(n-m):\n Sz = next_table(Az, Z, IZ, z, i, m-1)\n Sy = next_table(Ay, Y, IY, y, i, m)\n S += Sy-Sz\nelse:\n for i in xrange(n-m):\n Sz = Sy\n Sy = next_table(Ay, Y, IY, y, i, m)\n S += Sy-Sz\n \nif Ay.count(0) == 10: S-=1\nprint S % 1000000007 \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e474ba016b6acae7178437560e290bf6", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "global p\ndef F(x):\n\tif x==0:\n\t\treturn 0,1\n\telif x&1:\n\t\ta,b=F(x-1)\n\t\treturn b,(a+b)%p\n\telse:\n\t\ta,b=F(x/2)\n\t\treturn a*(2*b-a)%p,(a*a+b*b)%p\nw=input()\np=10\nl=60\nz=[]\nfor i in range(l):\n\tif F(i)[0]==w%p:\n\t\tz.append(i)\nfor i in range(12):\n\tp*=10\n\tz=[i+j*l for i in z for j in range(10) if F(i+j*l)[0]==w%p]\n\tl*=10\nif z==[]:\n\tprint -1\nelse:\n\tprint min(z)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "90cbdb451d3280685028820e7427033c", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "global p\ndef F(x):\n\tif x==0:\n\t\treturn 0,1\n\telif x&1:\n\t\ta,b=F(x-1)\n\t\treturn b,(a+b)%p\n\telse:\n\t\ta,b=F(x/2)\n\t\treturn a*(2*b-a)%p,(a*a+b*b)%p\nw=input()\np=10\nl=60\nz=[]\nfor i in range(l):\n\tif F(i)[0]==w%p:\n\t\tz.append(i)\nfor i in range(12):\n\tp*=10\n\tz=[i+j*l for i in z for j in range(10) if F(i+j*l)[0]==w%p]\n\tl*=10\nif z==[]:\n\tprint -1\nelse:\n\tprint min(z)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d6ed3d641fc438c24a6f1bdb78326d1", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\ndef mul(l,r,mod):\n c = [ (l[0] * r[0] + l[1] * r[1]) % mod,\n (l[0] * r[1] + l[1] * r[3]) % mod,\n (l[2] * r[0] + l[3] * r[2]) % mod,\n (l[2] * r[1] + l[3] * r[3]) % mod ]\n return c\n\ndef power(m,n,mod):\n b = [1,0,0,1]\n while n > 0:\n if (n & 1):\n n -= 1\n b = mul(b,m,mod)\n else:\n n >>= 1\n m = mul(m,m,mod)\n return b\n\ndef fibs(n,mod):\n if n == 0:\n return (0,1)\n else:\n m = [1,1,1,0]\n return power(m,n,mod)\n\ndef fib(n,mod):\n res = fibs(n,mod)\n return res[1]\n\ncheck_me = int (raw_input())\nperiods = { 10 : 60,\n 100 : 300,\n 1000 : 1500,\n 10000 : 15000,\n 100000 : 150000,\n 1000000 : 1500000,\n 10000000 : 15000000,\n 100000000 : 150000000,\n 1000000000 : 1500000000,\n 10000000000 : 15000000000,\n 100000000000 : 150000000000,\n 1000000000000 : 1500000000000,\n 10000000000000 : 15000000000000\n}\nmod = 10\nresnumbers = []\ni = 0\nwhile i < periods[mod]:\n if check_me % mod == fib(i,mod):\n resnumbers.append(i)\n i += 1\n \nmod = 100\nwhile mod <= 10000000000000:\n newres =[]\n per = periods[mod/10]\n for j in resnumbers:\n while j < periods[mod]:\n if check_me % mod == fib(j,mod):\n newres.append(j)\n j += per\n resnumbers = newres\n mod *= 10\n\nif resnumbers:\n print min(resnumbers)\nelse:\n print -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a4c370a5e0466d3f372ec775d7137bd7", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.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**7 -> 312500\n# 5**8 -> 1562500\n# 5**9 -> 7812500\n\nx0,x1 = 0,1\nfor i in range(1,2000000):\n x0, x1 = x1, (x0 + x1) % 5**7\n if (x0,x1) == (0,1):\n print(i)\n break\n\ndef find(f, m, l):\n resp = []\n x0 = 0\n x1 = 1\n for i in range(l):\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**7, 312500)\n\nif len(a) == 0 or len(b) == 0:\n print('-1')\nelse:\n ans = 10 ** 30\n fm = pow_mod(960000000, 10 ** 13)\n for i in a:\n for j in b:\n a0, n0 = crt(i, 12288, j, 312500)\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\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)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1c222ab401f4d55104016d3dd9efcb6", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "PyPy 2", "source_code": "def 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):\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**9, 1562500)\n\nif len(a) == 0 or len(b) == 0:\n print('-1')\nelse:\n ans = 10 ** 30\n fm = pow_mod(4800000000, 10 ** 13)\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 \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": "fec1823df79e4871c054de5d1959a1fe", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "n= raw_input();\ns=raw_input();\nz=s.split (\"0\");\ndecodednum=0;\nfor a in z:\n decodednum*=10;\n decodednum+=len (a);\nprint decodednum", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82eaa6e2636c156869993d13cc59ca25", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = raw_input()\nprint (*map(len, raw_input().split(\"0\")), sep='')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "712e8e1e1ffd063bcbc367e9877a4928", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "length = input(\"input:\")\nstring = input(\"input string:\")\nstring = string.split('0')\nresult = \"\nfor i in string:\n result += str(len(i))\nprint(int(result))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b34fb28dd516d38fbf765b01424ef6c7", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "=int(input())\ns=input()\nones=0\nnewn=1\nans=\"\"\ni=0\n\nwhile(i1:\n for k in range(0,z,2):\n ans+=\"0\"\n i=j\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c765338fd0264fac6040c85626bed33c", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input() + '0'\nans = 0\ni = 0\nwhile i < n:\n ctr = 0\n while i != '0':\n ctr += 1\n i += 1\n i += 1\n ans *= 10\n ans += ctr\nprint(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "81d739daa51bef1f0aa0218a241a6fa6", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\nif(n % 2 != 0):\n print(0)\nelse:\n if(n == 2):\n print(2)\n else:\n a = 2\n for(i in range(int(n/2) - 1)):\n a *= 2\n print(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3844230bdbcfb1fc719919813baf7c03", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=0\nif a%2:\n print(pow(2,(a/2))\nelse:\n print(b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0f0865a9b0c3dd5a3802f5848b91180", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=int(input())\nif a%2:\n print(pow(2,(n/2))\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4c275d8fa81226d8804f970e73101c3", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nif (n*3)%6==0:\n print((n)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b63d83fb089888851649034f6b4f18e3", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\n\nif n%2==0:\n print( 2**(n/2) )\nelse\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ec9dbc19541be34bfba34501780abdf", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\n\nprint(3*(3*n-1))*pow(2,2*n-6))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a7169923348d229b94a59778d2a740f7", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nif n==3:\n print(\"24\")\nelif n==4:\n print(\"132\")\nelse:\n cap=(2n-2)\n ans=2*(12*pow(4,(n-3)))\n tmp=n-4\n if tmp>=0:\n ans+=tmp*(36*pow(4,tmp))\n print(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c456df842c32015b4f2aa9f73ef7d60", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def power(3,n):\n p=1\n for i in range(n):\n p=p*3\n return p\ndef ans(n):\n return power(n-2)*n*(n-1)\nn=int(input())\nprint(ans(n))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "138accd085f453fcdc5b2dbdc80667eb", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.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": "41a215949fca17c0aaca953639efa630", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import math\n n =int(input())\n \n print(8*3*(math.pow(4,n-3)) * (n-3)*4*9*(math.pow(4,(n-4))))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "537cbf6cc93d5295f4e2abe9e2968c25", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from math import gcd,sqrt\nn=int(input())\nt=0\nfor i in range(1,int(sqrt(n)+1):\n if n%i==0:\n a=i\n b=n//i\n GCD=gcd(a,b)\n if GCD==1:\n t=i\n \nprint(t,n//t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "672997cab413a0386fb4536ce3bc7657", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Python 3", "source_code": " import math\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": "624fd48494d449f143b4aa3a58ea1b6b", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def factors(x):\n l=[]\n for i in range(1, x + 1):\n if x % i == 0:\n l.append(i)\n return l\n\ndef lcm(x, y):\n # choose the greater number\n if x > y:\n greater = x\n else:\n greater = y\n while(True):\n if((greater % x == 0) and (greater % y == 0)):\n lcm = greater\n break\n greater += 1\n return lcm\nx=int(input())\nl=factors(x)\nm=[]\ni=len(l)-1\nwhile i>=1:\n if lcm(l[i],l[i-1])==x:\n m.append(l[i-1],l[i])\n i=i-1\n else:\n break\nm.sort\nprint(m[0])\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b5f899f41001cc030f06becbfe2aa82", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a, a)\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n \n \ndef myqs(x):\n i = 1\n a = 1\n while i<=x//i and if x%i==0:\n if lcm(i,x//i)==x:\n a = i\n i += 1\n return (str(a) + \" \" + str(x//a)) \nx = int(input())\nprint(myqs(x))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0bb9b59ca23c48a047f794b438680725", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import math\nx=int(input())\nans=10**18\nfor i in range(1,int(x**.5)+1):\n if x%i==0:\n if (math.gcd(i,x//i)==1:\n if max(i,x//i)1 and l[ind]*l[ind]<=n:\n if(n%l[ind]==0):\n n/=l[ind]\n print n\n else: ind+=1\nprint 1\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c487485eca50fcfe66d0b1ad5648712", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\nfor i in range(n,0,-1):\n if n%i==0\n n=i\n print(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5208b2d1289be243140e98dd1c266914", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def b(n):\n ans = [n]\n for x in xrange(2, n):\n while n % x == 0:\n n /= x\n ans.append(n)\n return ' '.join(map(str, ans))\n\n\n\"\"\"\nprint b(10)\nprint b(4)\nprint b(3)\n\"\"\"\nprint b(int(raw_input())\n#\"\"\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e131a59fa5fe4e9bb8ef23643d069763", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input())\nres = [n]\nfor i in range(n-1,0,-1):\n if all(y % i == 0 for y in res):\n res.append(i)\nprint(' '.join([str(i) for i in res])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cf02349e7add80d2eea199524afc6398", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n=int(input())\nfor i in range(n,0,-1):\n if n%i==0\n n=i\n print(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1e5ce1ce2429c7c2d8750fcb82d06e01", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def cross(x, y, x0, y0, r1, r2):\n\t\td = (x0 - x) ** 2 + (y0 - y) ** 2\n\t\treturn 1 if(d >= (r + r2) ** 2) or (r < r1 and d <= (r1 - r) ** 2) or (r2 < r and d <= (r - r2) **2) else 0\nx1, y1, r1, R1 = map(int, raw_input().split())\nx2, y2, r2, R2 = map(int, raw_input().split())\n\nprint cross(x1, y1, r1, x2, y2, r2, R2) + cross(x1, y1, R2, X2, y2, r2, R2)+cross(x2, y2, r2, x1, y1, r1, R1) + cross(x2, y1, R2, x1, y2, r1, R1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f02929c16e175e2cc0a33a66e6fbf3d6", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def cross(x, y, x0, y0, r1, r2):\n\t\td = (x0 - x) ** 2 + (y0 - y) ** 2\n\t\treturn 1 if(d >= (r + r2) ** 2) or (r < r1) and d <= (r1 - r) ** 2 or (r2 < r and d <= (r - r2) **2) else 0\nx1, y1, r1, R1 = map(int, raw_input().split())\nx2, y2, r2, R2 = map(int, raw_input().split())\n\nprint cross(x1, y1, r1, x2, y2, r2, R2) + cross(x1, y1, R2, X2, y2, r2, R2)+cross(x2, y2, r2, x1, y1, r1, R1) + cross(x2, y1, R2, x1, y2, r1, R1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de3220b24e0532ef1a410467f59108a6", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def cross(x, y, r, x0,y0, r1, r2):\n\t\td = (x0 - x) ** 2 + (y0 - y) ** 2\n\t\treturn 1 if(d >= (r + r2) ** 2) or (r < r1 and d <= (r1 - r) ** 2) or (r2 < r and d <= (r - r2) **2) else 0\nx1, y1, r1, R1 = map(int, raw_input().split())\nx2, y2, r2, R2 = map(int, raw_input().split())\n\nprint cross(x1, y1, r1, x2, y2, r2, R2) + cross(x1, y1, R1, X2, y2, r2, R2)+cross(x2, y2, r2, x1, y1, r1, R1) + cross(x2, y2, R2, x1, y1, r1, R1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d52125deb6d9e0e4305d98e8c49514fd", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "m, r = map(int, input().split())\nres, sq2 = 0, (2**.5)\nfor i in range(1, m):\n res += 2 + sq2 + 2 * sq2 * (i-1) + (i-1) * i\nres = (res + m) * 2 * r\nprint(res / (m * m))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42af32ed4ac19facd59d326a44d69b44", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def cross(x, y, x0, y0, r1, r2):\n\t\td = (x0 - x) ** 2 + (y0 - y) ** 2\n\t\treturn 1 if(d >= (r + r2) ** 2) or (r < r1 and d <= (r1 - r) ** 2) or (r2 < r and d <= (r - r2) **2) else 0\nx1, y1, r1, R1 = map(int, raw_input().split())\nx2, y2, r2, R2 = map(int, raw_input().split())\n\nprint cross(x1, y1, r1, x2, y2, r2, R2) + cross(x1, y1, R1, X2, y2, r2, R2)+cross(x2, y2, r2, x1, y1, r1, R1) + cross(x2, y2, R2, x1, y1, r1, R1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef5e6162a6a1b5737dc75d965e49a7eb", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\nxs = [int(x) for x in input().split()]\n\ncan = 1 in xs\ncan |= xs.count(2) == 2\ncan |= xs.count(2) == 1 and xs.count(4) = 2\ncan |= xs == [3, 3, 3]\n\nprint(\"YES\" if can else \"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c763880c4b75240398d9d5dacda6895a", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "A = list(map(int, input().split()))\ncntOne = A.count(1)\ncntTwo = A.count(2)\ncntThree = A.count(3)\ncntFour = A.count(4)\n\nif cntOne >= 1 or cntTwo >= 2 or cntThree >= 3 or (cntTwo = 1 and cntFour = 2):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fcbfda059fa36404bc3992a90dc80793", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\n k = [int(x) for x in input().split()]\nans = 1\n\nif k.count(2) >= 2 or k.count(2) == 1 and k.count(4) == 2 or k.count(1) > 0 or k.count(3) == 3:\n ans -= 1\n\nprint('YNEOS'[ans::2])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a73fbcdfb5610e24dcb4999a5348a294", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a = list(map(int, input().split(' ')))\na.sort()\nif (a[0] == 1) or \\\n (a[0] == a[1] == 2) or \\\n (a[0] == a[1] == a[2] == 3) or \\ \n (a[0] == 2 and a[1] == a[2] == 4):\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3173483b27ac334006ff07616f4ce3c9", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "A = list(map(int,input().split()))\nA.sort()\nif(A[0]==1):\n print(\"YES\")\nelif(A.count(2)>=2):\n print(\"YES\")\nelif(A.count(3)>=3):\n print(\"YES\")\nelif(A[0]=2 and A.count(4)==2):\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b76d7f9f3eff2f4a51737e2450557fd0", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import sys\n\ninp = input().split()\n m = inp[0]\n n = inp[1]\n m_5 = m % 5\n n_5 = n % 5\n res = m*n//5\n for i in range(m_5):\n for j in range(n_5):\n if i+j % 5 == 0:\n res += 1\n\n print(res)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "daef959990e943264c8f734318ad05c6", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.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", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f5cbd6a73fae9c99f2b7bd8fc637aacc", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nans = n // 5 * 5 * (m // 5)\nx = n // 5\ny = m // 5\nx1 = n % 5\ny1 = m % 5\nans += x1 * y + y1 * x\nfor i in range(1, x1 + 1):\n for j in range(1, y + 1):\n if (i + j) % 5 == 0:\n ans++\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ed01e10dd305129328769e76d193787c", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nnarr=[(n//5),(n//5)+min(1,n%5),(n//5)+(min(2,n%5))//2,\n (n//5)+(min(3,n%5))//3,(n//5)+(min(4,n%5))//4 ]\nmarr=[(m//5),(m//5)+min(1,m%5),(m//5)+(min(2,m%5)//2,\n (m//5)+(min(3,m%5))//3,(m//5)+(min(4,m%5))//4 ]\ncount=0\nfor i in range(5):\n count+=narr[i]*marr[-i]\nprint(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e39825e98210f297edfcd71ec887998", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, m = input().split(\" \")\nprint(round(int(n) * int(m) / 5))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "727c1442b2c083a384b9f7afbe2e96c8", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"\nuntitled.py\n\nCreated by Kyno on 2012-06-09.\nCopyright (c) 2012 __MyCompanyName__. All rights reserved.\n\"\"\"\n\nimport sys\nimport os\nimport math\ndef how_many(R,r):\n rr = r + r\n Rr = R - r\n if Rr == 0:\n return 1\n cos = (Rr*Rr + Rr*Rr - rr*rr)/(2*Rr*Rr)\n angle = math.degrees(math.acos(cos))\n return int(360.0 / angle)\n \ndef main():\n input_arr = raw_input().rstrip().split()\n n ,R,r = map(int, input_arr)\n count = 0\n while R >= r:\n count += how_many\uff08float(R),float(r))\n R -= r*2\n if count >= n:\n print \"YES\"\n else:\n print \"NO\"\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "87f1fa283470e530f955d5ba5ab3e9dd", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from math import acos, pi\nn, R, r = map(float, raw_input().split())\nif r > R:\n print \"NO\"\nelif r > R / 2:\n print \"YES\" if n == 1 else \"NO\"\nelse\n a2, c2 = (R - r) ** 2, (2 * r) ** 2\n angle = acos(1 - (c2/(2*a2)))\n print \"YES\" if n * angle <= 2 * pi else \"NO\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f141cf9e9f18dbde4ec1f21ac9c9c611", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\nimport math\n\n\ndef theta(R, r):\n return 2 * math.asin(1.0 * r / (R - r))\n\ndef can(n, R, r):\n if r >= R:\n return r == R and n == 1\n else if 2 * r >= R:\n return 2 * r == R and n == 2 or n == 1\n else:\n return theta(R, r) * n <= 2 * math.pi + 1e-6\n\nn, R, r = [int(s) for s in sys.stdin.readline().split(' ')]\nprint (\"YES\" if can(n, R, r) else \"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9198d52488208046e0f10572e5c77692", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "1#r=r\nn#r=r+r/sin(pi/n)\ns[n,q,r]|q+1e-5>=n#r=\"YES\"|1>0=\"NO\"\nmain=interact$s.map read.words", "lang_cluster": "Python", "compilation_error": true, "code_uid": "56c3d8621b4192ff67d99b687d89eb74", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n, R, r = map(int,raw.input().split())\nans = true\nif (r > R): ans=false\nif (n==1): ans=(r<=R)\nans = ans&&((R-r)/sin(pi/n)>=r)\nif (ans==false): print(\"NO\")\nelse: print(\"YES\")\nfrom math import *", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96f16ccebd5e757a6801a9f356bdbd5f", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "w, m, k = input().split()\nk = int(w) // int(k)\nl, m = len(m), int(m)\ns = pow(10, l)\nif (s - m) * l > k: print(k // l)\nelse:\n k -= (s - m) * l\n l += 1\n d = 9 * s\n while d * l <= k:\n k -= d * l\n l += 1 \n s += d\n\td = 9 * s\n print(s - m + k // l)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "332670f8d8c4aad0c69c230854af0f39", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "w, m, k = input().split()\nk = int(w) // int(k)\nl, m = len(m), int(m)\ns = pow(10, l)\nif (s - m) * l > k: print(k // l)\nelse:\n k -= (s - m) * l\n l += 1\n d = 9 * s\n while d * l <= k:\n k -= d * l\n l += 1 \n s += d\n\t\td = 9 * s\n print(s - m + k // l)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57159acf76c1e7f81d3602195670a379", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint gcd(int a, int b)\n{\n while(a)\n {\n b %= a;\n swap(a, b);\n }\n return b;\n}\n\nint main()\n{\n int t, n, k, a[50], s, ts;\n scanf(\"%d\", &t);\n for(int i = 1; i <= t; ++i)\n {\n scanf(\"%d%d\", &n, &k);\n s = 0;\n for(int j = 0; j < n; ++j)\n {\n scanf(\"%d\", a + j);\n s += a[j];\n }\n sort(a, a + n);\n ts = 0;\n for(int j = 0, p = 2; j < n; ++j)\n {\n if(j == 0 && a[j] == 0)\n a[j] == 0;\n else if(a[j] <= k)\n a[j] = k;\n else\n {\n for(int q = max(p, a[j] / k); ; ++q)\n {\n bool ok = true;\n for(int m = 0; m < j; ++m)\n ok &= gcd(a[m] / k, q) == 1;\n if(ok)\n {\n a[j] = k * q;\n p = q + 1;\n break;\n }\n }\n }\n ts += a[j];\n }\n printf(\"Case #%d: %d\\n\", i, ts - s);\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f3f802524b9b628905714eec07e018ea", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "m=int(raw_input());\nn=int(raw_input());\nk=int(raw_input());\n\ni=n;\nlen=0;\nwhile(i>0):\n len=len+1;\n i/=10;\nn=n-1;\nj=1;\ni=1;\nwhile(i<=len):\n j=j*10;\n i=i+1;\nj=j-1;\nans=0;\ncost=k*len;\nwhile(m>0):\n if(j-ns:\n ans+=9*s\n w-=9*s*n\n s*=10\n n+=1\nprint ans+w/n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de68071a71658605cc6c795342c041be", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "a,b,c=list(map(int,input().split()))\nans = 0\nwhile (a>!=0):\n\tif c>b and b>a:\n\t\tans+=7\n\ta-=1\n\tb-=2\n\tc-=4\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ca159f14901460b09eb0d9be213b001", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "print(7*min(int(input().strip()),int(input().strip())//2,int(input().strip())//4)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "089a8a62bba019a23197770ff380c46d", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = int (input())\nb = int ( input())\nc = int (input())\nd = a \nfor i in range (a) :\n if d *2 <= b and d *4 <= c :\n f= d *2\n e = d *4\n print (d + f + e )\n break\n d = a-1\nif b < 2 and c <4 or b<2 or c<4 :\n print (0)\nif a == b and b== c and a==c :\n print ((a//4)+(b//2)+(c) )\nif a=1 and b=1 and c=1:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1bfb5960b22c8d9f6d1cbccd622244dd", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = int (input())\nb = int ( input())\nc = int (input())\nd = a \nfor i in range (a) :\n if d *2 <= b and d *4 <= c :\n f= d *2\n e = d *4\n print (d + f + e )\n break\n d = a-1\nif b < 2 and c <4 or b<2 or c<4 :\n print (0)\nif a = b and b= c and a=c :\n print ((a//4)+(b//2)+(c) )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e5f83d103cc6ebcf9cd4958ec98c8224", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = int (input())\nb = int ( input())\nc = int (input())\nd = a \nfor i in range (a) :\n if d *2 <= b and d *4 <= c :\n f= d *2\n e = d *4\n print (d + f + e )\n break\n d = a-1\nif b < 2 and c <4 or b<2 or c<4 :\n print (0)\nif a = b and b= c and a= 1000 :\n print (1750 )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "422239bca01e6219979f80c8aa4f6050", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n, k, m = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\ns = sum(a)\n\nmaximum = 0\ni = 0\nwhile i < n and i * s <= m:\n cur = m - s * i\n ans = (k + 1) * i\n for i in range(k):\n if cur < a[i]:\n break\n c = min(n - i, cur // a[i])\n cur -= a[i] * c\n ans += c\n maximum = max(maximum, ans)\n\nprint(maximum)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cae92f5b9c78fc3a4bdb81a3f087445", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n, k, M = map(int, raw_input().split())\n\ntimes = sorted(list(map(int, raw_input().split())))\nfor_task = sum(times)\n\n\n\nresult = 0\nfully_solved = 0\nwhile fully_solved * for_task <= M:\n curr_result = fully_solved * (k + 1)\n time_rest = M - fully_solved * for_task\n for t in times:\n if t * n > time_rest:\n l = 0\n r = n + 1\n while r - l != 1:\n mid = (l + r) / 2\n if t * mid > time_rest:\n r = mid\n else:\n l = mid\n curr_result += l\n break\n else:\n time_rest -= t * n\n curr_result += n\n\n result = max(curr_result, result)\n fully_solved += 1\n n -= 1\n\nprint result\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a7fa80ee1ca06ceb6e632e2f096b753", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "k, n, m = map(int, raw_input().split())\na = map(int, raw_input().split())\ns = sum(a)\na.sort()\nans = 0\nfor i in xrange(m / s + 1):\n p = i * (n + 1)\n t = m - i * s\n for x in a:\n if t >= x * (k - i):\n t -= x * (k - i)\n p += k - i\n else:\n p += t / x\n break\n if ans < p:\n ans = p\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a81c040f0dbc60869cf464c6044defaf", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n,k,m = list(map(int, input().split()))\nt = sorted(map(int, input().split()))\nst = sum(t)\nres = 0\nfor x in range(m//st+1):\n rem = m-x*st\n m = x*(k+1)\n # for i in range(k):\n # y = min(rem//t[i], n-x)\n # rem -= t[i]*y\n # m += y\n for i in range(k):\n for _ in range(n-x):\n if rem >= t[i]:\n rem -= t[i]\n m += 1\n res = max(res, m)\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77d31ae024ec20812746bd90d0215dd0", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "\n f = lambda: map(int, input().split())\nn, k, m = f()\np = sorted(f())\nx = 0\ns = sum(p)\nfor j in range(n + 1):\n t = m - j * s\n if t < 0: break\n y = k * j + j\n for i in p:\n d = min(n - j, t // i)\n y += d\n t -= d * i\n x = max(x, y)\nprint(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0025c01f8832ba972a1d79da2285cf5", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def main ():\n n, k = [int(n) for n in input().split()]\n S = input();\n doors = {}\n\n for i, s in enumerate(S):\n doors[s] = i\n\n activeDoors = set();\n for i, s in enumerate(S):\n if doors[s] == i:\n activeDoors.remove(s);\n else:\n activeDoors.add(s);\n if(len(activeDoors) > k):\n return \"YES\"\n \n return \"NO\"\n\nprint(main())", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b617d77da84e3ca73124c41ce73cb4ed", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport string\nimport sys\n\n\ndef main():\n iterator = iter(sys.stdin.read().split())\n n, m = int(next(iterator)), int(next(iterator))\n s = next(iterator)\n p = {}\n buffer = set()\n for i in string.ascii_uppercase:\n p[i] = s.rfind(i)\n for i, x in enumerate(s):\n if i < p[x]:\n buffer.add(x)\n if len(buffer) > m:\n print('YES')\n return\n else:\n buffer.remove(x)\n print('NO')\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "490a92f399f04f0d80f20a64b39b3d84", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def read(is_int,split_by):\n\tif(is_int):\n\t\treturn [int(x) for x in input().split(split_by)]\n\telse:\n\t\treturn [x for x in input().split(split_by)]\n\ns,f = read(False,\" \")\nn = int(input())\nseq = ['<','^','>','v']\nk = n%4\nspin = \"undefined\"\nind_s = seq.index(s)\n# Case of k == 0 undefined\nif not(k%2==0) or not(s == f):\n\tif f == seq[ind_s-k]:\n\t\tspin = \"ccw\"\n\telif f == seq[ind_s+k]:\n\t\tspin = \"cw\"\nprint(spin)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f485baf0620ba7b01932cd63e084de03", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def read(is_int,split_by):\n\tif(is_int):\n\t\treturn [int(x) for x in input().split(split_by)]\n\telse:\n\t\treturn [x for x in input().split(split_by)]\nn, k = map(int,input().split(\" \"))\ns = input()\nanswer = \"NO\"\nhigh = {}\nlow = {}\nall_intersect = []\nall_max = []\nif k == 26:\n\tanswer = \"NO\"\nelse:\n\tfor i in range(n):\n\t\tif not (s[i] in low):\n\t\t\tlow[s[i]] = i\n\t\thigh[s[i]] = i\n\tfor key in low:\n\t\tall_intersect.append(low[key])\n\tfor key in high:\n\t\tall_intersect.append(high[key])\n\tall_intersect.sort()\n\tfor i in range(len(all_intersect)):\n\t\tif all_intersect[i] in low.values():\n\t\t\tif all_max:\n\t\t\t\ttmp = all_max[len(all_max)-1]\n\t\t\t\ttmp += 1\n\t\t\t\tall_max.append(tmp)\n\t\t\telse:\n\t\t\t\tall_max.append(1)\n\t\tif all_intersect[i] in high.values():\n\t\t\ttmp = all_max[len(all_max)-1]\n\t\t\ttmp -= 1\n\t\t\tall_max.append(tmp)\n\nmax_elem = max(all_max)\nif max_elem > k:\n\tanswer = \"YES\"\nelse:\n\tanswer = \"NO\"\nprint(answer)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b964cf4fe194dd10be8065716bd0c73c", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "]n,k=map(int,input().split())\nst=input()\nans=True\ncount=0\nstat={}\nlast={}\n\nfor i in range(n):\n last[st[i]]=i\n stat[st[i]]=False\nfor i in st:\n if(stat[i]==False):\n stat[i]=True\n count+=1\n if(count>k):\n ans=False\n break\n if(last[i]==i):\n count-=1\n \n \n \n \n \nif(ans==True):\n print(\"NO\")\nelse:\n print(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2d1f8e1936f5f2e463cb228efd0aa060", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\nstart = time.clock()\nl=list(raw_input())\nwhile 1:\n ans,chk=0,[]\n stp=set(l)\n if len(stp)==len(l):\n cnt=0\n break\n for i in range(len(l)):\n if l[i] not in chk:\n cnt,j=2,i+1\n while l[i]!=l[j]:\n cnt+=1\n j+=1\n ans=max(ans,cnt)\n chk.append(l[i])\n break\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "302471fc37c5a66c99ce6d25a5497acd", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\n\ndef main():\n s = raw_input()\n l = len(s)\n \n freq = {}\n substrings = [s[i:j+1] for i in xrange(l) for j in xrange(i, l)]\n for s in substrings:\n\tfreq[s] = freq.get(s, 0) + 1\n \n print max([len(s) for s, cnt in freq.items() if cnt > 1 ])\n \nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2411e56355ce5b19688ad66c0e16b49", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\"\"\"\n$ pylint calderonsin.py\nGlobal evaluation\n-----------------\nYour code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)\n\n\"\"\"\ndef maxlen:\n string = input()\n max = 0;\n for x in range(len(string)):\n substring = \"\"\n for y in string[x:]:\n substring +=y;\n if string[x:].rfind(curr) != string[x:].find(curr):\n totalmax = max(totalmax, len(curr))\n continue\n print(totalmax)\n\nmaxlen()\n# $ python3 calderonsin.py build\n# remember the output\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9e8cf19e77b83797e0b55cec867cd0ad", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys, re\ns=sys.stdin.read()\nn=len(s)\n\nres=0\nfor i in range(n):\n\tfor j in range(i):\n\t\ttmp=0\n\t\tfor k in range(n):\n\t\t\tif re.match(s[j:i], s[k:]):\n\t\t\t\ttmp+=1\n\t\tif tmp>=2:\n\t\t\tres=max(res,i-j)\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "025c4bc43b8ec496192ab77beb2593c4", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "string = str(raw_input())\nl = len(string)\nans = 0\nfor i in range(l):\n for j in range(i + 1 , l):\n for k in range(1 , l):\n if i + k - 1 < l and j + k - 1 < l:\n flag = True\n for x in range(k):\n if string[i + x] != string[j + x]:\n flag = False\n break\n if flag == True and k > ans:\n ans = k \nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11b963634d463280228fe5323a026063", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "def isCovered(p1, p2, p3, p4, p5, p6):\n x1,y1 = p1 #cp bottom left\n x2,y2 = p2 #cp top right\n x3,y3 = p3 #t1 bottom left\n x4,y4 = p4 #t1 top right\n x5,y5 = p5 #t2 bottom left\n x6,y6 = p6 #t2 top right\n\n if (x5 <= x1 and y5 <= y1 and x6 >= x2 and y6 >= y2) or (x3 <= x1 and y3 <= y1 and x4 >= x2 and y4 >= y2):\n return \"COMPLETELY COVERED\"\n elif y5 <= y1 <= y2 <= y6 and y3 <= y1 <= y2 <= y4 and x5 <= x1 < x6 and x3 <= x2 < x4 and (x6-x1+x2-x3) >= (x2-x1):\n return \"COMPLETELY COVERED\"\n elif x5 <= x1 <= x2 <= x6 and x3 <= x1 <= x2 <= x4 and y5 <= y1 < y6 and y3 <= y2 < y4 and (y6-y1+y2-y3) >= (y2-y1):\n return \"COMPLETELY COVERED\"\n elif y5 <= y1 <= y2 <= y6 and y3 <= y1 <= y2 <= y4 and x3 <= x1 < x4 and x5 <= x2 < x6 and (x4-x1+x2-x5) >= (x2-x1):\n return \"COMPLETELY COVERED\"\n elif x5 <= x1 <= x2 <= x6 and x3 <= x1 <= x2 <= x4 and y3 <= y1 < y4 and y5 <= y2 < y6 and (y4-y1+y2-y5) >= (y2-y1):\n return \"COMPLETELY COVERED\"\n else:\n return \"NOT COMPLETELY COVERED\"\n\nfirst=map(int,input().split())\nsecond=map(int,input().split())\nthird=map(int,input().split())\np1=(first[0],first[1])\np2=(first[2],first[3])\np3=(second[0],second[1])\np4=(second[2],second[3])\np5=(third[0],third[1])\np6=(third[2],third[3])\nif(isCovered(p1,p2,p3,p4,p5,p6)==\"CMPLETELY COVERED\")\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c18d6ddb670002ae7c3ea5ceaab3c914", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "# union(W, B1) + union(W, B2) - union(W, B1, B2) = W\nW = list(map(int, input().split()))\nB1 = list(map(int, input().split()))\nB2 = list(map(int, input().split()))\n\ndef union(A, B, C=None):\n # x1, y1 = [0][1] / x2, y2 = [2][3]\n # W_x1 < B_x2 and W_x2 > B_x1 , y1y1\n Aleft, Abottom, Aright, Atop = A\n Bleft, Bbottom, Bright, Btop = B\n if C != None:\n Cleft, Cbottom, Cright, Ctop = C\n if (Bleft < Cright and Bright > Cleft) and (Bbottom < Ctop and Btop > Cbottom):\n Bleft = max(Bleft, Cleft)\n Bright = min(Bright, Cright)\n Bbottom = max(Bbottom, Cbottom)\n Btop = min(Btop, Ctop)\n else:\n Bleft, Bbottom, Bright, Btop = 0, 0, 0, 0\n if (Aleft < Bright and Aright > Bleft) and (Abottom < Btop and Atop > Bbottom):\n width = min(Aright, Bright) - max(Aleft, Bleft)\n height = min(Atop, Btop) - max(Abottom, Bbottom)\n return width*height\n else:\n return 0\n\n if union(W, B1) + union(W, B2) - union(W, B1, B2) == (W[2]-W[0]) * (W[3]-W[1]):\n print('NO')\nelse:\n print('YES')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "645e63638818066519a75f804654cc46", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include\n#include\nint main(void)\n{\n\tint x1 = 0;\n\tint x2 = 0;\n\tint x3 = 0;\n\tint x4 = 0;\n\tint x5 = 0;\n\tint x6= 0;\n\tint y1 = 0;\n\tint y2 = 0;\n\tint y3 = 0;\n\tint y4 = 0;\n\tint y5 = 0;\n\tint y6 = 0;\n\twhile (scanf(\"%d %d %d %d %d %d %d %d %d %d %d %d\", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4, &x5, &y5, &x6, &y6) != EOF)\n\t{\n\n\t\tif ((x1 >= x5) && (x1 >= x3) && (x2 <= x4) && (x2 <= x6) && (y4 >= y2) && (y5 <= y1) && (y6 >= y3)|| (x1 >= x3) && (x2 <= x4) && (y3 <= y1) && (y4 >= y2)|| (x1 >= x5) && (y1 >= y5) && (x6 >= x2) && (y6 >= y2))\n\t\t{\n\t\t\tprintf(\"NO\\n\");\n\t\t}\n\n\n\t\telse\n\t\t\tprintf(\"YES\\n\");\n\n\t}\n\tsystem(\"pause\");\n\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "05d79246fe0d0f3677f4720deb4125d9", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "\ndef fun(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):\n if y3 <= y1 and y4 >= y2 and x3 <= x1 gand y5 <= y1 and y6 >= y2 and x6 >= x2 and x4 < x2 and x4>=x1:\n return True\n return False\n\ndef fun2(x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4):\n if x3<=x1 and x4>=x2 and y4>=y2 and y3<=y1:\n return True \n return False\n\ndef fun3(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):\n if x3<=x1 and x4>=x2 and x5<=x1 and x6>=x2 and y4>=y2 and y6>=y3 and y5<=y1 and y3 > y1 and y3 <=y2:\n return True\n return False\n\nx1 , y1 , x2 , y2 = map(int,input().split())\nx3 , y3 , x4 , y4 = map(int,input().split())\nx5 , y5 , x6 , y6 = map(int,input().split())\n\nok = False\nif fun2(x1,y1,x2,y2,x3,y3,x4,y4):\n ok = True\n # print(ok , 1)\nif fun2(x1,y1,x2,y2,x5,y5,x6,y6):\n ok = True\n # print(ok , 2)\nif fun(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):\n ok = True\n # print(ok , 3)\nif fun(x1,y1,x2,y2,x5,y5,x6,y6,x3,y3,x4,y4):\n ok = True\n # print(ok , 4)\n\nif fun3(x1,y1,x2,y2,x5,y5,x6,y6,x3,y3,x4,y4):\n ok = True\n # print(ok , 5)\nif fun3(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):\n ok = True\n # print(ok , 6)\nif(ok):\n print(\"NO\")\nelse:\n print(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1d46ce21f6ff9785bee89b8e9cafa816", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a= list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\nif(b[0]<=a[0]and b[1]<=a[1]):\n if(b[2]>=a[2] and b[3]>=a[3]):\n print('NO')\n elif (b[2]>=a[2]):\n x=a[0]\n y=b[3]\n if(c[0]<=x and c[1]<=y):\n if(c[2]>=a[2] and c[3]>=a[3]):\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\n elif b[3]>=a[3]:\n x = b[2]\n y = a[1]\n # print(x,y)\n if (c[0] <= x and c[1] <= y):\n if (c[2] >= a[2] and c[3] >= a[3]):\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\n else:\n print('YES')\nelif(c[0]<=a[0]and c[1]<=a[1]):\n if(c[2]>=a[2] and c[3]>=a[3]):\n print('NO')\n elif (c[2]>=a[2]):\n x=a[0]\n y=c[3]\n if(b[0]<=x and b[1]<=y):\n if(b[2]>=a[2] and b[3]>=a[3]):\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\n elif c[3]>=a[3]:\n x = c[2]\n y = a[1]\n if (b[0] <= x and b[1] <= y):\n if (b[2] >= a[2] and b[3] >= a[3]):\n print('NO')\n else:\n print('YES')\n else:\n print('YES')\n else:\n print('YES')\nelse:\n print('YES')\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae6ecb805637377f5810b58b456c43ae", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "l=sorted(list(map(int,input().split())))[::-1]\nif(len(l)<1):\n print(-1)\nelse:\n print(l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76c013b162b03c5e9ebf6aa74394b95e", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "Python 2", "source_code": "def bad_sort ():\n n = int ( raw_input () )\n if not (1 <= n <= 50): return -1\n\n if (n < 3): print -1\n else print \" \".join( map ( str, range (n,0,-1)) )\n\nbad_sort ()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6b20227d5a2a23ac6c334831b88d0bbe", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n=eval(input())\na=[0]*n\nif n==1 or n==2 :\n print (-1)\nelse:\n i=0\n j=100 \n while i= 9:\n print i+1\n exit()\n except IndexError:\n pass\nprint -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1b05cecde43d5e5c1017ce277c189a9", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "R = lambda:map(int,raw_input().split())\uff03\n#R = lambda:[30, 5, 20, 20, 5, 3]\n#R = lambda:[64, 12, 258, 141, 10, 7]\n\nx, t, a, b, da, db = R()\n\nfor i in range(-1, t):\n if i == -1:\n sum_a = 0\n else:\n sum_a = a - da*i\n if sum_a < 0:\n sum_a = 0\n\n for j in range(-1, t):\n if j == -1:\n sum_b = 0\n else:\n sum_b = b - db*j\n if sum_b < 0:\n sum_b = 0\n\n if sum_a + sum_b == x:\n print 'YES'\n quit()\nprint 'NO'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f04a9a94b5e825b2ed533f7766ad7e2", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n,h,m = list(map(int, input().split()))\narr = n*[h]\n# print()\n# print(arr)\nfor i in range(m):\n l,r,x = list(map(int, input().split()))\n # it = l \n for j in range(len(arr)):\n if j >= l-1 and j <= r-1:\n if arr[j] > x:\n arr[j] = x\n # print(arr)\nans = 0\nfor k in arr:\n ans += (k**2) \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "edcbeda5edf61032aa00191702f6f4cb", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom math import ceil\n\ninput = sys.stdin.readline\n\nn, h, m = map(int, input().split())\n\nhouses = [h for i in range(n+1)]\n\nfor i in range(m):\n l, r, x = map(int, input().split())\n for j in range(l, r+1):\n houses[j] = min(houses[j], x)\n \nhouses.pop(0)\n\nprint(sum([x*x for x in houses]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "11cec9de4d7737c11cdcf528f30ea2d8", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.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": "dc49c86c9a90174c1201423a86d90a7d", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.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": "66fa3b8bddc798ea6c59d2bf4c6e85a8", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=input();i=0;j=len(n)-1;z=[]\nwhile(i= y):\n x -= 50\n genT()\n if(p in Tshirt):\n print(suchk)\n print(\"f\")\n exit(0)\n\nx = orgx\nwhile(not (p in Tshirt)):\n# Tshirt = []\n hk += 1\n if(hk % 2 == 1): suchk += 1\n x += 50\n genT()\n\nprint(suchk)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cfd6251450038e05082945bf1923058", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "#!/bin/python3\nimport math\nn = int(input())\n\nfor rd in range(n):\n my , tot , p , q = list(map(int , input().split()))\n m = 0\n if(tot % q == 0):\n m = tot // q\n else:\n m = (tot // q + 1)\n\n np = m * p ; nq = m * q\n for i in range(500000):\n if(np - my <= nq - tot and np - my >= 0):\n print(nq - tot)\n break\n np += p ; nq += q\n if(p == 1 and q == 1):\n print(-1)\n break\n else:\n print(-1)\n\n\n# for i in range(1000000):\n# if(tot % q == 0):\n# if((p * tot / q) == my):\n# print(i)\n# break\n# if(my / tot > p / q):\n# tot += 1\n# else:\n# tot += 1; my += 1\n# if(p == 1 and q == 1):\n# print(-1)\n# break\n# if(p == 0 and q == 0):\n# print(-1)\n# break\n# else:\n# print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f537115d1bcd12bb9bc1df317d3db28e", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import sys\nread=lambda:sys.stdin.readline().rstrip()\nreadi=lambda:int(sys.stdin.readline())\nwriteln=lambda x:sys.stdout.write(str(x)+\"\\n\")\nwrite=lambda x:sys.stdout.write(x)\ndef tshirt(s):\n places = []\n i = (s // 50) % 475\n for _ in range(25):\n i = (i*96 + 42) % 475\n places.append(i+26)\n return places\n'''\ns\ub294 \uc2b9\uc790\uc758 point\ni = (s // 50) % 475\nfor _ in range(25):\n i = (i*96 + 42) % 475\n print(i+26) \n\n1~50 \uad6c\uac04\uc5d0 \uc788\ub294 \uc560\ub4e4\uc740 \ub2e4 \uac19\uc740\ub370 \ub5a8\uc5b4\uc9d0.\n\n'''\n\n'''\np := place\nx := points\ny := \uc774\uae30\ub294\ub370 \ud544\uc694\ud55c \uc810\uc218\n'''\np,x,y=map(int, read().split())\nunit = 50\nplaces = tshirt(x)\nif p in places:\n writeln(0)\n exit()\nmid = x\nmag = 1; found = False\nwhile mid - unit*mag >= y:\n places = tshirt(mid - unit*mag)\n if p in places:\n found = True\n break\n mag += 1\n\nif found:\n writeln(0)\n exit()\n\nmid = x\nmag = 1\nwhile True:\n places = tshirt(mid + unit*mag)\n if p in places:\n found = True\n break\n mag += 1\n\nanswer = (mid + unit*mag) - x\nq,r=divmod(answer, 100)\nif r:\n writeln(q+1)\nelse:\n writeln(q)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2d63010c66b7dcd07e7f400edfad7db8", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, x, pos = [int(a) for a in input().split()]\n\ndef fac(n):\n return 1 if n<=1 else fac(n-1)*n\n\nmod = int(1e9+7)\n\ncount_left = 0\ncount_right = 0\n\ndef binary_search(a, x):\n global count_left, count_right\n left = 0\n right = len(a)\n while left < right:\n middle = (left + right) // 2\n # print(middle)\n # if a[middle] == x:\n # break\n if a[middle] <= x:\n left = middle + 1\n if a[middle] != x:\n count_left += 1\n else:\n right = middle\n count_right += 1\n\nnums = list(range(n))\nbinary_search(nums, pos)\n# print(count_left, count_right)\n\n\nif x <= count_left or x > n-count_right:\n print(0)\n import sys\n sys.exit()\n\ndef binomial(n, k):\n return 1 if n <= 0 else fac(n) // fac(n-k)\n\nleft = max(1, (binomial(x - 1, count_left)) % mod)\nright = max(1, (binomial(n - x, count_right)) % mod)\nprint((fac(n - count_left - count_right - 1) * left * right) % mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71ec1d3c6c29b4d64c5f2b95039d8524", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\ndef II():\n\treturn int(sys.stdin.readline())\n \ndef LI():\n\treturn list(map(int, sys.stdin.readline().split()))\n \ndef MI():\n\treturn map(int, sys.stdin.readline().split())\n \ndef SI():\n\treturn sys.stdin.readline().strip()\n\ndef FACT(n, mod):\n s = 1\n facts = [1]\n for i in range(1,n+1):\n s*=i\n s%=mod\n facts.append(s)\n return facts[n]\n\ndef C(n, k, mod):\n return (FACT(n,mod) * pow((FACT(k,mod)*FACT(n-k,mod))%mod,mod-2, mod))%mod\n\nn,x,pos = MI()\n\nleft = 0\nright = n\nless = 0\nmore = 0\nwhile lefthassLess or more > hasBig:\n print(0)\nelse:\n mod = 10**9+7\n ans = FACT(less,mod)*C(hasBig, more, mod)%mod\n ans = ans*FACT(more,mod)%mod\n ans = ans*C(hasLess, less, mod)%mod\n ans*=FACT(n-less-more-1, mod)\n ans%=mod\n print(ans)\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f95035ec0271bb854cef2c705fb6fa6", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "/*\n In the name of ALLAH\n Author : Raashid Anwar\n*/\n \n#include \nusing namespace std;\n \n#define int int64_t\nconst int M1 = 998244353;\nconst int M2 = 1000000007;\nmt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());\n \nint mpow(int a, int b) {\n int r = 1;\n while (b) {\n if (b & 1)\n r = (r * a) % M2;\n a = (a * a) % M2;\n b >>= 1;\n }\n return r;\n}\n \nvoid solve() {\n int n, x, pos, less = 0, high = 0;\n cin >> n >> x >> pos;\n vector fact(n + 1, 1), inv(n + 1, 1);\n for (int i = 1; i <= n; i++)\n fact[i] = (fact[i - 1] * i) % M2;\n for (int i = 0; i <= n; i++)\n inv[i] = mpow(fact[i], M2 - 2) % M2;\n vector a(n, 0);\n int lo = 0, hi = n;\n while (lo < hi) {\n int mi = (lo + hi) >> 1;\n if (mi <= pos) {\n lo = mi + 1;\n a[mi] = -1;\n } else {\n hi = mi;\n a[mi] = 1;\n }\n }\n a[pos] = 0;\n for (int i = 0; i < n; i++) {\n if (a[i] == -1)\n less++;\n if (a[i] == 1)\n high++;\n }\n \n auto nCr = [&](int a, int b) {\n if (a < b || a < 0 || b < 0)\n return (int)0;\n int ans = (fact[a] * inv[b]) % M2;\n ans = (ans * inv[a - b]) % M2;\n return ans;\n };\n \n cout << nCr(x - 1, less) << \", \" << nCr(n - x, high) << \", \" << fact[less] << \", \" << fact[high] << \", \" << fact[n - less - high - 1] << \"\\n\";\n int ans = (nCr(x - 1, less) * nCr(n - x, high)) % M2;\n ans = (ans * fact[less]) % M2;\n ans = (ans * fact[high]) % M2;\n ans = (ans * fact[n - less - high - 1]) % M2;\n cout << ans << \"\\n\";\n}\n \nint32_t main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n solve();\n}\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fff4e2330a2829e808a24adb20674a9e", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import math\n\ndef binary_search(a, x):\n left = 0\n right = len(a)\n n_less = 0\n n_greater = 0\n while left < right:\n middle = (left + right) // 2\n # print(f\"middle: {middle}\")\n if a[middle] <= x:\n left = middle + 1\n if x != middle:\n n_less += 1\n else:\n right = middle\n n_greater += 1\n if left > 0 and a[left - 1] == x:\n return True, n_less, n_greater\n else:\n return False, n_less, n_greater\n\ndef combination(n, k):\n # print(f\"n: {n} k: {k}\")\n if k > n:\n return 0\n else:\n return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))\n\nnxpos = input().split(\" \")\n\nn = int(nxpos[0])\nx = int(nxpos[1])\npos = int(nxpos[2])\n\nn_smaller_numbers = x - 1\nn_bigger_numbers = n - x\n\na = [i for i in range(n)]\n_, n_less, n_greater = binary_search(a, pos)\n\n# print(f\"n_less: {n_less} n_greater: {n_greater}\")\n# print(f\"n_smaller_numbers: {n_smaller_numbers} n_bigger_numbers: {n_bigger_numbers}\")\n\nc1 = combination(n_smaller_numbers, n_less) * math.factorial(n_less)\nc2 = combination(n_bigger_numbers, n_greater) * math.factorial(n_greater)\nres = c1 * c2 * math.factorial(n - n_less - n_greater - 1)\nprint(res % (1000000000 + 7))\n\n\n\n\n\u00a0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e1028cdf1e2f06984eb23669358e20b", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env pypy\nfrom __future__ import division, print_function\nfrom collections import defaultdict, Counter, deque\nfrom future_builtins import ascii, filter, hex, map, oct, zip\nfrom itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement,product\nfrom __builtin__ import xrange as range\nfrom math import ceil, factorial, log,tan,pi,cos,sin,radians\nfrom _continuation import continulet\nfrom cStringIO import StringIO\nfrom io import IOBase\nimport __pypy__\nfrom bisect import bisect, insort, bisect_left, bisect_right\nfrom fractions import Fraction\nfrom functools import reduce\nfrom decimal import *\nimport copy\nimport string\nimport sys\nimport os\nimport re\ninf = float('inf')\nmod = int(1e9) + 7\nmod_ = 998244353\n\ndef factors(n):\n from functools import reduce\n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef sieve(n):\n arr=[1]*n\n for i in range(2,int(n**0.5)+1):\n if arr[i]==1:\n for j in range(i,n,i):\n arr[j]=i\n return arr\n\n\ndef isprime(x):\n if x<=3:\n return True\n for i in range(2,int(x**0.5)+1):\n if x%i==0:\n return False\n return True\n\ndef check(arr):\n rev=[]\n for i in arr:\n rev.append(reversed(i))\n for i in range(len(arr)):\n if not(isprime(sum(arr[i])) and isprime(sum(rev[i]))):\n return False\n return True\n\ndef main():\n n,x,pos=map(int,input().split())\n def binary_search(x,n,pos):\n l=0\n r=n\n cnt=cnt2=0\n rem=n-1\n temp=1\n while l<=r:\n mid=(l+r)//2\n # print(mid)\n if mid==pos:\n # print(cnt,cnt2,rem,temp)\n l=mid+1\n \n elif mid\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define rep(i, n) f(i, 0, n - 1)\n#define f(i, a, b) fd(i, a, b, 1)\n#define fd(i, a, b, d) for(int i = (a); i <= (int)(b); i += (d))\n#define uint64 unsigned int64\n#define int64 long long\n\ntemplate\nT bpow_m(T a, T n, T m)\n{\n T b = 1;\n while(n)\n {\n if(n & 1)\n b = (b * a) % m;\n a = (a * a) % m;\n n >>= 1;\n }\n return b;\n}\n\nbool isSquare(int x, int p)\n{\n f(i, 1, p - 2)\n if (bpow_m(x, i, p) - 1 == 0)\n return false;\n return bpow_m(x, p - 1, p) - 1 == 0;\n}\n\nvoid main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n int p;\n cin >> p;\n int count = 0;\n f(x, 1, p - 1)\n if(isSquare(x, p))\n count++;\n cout << count;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "73c85d8bfef26d0c4cb4ba54c7c91d7b", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "from __future__ import print_fucntion\nn = int(raw_input())\ndef sqrt(i):\n global n\n x = i\n for rep in range(1, n-1):\n if x == 1: return 0\n x = x*i%n\n if x == 1: return 1\n return 0\na = []\nfor i in range(1,n):\n a[i] = sqrt(i)\nprint(sum(a))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c8e355f8ea96fdbb7ba011050252b534", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "k, a, b = map(int, raw_input().split())\n\naa, bb = a / k, b / k\nif aa == 0 && b % k != 0:\n print -1\nelif bb == 0 && a % k != 0:\n print -1\nelse:\n print aa + bb", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ad79614dfbcf386b7e8ff4c88f9af03d", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "string = input()\nn, a, b = map(int, string.split())\ns = a // n + b // n\nif s == 0:\n print(-1)\nelse:\n print(s)string = input()\nn, a, b = map(int, string.split())\ns = a // n + b // n\nif s == 0:\n print(-1)\nelse:\n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e5591cc1e96894c9888014663ceb685", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "K, a, b = map(int, input().split())\nif a >= K and b >= K:\n print(a\\K + b\\K)\nelif a >= K and b < K:\n print(-1 if a%K != 0 else a\\K)\nelif a < K and b >= K:\n print(-1 if b%K != 0 else b\\K)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bea9e7bc18c5da4a1087c662029389bc", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k,a,b = list(map(int,input()))\nans = ( (a+b) // k )\n\nif( ans == 0 ):\n print(\"-1\")\nelse\n print( ans )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "263eec02d2cac72bdc17e736a9f3222b", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "k,a,b=map(int,input().split())\nif a>=k or b>=k or a%k==0 or b%k==0:\n print(a//k+b//k if a//k+b//k or -1)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "106efe028b77be40107d1ad6dcc2cf07", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python2\nfrom __future__ import print_function\n\nimport os\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\nrange = xrange\n\n\ndef mat_mul(A, B, MOD):\n n = len(A)\n m = len(B)\n p = len(B[0])\n\n MODF = float(MOD)\n\n C = [[0] * p for _ in range(n)]\n B = [[(Bi[j] & (2**16 - 1)) + 1j * (Bi[j] >> 16) for j in range(n)] for Bi in B]\n\n for i in range(n):\n row = [0.0] * p\n\n Ai = A[i]\n for k in range(m):\n Aik = Ai[k] + 1j * ((Ai[k] << 16)\n Bk = B[k]\n for j in range(p):\n row[j] += Aik.real * Bk[j].real + Aik.imag * Bk[j].imag\n\n C[i] = [int(row[j] % MODF) for j in range(p)]\n\n return C\n\n\ndef eye(m):\n identity = [[0] * m for _ in range(m)]\n for i, row in enumerate(identity):\n row[i] = 1\n\n return identity\n\n\ndef mat_pow(mat, n, mod):\n res = eye(len(mat))\n\n if n == 0:\n return res\n\n for i in bin(n)[:1:-1]:\n if i == '1':\n res = mat_mul(mat, res, mod)\n mat = mat_mul(mat, mat, mod)\n\n return res\n\n\ndef main():\n n, m = map(int, input().split())\n\n mat = [[0] * m for _ in range(m)]\n mat[0][0] = 1\n mat[-1][0] = 1\n for i in range(m - 1):\n mat[i][i + 1] = 1\n\n print(mat_mul(mat_pow(mat, n, 1000000007), [[1] * m], 1000000007)[0][-1] % 1000000007)\n\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "78630b36e7f4623beef00a6b8a7032fa", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "\n 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\nlltwo = ll(2)\n\nMOD = ll(10**9+7)\n\nbitmask = 32-1\ndef mult(A,B):\n n,m,p = len(A[0]),len(B),len(A)\n C = np.zeros((m,n),lltype)\n for j in range(p):\n for i in range(n):\n if lltwo*A[j,i]>=MOD:\n A[j,i]-=MOD\n \n for j in range(m):\n for k in range(p):\n Bjk = B[j,k]\n if lltwo*Bjk>=MOD:\n Bjk -= MOD\n \n for i in range(n):\n C[j,i] += A[k,i] * Bjk\n if k&bitmask==bitmask or k == p-1:\n for i in range(n):\n C[j,i] %= MOD\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 = np.zeros((m,m),lltype)\n\nmat[0,0] = 1\nmat[-1,0] = 1\nfor i in range(m-1):\n mat[i,i+1] = 1\n\nvec = np.empty((1,m),lltype)\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": "b5badf36118bcaf55e8c7ed24100f009", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nimport sys\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef mat_mul_mod(A, B, mod):\n n, p = len(A), len(B[0])\n fmod = float(mod)\n float_prec = float((1 << 51) - 1)\n\n B = [[(Bij & ((1 << 16) - 1)) - 1j * (Bij >> 16) for Bij in Bi] for Bi in B]\n C = [[0] * p for _ in range(n)]\n\n for i, Ai in enumerate(A):\n row = [0.0] * p\n for j, Bj in enumerate(B):\n imag = 0\n for i in range(16):\n imag *= 2\n imag -= 0 if imag < mod else mod\n Aij = Ai[j] + 1j * imag\n for k, Bjk in enumerate(Bj):\n row[k] += (Aij * Bjk).real\n if row[k] > float_prec:\n row[k] %= fmod\n\n C[i] = [int(r % fmod) for r in row]\n\n return C\n\n\ndef main():\n MOD = 10**9 + 7\n\n n, m = map(int, input().split())\n\n mat = [[0] * m for _ in range(m)]\n mat[0][0] = 1\n mat[0][-1] = 1\n for i in range(m - 1):\n mat[i + 1][i] = 1\n\n vec = [1] * m\n\n for i in bin(n)[:1:-1]:\n if i == '1':\n vec = [sum(a * b for a, b in zip(row, vec)) % MOD for row in mat]\n mat = mat_mul_mod(mat, mat, MOD)\n\n print(int(vec[-1]))\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "185756aeaf25694b232da24a27d84ff5", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom math import trunc\n# How to multiply matrices in 32 bit python?\n# Solution: Use doubles with homemade mult and mod.\n# This should be around 4-6 times faster than using int\n# and around 50% to the speed you'd get in 64 bit python.\n\nMOD = 10**9 + 7\nMODF = float(MOD)\nMODF_inv = 1.0/MODF\nFLOAT_PREC = float(2**52)\n\n# Mods float x, note modder(-1.0)=-1.0\ndef modder(a):\n return a - MODF * trunc(a * MODF_inv)\n\nSHRT = float(1 << 16)\nSHRT_inv = 1.0/SHRT\n# Calc modder(c+a*b)\ndef mod_prod(a, b, c=0):\n a1 = trunc(a*SHRT_inv)\n a2 = a-SHRT*a1\n b1 = modder(b * SHRT)\n b2 = b\n return modder(a1*b1+a2*b2+c)\n\n# Slower version, but readable\ndef mult(A,B):\n n,m = len(A[0]),len(B)\n C = [[0.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] = 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.0]*m for _ in range(m)]\n\nmat[0][0] = 1.0\nmat[-1][0] = 1.0\nfor i in range(m-1):\n mat[i][i+1] = 1.0\n\nvec = [[1.0]*m]\nvec = power(mat,vec,n,mult)\nprint(int(vec[0][-1]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c9f50a2992809749dba38ba286812586", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.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)\n\ndef mult(A,B):\n n,m = len(A[0]),len(B)\n C = np.zeros([n,m],lltype)\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] = (C_j[i]+Aik*Bkj)%MOD\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 = np.zeros([m,m],lltype)\n\nmat[0][0] = 1\nmat[-1][0] = 1\nfor i in range(m-1):\n mat[i][i+1] = 1\n\nvec = np.zeros([m,1],lltype)\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": false, "code_uid": "210a63eaf8a6a41e2bf7094729749b44", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "\n\n n = int(input())\n arr = [[int(i) for i in input().split()] for j in range(n)]\n ans = 0\n for i in range(n):\n ans += arr[i][i]\n arr[i][i] = 0\n ans += arr[n - 1 - i][i];\n arr[n - i - 1][i] = 0\n ans += arr[n-1-i][n//2];\n arr[n-i-1][n//2] = 0\n ans += arr[n//2][n-1-i];\n arr[n//2][n-1-i] = 0\n print(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5de1c83b3dfef532c7918af42c9fe041", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n = int(input())\nk = 0\nfor i in range(n):\n l = list(map(int,input().split()))\n k += l[n//2]\n if n != n//2:\n k=k+l[i]+l[-i-1]\nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "81bac4ce309dba983609dca6bfa7d8e3", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "Python 3", "source_code": " n = int(input())\ns = 0\n\nfor i in range(n):\n a = list(map(int, input().split()))\n \n if n == 1 :\n s = a[0]\n \n elif n == 2 or n == 3:\n s += sum(a)\n \n else:\n \n if n % 2 == 0:\n s += a[i] + a[-i-1]\n \n else:\n \n if i == int(n/2)+1:\n s += sum(a)\n \n else:\n s += a[i] + a[-i-1] + a[int(n/2)+1]\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "88545c0ce358a2449575e2d858016b4c", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n=input()\nm=[map(int, raw_input().split() for i in [0]*n]\nprint sum( m[i][j] for i in range(n)\n for j in range(n)\n if i == j or i == n-j-1 or i == n/2 or j == n/2)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96c9534d067e177e6a014c82dc71df69", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\na=[]\nsum=0\nfor i in range(n):\n\ta.append(map(int,input().split()))\nfor x in range(n):\n\tfor y in range(n):\n\t\tif x==y or x=n-(y+1):\n\t\t\tsum+=a[x][y]\n\t\telif x==int(n%2) or y==int(n%2):\n\t\t\tsum=a[x][y]\nprint(sum)\t\t\t\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "137ae75a8337f3e5de44af58a20aab0f", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "PyPy 2", "source_code": "ways = int(raw_input())\ndivisors = [val ** 3.0 for val in xrange(2, 170417)]\nintdivisors = [val * val * val for val in xrange(2, 170417)]\nlow, high = 1, 4949100894494448\nwhile low < high:\n mid = (low + high) / 2\n if sum(int(mid / divisors[i]) for i in xrange(min(len(divisors), int(mid ** 0.3336)))) >= ways:\n high = mid\n else:\n low = mid + 1\nprint -1 if sum(low / divisor for divisor in intdivisors) != ways else low\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e07c31b7203f5e4e2cd3a01199b19915", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "n = int(input())\nbe, en, ans = 8, 8 * 10 ** 15, float('inf')\nall = [x * x * x for x in range(2, 200001)]\n\nwhile be <= en:\n cur, md, k = 0, (be + en) >> 1, 0\n\n while all[k] <= md:\n cur += md // all[k]\n k += 1\n\n if cur < n:\n be = md + 1\n else:\n if cur == n:\n ans = min(ans, md)\n en = md - 1\n # print(cur,ans,md)\n\nprint(-1 if ans == float('inf') else ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ac0887edb0e4eafac2ee8faa2817e036", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nl, r = 0, 10**16\nD = [x ** 3.0 for x in range(2, 170417)]\nDD = [x*x*x for x in range(2, 170417)]\nwhile l < r:\n m = (l+r) // 2\n if sum(int(m/d) for d in D) < n:\n l = m + 1\n else:\n r = m;\nif sum(l//d for d in DD) == n:\n print(l);\nelse :\n print(-1);\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "becdc5de62fa48eb55767f98bca1c04d", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "SIZE = 171000\nL = [i ** 3 for i in range(SIZE)]\n\ndef get_count(n):\n MAX = int(n ** (1 / 3)) + 1\n if L[MAX] > n:\n MAX -= 1\n\n res = 0\n for i in range(2, MAX + 1):\n x = n // L[i]\n if x != 1:\n res += x\n else:\n res += MAX - i + 1\n break\n return res\n\ndef bin_search(m):\n beg = int(4.8 * m)\n end = min(8 * m, int(5e15))\n while beg <= end:\n mid = (beg + end) // 2\n count_mid = get_count(mid)\n if count_mid == m:\n if beg == end:\n return mid\n end = mid\n elif count_mid > m:\n end = mid - 1\n else:\n beg = mid + 1\n return -1\n\nm = int(input())\nprint(bin_search(m))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "08565dbe66beda0c75db829563a63405", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import math\nfrom bisect import bisect_right, bisect_left\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush\nfrom itertools import accumulate\n\nR = lambda: map(int, input().split())\n\nt = int(input())\ntab = [x*x*x for x in range(2, 2*10**5)]\nl, r = 1, 5*10**15\nwhile l < r:\n n = (l + r) // 2\n s = sum(n // x for x in tab)\n if s < t:\n l = n + 1\n elif s > t:\n r = n - 1\n else:\n r = n\ns = sum(l // x for x in tab)\nif s != t:\n print(-1)\nelse:\n print(l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "517245eb195aee15644bd8c76ecbcd1e", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\nimport math\n\nn, m = sys.stdin.readline().split()\nn = int(n.strip())\nm = int(m.strip())\n\nln = int(math.log(n, 7) + 1)\nlm = int(math.log(m, 7) + 1)\n\ndef gen_perm(l, lst):\n if l > len(lst):\n return 0\n elif l == 0:\n return []\n else:\n res = []\n for i in range(len(lst)):\n if l == 1:\n res += [[lst[i]]]\n else:\n for prm in gen_perm(l-1, lst[0:i] + lst[i+1::]):\n res += [[lst[i]] + prm]\n return res\n\n\ndef nfa(a):\n res = 0\n for i in range(len(a)):\n res = 7*res + a[i]\n return res\n\nres = 0\nl = ln + lm\n\nfor prm in gen_perm(l, range(7)):\n if nfa(prm[0:ln]) < n and nfa(prm[ln::]) < m:\n res += 1\n\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71cc7c3de2204827724fdff4c6e984c9", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import math\n\ndef make_digits(i,dn,s):\n l = 0\n t = set([])\n while i > 0:\n di = i % 7\n i = i / 7\n if di in s or di in t:\n return None\n else:\n t.add(di)\n l += 1\n while l < dn:\n if 0 in s or 0 in t:\n return None\n else:\n t.add(0)\n l += 1\n return t\n\nn,m = map(int,raw_input().split(' '))\n\ndn = int(math.log(n,7)) + 1\ndm = int(math.log(m,7)) + 1\n\ncount = 0\nfor i in range(n):\n s = set([])\n s = make_digits(i,dn,s)\n if s == None:\n continue\n for j in range(m):\n flag = False\n t = make_digits(j,dm,s)\n if t == None:\n continue\n count += 1\nprint count\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef4975d18b14a1bd5ca48cbf3b71d9a6", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nn , m = list( map( int , input().split() ) )\n\nn = min( n , 7 ** 7 )\nm = min( m , 7 ** 7 )\n\ndef f( hour , minutes , l ):\n\tif len( l ) == 0:\n\t\treturn 1\n\tres = 0\n\tfor i in l:\n\t\tlp = [ x for x in l if x != i ]\n\t\th = hour * 10 + i\n\t\tif( h < n ) res += f( h , minutes , lp )\n\t\tmi = minutes * 10 + i\n\t\tif( m < mi ) res += f( hour , mi , lp )\n\treturn res\n\nprint( f( 0 , 0 , range( 7 ) ) )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a47841054c2e6b365dfddc2ed4a84054", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nn , m = list( map( int , input().split() ) )\n\nn = min( n , 7 ** 7 )\nm = min( m , 7 ** 7 )\n\ndef f( hour , minutes , l ):\n\tif len( l ) == 0 || hour != minutes :\n\t\tres = 1\n\telse res = 0\n\tfor i in l:\n\t\tlp = [ x for x in l if x != i ]\n\t\th = hour * 10 + i\n\t\tif( h < n ):\n\t\t\tres += f( h , minutes , lp )\n\t\tmi = minutes * 10 + i\n\t\tif( mi < m ):\n\t\t\tres += f( hour , mi , lp )\n\treturn res\n\nprint( f( 0 , 0 , range( 7 ) ) )", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b243f11b153f4832adc2415fcbdb4fef", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n#define FOR(I,A,B) for(long long i=I;i=A;j-=B)\n#define str(A) for(long long k=0;A[k]!='\\0';k++)\n#define pb push_back\n#define mp make_pair\n#define pii pair\n#define all(v) v.begin(),v.end()\nvector adj[100001];\nbool visit[100001];\nconst int mod = 1000000007;\nll mod_mult(ll a,ll b)\n{\n\treturn ((a%mod)*(b%mod))%mod;\n}\nll mult(ll x,ll y) { ll prod = 1; while(y>0){ if(y&1) prod = mod_mult(prod,x); x=mod_mult(x,x); y/=2;} return prod;}\nint base(int n)\n{\n\tint i =0;\n\twhile(n>0)\n\t\ti++,n/=7;\n\treturn i;\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\tll n,m,i;\n\tcin>>n>>m;\n\tint a = base(n), b = base(m);\n\tcout<7)\n\t\tcout<<0;\n\telse\n\t{\n\t\tint ans=0,arr[] = {0,1,2,3,4,5,6};\n\t\tdo{\n\t\t\tint x = 0, y = 0;\n\t\t\tfor(int i = 6, j = 0; i>6-b; i--, j++)\n\t\t\t{\n\t\t\t\tx += mult(7,j)*arr[i];\n\t\t\t}\n\t\t\tfor(int i = 6-b, j =0; i>6-a-b; i--,j++)\n\t\t\t{\n\t\t\t\ty += mult(7,j)*arr[i];\n\t\t\t}\n\t\t\tcout<=0:\n z1=y1\n z2=y2\n mindif=t-t0\n if y2==0 or y1==0:break\n if(t-t0)>0: \n y2-=1\n elif (t-t0)<0:y1-=1\n else: break \n\nprint z1,z2\n \n \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2b09a241c07d25d4df5c0c78c70d1aa", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "import math\ndef gcd(a,b):\n if(b==0):\n return a\n return gcd(b,a%b)\nl=input().split()\nt1=int(l[0])\nt2=int(l[1])\nx1=int(l[2])\nx2=int(l[3])\nt0=int(l[4])\nnum1=t2-t0\nnum2=t0-t1\nif(t1==t2):\n print(x1,x2)\n quit()\nif(num1==0):\n print(0,x2)\n quit()\nif(num2==0):\n print(x1,0)\n quit()\nz=num2/num1\nmaxa=10**18\nans=(0,0)\nfor i in range(1,x1+1):\n ok=z*i\n if(ok>x2):\n break\n num1=i\n num2=math.ceil(ok)\n if(maxa==((num2/num1)-z) and num2+num1>ans[0]+ans[1]):\n ans=(num1,num2)\n elif(maxa>((num2/num1)-z)):\n ans=(num1,num2)\n maxa=((num2/num1-z))\nif(ans==(0,0)):\n ans=(0,x2)\nprint(ans[0],ans[1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e7453bbc5ba17f31550ae1522f9a8d57", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"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 if temp < t:\n return [a,b,100000000000000]\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\n bestans.append(give(x1,x2))\n bestans.append(give(0,x2))\n bestans.append(give(x1,0))\n\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 for i in range(1,x2 + 1):\n curry1 = i*r\n a = curry1\n b = i\n if 0 <= int(curry1) <= x1:\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 <= math.ceil(curry1) <= x1:\n c,d,e = give(math.ceil(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\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": "7b7a0df5adf739344a333b50ac8182fe", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"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\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\n r = (t2 - t)/(t - t1)\n bestans.append([x1,x2,0])\n bestans.append([0,x2,0])\n bestans.append([x1,0,0])\n\n for i in range(1,x2 + 1):\n curry1 = i*r\n if 0 <= int(curry1) <= x1:\n bestans.append([int(curry1),i,curry1 - int(curry1)])\n if 0 <= math.ceil(curry1) <= x1:\n bestans.append([math.ceil(curry1),i,math.ceil(curry1) - curry1])\n\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(*bestans[0][:-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "82d91dabef3baaef5d2073d49fe50afb", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import fractions\nimport sys\nimport math\n\ntoks = sys.stdin.readline().split()\nt1 = int(toks[0])\nt2 = int(toks[1])\ny1max = int(toks[2])\ny2max = int(toks[3])\nt0 = int(toks[4])\n\ndt1 = t0 - t1\ndt2 = t2 - t0\n\nif dt1>0:\n calc1max = (y2max * dt2) / dt1\n if calc1max1:\n y2 -= 1\n err = (1*t1 + y2*t2) / float( 1+y2)\n if err<0.0: break\n if erry1max:\n y2 = (y1max * dt1 + dt2 - dt2) / dt2\n y1 = (y2 * dt2) / dt1\n\n g = fractions.gcd( dt1, dt2)\n if g > 1:\n dt1 /= g\n dt2 /= g\n\n minErr = (float( y2 * t2 + y1 * t1 ) / (y1+y2)) - t0\n\n rem1 = y1 % dt2\n rem2 = y2 % dt1\n y11, y12, y21, y22 = y1, y1, y2, y2\n err1, err2 = minErr,minErr\n\n if rem11:\n y2-=1\n y1 = (y2 * dt2) / dt1\n err = (float( y2*t2 + y1*t1 ) / (y1+y2)) - t0\n if err 0:\n\t\tprint((max(x2, x1) - min(x1, x2)) * (max(y1, y2) - min(y1, y2)))\n\telse:\n\t\tprint(-1)\nelif n == 3:\n\tx1, y1 = map(int, input().split())\n\tx2, y2 = map(int, input().split())\n\tx3, y3 = map(int, input().split())\n\tif (max(x3, x2, x1) - min(x1, x2, x3)) * (max(y1, y2, y3) - min(y1, y2, y3)) > 0:\n print((max(x2, x1, x3) - min(x1, x2, x3)) * (max(y1, y2, y3) - min(y1, y2, y3)))\n\telse:\n\t\tprint(-1)\nelif n == 4:\n x1, y1 = map(int, input().split())\n x2, y2 = map(int, input().split())\n x3, y3 = map(int, input().split())\n\tx4, y4 = map(int, input().split())\n if (max(x3, x2, x1, x4) - min(x1, x2, x3, x4)) * (max(y1, y2, y3, y4) - min(y1, y2, y3, y4)) > 0:\n print((max(x2, x1, x3, x4) - min(x1, x2, x3, x4)) * (max(y1, y2, y3, y4) - min(y1, y2, y3, y4)))\n else:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7f2354d2577fa0729820e519042cef30", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nxs = set()\nys = set()\nfor i in range(n)\n x, y = map(int, raw_input().split())\n xs.add(x)\n ys.add(y)\n\nif len(xs) > 1 and len(ys) > 1:\n dx = max(xs) - min(xs)\n dy = max(ys) - min(ys)\n print dx*dy\n\nelse:\n print -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e534421a8168f47a19cc9d546e8d0c5a", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import math\n\ndef get_n():\n return int(input())\n\ndef get_int_vector():\n return [int(x) for x in input().split()]\n\ndef list2string(list):\n result = []\n for i in list:\n result.append(str(i))\n return ':'.join(result)\n\ndef string2vector(string):\n return [int(x) for x in string.split(':')]\n\nn = get_n()\n\npoints = []\nfor _ in range(n):\n points.append(get_int_vector())\n\npoints.sort(key=lambda x: x[1])\npoints.sort(key=lambda x: x[0])\n\nif n == 1:\n print(-1)\n exit(0)\nif n == 2 and (points[0][0] == points[1][0] or points[0][1] == points[1][1]):\n print(-1)\n exit(0)\n\nif n == 3:\n vec_a = [points[1][0] - points[0][0], points[1][1] - points[0][1]]\n vec_b = [points[2][0] - points[1][0], points[2][1] - points[1][1]]\n vec_mult = abs(vec_a[0]*vec_b[1] - vec_b[0]*vec_a[1])\n result = 1\n #print(vec_mult)\n while result**2 != vec_mult:\n result += 1\n print(result)\nelif n == 2:\n print(abs(points[0][0]-points[1][0])*abs(points[0][1]-points[1][1]))\nelse:\n print(abs(points[0][1]-points[1][1])*abs(points[0][0]-points[3][0]))\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "30094520cb879d5450a835128e9f3aea", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "import sys\n\ndef main(argv):\n\tnum = int(raw_input())\n\n\tif num < 2:\n\t\tprint \"-1\"\n\t\tsys.exit()\n\n\tpoints = list()\n\tfor x in xrange(num):\n\t\tpos = [int(item) for item in raw_input().split(' ')]\n\t\tpoints.append(pos)\n\n\tif num == 2:\n\t\tif points[0][0] == points[1][0] or points[0][1] == points[1][1]:\n\t\t\tprint \"-1\"\n\t\t\tsys.exit()\n\n\tlen1 = 0\n\tlen2 = 0\n\tindex = 0\n\twhile len1 == 0 or len2 == 0:\n\t\tif points[index][0] != points[index + 1][0]:\n\t\t\tlen1 = abs(points[index][0] - points[index + 1][0])\n\n\t\tif points[index][1] != points[index + 1][1]:\n\t\t\tlen2 = abs(points[index][1] - points[index + 1][1])\n\n\tprint repr(len1 * len2)\n\n\nif __name__ == \"__main__\":\n\tmain(sys.argv)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "755d3f791f59f9584169aa16f39cb46d", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def solve(n, s):\n cur = -1\n for i in xrange(s, n + 1):\n ds = sum(map(int, str(i)))\n if i - ds >= s:\n cur = i\n break\n if cur == -1:\n return 0\n return n - cur + 1\n \nassert solve(12, 1) == 3\nassert solve(25, 20) == 0\nassert solve(10, 9) == 1\n\n\n(n, s) = map(int, raw_input().split())\nprint solve(n, s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d37249f7b9465af43712ccbdbc8fc4d1", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def f(n):\n res = n\n while n != 0:\n res -= n % 10\n n /= 10\n return res\n\n\n\nn,s = raw_input().split(\" \")\n\nl = 1\nd = n\n\nif f(n) < s:\n print \"0\"\n return\n\nwhile l < d:\n mid = l + (d - l)/2\n if f(mid) >= s:\n d = mid\n else:\n l = mid + 1\n\nprint n - l + 1\n\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3596b02b47dc25d14311ee6ec60d5cbb", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nfor num in range(n+1):\n\tst = str(num)\n\tsumm = sum_digits(x)\n\tif num - summ >= s:\n\t\tcount += 1\n\nprint( count)\n\nfor num in range(n+1):\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9c1e987507ddf2f80ded9a46099a1b65", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, s = [int(x) for x in input().strip().split(\" \")]\ns = 1, e = n + 1\nwhile(s < e):\n mid = (s+ e)/2\n if mid - sum(map(int, str(c))) < s:\n a = c + 1\n else:\n b = c\nprint(n-a+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0489e0cbda30e72b3d0bf12abf128500", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, k = [int(x) for x in input().strip().split(\" \")]\ns = 1, e = n + 1\nwhile(s < e):\n mid = (s+ e)/2\n if mid - sum(map(int, str(c))) < k:\n a = c + 1\n else:\n b = c\nprint(n-a+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f834afddc435ec8ff79346fe9a913a5", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def isPossible(w):\n currentPlayers = [1,2]\n allPlayers = [1,2,3]\n\n for(player in w):\n if(player in possiblePlayers):\n for(spectator in allPlayers):\n if spectator not in currentPlayers:\n nextPlayer = spectator\n possiblePlayers.append(nextPlayer)\n possiblePlayers.remove(player)\n else:\n return 'NO'\n \n return 'YES'\n \n\nw = []\nwhile True:\n line = input()\n if line:\n w.append(int(line))\n else:\n break\n\n\nprint(w)\n\nprint(isPossible(w))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76811164b68815b5376a9dd5d55675b1", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Python 3", "source_code": "c = 3\nn = int(input())\nfor i in range(n):\n a = int(input())\n\tif a == c:\n\t print('NO')\n\t\texit()\n c = 6-c-a\nprint('YES')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0196bef89855360618e99c426369b56", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(input())\nperson = 3\nfor i in range(n):\n win = int(input())\n if win == person:\n\tprint('NO')\n\texit()\n else:\n\tperson = 6 - person - win\nprint('YES')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "17c41e71f233dd6dcab96d824347927d", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Python 3", "source_code": "p1,p2,valid=1,2,True\nfor i in range(int(input()):\n a=int(input())\n if valid:\n continue\n if a!=p1 and a!=p2:\n valid=False\n s=6-p1-p2\n if a==p1:\n p2=s\n else:\n p1=s\nif valid:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82452087dee61cac07f34c2cc98174d9", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Python 3", "source_code": "##chess for tree\n##893A\n\n\ndef getplayers(lst): ##gets the players of the first game with a different winner\n for i in range(len(lst)):\n if lst[i] != lst[0]:\n finali = i\n break\n return i, lst[0], lst[i]\n\ndef getnewplayer(lst):\n for i in range(1,4):\n if i is not in lst:\n return i\n \n\n\n\n\n \n\n\n\nresult = \"YES\"\nn = input() ##number of games played\nwinners = []\nfor i in range(n):\n winner = input()\n winners.append(winner)\ngameandplayers = getplayers(winners)\ngame = gameandplayers[0]\nplayers = gameandplayers[1,2]\nfor i in range(game, n):\n if winners[i] is not in players:\n result = \"NO\"\n break\n else:\n newplayer = getnewplayer(players)\n players = (winner, newplayer)\n \n\nprint(result)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c723b46903faea76bfd47a9099cb0392", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n, a, b = map(int, input().split())\nprint(min(n-a, b+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "101c63c4226e6b3c9330e78a649c868b", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Python 3", "source_code": " n, a, b = map(int, input().split())\n print(min(n-a, b+1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6127cdf05a0ca0528b1886121ab1494b", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\n\ndef main():\n\tinp = input.readline().split(' ')\n\tn = int(inp[0])\n\ta = int(inp[1])\n\t#b = int(inp[2])\n\n\toutput.write(n - a)\n\t\n\ndef run():\n\t\n\tglobal input, output\n\tinput = sys.stdin\n\toutput = sys.stdout\n\n\tmain()\n\n\nif __name__ == '__main__':\n\trun(", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ea17bfcc1c69fe189276d6fb1346722e", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n, a, b = map(int, input().split())\nprint(min((n-a),b+1)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "65d2bf80f75adebe9b37c289844be877", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "arr = [int(x) for x in input().split(' ')\nn=arr[0] \na=arr[1]\nb=arr[2]\npos=0\nfor i in range(a+1, n+1):\n pos+=1\nprint(pos)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "166d3259ff477b99ddd1a1526853b720", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "a = map(int, raw_input().split())\nprint min(a[0], a[1], a[2] / 2, a[3] / 7, a[4] / 4)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91df7bf194d4e528911e293051e56d0e", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "a, b, c, d, e = map(int, input().split())\n\na //= 1\n\nb //= 1\n\nd //= 7\n\ne //= 4\n\nc //= 2\n\nprint(min(a, b, c, d, e))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2498649a117ff279de3d6d01bc16bd11", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def solve(in):\n if in=='2 4 6 8 10': return 1\n return 0\n ar = list(map(int,in.split(' ')))\n r = 1\n d = ar[1]-ar[0]\n for i in range(len(ar)-2):\n if ar[i+2]-ar[i+1]!=d: r = 0\n return r\n\nin = input()\nprint(solve(in))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "786cd72fa78698921283c6af09c355c0", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#coding:utf-8\nimport os\nimport sys\n\nf = None\ndef readLine():\n global f\n if len(os.environ) == 63:\n if not f:\n f = open(\"a.txt\")\n return f.readline()\n else:\n return raw_input()\n\n\nif __name__ == '__main__':\n print min([x/y for x, y in zip(map(int, readLine().split()), [1, 1, 2, 7, 4])])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9cdacd11bcf5fdf32a23fef1aa655de4", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "requirements = (1, 1, 2, 7, 4)\n\ningrs = [int(x) for x in input().split(\" \")]\n\nmin_count = 2**64\n\nfor i, x in enumerate(ingrs):\n if i >= len(requirements):\n continue\n min_count = min(int(x / requirement[i]), min_count)\n\nprint(min_count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56f38792dcec74cc6749a4ee0ae94833", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "contador = 0\nif (2 * a <= b):\n return contador\nelif (a >= b):\n superior = b - 1\n inferior = 1\n while (inferior < superior and inferior != superior):\n contador += 1\n inferior += 1\n superior -= 1\n return contador\nelif (a < b):\n vec = []\n inferior = b - a\n superior = a\n while (inferior < superior and inferior != superior):\n contador += 1\n inferior += 1\n superior -= 1\n return contador\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2c61eddfaa16553f9e59f2c4ac1f1b5c", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "#include\n#define int long long\n#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)\nusing namespace std;\n\nint32_t main(){\n IOS; int n, m; cin>>n>>m;\n string s, t; cin>>s>>t;\n int start = 0, end = n-1;\n vectorresult(n+1), temp;\n while(endtemp.size())\n result = temp;\n start++, end++;\n }\n cout< n:\n perv = k - n \n rasn = n - perv + 1\n otvet = rasn / 2\n math.floor(otvet)\n print(int(otvet))\n elif k == n:\n if k % 2 == 0:\n otvet = k / 2\n print(int(otvet))\n else:\n k -= 1\n otvet = k / 2\n print(int(otvet))\n else:\n otvet = (k - 1) / 2 \n math.floor(otvet)\n print(int(otvet))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4c3626d70f5676c8dbc3fccebb4aaeab", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\nint main(){\n long long int n, k;\n cin>>n>>k;\n long long int arr[n];\n for(int i=0;i0):\n ans = s1+'/'+s2\n else:\n ans = s1+s2\n print(ans)\n else:\n for i in range(len(s)):\n if(s[i]=='r' and s[i+1]=='u' ):\n sm =s[:i]\n s1 = s1+sm+'.ru'\n s2 = s2+s[i+2:]\n break\n if(len(s2)>0):\n ans = s1+'/'+s2\n else:\n ans = s1+s2\n print(ans)\nelif(s[0]=='f'):\n\n s1 = s[:3]+'://'\n s2 = ''\n s =s[3:]\n if (s[0] == 'r' and s[1] == 'u'):\n s1 = s1 + s[0] +s[1]\n else:\n for i in range(len(s)):\n if(s[i]=='r' and s[i+1]=='u' ):\n sm =s[:i]\n s1 = s1+sm+'.ru'\n s2 = s2+s[i+2:]\n break\n if(len(s2)>0):\n ans = s1+'/'+s2\n else:\n ans = s1+s2\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "207a288d78a8e6d6eeebebd0d97c02e3", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "if(s[0] == 'f'):\n fs = 'ftp://'\n s = s[3:]\nelse:\n fs = 'http://'\n s = s[4:]\nfor i in range(len(s)-1):\n if(s[i]+s[i+1] == 'ru'):\n j = i+1\n break\nfs = fs+s[0:j-1]+'.ru'\nif(j != len(s)-1):\n fs = fs+'/'+s[j+1:]\nprint(fs)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c85332318b8521cd25b193721694d30", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s = input().strip()\n\nj = 3\nif s[0] == 'h':\n j = 4\n\ni = j\nk = 0\nwhile i < len(s):\n if k > 0 and s[i] == 'r' and s[i + 1] == 'u':\n break\n i += 1\n k = 1\n\nif i + 2 == len(s):\n print s[:j] + \"://\" + s[j:i] + \".ru\"\nelse:\n print s[:j] + \"://\" + s[j:i] + \".ru/\" + s[i+2:]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "57578448baed19c1e4712042a0fcefa2", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = raw_input()\nj = s.find('ru')\nans = ''\nif s[0] == 'f'\n ans += 'ftp://'\n i = 3\nelse:\n ans += 'http://'\n i = 4\nans += (s[i:j] + '.ru')\nif j + 2 <= len(s)\n ans += ('/' + s[j + 2:])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2e0225d3d1d0168658b1126da427543a", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "s=input().strip()\n\ncon1, con2 = 'http://', 'ftp://'\n\nif s[0]=='h':\n\tstart= 4\n\tend = 4\n\tfor i in range(4,len(s)-1):\n\t\tif s[i]+s[i+1] == 'ru' && start !=end:\n\t\t\tend = i\n\t\t\tbreak\n\tans = s[start:end]\n\n\tans = con1+ans+'.ru/'+s[end+2:]\n\tprint(ans)\n\nelif s[0]=='f':\n\tstart= 3\n\tend = 3\n\tfor i in range(3,len(s)-1):\n\t\tif s[i]+s[i+1] == 'ru' && start !=end:\n\t\t\tend = i\n\t\t\tbreak\n\tans = s[start:end]\n\n\tans = con2+ans+'.ru/'+s[end+2:]\n\tprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4bff38a8a01f972225b6b93dfeefbfc8", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "def primeFactorize(n):\n factors = []\n div = 2\n while n > 1:\n while n % div == 0:\n factors.append(div)\n n //= div\n div += 1\n return factors\n\na,b = [primeFactorize(int(x)) for x in input().split()]\nans = -1\n\nif a[-1] <= 5 and b[-1] <= 5:\n ptrA = 0\n ptrB = 0\n ans = 0\n while ptrA < len(a) and ptrB < len(b):\n if a[ptrA] < b[ptrB]:\n ptrA += 1\n ans += 1\n elif a[ptrA] > b[ptrB]:\n ptrB += 1\n ans += 1\n else:\n ptrA += 1\n ptrB += 1\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d1caca557a2a9afcc2aee6ade0e4fa9", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na = map(int, raw_input().split(' '))\nm = max(a)\nm1 = min(a)\ni = a.index(m)\na[i], a[0] = a[0], a[i]\ni = a.index(m1)\na[i], a[n - 1] = a[n - 1], a[i]\na = a[1:n - 1]\na.sort()\nprint m,\nfor i in range(n - 2):\n print a[i],\nprint m1,\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d5bb0b25fa7d54975ca23f6c0a10720", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\"\"\"B - Fox Dividing Cheese\"\"\"\n\ndef pieces(a, b):\n div = [2, 3, 5]\n op = 0\n if a >= 1 and b <= 1E+10:\n if a == b:\n return op\n else:\n for i in div:\n while a % i == 0 and b % i == 0:\n a = a / i\n b = b / i\n while a % i == 0:\n a = a / i\n op += 1\n while b % i == 0:\n b = b / i\n op += 1\n if a == b:\n return op\n else:\n return -1\n else:\n return \"Error\"\n\n\na = int(input())\nb = int(input())\nprint(pieces(a, b))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bba6981bc6a92ca89199c3dacbdc2969", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "def primeFactorize(n):\n factors = []\n div = 2\n while n > 1:\n while n % div == 0:\n factors.append(div)\n n //= div\n div += 1\n return factors\n\na,b = [primeFactorize(int(x)) for x in input().split()]\nans = -1\n\nif a[-1] <= 5 and b[-1] <= 5:\n a2, a3, a5 = 0, 0, 0\n b2, b3, b5 = 0, 0, 0\n\n for i in a:\n if i==2: a2 += 1\n if i==3: a3 += 1\n if i==5: a5 += 1\n for i in b:\n if i==2: b2 += 1\n if i==3: b3 += 1\n if i==5: b5 += 1\n \n ans = abs(a2-b2) + abs(a3-b3) + abs(a5-b5)\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e4d87297bfc7c6fa5371fbe8ff95e914", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "def mdc(num_a, num_b):\n aux_1 = num_a\n aux_2 = num_b\n\n while True:\n rest = aux_1 % aux_2\n if rest == 0:\n break\n else:\n aux_1 = aux_2\n aux_2 = rest\n \n return aux_2\n\ncheese_a, cheese_b = map(int,raw_input().split(' '))\noperations = 0\n\nwhile True:\n if cheese_a > cheese_b:\n\n max_d = mdc(cheese_a, cheese_b)\n cheese_a = cheese_a / max_d\n cheese_b = cheese_b / max_d\n\n if cheese_a % 2 == 0:\n cheese_a = cheese_a / 2\n operations +=1\n elif cheese_a % 3 == 0:\n cheese_a = cheese_a / 3\n operations += 1\n elif cheese_a % 5 == 0:\n cheese_a = cheese_a / 5\n operations += 1\n else:\n operations = -1\n break\n elif cheese_b > cheese_a:\n\n max_d = mdc(cheese_b, cheese_a)\n cheese_a = cheese_a / max_d\n cheese_b = cheese_b / max_d\n\n if cheese_b % 2 == 0:\n cheese_b = cheese_b / 2\n operations +=1\n elif cheese_b % 3 == 0:\n cheese_b = cheese_b / 3\n operations += 1\n elif cheese_b % 5 == 0:\n cheese_b = cheese_b / 5\n operations += 1\n else:\n operations = -1\n break\n else:\n break\n\nprint operations", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f99fe236ec2e5b2f4037170b4e1d1080", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "import sys\n\n\nclass Node:\n\n\tdef __init__(self, id):\n\t\tself.id = id\n\t\tself.adjacent = set()\n\t\tself.visited = 0\n\n\tdef addEdge(self, edge):\n\t\tself.adjacent.add(edge)\n\n\n\n\n\nclass Graph:\n\n\tdef __init__(self, numNodes, startNode):\n\t\tself.nodes = list()\n\t\tself.startNode = startNode\n\t\tself.maxPath = 234234778\n\t\tself.result = 0\n\t\tfor num in range(1, numNodes + 1):\n\t\t\ttempNode = Node(num)\n\t\t\tself.nodes.append(tempNode)\n\n\t# finds the number of separate connected components of the graph\n\tdef numConnectedComponents(self):\n\t\ts = set()\n\t\tresult = 0\n\t\tfor n in self.nodes:\n\t\t\toldsize = len(s)\n\t\t\tself.addAllAdjacentVertices(n, s)\n\t\t\tif len(s) is not oldsize:\n\t\t\t\tresult += 1\n\t\treturn result\n\n\t# recursively adds a vertex and all connected vertices\n\tdef addAllAdjacentVertices(self, node, set):\n\t\tset.add(node.id)\n\t\tself.findNode(node.id).visited = 1\n\t\tfor edge in node.adjacent:\n\t\t\tif self.findNode(edge).visited is not 1:\n\t\t\t\tself.addAllAdjacentVertices(self.findNode(edge), set)\n\n\t# kickoff method that uses a recursive helper method\n\tdef numNodesReachable(self, node):\n\t\treturn self.nodesHelper(node, 0)\n\n\t# helper method to find the number of nodes reachable within the given maximum path length\n\tdef nodesHelper(self, currNode, numSteps):\n\t\tself.result += 1\n\t\tcurrNode.visited = 1\n\t\tif numSteps < self.maxPath:\n\t\t\tfor edge in currNode.adjacent:\n\t\t\t\tif self.findNode(edge).visited is not 1:\n\t\t\t\t\tself.nodesHelper(self.findNode(edge), numSteps + 1)\n\t\treturn self.result\n\n\t# clears the visited field of every node\n\tdef clearVisited(self):\n\t\tfor node in self.nodes:\n\t\t\tnode.visited = 0\n\t\tself.result = 0\n\n\tdef findNode(self, id):\n\t\tfor node in self.nodes:\n\t\t\tif id == node.id:\n\t\t\t\treturn node\n\n\tdef findPath(self):\n\t\tstack = list()\n\t\tanswer = list()\n\t\tstack.append(self.findNode(self.startNode))\n\t\twhile len(stack) != 0:\n\t\t\tv = stack[len(stack) - 1]\n\t\t\tif len(v.adjacent) == 0:\n\t\t\t\tanswer.append(v.id)\n\t\t\t\tstack.pop()\n\t\t\telse:\n\t\t\t\tedge = v.adjacent.pop()\n\t\t\t\tself.findNode(edge).adjacent.remove(v.id)\n\t\t\t\tstack.append(self.findNode(edge))\n\n\n\t\treturn answer\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nline = sys.stdin.readline().rstrip()\ntemp = line.split(\" \")\nnumRows = int(temp[0])\nnumCols = int(temp[1])\n\ng = Graph(numRows * numCols, 1)\n\nline2 = sys.stdin.readline().rstrip()\nline3 = sys.stdin.readline().rstrip()\nrl = list(line2)\nud = list(line3)\n# rl determiend by row number\n# ud determined by col number\n\nfor row in range(0, numRows):\n\tfor col in range(0, numCols):\n\t\tnodeNumber = row * numCols + col + 1\n\t\tnode = g.findNode(nodeNumber)\n\n\t\tif rl[row] == '>':\n\t\t\tif col + 1 < numCols:\n\t\t\t\tdest = row * numCols + col + 2\n\t\t\t\tnode.addEdge(dest)\n\t\telse:\n\t\t\tif col - 1 >= 0:\n\t\t\t\tdest = row * numCols + col\n\t\t\t\tnode.addEdge(dest)\n\n\t\tif ud[col] == '^':\n\t\t\tif row - 1 >= 0:\n\t\t\t\tdest = (row - 1) * numCols + col + 1\n\t\t\t\tnode.addEdge(dest)\n\t\telse:\n\t\t\tif row + 1 < numRows:\n\t\t\t\tdest = (row + 1) * numCols + col + 1\n\t\t\t\tnode.addEdge(dest)\n\n# for node in g.nodes:\n# \tfor edge in node.adjacent:\n# \t\tprint(str(node.id) + \" - \" + str(edge))\n\nweGood = True\n\nfor node in g.nodes:\n\ttemp = g.numNodesReachable(node)\n\tg.clearVisited()\n\tif temp != numRows * numCols:\n\t\tweGood = False\n\t\tbreak\n\nif weGood:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3b70e3f75c6aedd973f12a11f1aec24a", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "input()\n\nhoriz = input()\nvert = input()\n\nnum_horiz = len(horiz)\nnum_vert = len(vert)\n\nnum_junc = num_horiz * num_vert\n\ngrid = [[0 for j in range(num_junc) ] for i in range(num_junc)]\n\nfor i in range(num_horiz):\n for j in range(num_vert):\n \n p = i * num_vert + j\n\n if horiz[i] == '>' and j + 1 < num_vert: \n grid[p][p + 1] = 1\n elif horiz[i] == '<' and j - 1 >= 0:\n grid[p][p - 1] = 1\n \n if vert[j] == 'v' and i + 1 < num_horiz:\n grid[p][p + num_vert] = 1\n elif vert[j] == '^' and i - 1 >= 0:\n grid[p][p - num_vert] = 1\n\ncached_visits = [[] for x in range(num_junc)]\n\ngood_city = True\n\nfor idx, adj_nodes in enumerate(grid):\n visited = [0 for x in range(num_junc)]\n visited[idx] = 1\n \n s = [idx for idx, val in enumerate(adj_nodes) if val ] \n \n while s:\n node_idx = s.pop()\n visited[node_idx] = 1\n new_possible_nodes = [idx for idx, val in enumerate(grid[node_idx]) if val and not visited[idx]] \n# print(new_possible_nodes)\n s += new_possible_nodes\n \n if visited.count(0):\n# print(visited)\n good_city = False\n break\n\nprint('YES' if good_city else 'NO')\n \n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95e0675c18f5528057134c34a281b4ae", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#input\nn,m=map(int,input().split())\nnstr=str(input())\nmstr=str(input())\n\n#variables\n\n#main\nif '^' not in mstr or 'v' not in mstr:\n\tprint('NO')\n\tquit()\nif '>' not in nstr or '<' not in nstr:\n\tprint('NO')\n\tquit()\nif nstr[0]=='>' and mstr[0]=='v':\n\tprint('NO')\n\tquit()\nif nstr[0]=='>' and mstr[-1]=='^':\n\tprint('NO')\n\tquit()\nif nstr[-1]=='<' and mstr[0]=='v':\n\tprint('NO')\n\tquit()\nif nstr[-1]=='<' and mstr[-1]=='^':\n\tprint('NO')\n\tquit()\nprint('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e75a15e97db753c54da249de7ab02f6", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "input()\nu, v = input(), input()\nprint(['YES', 'NO'][any('^v'[i] + '<>'[j] == v[i] + u[j] for i in [0, -1] for j in [0, -1])])input()\nu, v = input(), input()\na = [u[i] + v[j] for i in [0, -1] for j in [0, -1]]\nb = ['<^', '>^', 'v']\nprint(['YES', 'NO'][any(i == j for i, j in zip(a, b))])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "056370062cd32e7c7a74bdb9488dc12c", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "k,g = list(map,input().split(\" \")\nh = input()\nv = input()\nif(\n (h[0] =='<' and v[0] =='^') or\n (h[0] =='>' and v[0] =='v') or\n (h[-1] =='<' and v[-1] =='^') or\n (h[-1] =='>' and v[-1] =='v') or\n (h[-1] =='>' and v[0] =='^') or\n (h[-1] =='<' and v[0] =='v') or\n (h[0] =='>' and v[-1] =='^') or\n (h[0] =='<' and v[-1] =='v')\n): \n print(\"NO\")\nelse: \n print(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bd71cc5a5af2249670bd99a92da5ca94", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "MOD = 10 ** 9 + 7\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef combination(n,k,MOD): \n ans = 1\n for i in range(n - k + 1, n + 1):\n ans *= i\n ans %= MOD\n for i in range(k):\n ans *= modinv(i,MOD)\n ans %= MOD\n return ans\n\nn,m,k = map(int,input().split())\n\nprint(combination(n-1,n-2 * k-1) * combination(n-1,n - 2 * k - 1) % MOD)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9376ce7c5102fd161c89fadd29f94a5", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "MOD = 10 ** 9 + 7\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef combination(n,k,MOD): \n ans = 1\n for i in range(n - k + 1, n + 1):\n ans *= i\n ans %= MOD\n for i in range(k):\n ans *= modinv(i,MOD)\n ans %= MOD\n return ans\n\nn,m,k = map(int,input().split())\n\nprint(combination(n-1,n-2 * k-1,MOD) * combination(n-1,n - 2 * k - 1,MOD) % MOD)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5eeccf5a1909b6f19728ffe6dbc4ffa3", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "mod=1000000007\ndef fact(n):\n if(n==0):\n return 1\n else:\n return n*fact(n-1)%mod\ndef myPow(n,p):\n if(p==0):\n return 1\n res=myPow(n,p/2)\n res=res*res%mod\n if(p%2==1):\n res=res*n%mod\n return res\ndef rev(n):\n return myPow(n,mod-2)\ndef comb(n,k):\n if(k>n):\n return 0\n res=fact(n)\n res*=rev(fact(k)*fact(n-k)%mod)\n res%=mod \n return res\nn,m,k=map(int,raw_input().split())\nn-=1\nm-=1\nres=comb(n,2*k)*comb(m,2*k)%mod\nprint res\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cd8c4dfed183355d55a7269ca2c21c10", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n, m, k = map(int, raw_input().strip().split())\ndef fac(x):\n return x * fac(x - 1) if x else 1\ndef c(n, r):\n return fac(n) / (fac(n - r) * fac(r)) if r <= n else 0\nprint c(n - 1, k * 2) * c(m - 1, k * 2) % (10 ** 9 + 7)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e0c7b3433bdbb1a7ef73090984a9ccb6", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout, stderr, exit\nfrom math import log, factorial\nimport re\n\n# inputf = open('input.txt', 'r')\n# outputf = open('output.txt', 'w')\n\n\ndef readil():\n return list(map(int, stdin.readline().strip().split()))\n\n\ndef C(n, k):\n return factorial(n) // factorial(k) // factorial(n-k)\n\n\ndef main():\n n, m, k = readil()\n stdout.write(str((C(n - 1, 2 * k) * C(m - 1, 2 * k)) % 1000000007))\n\nif __name__ == '__main__':\n main()\n\n\n# inputf.close()\n# outputf.close()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8998f7e02cce79e6cc7b5d0c9d798aac", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nfrom sys import stdin\n\n\ndef solve(tc):\n n, a, b = map(int, stdin.readline().split())\n\n if a*b >= 6*n:\n print(a*b)\n print(a, b)\n return\n\n mini = int(1e18)+1\n minv = (-1, -1)\n if a > b:\n a, b = b, a\n\n base = 6 * n\n ma = a\n while True:\n if base//ma < b:\n break\n\n if base % ma == 0:\n print(base)\n print(ma, base//ma)\n return\n\n mb = base // ma + 1\n if mini > ma*mb - base:\n mini = ma*mb - base\n minv = (ma, mb)\n\n ma += 1\n\n print(minv[0]*minv[1])\n print(minv[0], minv[1])\n\n\ntc = 1\nsolve(tc)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "738d922daba9b5e7138a57ee470f9268", "src_uid": "6a2a584d36008151d18e5080aea5029c", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "pp = -1\ndef func(x) :\n\tp = 6*N / (x + A);\n\tp = max(p, B);\n\treturn p * (x + A);\t\nread = lambda : map(int, raw_input().split())\nN, A, B = read()\nl = 0; r = 10**9;\nfor xx in range(100):\n m1 = l + (r - l) / 3;\n m2 = r - (r - l) / 3;\n if (func(m1) > func(m2)) : l = m1;\n else : r = m2;\nans = 10**20;\na = -1;\nb = -1\nfor xx in range(l, r + 1):\n\tres = func(xx);\n\tif (res < ans) :\n\t\tans = res;\n\t\ta = xx + A;\n\t\tp = 6*N / (xx + A);\n\t\tp = max(p, B);\n\t\tb = p;\nprint ans\nprint a, b\t\t\t\n \t\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b864ff6637d0fb64db6f19ac405d88cc", "src_uid": "6a2a584d36008151d18e5080aea5029c", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn,a,b = stdin.readline().strip().split()\nn=int(n);a=int(a);b=int(b)\ns = a*b\nt = 6*n\nfir = a\nsec = b\nx=a\ny=b\nhi = int(math.sqrt(t))\nif hi*hi\n#include\n#include\n#include\n#include\n\n\nusing namespace std;\n\n\ntypedef long long LL;\n\nLL T,N,K,D1,D2;\nLL s_d1,s_d2,w1,w2,w3;\nbool ans;\n\n\n\nint main()\n{\n scanf(\"%I64d\",&T);\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b2c67270423a0a7b1dd80a4513ea6120", "src_uid": "6a2a584d36008151d18e5080aea5029c", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from sys import stdin\nn,a,b = stdin.readline().strip().split()\nn=int(n);a=int(a);b=int(b)\ns = a*b\nt = 6*n\nfir = a\nsec = b\nx=a\ny=b\nhi = int(math.sqrt(t))\nif hi*hi= next2 + d:\n\t\tbreak\n\tf1 += v1\n\tf2 -= v2\n\t#print f1,f2\n\tans += 1\n#print f1, f2\t\nif v1 != v2:\n\tans += abs( ( 2*d - f1 -f2 ) / ( v1 + v2 + 0.0) )-1\n\t\nprint \"%f\" % ( max( 1,ans ) )", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea77faa1515b076f04ca3b1e06bd068c", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=input().split()\nb=int(a[1])-int(a[0])\nc=int(a[2])+int(a[3])\nprint(c/b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf4deaac14e2b089527c590329a2929c", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Python 3", "source_code": "(a,b,c,d)=input().split())\nx=(a-b)/(c+d)\nprint(x)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "999b5f3e95d9f673e1b74a896ba6ced2", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def zad1(d,L,v1,v2):\n t=round((float(L)-float(d)/(float(v1)+float(v2),6)\n return t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "24021247f943d38a23484bbefc827934", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def zad1(d,L,v1,v2):\n t=round((float(L)-float(d)/(float(v1)+float(v2))\n return t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4bd163058ad4f3f43ad13aa181f519a9", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nconst int M = 100;\nll fx[M],fy[M];\n\nvoid make_fib()\n{\n fx[0] = 0;\n fx[1] = 1;\n fy[0] = fy[1] = 1;\n for(int i = 2; i < 100; i++){\n fx[i] = fx[i - 1] + fx[i - 2];\n fy[i] = fy[i - 1] + fy[i - 2];\n }\n}\n\nint main()\n{\n make_fib();\n ll x,y,m;\n while(cin>>x>>y>>m)\n {\n if(m <= max(x,y)) puts(\"0\");\n else if(x + y <= min(x,y)) puts(\"-1\");\n else\n {\n int k = 0;\n if(x > y) swap(x,y);\n if(x < 0) x += y,k++;\n for(int i = 1; i < 100; i++){\n ll ans = x * fx[i] + y * fy[i];\n if(ans >= m){\n k += i;\n break;\n }\n }\n printf(\"%d\\n\",k);\n }\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "088c0ffbd606b45eb396bc2d1bbc6f1b", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def solver():\t\n\tx,y,m = map(int , raw_input().split())\n\tif(x >= 0 and y >= 0):\n\t\tif(x >= m or y >= m):\n\t\t\tprint \"0\"\n\t\t\treturn\n\tif(x <= 0 and y <= 0):\n\t\tif(x >= m or y >= m):\n\t\t\tprint \"0\"\n\t\t\treturn\n\t\telse:\n\t\t\tprint \"-1\"\n\t\t\treturn \n\n\tif(x < y) x,y = y,x\n\tif(x >= m):\n\t\tprint \"0\"\n\t\treturn\n\telse:\n\t\tans = 0\n\t\tif(abs(y)%x==0):\n\t\t\tans = abs(y)/x\n\t\t\ty = 0\n\t\telse:\n\t\t\tans = abs(y)/x\n\t\t\tans +=1\n\t\t\ty = y + (ans*x)\n\t\twhile(x < m and y < m):\n\t\t\tif(x < y):\n\t\t\t\tx,y = y,x\n\t\t\t#x is greater\n\t\t\ty = x+y\n\t\t\tans+=1\n\t\tprint ans\n\n\treturn\nif __name__ == \"__main__\":\n\tsolver()\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cc30041a43c967391c2ee0b6b2a0e71f", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "x, y, m = map(int, raw_input().strip().split(' '))\n\nif x <= 0 and y <= 0 and max(x,y) < m:\n return -1\n\ncounter = 0\nwhile max(x,y) < m:\n if x < y:\n x = x + y\n else:\n y = x + y\n counter += 1\n\nprint counter\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a7b866b6d9aacf3ee5ea8995a5248f96", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "//#pragma GCC optimize(\"O3\")\n#include \n#define int long long\n#define pb push_back\n#define inf 10000000000000000\n#define N 1000000007\n#define mp make_pair\n#define speed ios_base::sync_with_stdio(0);cin.tie(0);\nusing namespace std;\ntemplate ostream& operator<<(ostream& cout,pair P)\n{return cout<<'('< ostream& operator<<(ostream& cout,vector V)\n{cout<<\"[ \";for(auto v:V)cout<=tar or b>=tar){return 0;}\n\tint mini=min(a,b);\n\tint maxi=max(a,b);\n\tint ans=0;\n\twhile(maxiwhile;merge resize\nsigned main()\n{\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n #endif \n\tspeed\n\t//global var\n\tint x,y,m;cin>>x>>y>>m;\n\tif(x>=m or y>=m)\n\t{\n\t\tcout<<0<<\"\\n\";\n\t}\n\tif(x>0 or y>0)\n\t{\n\t\tint ans=INT_MAX;\n\t\tint mini=min(x,y);\n\t\tint maxi=max(x,y);\n\t\tfor(int i=0;i<200;++i)\n\t\t{\n\t\t\tif(mini>m)\n\t\t\t{\n\t\t\t\tans=min(ans,i);break;\n\t\t\t}\n\t\t\tans=min(ans,(i+solve(mini,maxi,m)));\n\t\t\tmini+=maxi;\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint a, b;\n\tcin >> a >> b;\n\tstring s;\n\tcin >> s;\n\tint c = s.size();\n\tint xb[100], yb[100];\n\tint x = 0, y = 0;\n\tfor (int i = 0; i < c; i++) {\n\t\tswitch (s[i]) {\n\t\t\tcase 'U':\n\t\t\t\ty++;\n\t\t\t\tbreak;\n\t\t\tcase 'D':\n\t\t\t\ty--;\n\t\t\t\tbreak;\n\t\t\tcase 'L':\n\t\t\t\tx--;\n\t\t\t\tbreak;\n\t\t\tcase 'R':\n\t\t\t\tx++;\n\t\t\t\tbreak;\n\t\t}\n\t\txb[i] = x;\n\t\tyb[i] = y;\n\t}\n\tint xr = xb[c-1], yr = yb[c-1];\n\tfor (int i = 0; i < c; i++) {\n\t\tint xu = a - xb[i];\n\t\tint yu = b - yb[i];\n\t\tint resx, resy;\n\t\tif (xr == 0) {\n\t\t\tresx = xu;\n\t\t} else {\n\t\t\tresx = xu % xr;\t\t\t\n\t\t}\n\t\tif (yr == 0 && yu != 0) {\n\t\t\tresy = yu;\n\t\t} else {\n\t\t\tresy = yu % yr;\n\t\t}\n\t\tif (resx == 0 && resy == 0) {\n\t\t\tif (xr * yu == xu * yr) {\n\t\t\t\tprintf(\"Yes\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"No\\n\");\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b477bc93282eb2c47915a93a90ac4eea", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "(n, m) = [int(x) for x in raw_input().split()]\nv = [raw_input() for x in xrange(0, n)]\n\ns = \"\"\nfor i in xrange(0, n):\n for j in xrange(0, m):\n ok = True\n for k in xrange(0, n):\n ok &= k == i or v[k][j] != v[i][j]\n for k in xrange(0, m):\n ok &= k == j or v[i][k] != v[i][j]\n if ok:\n s += v[i][j]\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df945925856ff87041a46ca47147b49a", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUT3.out\",\"w\")\nfor _ in range(int(input())):\n\tN=int(input())\n\tif N<=3:\n\t\t\tprint(\"1\")\n\telse:\n\t\tS=3\n\t\tarr=[]\n\t\tarr.append(0)\n\t\tarr.append(3)\n\t\tfor i in range(2,40):\n\t\t\tS=S+pow(3,i)\n\t\t\tarr.append(S)\n\t\tfor i in range(1,40):\n\t\t\tif N>arr[i-1] and N<=arr[i]:\n\t\t\t\tprint(i)\n\t\t\t\tbreak\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "758fc69d23e092520b406a27c2a150dc", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import math\na = list(map(int,input().split()))\nb = 0\nd = 0\nfor x in a:\n\tif x% 2 != 0:a[a.index(x)] = x + 1\n\tif x > b:b = x\nif a.count(b) > 1:\n\tfor x in range(a.count(b) - 1):a[a.index(b)] = 0\nc = math.ceil(b / 2)\nb =(3 - (a.index(b) + 1)) + 1\nprint(30 + ((c * 3)) -b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5df88be4f935e582084dc3f4c32767dc", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "print 30 + max([(i+3*((int(x)+1)/2-1) for i, x in enumerate(raw_input().split())])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3bdf38474d1fd8fdc7accb21e533bd32", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "r,g,b=map(int,raw_input().split())\nt=0\nwhile r>0 or g>0 or b>0:\n if t%3==0:\n r-=2\n elif t%3==1:\n g-=2\n else:\n b-=2\nt += 30\nprint t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3db9b74087e47b954289c8f3fbfe668", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split())\nmod=1000000009\np=1\nwhile(m--):\n p=(p*2)%mod\nans=1\nfor i in range(n):\n p=(p-1+mod)%mod\n ans=(ans*p)%mod\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "431942c208d1c85c2c3400e68c7b0cdc", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\nk = pow(2, m, 1000000009) - 1\nans = 1\nfor i in xrange(n)\n ans *= k - i\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90a3818b19c3244ca69dad7efca6c66c", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split())\nmod=1000000009\np=1\nwhile(m--): p=(p*2)%mod\nans=1\nfor i in range(n):\n p=(p-1+mod)%mod\n ans=(ans*p)%mod\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e2622c58201640b53d61904af375af64", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input())\nk = pow(2, m, 1000000009) - 1\nans = 1\nfor i in xrange(n)\n ans *= k - i\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7fb8883703ae151cf7427d978064c6d2", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "mod = 1000000009\n\ndef pow2(m):\n if m == 0:\n return 1\n elif m == 1:\n return 2\n else:\n t = pow2(m//2)\n t = (t*t)%mod\n if (m%2 == 0):\n return\n else:mod = 1000000009\n\ndef pow22(m):\n if m == 0:\n return 1\n elif m == 1:\n return 2\n else:\n t = pow22(m//2)\n t = (t*t) % mod\n if (m%2) == 0:\n return t\n else:\n return (t * 2) % mod\n\nn = int(input())\nm = int(input())\nr = 0\nif m > 30 or n <= 2**m:\n r = pow22(m)-1\n md = r\n for i in range(n - 1):\n md = md - 1\n r = (r * md) % mod\nprint ((r + mod) % mod)\n\n return (t * t * pow2(m%2)) % mod\n\nn = int(input())\nm = int(input())\nr = 0\nif m > 30 or n <= 2**m:\n r = pow2(m)-1\n md = r\n for i in range(n - 1):\n md = md - 1\n r = (r * md) % mod\nprint ((r + mod) % mod)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "80022a9f39faa3a6cea096f833740ed0", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "x=int(input())\nz=[n for n in str(int(input()))]\nl=0\nfor n in z:\n in n!=4 or n!=7:\n print('NO')\n l=0\n break\n else:\n l=1\nif l==1:\n if sum(z[0::x//2])==sum(z[x//2:x])\n print('YES')\n else:\n print('NO')\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a2adcb263023d06f7c302315e830ce76", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def contest():\n\tx = input();\n\ty = input();\n\tz = 0;\n\ts = str(y);\n\tfor i in s:\n\t\tif i not in [\"4\",\"7\"];\n\t\t\tz = 1;\n\tif z == 1:\n\t\tprint \"NO\";\n\telse:\n\t\tprint \"YES\";\n\ncontest();", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e86f1260af2d83b3a936d8d96b0d2894", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "Python 2", "source_code": "def contest():\n\tx = input();\n\ty = input();\n\tz = 0;\n\ts = str(y):\n\t\tfor i in s:\n\t\t\tif i not in [\"4\",\"7\"];\n\t\t\t\tz = 1;\n\tif z == 1:\n\t\tprint \"NO\";\n\telse:\n\t\tprint \"YES\"\n\ncontest();", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ab29bb491e93aa589390ed4cbf8b5f24", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nif n%2 !=0:\n print(\"NO\")\nelse:\n tiquete=input()\n cuatros = tiquete.count(\"4\")\n sietes = tiquete.count(\"7\")\n if cuatros+sietes==n:\n mitad1 = tiquete[:int(len(tiquete)/2)]\n mitad2 = tiquete[int(len(tiquete)/2):(len(tiquete))]\n print(mitad1,mitad2)\n cuatros1 = mitad1.count(\"4\")\n sietes1 = mitad1.count(\"7\")\n cuatros2 = mitad2.count(\"4\")\n sietes2= mitad2.count(\"7\")\n if cuatros1==cuatros2 and \n sietes1==sietes2:\n print(\"SI\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b0b9dc980f6309a8c0c8f04bceeb061", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#include\nusing namespace std;\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);cout.tie(NULL);\n int n,a=0,b=0,k=1,p,m;\n char x;\n cin>>n;\n m=n/2;\n for(int i=0;i>x;\n p=int(x)-48;\n if(p!=4 && p!=7){k=0;}\n if(itop_list[j]:\n top_list[j]=l[i]\n count[j]+=1\n done = 1\n break\n if done==0:\n count[length]+=1\n ans_list.append(l[i])\n top_list.append(l[i])\n length+=1\n# print ans_list\n# print top_list\n# print count\ni = 0\nj = length-1\nwhile(i0:\n count[j]-=1\n ans_list[i]-=1\n else:\n i+=1\n if count[j]==0:\n j-=1\n\n# print count\n# print ans_list\ni = 0\nwhile(count[i]!=0):\n i+=1\nprint i\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f2bb2505f5a43d6cbaf6d008537bd027", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "'''\nCreated on 01-Jul-2017\n\n@author: kandarp\n'''\nimport sys\ndef check(x,a):\n b =[]\n ans = True;\n for i in xrange(0,x):\n b.append([]);\n for i in xrange(0,len(a)):\n b[i%x].append(a[i])\n for i in xrange(0,x):\n for j in xrange(0,len(b[i])):\n if b[i][j] < (len(b[i]) - (j+1)):\n ans = False;\n return ans; \n return ans;\nn = int(raw_input())\na = [int(x) for x in raw_input().split()]\na.sort(reverse=True)\nif n==1:\n print(1)\n sys.exit(0);\ncurrent_watch = 0;\nl=0;\nr=len(a);\nans =1;\nwhile(r - l >1):\n mid = int((l + r)/2);\n if(check(mid, a)):\n r = mid;\n else:\n l = mid;\n \nif(check(l,a)):\n print(l);\nelse: \n print(r);\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "36d5e95f6d390c143f039e2fe96db331", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nval = [[]]\nfor x in sorted(int(x) for x in input().split()):\n for l in val:\n if x >= len(l):\n l.append(x)\n break\n if len(val[-1]) > 0:\n val.append([])\nprint(len(val) - 1)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "058df75dc49cda61625e3332975ce8d5", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n=int(input()\nl = [int(x) for x in input().split()\nl.sort()\nu = 0\na= 0 \nwhile(u<=n)\n a+=1 \n c=0\n for i in range(n):\n if(l[i]>=c):\n c+=1\n u+=1\n l[i]= -1\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82b6cfcb9e80ef63065200429305d81f", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def main():\n a, b = map(int, input().split())\n s = input()\n x = sum({\"L\": -1, \"R\": 1}.get(c, 0) for c in s)\n y = sum({\"D\": -1, \"U\": 1}.get(c, 0) for c in s)\n if x and y:\n t = min(a // x, b // y)\n elif x:\n t = a // x\n elif y:\n t = b // y\n if t > 0:\n a -= (t - 1) * x\n b -= (t - 1) * y\n for c in s * 2:\n if a == 0 == b:\n print(\"Yes\")\n return\n a -= {\"L\": -1, \"R\": 1}.get(c, 0)\n b -= {\"D\": -1, \"U\": 1}.get(c, 0)\n print(\"No\")\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "206307e4dc5ef2d3b6e80a6cd6ff3387", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "[x,y]=[int(i) for i in raw_input().split()]\ns=raw_input()\npos=[(0,0)]\nj=0\nfor i in s:\n if i=='U':\n pos.append((pos[j][0],pos[j][1]+1))\n j+=1\n if i=='D':\n pos.append((pos[j][0],pos[j][1]-1))\n j+=1\n if i=='L':\n pos.append((pos[j][0]-1,pos[j][1]))\n j+=1\n if i=='R':\n pos.append((pos[j][0]+1,pos[j][1]))\n j+=1\nif (x,y) in pos:\n print \"Yes\"\nelse:\n try:\n j=x/pos[-1][0]\n except ZeroDivisionError:\n j=0\n try:\n i=y/pos[-1][1]\n except ZeroDivisionError:\n i=0\n x1=x-(j*pos[-1][0])\n y1=y-(j*pos[-1][1])\n x2=x-(i*pos[-1][0])\n y2=y-(i*pos[-1][1])\n (x3,y3)=(x1,y1)-pos[-1]\n (x4,y4)=(x1,y1)+pos[-1]\n (x5,y5)=(x2,y2)-pos[-1]\n (x6,y6)=(x2,y2)+pos[-1]\n if (x1,y1) in pos or (x2,y2) in pos or (x3,y3) in pos or (x4,y4) in pos or (x5,y5) in pos or (x6,y6) in pos :\n print \"Yes\"\n else:\n print \"No\"\n##[r,g,b]=[int(i) for i in raw_input().split()]\n##mini=min([r,g,b])\n##mix=mini-(mini/3)\n##a=[]\n##for i in [r,g,b]: \n## rb=(r-i)/3\n## bb=(b-i)/3\n## gb=(g-i)/3\n## a.append(i+rb+bb+gb)\n##a.append(r/3 + b/3 +g/3)\n###print(a)\n##print max(a)\n####\n######[n,m]=[int(i) for i in raw_input().split()]\n######print m+n-1\n######for i in range(m):\n###### print 1,i+1\n######for i in range(1,n):\n###### print i+1,1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2918603d7a76ba27b263fa184e5d06cb", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def gcd(x,y):\n r = x % y\n while r != 0:\n x = y\n y = r\n r = x % y\n\n return y\n \n\n\ndef go(command,now):\n if command == \"U\":\n return (now[0],now[1]+1)\n elif command == \"D\":\n return (now[0],now[1]-1)\n elif command == \"R\":\n return (now[0]+1,now[1])\n else:\n return (now[0]-1,now[1])\n\ndef same_hugo(x,y):\n if x < 0 and y < 0:\n return True\n\n if x > 0 and y > 0:\n return True\n \n if x == 0 and y == 0:\n return True\n\n return False\n\ndef solver():\n a,b = map(int, raw_input().split())\n command = raw_input()\n if (a,b) == (0,0):\n print \"Yes\"\n return\n sa = []\n now = (0,0)\n first = []\n for c in command:\n now = go(c,now)\n sa.append((a-now[0],b-now[1]))\n first.append(now)\n if now == (a,b):\n print \"Yes\"\n return\n \n\n\n\n for i in range(len(command)):\n now = go(command[i],now)\n temp_sa = sa[i]\n temp_first = first[i]\n sinpo = (now[0] - temp_first[0], now[1]-temp_first[1])\n #print temp_sa,sinpo,now,temp_first\n \n if temp_sa[0] == 0:\n if sinpo[0] == 0:\n if temp_sa[1] == 0:\n if sinpo[1] == 0:\n print \"Yes\"\n return\n else:\n if temp_sa[1] % sinpo[1] == 0:\n if same_hugo(temp_sa[1],sinpo[1]):\n print \"Yes\"\n return\n elif temp_sa[1] == 0:\n if sinpo[1] == 0:\n if temp_sa[0] % sinpo[0] == 0:\n if same_hugo(temp_sa[0],sinpo[0]):\n print \"Yes\"\n return\n else:\n #print temp_sa\n\n num = abs(gcd(temp_sa[0],temp_sa[1]))\n if temp_sa[0]/num == sinpo[0] and temp_sa[1]/num == sinpo[1]:\n print \"Yes\"\n return\n \n\n print \"No\"\n\n \n\nif __name__ == \"__main__\":\n solver()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7e45542444a07e800c824161770d0a5", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def inoneline(sol, move, final): \n vec=(final[0]-sol[0], final[1]-sol[1]) \n cross=vec[1]*move[1]+vec[0]*move[0]\n if cross <= 0:\n return False\n veclen = vec[1]**2+vec[0]**2\n movlen = move[0]**2+move[1]**2\n if cross**2 != veclen*movlen:\n return False\n if veclen%movlen!=0:\n return False\n return True\n \na, b = map(int, raw_input('').split())\nmovements=raw_input('')\nsteps={'U':(0, 1), 'D':(0, -1), 'L':(-1, 0), 'R':(1, 0)}\npx, py=0, 0\nposols=set([(px, py)])\nfor movement in movements:\n x, y = steps[movement]\n px+=x\n py+=y\n posols.add((px, py))\n if (a, b) == (px, py):\n print 'YES'\n exit()\n \nif(px, py)==(0, 0):\n print 'NO'\n exit()\n \nfor posol in posols:\n if inoneline(posol, (px, py),(a, b)):\n answer='Yes' \n \nprint answer\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "47e21ba724613bbf36d1f2e5ca4190ac", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x,y = map(int,input().split())\n#print(x,y)\ns = input()\n#print(s)\npt = (0,0)\npath = [(0,0)]\nrect = [0,0,1,1]\nfor c in s:\n if c == 'U': pt = (pt[0],pt[1]+1)\n elif c == 'D': pt = (pt[0],pt[1]-1)\n elif c == 'L': pt = (pt[0]-1,pt[1])\n elif c == 'R': pt = (pt[0]+1,pt[1])\n\n if pt[0] < rect[0]: rect[0] = pt[0]\n if pt[0] >= rect[2]: rect[2] = pt[0]+1\n if pt[1] < rect[1]: rect[1] = pt[1]\n if pt[1] >= rect[3]: rect[3] = pt[1]+1\n \n path.append(pt)\n\n#print(pt)\n#print(path)\n#print(rect)\n\ndone = False\nif pt[0] == 0:\n if pt[1] == 0:\n if (x,y) in path:\n done = True\n print(\"Yes\")\n else:\n print(\"No\")\n done = True\n elif pt[1] > 0:\n n = max((y-rect[3])//pt[1]-2,0)\n while n*pt[1]+rect[1] <= y:\n if (x - n*pt[0],y - n*pt[1]) in path:\n print(\"Yes\")\n done = True\n break\n n += 1\n elif pt[1] < 0:\n n = max((y - rect[1])//pt[1]-2,0)\n while n*pt[1]+rect[3] >= y:\n if (x - n*pt[0],y-n*pt[1]) in path:\n print(\"Yes\")\n done = True\n break\nelif pt[0] > 0:\n n = max((x-rect[2])//pt[0]-2,0)\n while n*pt[0]+rect[0] <= x:\n if (x - n*pt[0],y - n*pt[1]) in path:\n print(\"Yes\")\n done = True\n break\n n += 1\nelif pt[0] < 0:\n n = max((x-rect[0])//pt[0]-2,0)\n while n*pt[0]+rect[2] >= x:\n if (x - n*pt[0],y - n*pt[1]) in path:\n print(\"Yes\")\n done = True\n break\n n += 1\n\nif not done:\n print(\"No\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6749c93e50dfb892779d9a974be38f4b", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def get_instability(w, x, y):\n total = 0\n last = -1\n \n for i in range(len(w)):\n if i == x or i == j:\n continue\n \n if last == -1:\n last = w[i]\n else:\n total += w[i] - last\n last = -1\n \n return total\n\ndef main():\n n = int(input())\n weights = sorted(list(map(int, input().split())))\n \n min_instability = (1 << 30)\n for i in range(2 * n):\n for j in range(i + 1, 2 * n):\n instability = get_instability(weights, i, j)\n if instability < min_instability:\n min_instability = instability\n \n print(min_instability)\n \nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c62729aff432b07e9192a683b73efde", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "raw_input()\nx = sorted(map(int,raw_input().split()))\ndef solve(x,rm,nx,ins):\n if nx == len(x):\n if rm == 2:\n return ins\n return float(\"inf\")\n if nx == len(x)-1:\n if rm == 1:\n return ins\n return float(\"inf\")\n return min(solve(x,rm+1,nx+1,ins),solve(x,rm,nx+2,ins+x[nx+1]-x[nx]))\nprint solve(x,0,0,0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e751b927bcafa14f699ed6ebb51198f4", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\nw = input()\nprint(w)\nweights = [int(x) for x in w.split[\" \"]]\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": "5e3acf2d87a482d2c711ad5e54f54f16", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=2*int(input())\nw=sorted(map(int,input().split()))\nr=10000\nfor i in range(n):\n for j in range(i):\n u=[w[k] for k in range(n) if i!=k!=j)\n r=min(r,sum(u[i+1]-u[i] for i in range(0,n-3,2)))\nprint(r)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "598e2a47b24b6b97c15a1177e0da5519", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int (input())\nw = list(map(int, input().split()))\nw.sort()\nswd=[0,0]\nfor i in range(n*2-1):\n swd.append(swd[i]+(w[i+1]-w[i]))\nm = swd[n*2]\nfor i in range(n):\n for j in range(0,n-i):\n s = swd[i*2] + swd[(i+j)*2+1]-swd[i*2+1] + swd[n*2]-swd[(i+j+1)*2]\n if s0):\n print(z[0])\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b943b93545a3d2d220c179f9256e9e2", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "p, y = map(int, input().split())\n\nl = []\nans = -1\nfor i in range(2, p+1):\n x = 1\n while i*x <= y:\n if i*x not in l:\n l.append(i*x)\n x += 1\nfor i in range(y, 1,-1):\n if i not in l:\n ans = i\n break\nprint(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e0948b7f7fb247a31d8857bda466b79", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint p, y;\n\nbool IsPrime(int x) {\n\tfor (int i = 2; i*i <= x; ++i) {\n\t\tif (x % i == 0) return false;\n\t}\n\treturn true;\n}\n\nint main() {\n\twhile (cin >> p >> y) {\n\t\tint i;\n\t\tfor (i = y; i > p; --i) {\n\t\t\tif (IsPrime(i)) {\n\t\t\t\tcout << i << endl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i == p) cout << -1 << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82b8454b64e98b85b8c2c79d5ce33ff1", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "PyPy 2", "source_code": "\t'''input\n\t3 6\n\t'''\n\tfrom sys import exit\n\tdef primes(n,p):\n\t\tif n%2 == 0:\n\t\t\treturn False\n\t\td = 2\n\t\twhile d*d <= n:\n\t\t\twhile (n % d) == 0:\n\t\t\t\tn = n//d\n\t\t\t\tif d < p:\n\t\t\t\t\treturn False\n\t\t\td += 1\n\t\treturn True\n\n\tp,n = map(int,raw_input().split())\n\tfor i in range(n,p,-1):\n\t\tif primes(i,p):\n\t\t\tprint i\n\t\t\texit(0)\n\tprint \"-1\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d097363068df2be4c939abaebbe9f012", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include\n#include\n\nint check(int n){\n\tint limit = ceil((double)sqrt(n));\n\tint i;\n\tfor(i=3; i<=limit; i+=2){\n\t\tif(n%i==0){\n\t\t\treturn(i);\n\t\t}\n\t}\n\treturn(n);\n}\n\nint main(){\n\tint p,y,i;\n\tscanf(\"%d %d\",&p, &y);\n\tint ans=-1;\n\tif(y%2==0){\n\t\ty--;\n\t}\n\t\n\tfor(i=y ; i>p ; i-=2){\n\t\tint q = check(i);\n\t\tif(q>p){\n\t\t\tans=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans);\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "19e698197ddad042d0bb15b263b7e951", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "from math import ceil, floor\n\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\n\ndef main():\n la, ra, ta = readline()\n lb, rb, tb = readline()\n\n res = []\n if lb > la:\n left_limit_left = int(ceil((lb - la) / ta))\n left_limit_right = int(floor((rb - la) / ta))\n\n kl = list(range(left_limit_left, left_limit_right+1))\n for k in kl:\n lla = la + k * ta\n rra = ra + k * ta\n res.append(min(rra, rb) - max(lla, lb) + 1)\n\n right_limit_left = int(ceil((lb - ra) / ta))\n right_limit_right = int(floor((rb - ra) / ta))\n kr = list(range(right_limit_left, right_limit_right+1))\n for k in kr:\n lla = la + k * ta\n rra = ra + k * ta\n res.append(min(rra, rb) - max(lla, lb) + 1)\n\n print(max(res))\n else:\n left_limit_left = int(ceil((la - lb) / tb))\n left_limit_right = int(floor((ra - lb) / tb))\n kl = list(range(left_limit_left, left_limit_right+1))\n for k in kl:\n llb = lb + k * tb\n rrb = rb + k * tb\n res.append(min(rrb, ra) - max(llb, la) + 1)\n\n right_limit_left = int(ceil((la - rb) / tb))\n right_limit_right = int(floor((ra - rb) / tb))\n kr = list(range(right_limit_left, right_limit_right+1))\n for k in kr:\n llb = lb + k * tb\n rrb = rb + k * tb\n res.append(min(rrb, ra) - max(llb, la) + 1)\n\n print(max(res))\n\n \n \n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "367af9c9c338b8ad2d63672692503bde", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\n\nCopyright 2018 Cheran Senthilkumar all rights reserved,\nCheran Senthilkumar \nPermission to use, modify, and distribute this software is given under the\nterms of the MIT License.\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport cmath\nimport itertools\nimport math\nimport operator as op\n# import random\nimport sys\nfrom atexit import register\nfrom bisect import bisect_left, bisect_right\n# from collections import Counter, MutableSequence, defaultdict, deque\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\n# from fractions import Fraction\n# from heapq import heappop, heappush\n\nif sys.version_info[0] < 3:\n # from cPickle import dumps\n from io import BytesIO as stream\n # from Queue import PriorityQueue, Queue\nelse:\n # from functools import reduce\n from io import StringIO as stream\n from math import gcd\n # from pickle import dumps\n # from queue import PriorityQueue, Queue\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n def gcd(x, y):\n \"\"\"gcd(x, y) -> int\n greatest common divisor of x and y\n \"\"\"\n while y:\n x, y = y, x % y\n return x\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef main():\n n, m, l = map(int, input().split(' '))\n a = list(map(int, input().split(' ')))\n points_to_cut = [1 if i > l else 0 for i in a]\n\n starts, ends = set(), set()\n if points_to_cut[0] == 1:\n starts.add(0)\n\n for i, pi in enumerate(points_to_cut):\n if i == 0:\n continue\n if pi == 0:\n if points_to_cut[i - 1] == 1:\n ends.add(i - 1)\n if pi == 1:\n if points_to_cut[i - 1] == 0:\n starts.add(i)\n\n if points_to_cut[-1] == 1:\n ends.add(n - 1)\n\n for _ in range(m):\n q = list(map(int, input().split(' ')))\n if q[0] == 0:\n print(len(starts))\n else:\n a[q[1] - 1] += q[2]\n if a[q[1] - 1] > l:\n if points_to_cut[q[1] - 1] == 0:\n if (q[1] in starts) and ((q[1] - 2) in ends):\n starts.remove(q[1])\n ends.remove(q[1] - 2)\n elif q[1] in starts:\n starts.remove(q[1])\n starts.add(q[1] - 1)\n elif (q[1] - 2) in ends:\n ends.remove(q[1] - 2)\n ends.add(q[1] - 1)\n else:\n starts.add(q[1] - 1)\n ends.add(q[1] - 1)\n\n points_to_cut[q[1] - 1] = 1\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n\n if 'PyPy' in sys.version:\n from _continuation import continulet\n\n def bootstrap(c):\n callable, arg = c.switch()\n while True:\n to = continulet(lambda _, f, x: f(x), callable, arg)\n callable, arg = c.switch(to=to)\n\n c = continulet(bootstrap)\n c.switch()\n\n main()\n\n else:\n import threading\n\n sys.setrecursionlimit(2097152)\n threading.stack_size(134217728)\n\n main_thread = threading.Thread(target=main)\n main_thread.start()\n main_thread.join()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9bcfa2676695d093c395e5d0125efe1", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "is_valid=1\nis_error=0\nmp=[-1,31,28,31,30,31,30,31,31,30,31,30,31]\ndbm=[-1]\ndb=0\nfor dim in mp:\n\tdbm.append(db)\n\tdb+=dim\n\ndef is_leap_year(year):\n\tif year%4==0 and year%100==0:\n\t\treturn 1\n\telif year%4==0:\n\t\treturn 1\n\ndef dby(year):\n\tnyear=year-1\n\treturn nyear*365+nyear//4-nyear//100+nyear//400\n\ndef calc_days_in_month(month,year):\n\tif month==2:\n\t\tif is_leap_year(year)==1:\n\t\t\treturn 29\n\t\telse:\n\t\t\treturn 28\n\treturn mp[month]\n\ndef days_previous_month(month,year):\n\treturn dbm[month]+(month>2 and is_leap_year(year))\n\ndef no_of_days_from_start(year,month,day):\n\treturn dby(year)+days_previous_month(month,year)+day\n\n\nf=open(\"input.txt\",\"r\")\nT=f.readline()\nD=T.split()\nf.close()\n\nD1=D[0].split(\"/\")\nD2=D[1].split(\"/\")\n\n\nd1=int(D1[0])\nm1=int(D1[1])\ny1=int(D1[2])\n\n\n\nd2=int(D2[0])\nm2=int(D2[1])\ny2=int(D2[2])\n\nif d1<1 or d1>calc_days_in_month(m1,y1) or m1<1 or m1>12:\n\tis_error=1\n\nif d2<1 or d2>calc_days_in_month(m2,y2) or m2<1 or m2>12:\n\tis_error=1\n\nif y1<2019: \n\tis_valid=0\nif y2<2019:\n\tis_valid=0\n\nif y1==2019 :\n\tif m1==12:\n\t\tif d1<30:\n\t\t\tis_valid=0\n\telse:\n\t\tis_valid=0\n\nif y2==2019:\n\tif m2==12:\n\t\tif d2<30:\n\t\t\tis_valid=0\n\telse:\n\t\tis_valid=0\n\ntot_no_of_days1=no_of_days_from_start(y1,m1,d1)\ntot_no_of_days2=no_of_days_from_start(y2,m2,d2)\n\nw1=tot_no_of_days1\nw2=tot_no_of_days2\n\nif w1>w2:\n\tis_valid=0\n\n\ntemp=tot_no_of_days1//7\nw1-=2*temp\ntemp=tot_no_of_days1%7\nif temp==0:\n\tw1-=1\nelif temp>=1:\n\tw1-=2\n\n\ntemp=tot_no_of_days2//7\nw2-=2*temp\ntemp=tot_no_of_days2%7\nif temp==0:\n\tw2-=1\nelif temp>=1:\n\tw2-=2\n\n\nf=open(\"output.txt\",\"w\")\nif is_error==1:\n\tf.write(\"error\")\nelif not is_valid ==1:\n\tf.write(\"invalid\")\nelse:\n\tans=w2-w1\n\tif tot_no_of_days1%7!=0 and tot_no_of_days1%7!=1:\n\t\tans+=1\n\tf.write(str(ans))\nf.close()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57d204a16e56edfe7c86f8a5d9efe337", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def solve(la, ra, ta, lb, rb, tb):\n if la > lb:\n la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta\n da = ra-la\n db = rb-lb\n ans = 0\n dist = lb - la\n dist %= ta\n if dist == 0:\n return min(da+1, db+1)\n if tb % ta:\n dist %= ta % (tb % ta)\n la, ra = lb - dist, lb - dist + da\n ans = max(ans, 1 + min(rb, ra) - lb)\n ans = max(ans, 1 + min(rb, ra + ta % (tb % ta)) - (la + ta % (tb % ta)))\n la, ra = lb - dist, lb - dist + da\n ans = max(ans, 1+min(rb, ra) - lb)\n ans = max(ans, 1+min(rb, ra+ta) - (la+ta))\n return ans\n\n\ndef main():\n la, ra, ta = [int(i) for i in input().split()]\n lb, rb, tb = [int(i) for i in input().split()]\n print(solve(la, ra, ta, lb, rb, tb))\n\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "824367dc0ca0b49bd18f0b120d1efd85", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\n\n\ndef gcd(a, b):\n if not b:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef solution(la, ra, ta, lb, rb, tb):\n g = gcd(ta, tb)\n d = (lb - la) % g\n return min(ra - la + 1 - d, rb - lb + 1)\n\n\nla, ra, ta = map(int, stdin.readline().split())\nlb, rb, tb = map(int, stdin.readline().split())\n\n\nans = max(solution(la, ra, ta, lb, rb, tb), solution(lb, rb, tb, la, ra, ta))\n\nans = max(ans, 0)\nsdout.write(str(ans))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "93b8fd7fe40a285753a08a999b1d4619", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "n, m = map(int,raw_input().split())\nif n >= 1 and m <= 100:\n\tif n == m and n%2 == 0:\n\t\tprint \"Malvika\"\n\telif n == m and n%2 != 0:\n\t\tprint \"Akshat\"\n\telif n != m and n%2 != 0 and m%2 != 0 :\n\t\tprint \"Akshat\"\n\telif n!= m and n%2 == 0 and m%2 == 0:\n\t\tprint \"Malvika\"\n\telif n == 1 or m == 1\n\t\tprint \"Akshat\"\n\telse: \n\t\tprint \"Malvika\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "047b3a1ef81936fe61a5a027e4951de2", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=(int(x) for x in input().split()\nif min(n,m)%2==0:\n print(\"Malvika\")\n else:\n \n print(\"akshat\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "29946b837f89aebba3a7f03722ce6b54", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "print\"MAaklsvhiakta\"[min(map(int,input().split()))[0]%2::2]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1c94f8bddebd60fef74b3ce8d8eebdc", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\ninput1 = raw_input()\n[row, col]=[int(x) for x in input1.split(\" \")]\nif (min(row,col)%2 == 0):\n print \"Malvika\"\nelse:\n print \"Akshat\"3 ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a91eb1a7b3b8fa3a83fa2363b8e87828", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\nflag=0\nif(n==1 and m==2):\n\tprint(\"Akshat\")\n\tbreak\nfor i in range(1,(n*m)+1):\n\tif(i%2==0):\n\t\tflag=1\t\n\telse:\n\t\tflag=0\n\ti+=2\nif(flag==1):\n\tprint(\"Malvika\")\nelse:\n\tprint(\"Akshat\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f58c1dec9a610d11d237e97f700612cc", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "Python 2", "source_code": "n, b = map(int, raw_input().split())\nend = []\nres = []\nlast_end = -1\nqueue_size = 0\nfor i in range(n):\n t, d = map(int, raw_input().split())\n while end and t >= end[0]:\n end.pop(0)\n queue_size -= 1\n if last_end <= t:\n last_end = t+d\n res.append(last_end)\n end.append(last_end)\n queue_size += 1\n elif queue_size <= b:\n last_end = last_end+d\n res.append(last_end)\n end.append(last_end)\n queue_size += 1\n else:\n res.append(-1)\n end.append(-1)\nprint ' '.join(map(str, res))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dda0c33b88cfc9f787e3bd89f58251db", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n,m = [int(i) for i in input().split()]\nif n%2 == 1:\n if m >= (n-1)/2:\n print (int((n-1)*n/2))\n else:\n t = 0\n for i in range((n-1)/2-m):\n t += 4*i+3\n print (int((n-1)*n/2-t))\nelse:\n if m >= n/2:\n print (int((n-1)*n/2))\n else:\n t = 0\n for i in range(n/2-m):\n t += 4*i+1\n print (int((n-1)*n/2-t))\n\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "502fcf9108671f3351870ef634d48f6f", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "(n, k) = map(int, raw_input().split())\n\naux = range(n)\nreversed = False\nfor i in xrange(k):\n\tif i > n-i-1:\n\t\treversed = True\n\t\tbreak\n\ttmp = aux[i]\n\taux[i] = aux[n-i-1]\n\taux[n-i-1] = tmp\n\t\nif reversed:\n\tprint n*(n-1)/2\nelse:\n\tout = 0\n\tfor i in xrange(n):\n\t\tfor j in xrange(i+1, n):\n\t\t\tif aux[i] > aux[j]:\n\t\t\t\tout += 1\n\tprint out", "lang_cluster": "Python", "compilation_error": false, "code_uid": "492b16139c1a15e99dc8cffb1302ac21", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\n s, j, l = input(), -1, [-1]\nfor c in s:\n while j != -1 and c != s[j]:\n j = l[j]\n j += 1\n l.append(j)\nle = l[-1]\nif l.count(le) < 2:\n le = l[le]\nprint(s[:le] if le > 0 else \"Just a legend\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dcfa697251bbfc9f3ac90ffe6b582e8d", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n, k = (int(i) for i in input().split())\nimport math\ndef combinations(a,b):\n i = math.factorial(a)\n x = math.factorial(b)\n y = math.factorial(a-b)\n return i/(x*y)\nif n == 1:\n print(0)\n exit()\nif k >= int(n/2):\n t = combinations(n,2)\n print(int(t))\n exit()\ns = n - 2 * k\np = combinations(s,2)\nl = combinations(n,2)\noutput = l - p\nprint(int(output))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e54bf25532d1315ab01cc99cc11237f", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import sys\nread=lambda:sys.stdin.readline().rstrip()\nreadi=lambda:int(sys.stdin.readline())\nwriteln=lambda x:sys.stdout.write(str(x)+\"\\n\")\nwrite=lambda x:sys.stdout.write(x)\n'''\na - \ud55c \ubcc0\uc758 \uae38\uc774\nx, y = \ub3cc\uc744 \ub358\uc9c4 \uacf3\uc758 \uc704\uce58\n\n\ubc18\ub4dc\uc2dc \ub124\ubaa8 \uc548\uc5d0 \ub4e4\uc5b4\uac00\uc57c\ub9cc \ud568\n\uacbd\uacc4\uc5d0 \uac78\uccd0\ub3c4 -1\n\n\nh = 5 (-a, 4a), (a, 5a)\nh = 4 (-a/2, 3a), (a/2, 4a)\nh = 3 (-a, 2a), (a, 3a)\nh = 2 (-a/2, a) (-a/2, 2a)\nh = 1 :(-a/2, 0) (a/2, 0)\n\nh = 1 \n (-a/2, 0),(a/2, 1*a)\nh = 2K + 1 ( K = 1, 2, 3, ...)\n (-a, (h-1)*a), (a, h*a) \nh = 2K\n (-a/2, h-1), (a/2, h)\n\nha - ha + a\n'''\ndef solve(a,x,y):\n if not y % a:\n return -1\n if abs(x) >= a:\n return -1\n if y < a:\n if -a/2.0 < x < a/2.0:\n return 1\n else:\n return -1\n\n\n\n h = y // a\n if not h % 2:\n if x == 0:\n return -1\n if -a < x < 0:\n return 3*h//2 \n if 0 < x < a:\n return (3*h//2) + 1\n else:\n return -1 \n else:\n if -a/2.0 < x < a/2.0:\n return 3*((h+1)//2) - 1\n else:\n return -1\n\nA,X,Y=map(int, read().split())\nwriteln(solve(A,X,Y))\n\n'''\nh = 1 2 3(h+1)/2 -1\nh = 3 5 \nh = 5 8\n\nh = 2 3 3(h//2)\nh = 4 6\nh = 6 9\n\n'''", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6854f9d76baffd61d9132f9efc0653b6", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "\n\nentrada = list(map(int,input().split(' ')))\nl = entrada[0]\nx = entrada[1]\ny = entrada[2]\n\n\nok = True\n\nres = 1\n\nax = True\n\nif y >= l:\n\ty -= l\n\tres = 2\n\t\n\nwhile(y >= l):\n\tif ax:\n\t\tres += 1\n\telse:\n\t\tres += 2\n\tax = not ax \n\t\t \n\ty -= l\n\nif y == 0:\n\tok = False\nif not ax:\n\tif x <= -l or x >= l or x == 0:\n\t\tok = 0\n\tif x > 0:\n\t\tres += 1\nelse:\n\tif x => (l/2) or x <= -(l/2):\n\t\tok = 0\n\n\nif ok:\n\tprint(res)\nelse:\n\tprint(-1)\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "125e8e24a25c7419f2b665190766b45e", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "a,r,w=map(int,raw_input().split())\nb=w%a\nif -a0:\n\tk=w/a\n\tk=k+min(1,b)\n\tif k==1:\n\t\tif -a/2.0 self.point2[0]:\n return -1\n if y < self.point1[1]+1 or y => self.point2[1]:\n return -1\n else:\n return self.number\n\n\n\na,x,y = map(int, input().split())\n\n\nrow = y//a + 1\n\nif row == 1:\n test = Square()\n test.GenerateCords(a, row)\nelif (row - 1)%2 == 1:\n test = Square()\n test.GenerateCords(a, ((((row-1)//2)*3)+2))\nelse:\n if x <= 0:\n test = Square()\n test.GenerateCords(a, (row//2)*3)\n else:\n test = Square()\n test.GenerateCords(a, ((row//2)*3)+1)\n\nprint(test.CheckIfIn(x,y))\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f7b0ba04b7baafe8592e68717224054e", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "a,x,y = map(int,(input().strip().split()))\n\nif(y<0 or y%a == 0):\n print(str(-1))\nelif x>a or x< (-1*a):\n print(str(-1))\nelse:\n if(y>0 and y(-1*a)/2 and x0 and x>(-1*a)/2 and xa and yRem<2*a and x>0 and x a and yRem < 2 * a and x < 0 and x > (-1*a)):\n print(str(3+3*k))\n else:\n print(str(-1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "60470ebac81abd1512fd05294c5df593", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def f(s):\n return s==s[-1::-1]\na,b=input().split(':')\np,q=int(a),int(b)\nc=0\nwhile not f(a+b):\n temp=q+1//60\n q=(q+1)%60\n p=(p+temp)%24\n c+=1\n a,b=str(p),str(q)\n if len(a)==1:\n a='0'+a\n if len(b)==1:\n b='0'+b\nprint(c)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38026de3cc5e052cc9e1ad2cfb05d828", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=list(map(str,input().split(\":\")))\na=list(a[0][0]+a[0][1]+a[1][0]+a[1][1])\ns=0\nwhile a!=a[::-1]:\n a[3]=str(int(a[3])+1)\n if a[3]==\"10\":\n a[3]=\"0\"\n a[2]=str(int(a[2])+1)\n if a[2]==\"6\":\n a[2]=\"0\"\n a[1]=str(int(a[1])+1)\n if a[0]+a[1]==\"24\":\n a[0],a[1],a[2],a[3]=\"0\",\"0\",\"0\",\"0\"\n s+=1\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9370dc8ca986a02e961360d9f8b5520", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "=input()\nch1=ch[0]+ch[1]\nch2=ch[3]+ch[4]\na=int(ch1)\nb=int(ch2) \ns=0\ndef pal(a,b):\n return (a==(b%10)*10+b//10)\nif pal(a,b):\n print(0)\nelse:\n while pal(a,b)==False:\n s=s+1\n if b!=59 :\n b=b+1\n else :\n b=0\n if a!=23:\n a=a+1\n else :\n a=0\n \n \n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "61142239aac6516f9dc2800741a4f468", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "dd = raw_input()\nans = 0\ns = [int(dd[0]), int(dd[1]), int(dd[2]), int(dd[3])]\nwhile s[0] != s[3] or s[1] != s[2]\n ans += 1\n s[3] += 1\n if s[3] == 10:\n s[3] = 0\n s[2] += 1\n if s[2] == 6:\n s[2] = 0\n s[1] += 1\n if s[1] == 10:\n s[1] = 0\n s[0] += 1\n\n if s[0] * 10 + s[1] == 24:\n s[0] = 0\n s[1] = 0\n \n \nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "454803d0e741567406149e618c11b4a1", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "import sys\n\ninput = sys.stdin.readline\n\ntime = [int (x) for x in input().split(\":\")]\n\ncount = 0\n\nwhile True:\n second = str(time[1])\n if (len(first) == 1 and second[0] == 0 and second[1] = first[0]):\n break\n if (len(second) == 1 and first[0] == 0 and first[1] = second[0]):\n break\n if str(time[0])[::-1] == second:\n break\n count += 1\n if time[1] < 59:\n time[1] += 1\n else:\n time[1] = 0\n if time[0] < 23:\n time[0] += 1\n else:\n time[0] = 0\n\nprint(count)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b370aaadfe04113a9230f22ef84850c5", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "Python 3", "source_code": " n=int(input())\nn=n+1\nn=n*n\na=int(n/4)\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb955db04a57cc347f9ea439b877091e", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n = int(input());\nn += 1;\nprint(((n + 1)) / 2) * (n / 2));", "lang_cluster": "Python", "compilation_error": true, "code_uid": "696d83574d1eb3c21c2a1510349cf5e8", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Python 3", "source_code": " n=int(input())\nn=n+1\na=int(n*n/4)\nprint(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "927a29e579955a39e63c3d40e21aa39a", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n=input()\ndict={}\ni=n\narr=[]\nwhile(i>0):\n k=0\n for j in range(n-i+1):\n arr.append([i,k,k+i])\n k+=1\n i-=1\n\nl=len(arr)\nans=0\nfor i in range(1,l):\n k=arr[i][0]\n l1=arr[i][1]\n l2=arr[i][2]\n if arr[i][0]!=-1:\n found=False\n for j in range(i+1,l):\n if arr[j][0]!=-1:\n p=arr[j][0]\n r1=arr[j][1]\n r2=arr[j][2]\n if k+p==n and (r1>=l2 or l1>=r2):\n arr[j][0]=-1\n ans+=1\n found=True\n break\n elif k+p=l2 or l1>=r2):\n p+=arr[j][0]\n arr[j][0]=-1\n if found!=True:\n ans+=1\n\n #print arr,ans\n\nprint ans+1\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1551e7dd8f6ab2dea11147225648aa0d", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def getans(n):\n if n == 2 :\n return 2\n if n == 3:\n return 4\n return n+getans(n-2)\nprint(getans(int(input())))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4da9872cf5058b9bec867a1a32503993", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "x=input().split()\n\nd =int(x[0])\nm =int(x[1])\n\nb= max(d,m); s= min(d,m)\n\nwhile(True):\n if (b%d==0 and b%m==0):\n c=b\n break\n b+=1\n\ny = c/d\nz = c/m\n\nif d>m:\n y+=1\nelse:\n z+=1\n\nif y>z:\n print(\"Dasha\")\n\nelif y b):\n\tprint \"Masha\"\nelse:\n\tprint \"Dasha\"\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2fcdbb405253d018414bcadfa767d3d7", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\ndef gcd(a, b):\n\treturn gcd(b, a%b) if b else a\n\na, b = map(int, input().split())\ng = gcd(a, b)\na /= g\nb /= g\nif a - b == 1 or b - a == 1:\n\tprint(\"Equal\")\nelif a < b:\n\tprint(\"Dasha\")\nelse:\n\tprint(\"Masha\")\n\nreturn 0\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0650eb8b1f6c0b97ba6afc9fc09180b4", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#include \nusing namespace std;\n\nint gcd(int a,int b){\n if(b == 0){\n return a; \n }\n else{\n return gcd(b,a%b); \n }\n}\n\nint main(){\n\tint a; \n\tint b;\n\tcin >> a >> b;\n\n\tint aa = a / gcd(a, b);\n\tint bb = b / gcd(a, b);\n\n\twhile (true){\n\t\tif(abs(aa-bb)==1){\n\t\t\tcout << \"Eqular\" << endl;\n\t\t\tbreak;\n\t\t}\n\t\tif(a < b){\n\t\t\tcout << \"Dasha\" << endl;\n\t\t\tbreak;\n\t\t}\n\t\tif(a > b){\n\t\t\tcout << \"Masha\" << endl;\n\t\t\tbreak;\n\t\t}\n\t}\n\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1947a27d860a3b6b6211b7a470961984", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "def gcd(a,b):\n if b==0: return a\n else return gcd(b,a%b)\na,b=map(int,raw_input().split())\nd=gcd(a,b)\na/=d\nb/=d\nif b==a+1 or b+1==a: print 'Equal'\nif a>b: print 'Masha'\nif a b:\n\t\t\ta = a - b\n\t\telse:\n\t\t\tb = b - a\n\treturn a\t\n\na, b, x, y = map(int, raw_input().split())\ngcd = GCD(x, y)\nx/=gcd\ny/=gcd\nc = a/x\n\nd = b/y\n \nif c < d:\n\tr1 = x*c\n\tr2 = y*c\nelif d <= c:\n\tr1 = x*d\n\tr2 = y*d\nif r1*y == r2*x:\n\tprint r1, r2\nelse:\n\tprint 0, 0\n\t\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "87f449e572dab65e007aa5356c61caae", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\nwidth = int(input())\nheight = int(input())\nx = int(input())\ny = int(input())\n\nn = x\nm = y\n\nwhile n != 0 and m != 0:\n if n > m:\n n = n % m\n else:\n m = m % n\n\nn += m\nx /= n\ny /= n\n\nw_new = 0\nh_new = 0\nbot = 1\ntop = 2e9\n\nwhile (bot <= top):\n c = int((bot + top) / 2)\n if c * x <= width and c * y <= height:\n bot = c + 1\n w_new = c * x\n h_new = c * y\n else:\n top = c - 1\n\nprint(w_new)\nprint(\" \")\nprint(h_new)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d53a0d982349a4fc60d118d71dbad548", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\nwidth = int(input())\nheight = int(input())\nx = int(input())\ny = int(input())\n\nn = x\nm = y\n\nwhile n != 0 and m != 0:\n if n > m:\n n = n % m\n else:\n m = m % n\n\nn += m\nx /= n\ny /= n\n\nw_new = 0\nh_new = 0\nbot = 1\ntop = 2e9\n\nwhile (bot <= top):\n c = int((bot + top) / 2)\n if c * x <= width and c * y <= height:\n bot = c + 1\n w_new = c * x\n h_new = c * y\n else:\n top = c - 1\n\nprint(str(w_new) + \" \" + str(h_new))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "446934727e7edf1e9da1325d39cbf11a", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "a,b,x,y = [int(x) for x in input().split()]\n\ndef gcd(r,s):\n if (r == 0 or s == 0):\n return r+s\n else:\n if r > s:\n return gcd(r-s,s)\n else:\n return gcd(r,s-r)\n\ng = gcd(x,y)\nx1 = int(x/g)\ny1 = int(y/g)\n\nif (x1 <= a and y1 <=b): \n c = 0\n while (x1*c <= a and y1*c<= b):\n c += 1\n print(x1*(c-1),y1*(c-1))\nelse:\n print(0,0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "480aaaefc3d93d2645697408bf936a65", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nc = 1\nfor i in range(1, 20):\n tmp = (2**i - 1)*(2**(i-1))\n if (n % tmp) == 0:\n c = tmp\nprint(c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fa6ce8627ef402460a1a46e0e13e1f2b", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.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\n#define int long long\n#define all(arr) begin(arr), end(arr)\n#define pb push_back\n#define em emplace_back\n\nusing namespace std;\nsigned main(){\n int n;\n cin>>n;\n vector arr(n);\n for(int i=0;i>arr[i];\n }\n int pos=-1;\n for(int i=0;iarr[pos+1])continue;\n cout<0:\n a = 0 \n b = 0\n break\n else:\n b+=1\n \n if b-a == 1: return lista[j]\n \n \nx = int(input())\nk = divisors(x)\nprint (k)\n# 1512531319532\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "298473031e60a87fafbcc709ba1e9423", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nx1=n\nwhile x1 > 0:\n if n%x1==0: \n count=0\n x=x1\n while x%2==0:\n x=x/2\n count+=1\n g=1\n count1 = 0\n for i in range(count):\n g=g*2+1\n count1 += 1\n if x==g:\n print(int(x*(2**count))\n x1=0\n x1-=1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0a1df2faabc123a498af54bcd5158909", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.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 <= n:\n if pair not in pythagDict[c]:\n pythagDict[c].append(pair)\n ans += 1\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\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91b593b480f358f2af47f190cc9eeb81", "src_uid": "36a211f7814e77339eb81dc132e115e1", "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,1+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": "274b4a743112545e879a163266518a78", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import math\n\nn = int(raw_input())\nsq = int(math.sqrt(n))\npythagList = []\nfor k in range(1,2+n/3):\n for x in range(1,sq+1):\n for nyin range(1,m):\n a = 2*k*m*n\n b = k*(m*m-n*n)\n c = k*(m*m+n*n)\n l = [a,b,c]\n l.sort()\n if l not in pythagList and c <= n:\n pythagList.append(l)\nprint len(pythagList)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "04a0962359e231e45b328742fc3af84f", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input())\ns=0\nw=0\nb=1\n\nif n==10000:\n print(12471)\nelif n=9999:\n print(12467)\nelse:\n while b(n)**2:\n break\n \n \n print(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "11cfe92d2528e719bc2e5a8cb47862a9", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#pragma comment(linker,\"/STACK:100000000,100000000\")\n\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 \n#include \n#include \n#include \n\nusing namespace std;\n\n/* Constants begin */\nconst long long inf = 1e18+7;\nconst long long mod = 1e9+7;\nconst double eps = 1e-9;\nconst double PI = 2*acos(0.0);\nconst double E = 2.71828;\n/* Constants end */\n\n/* Defines begin */\n#define pb push_back\n#define mp make_pair\n#define ll long long\n#define double long double\n#define F first\n#define S second\n#define all(a) (a).begin(), (a).end()\n#define forn(i,n) for (ll (i)=0;(i)<(ll)(n);(i)++)\n/* Defines end */\n\nll gcd(ll x, ll y){\n return !y ? x : gcd(y,x%y);\n}\n\nint main(void) {\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"rt\",stdin);\n freopen(\"output.txt\",\"wt\",stdout);\n #endif\n ll n, ans = 0;\n cin >> n;\n ll to = sqrt(n+.0);\n for(ll i=1;i<=to;i++)\n for(ll j=i;j<=to;j++){\n ll c = i*i+j*j;\n if(c > n) break;\n if(gcd(i,j) != 1 || ~(j-i) & 1) continue;\n ans += n/c;\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "26c48ee5fc01b38eaba6e2ff5b081351", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "import sys\nimport itertools as it\nimport bisect as bi\nimport math as mt\nimport collections as cc\ninput=sys.stdin.readline\nI=lambda:list(map(int,input().split()))\nn,m=I()\na=[]\nb=[]\nc=[]\nfor i in range(1,int(n**0.5)+1):\n\tif n%i==0:\n\t\ta.append(i)\nfor i in range(1,int(m**0.5)+1):\n\tif m%i==0:\n\t\tb.append(i)\nne=n+m\nfor i in range(1,int(ne**0.5)+1):\n\tif ne%i==0:\n\t\tc.append(i)\nans=10**9+7\nfor i in c[::-1]:\n\tj=ne//i\n\ttf=0\n\tfor ii in a:\n\t\tif ii<=i and n//ii<=j:\n\t\t\ttf=1\n\t\t\tbreak\n\tfor jj in b:\n\t\tif jj<=i and m//jj<=j:\n\t\t\ttf=1\n\t\t\tbreak \n\tif tf:\n\t\tans=min(ans,2*(i+j))\n\t\tbreak\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fb8c7eacd47aa39c413e3931b8a9fd08", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "#coding:utf-8\n\na, b = map (int, raw_input ().split ())\nc = a+b\nans = c*2+2\n\nx, y = 1, a\nindex = 1\ni = 2\nwhile i*i <= c:\n\tif c%i == 0:\n\t\twhile index <= i:\n\t\t\tif a%index == 0:\n\t\t\t\tx, y = index, a/index\n\t\t\tindex += 1\n\t\tif x <= i and y <= c/i:\n\t\t\tans = min (ans, 2*(i+c/i))\n\ti += 1\n\n\nprint ans\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1818699321c38dd5028813b8347a6ef0", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys,bisect as bi\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\n\ndef an(x,y):\n\tvd=[1,x]+([] if x%2 else [2,x//2])\n\tfor i in range(3,int(x**0.5)+1,2):\n\t\tif x%i==0:\n\t\t\tvd.append(i)\n\t\t\tif i!=x//i:\n\t\t\t\tvd.append(x//i)\n\tvd.sort()\n\tan=4*x+4*y\n\tfor i in range(len(dv)):\n\t\tcr=dv[i]\n\t\tp=bi.bisect(vd,cr)\n\t\tp-=1\n\t\tif (x+y)//cr>=x//vd[p]:\n\t\t\tan=min(an,2*(cr+(x+y)//cr))\n\treturn an\na,b = I()\nx=a+b\ndv=[1,x]+([] if x%2 else [2,x//2])\nar=[1,2,3]\nfor i in range(3,int(x**0.5)+1,2):\n\tif x%i==0:\n\t\tdv.append(i)\n\t\tif i!=x//i:\n\t\t\tdv.append(x//i)\nprint(min(an(a,b),an(b,a)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0197dc5151cb3c28570731b64ba9da94", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "d_a = []\nd_b = []\n\ndef solve(a, b):\n global d_a, d_b\n \n n = a + b\n ans = (1 + n) << 1\n\n for i in xrange(1, int(n ** 0.5) + 1):\n if n % i == 0:\n j = 0\n while j < len(d_a) and d_a[j] <= i:\n if (a // d_a[j] <= n // i):\n ans = min(ans, (i + n // i) << 1)\n j += 1\n\n for i in xrange(1, int(n ** 0.5) + 1):\n if n % i == 0:\n j = 0\n while j < len(d_b) and d_b[j] <= i:\n if (b // d_b[j] <= n // i):\n ans = min(ans, (i + n // i) << 1)\n j += 1\n\n return ans\n\na, b = map(int, raw_input().strip().split())\n\nfor i in xrange(1, int(a ** 0.5) + 1):\n if a % i == 0: d_a.append(i)\nfor i in xrange(1, int(b ** 0.5) + 1):\n if b % i == 0: d_b.append(i)\n\nprint solve(a, b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7206a36e387ca66ff0c69c242e541e3e", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\nimport itertools as it\nimport bisect as bi\nimport math as mt\nimport collections as cc\ninput=sys.stdin.readline\nI=lambda:list(map(int,input().split()))\nn,m=I()\na=[]\nb=[]\nc=[]\nfor i in range(1,int(n**0.5)+1):\n\tif n%i==0:\n\t\ta.append(i)\nfor i in range(1,int(m**0.5)+1):\n\tif m%i==0:\n\t\tb.append(i)\nne=n+m\nfor i in range(1,int(ne**0.5)+1):\n\tif ne%i==0:\n\t\tc.append(i)\nans=10**9+7\nfor i in c:\n\tj=ne//i\n\ttf=0\n\tfor ii in a:\n\t\tif ii<=i and n//ii<=j:\n\t\t\ttf=1\n\t\t\tbreak\n\tfor jj in b:\n\t\tif jj<=i and m//jj<=j:\n\t\t\ttf=1\n\t\t\tbreak \n\tif tf:\n\t\tans=min(ans,2*(i+j))\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "16ad4ff7147667cb9da4cc30b549a7c3", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def main():\n n, m = map(int, input().split(' '))\n if (n % 2 == 0) and (m % 2 == 0):\n if (n == 2) and (m == 2):\n print(0)\n else:\n print(m*n)\n else:\n if (n % 2 == 1) and (m % 2 == 1):\n if (n == 1) and (m == 1):\n print(0)\n elif (n == 1) and (m % 6 == 3):\n print(m - 3)\n elif (n % 6 == 3) and (m == 1):\n print(n - 3)\n else:\n print(m*n - 1)\n else:\n if (n == 1) or (m == 1):\n if (n % 6 == 0) or (m % 6 == 0):\n print(m*n)\n else:\n print(m*n - 2)\n elif (n == 2) or (m == 2):\n if (n in [3, 7]) or (m in [3, 7]):\n print(m*n - 2)\n else:\n print(m*n)\n else:\n print(m*n)\n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3db14271a752b11e5cb9ce5e76eb5806", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n,m=set(map(int,input().split()))\nprint(n*m-{1:min(m%6,6-m%6),2:2*(m in [3,7])+4*(m==2)}.get(n,n&1*m&1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2bbb791da6553c8e67f57ae5e9791b5c", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n,m=set(map(int,input().split()))\nprint(n*m-(min(m%6,6-m%6) if n==1 else 2*(m in [3,7])+4*(m==2) if n==2 else n&1*m&1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "725f5f8d8fe15759648214ad8b3950d5", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nif n > m:\n n, m = m, n\nif n == 1:\n print(m // 6 + (m + 1) // 6 + (m + 2) // 6 << 1)\nelif n == 2:\n print(0 if m == 2 else 4 if m == 3 12 if m == 7 else n * m)\nelse:\n print(n * m >> 1 << 1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "15016c938624d1de0889722eeaa541ef", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split(\" \"))\nif n*m<6:\n print(0)\n \nelif n*m==6:\n print(4)\nelif (n==2 and m%2==1) or (m==2 and n%2==1):\n print(n*m-2)\nelif((n==2 and m%2==0) or (m==2 and n%2==0))\n print(n*m)\nelse:\n print(n*m-(n*m)%2)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "076fa5aaf152da648ebab1d9edc5a041", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "\ufeffn = int(input.split())\nll = [int(x) for x in input().split()]\n\ncount = 0\n\nidx = -1\nfor i in ll:\n idx = idx + 1\n \n if i == 1:\n count += 1\n \n if (idx > 0) and (idx < len(ll)-1):\n if ll[idx-1] == 1 and ll[idx] == 0 and ll[idx+1] == 1:\n count += 1\n \nprint(count) \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0379f57f06ee0a20ca8afef7b2e9dfb", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeffn = map(int, input().split())\nll = [int(x) for x in input().split()]\n\ncount = 0\n\nidx = -1\nfor i in ll:\n idx = idx + 1\n \n if i == 1:\n count += 1\n \n if (idx > 0) and (idx < len(ll)-1):\n if ll[idx-1] == 1 and ll[idx] == 0 and ll[idx+1] == 1:\n count += 1\n \nprint(count) \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e804815b401d79e3b5d33db96bdb82fe", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeffimport sys\nfrom sys import stdin, stdout\nn = int(input())\nll = [int(x) for x in stdin.readline().rstrip().split()]\n\ncount = 0\n\nidx = -1\nfor i in ll:\n idx = idx + 1\n \n if i == 1:\n count += 1\n \n if (idx > 0) and (idx < len(ll)-1):\n if ll[idx-1] == 1 and ll[idx] == 0 and ll[idx+1] == 1:\n count += 1\n \nstdout.write(str(count)+\"\\n\") \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "197aae2dda01471b66e16cff2eadd57d", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\ns = 0\nfor i in xrange(n):\n if a[i] == 1:\n s += 1\n elif a[i] == 0 and (i > 0 and i + 1 < n and a[i-1] == 1 and a[i+1] == 1):\n s += 1\n\nprint s\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71d1fc5eb4f761359d13de1c49b23c63", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufefffrom sys import stdin, stdout\nn = map(int, input().split())\nll = [int(x) for x in stdin.readline().rstrip().split()]\n\ncount = 0\n\nidx = -1\nfor i in ll:\n idx = idx + 1\n \n if i == 1:\n count += 1\n \n if (idx > 0) and (idx < len(ll)-1):\n if ll[idx-1] == 1 and ll[idx] == 0 and ll[idx+1] == 1:\n count += 1\n \nstdout.write(str(count)+\"\\n\") \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f81826bbd9fa374cec0a9696575e9e9b", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0} {"lang": "Python 3", "source_code": "k = input()\nq = input()\nans = []\ncur = \"\"\nused = set()\nfor i in range(len(q)):\n\tif q[i] not in used:\n\t\tif len(cur) > 0:\n\t\t\tans.append(cur)\n \t\tcur = \"\"\n\t\tcur += q[i]\n\t\tused.add(q[i])\n\telse:\n\t\tcur += q[i]\nans.append(cur)\nif len(ans) < k:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\tfor i in range(k, len(ans)):\n\t\tans[k - 1] += ans[i]\n\tfor i in range(k):\n\t\tprint(ans[i])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fe35755df57538fb219467ca2fb9004b", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.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 alpha[s[i] - 'a']--;\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 alpha[s[i] - 'a']--;\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": "4251761002e011bd64a8e93dae705394", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input())\ns = input()\nif (n > len(s)):\n print('NO')\nelse:\n print('YES')\n for i in range(n - 1):\n print(s[i])\n print(s[i + 1:])\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ad420d753327a1b47b08f6613a5ee25f", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\n\"\"\"\ncreated by huash06 at 2015-05-18 15:10\n\"\"\"\n__author__ = 'huash06'\n\nimport sys\nimport os\nimport datetime\nimport functools\nimport itertools\nimport collections\n\n\n\ndef findBeautifulStr(astr, index, pres, firsts, n):\n if index >= len(astr):\n if n == len(pres):\n return pres\n else:\n return []\n if len(astr) - index < n - len(pres):\n return []\n\n if astr[index] in firsts:\n return []\n\n if n == len(pres) + 1:\n return pres + [astr[index:]]\n for i in range(index+1, len(astr)-(n-len(pres))+1):\n res = findBeautifulStr(astr, i, pres + [astr[index:i]], firsts.union(astr[index]), n)\n if res:\n return res\n return []\n\n\n\nN = int(input())\nS = input()\n\nres = findBeautifulStr(S, 0, [], set(), N)\nif res:\n print('YES')\n for seg in res:\n print(seg)\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2c438e51fae251b9356ed64c280e6394", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def DFS(depth, start, str, used):\n if start >= len(str):\n return None\n if str[start] in used:\n return None\n if depth == 1:\n return [str[start:]]\n for i in range(start, len(str)):\n res = DFS(depth - 1, i + 1, str, used + str[start])\n if res != None:\n return res + [str[start:i+1]]\n return None\n\n\ndef main():\n k = int(input())\n str = input()\n res = DFS(k, 0, str, \"\")\n if res == None:\n print(\"NO\")\n else:\n print(\"YES\")\n res.reverse()\n for token in res:\n print(token)\n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef5842e7d9f147bd724c9f0153c3e592", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "import string\n\nclass Position:\n def __init__(self, r, c):\n self.r = r\n self.c = c\n\ndef s_to_position(s):\n letter, number = s[0], s[1]\n return Position(string.ascii_letters.index(letter), int(number) - 1)\n\ndef finish(message):\n print(message)\n import sys; sys.exit()\n\ndef king_attacks(attacker, defender):\n for dr in range(-1, 2):\n r = attacker.r + dr\n for dc in range(-1, 2):\n c = attacker.c + dc\n if r == defender.r and c == defender.c:\n return True\n return False\n\ndef rook_attacks(attacker, defender, blockers=[]):\n if attacker.r == defender.r and attacker.c == defender.c:\n return False\n if attacker.r == defender.r:\n blocked = False\n for blocker in blockers:\n if blocker.r == attacker.r:\n if attacker.c < blocker.c and blocker.c < defender.c:\n blocked = True\n if defender.c < blocker.c and blocker.c < attacker.c:\n blocked = True\n if not blocked:\n return True\n if attacker.c == defender.c:\n blocked = False\n for blocker in blockers:\n if blocker.c == attacker.c:\n if attacker.r < blocker.r and blocker.r < defender.r:\n blocked = True\n if defender.r < blocker.r and blocker.r < attacker.r:\n blocked = True\n if not blocked:\n return True\n return False\n\nrook_a, rook_b, king_white, king_black = map(s_to_position, input().split())\n\nfor dr in range(-1, 2):\n r = king_black.r + dr\n for dc in range(-1, 2):\n c = king_black.c + dc\n if r < 0 or r > 7 or c < 0 or c > 7:\n continue\n current_king = Position(r, c)\n if king_attacks(king_white, current_king):\n #print('king attacks %d, %d' % (r, c))\n continue\n if rook_attacks(rook_a, current_king, [king_white]):\n #print('rook A attacks %d, %d' % (r, c))\n continue\n if rook_attacks(rook_b, current_king, [king_white]):\n #print('rook B attacks %d, %d' % (r, c))\n continue\n #print('%d, %d is safe' % (r, c))\n finish('OTHER')\n\nfinish('CHECKMATE')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "50448788593ae2c40a90307a4c6b529e", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "\n\nstdin_flag=1\nif not stdin_flag:\n read_line_index=0\n testcasefilename=\"test.txt\"\n Stestcase=open(testcasefilename).read()\n read_line_datas=Stestcase.split(\"\\n\")\n\n\ndef debugs(s):\n if not stdin_flag:\n print \";;;\",s\n\ndef puts(s):\n import sys\n sys.stdout.write(str(s))\n\n#####################################\n######################################\n\ndef read_line():\n global read_line_index\n if stdin_flag:\n return raw_input()\n else:\n s=read_line_datas[read_line_index]\n read_line_index+=1\n return s\n\ndef answer():\n if stdin_flag:\n return solve()\n else:\n while read_line_proceed():\n solve()\n \n\ndef read_line_proceed():\n global read_line_index\n print\"##################\"\n while 1:\n if read_line_index>= len (read_line_datas ):\n return False\n if read_line_datas[read_line_index]==\"%%%\":\n read_line_index+=1\n return True\n read_line_index+=1\n\n\ndef readint():\n return int (read_line() )\n\n\ndef readints():\n return map(int, read_line().split(\" \"))\n\ndef reads():\n return read_line()\n\n\n\n\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n\ndef compute(m,n,d):\n pass\n\ndef pos(s):\n return ord(s[0])-ord(\"a\") , int(s[1])-1\n\ndef between(a,b,c):\n return a= 0:\n square = [intPos[0][0]+shift,intPos[0][1]]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift -= 1\n \nshift = 1\nwhile intPos[1][0] + shift < 8:\n square = [intPos[1][0]+shift,intPos[1][1]]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift += 1\n \nshift = -1\nwhile intPos[1][0] + shift >= 0:\n square = [intPos[1][0]+shift,intPos[1][1]]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift -= 1\n \nshift = 1\nwhile intPos[0][1] + shift < 8:\n square = [intPos[0][0],intPos[0][1]+shift]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift += 1\n \nshift = -1\nwhile intPos[0][1] + shift >= 0:\n square = [intPos[0][0],intPos[0][1]+shift]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift -= 1\n \nshift = 1\nwhile intPos[1][1] + shift < 8:\n square = [intPos[1][0],intPos[1][1]+shift]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift += 1\n \nshift = -1\nwhile intPos[1][1] + shift >= 0:\n square = [intPos[1][0],intPos[1][1]+shift]\n if square == intPos[2]:\n break\n guarded.append(square)\n shift -= 1\n \nfor x in range(-1,2):\n for y in range(-1,2):\n square = [intPos[2][0]+x,intPos[2][1]+y]\n guarded.append(square)\n \nmate = True\nfor x in range(-1,2):\n for y in range(-1,2):\n square = [intPos[3][0]+x,intPos[3][1]+y]\n if square[0] < 8 and square[0] >= 0:\n if square[1] < 8 and square[1] >= 0:\n if square not in guarded:\n mate = False\n \nif mate:\n print(\"CHECKMATE\")\nelse:\n print(\"OTHER\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bbd91d22280ab6081dfc3ade5aad1510", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n# coding=utf-8\n\ndef inboard(x, y):\n\treturn x >= 1 and x <= 8 and y >= 1 and y <= 8\n\ndirection = [ [ 0, 0],\n\t\t[ 1, 0],\n\t\t[ 0, 1],\n\t\t[-1, 0],\n\t\t[ 0,-1],\n\n\t\t[ 1, 1],\n\t\t[ 1,-1],\n\t\t[-1, 1],\n\t\t[-1,-1]]\n\ndef reach(x, y, dx, dy):\n\tglobal g\n\tx += dx\n\ty += dy\n\twhile inboard(x,y):\n\t\tif g[x][y] > 0:\n\t\t\tif g[x][y] == ME:\n\t\t\t\treturn True\n\t\t\telse:\n\t\t\t\treturn False\n\t\tx += dx\n\t\ty += dy\n\treturn False\n\n\ndef judge():\n\tglobal g\n\tfor i in range(1, 9):\n\t\tfor j in range(1, 9):\n\t\t\tif g[i][j] == ROOK:\n\t\t\t\tif reach(i, j, 0, 1): return False\n\t\t\t\tif reach(i, j, 0,-1): return False\n\t\t\t\tif reach(i, j, 1, 0): return False\n\t\t\t\tif reach(i, j,-1, 0): return False\n\t\t\tif g[i][j] == KING:\n\t\t\t\tfor dx, dy in direction:\n\t\t\t\t\t#print \"dx = %d, dy = %d\" % (dx, dy)\n\t\t\t\t\tif inboard(i + dx, j + dy) and g[i + dx][j + dy] == ME:\n\t\t\t\t\t\treturn False\n\treturn True\n\n\ng = [[0 for i in range(0, 9)] for i in range(0, 9)]\n\nROOK = 1\nKING = 2\nME = 3\n\nchess = raw_input().strip().split(\" \")\nchess =[[ord(chess[0][0]) - ord('a') + 1, ord(chess[0][1]) - ord('0')],\n\t\t[ord(chess[1][0]) - ord('a') + 1, ord(chess[1][1]) - ord('0')],\n\t\t[ord(chess[2][0]) - ord('a') + 1, ord(chess[2][1]) - ord('0')],\n\t\t[ord(chess[3][0]) - ord('a') + 1, ord(chess[3][1]) - ord('0')]]\ng[chess[0][0]][chess[0][1]] = ROOK;\ng[chess[1][0]][chess[1][1]] = ROOK;\ng[chess[2][0]][chess[2][1]] = KING;\n\n#for i in range(1, 9): print g[i]\n\nok = True\nfor dx,dy in direction:\n\tx = chess[3][0] + dx\n\ty = chess[3][1] + dy\n\t#print \"dx = %3d, dy = %3d\" % (dx, dy)\n\tif inboard(x, y) and g[x][y] != KING:\n\t\tprev = g[x][y]\n\t\tg[x][y] = ME\n\t\tif judge():\n\t\t\tok = False\n\t\t\t#for i in range(1, 9): print g[i]\n\t\t\t#print \"\"\n\t\tg[x][y] = prev\n\nif ok:\n\tprint \"CHECKMATE\"\nelse:\n\tprint \"OTHER\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1680ada5105bcc390d1f5c54a5decca3", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\ndef iswin(r1,r2,wk,bk):\n m = False\n \n if r1 == bk or r2 == bk:\n return False\n \n #if wk == bk:\n # return True\n\n #print r1, r2, wk, bk\n if r1[:1]==bk[:1]:\n lb = min(r1[1:],bk[1:])\n ub = max(r1[1:],bk[1:])\n if (r2[:1] != r1[:1] or r2[1:] < lb or r2[1:] > ub) and \\\n (wk[:1] != r1[:1] or wk[1:] < lb or wk[1:] > ub):\n m = True\n\n if r1[1:]==bk[1:]:\n lb = min(r1[:1],bk[:1])\n ub = max(r1[:1],bk[:1])\n if (r2[1:] != r1[1:] or r2[:1] < lb or r2[:1] > ub) and \\\n (wk[1:] != r1[1:] or wk[:1] < lb or wk[:1] > ub):\n m = True\n\n if r2[:1]==bk[:1]:\n lb = min(r2[1:],bk[1:])\n ub = max(r2[1:],bk[1:])\n\nif (r1[:1] != r2[:1] or r1[1:] < lb or r1[1:] > ub) and \\\n (wk[:1] != r2[:1] or wk[1:] < lb or wk[1:] > ub):\n m = True\n \n if r2[1:]==bk[1:]:\n lb = min(r2[:1],bk[:1])\n ub = max(r2[:1],bk[:1])\n if (r1[1:] != r2[1:] or r1[:1] < lb or r1[:1] > ub) and \\\n (wk[1:] != r2[1:] or wk[:1] < lb or wk[:1] > ub):\n m = True\n\n x1,y1 = map(ord,wk)\n x2,y2 = map(ord,bk)\n \n if abs(x1-x2)<=1 and abs(y1-y2)<=1:\n m = True\n\n return m\n\nr1, r2, wk, bk = sys.stdin.readline().strip().split(' ')\nmate = True\n\nif iswin(r1,r2,wk,bk)==False:\n mate = False\n\nif bk[:1] >'a':\n nbk = chr(ord(bk[:1])-1) + bk[1:]\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[:1] < 'h':\n nbk = chr(ord(bk[:1])+1) + bk[1:]\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[1:] > '1':\n nbk = bk[:1] + chr(ord(bk[1:])-1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[1:] < '8':\n nbk = bk[:1] + chr(ord(bk[1:])+1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[:1] > 'a' and bk[1:] > '1':\n nbk = chr(ord(bk[:1])-1) + chr(ord(bk[1:])-1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[:1] > 'a' and bk[1:] < '8':\n nbk = chr(ord(bk[:1])-1) + chr(ord(bk[1:])+1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[:1] < 'h'and bk[1:] > '1':\n nbk = chr(ord(bk[:1])+1) + chr(ord(bk[1:])-1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif bk[:1] < 'h' and bk[1:] < '8':\n nbk = chr(ord(bk[:1])+1) + chr(ord(bk[1:])+1)\n if iswin(r1,r2,wk,nbk) == False:\n mate = False\n\nif mate:\n print 'CHECKMATE'\nelse:\n print 'OTHER'\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1ae31b8cccf6e77ef634244cb0512573", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\ndesired = 'BERLAND'\nmatches = 5\n\ndef check(x, y):\n global result, played, victim\n standing = played.keys()\n for i in range(4):\n points = 0\n team = standing[i]\n got, lost = 0, 0\n for j in range(5):\n if result[j][1] == team:\n result[j][0], result[j][1] = result[j][1], result[j][0]\n result[j][2][0], result[j][2][1] = result[j][2][1], result[j][2][0]\n if result[j][0] != team:\n continue\n diff = result[j][2][0] - result[j][2][1]\n got += result[j][2][0]\n lost += result[j][2][1]\n if diff == 0: points += 1\n if diff > 0: points += 3\n if team == desired:\n points += 3\n got += x\n lost += y\n if team == victim:\n got += y\n lost += x\n standing[i] = (-points, -(got - lost), -got, team)\n standing = sorted(standing)\n return standing[0][3] == desired or standing[1][3] == desired\n\ndef add(s):\n global played\n if played.has_key(s):\n played[s] += 1\n else:\n played[s] = 1\n\nresult = []\nplayed = dict()\nfor _ in range(matches):\n buf = raw_input().split()\n add(buf[0])\n add(buf[1])\n buf[2] = list(map(int, buf[2].split(':')))\n result.append(buf)\nfor pair in played.items():\n if pair[1] == 2 and pair[0] != desired:\n victim = pair[0]\nfor delta in range(1, 100):\n for x in range(delta, 100):\n y = x - delta\n if check(x, y):\n print str(x) + ':' + str(y)\n sys.exit(0)\nprint 'IMPOSSIBLE'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4bf69d7969dadebb69617ddca3dcba6c", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "teams={}\nfor _ in range(5):\n t1,t2,scores=raw_input().split()\n s1,s2=map(int,scores.split(':'))\n teams[t1]=teams.get(t1) or [0,0,0,t1,0]\n teams[t2]=teams.get(t2) or [0,0,0,t2,0]\n if s1>s2:\n teams[t1][0]-=3\n elif s12]+[t1,t2]\n tms.sort()\n if tms[0][3]=='BERLAND' or tms[1][3]=='BERLAND':\n print '%d:%d'%(y+xy,y)\n exit()\nprint 'IMPOSSIBLE'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38c032c4c554fda4defda447b77e1588", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "teams={}\nfor _ in range(5):\n t1,t2,scores=raw_input().split()\n s1,s2=map(int,scores.split(':'))\n teams[t1]=teams.get(t1) or [0,0,0,t1,0]\n teams[t2]=teams.get(t2) or [0,0,0,t2,0]\n if s1>s2:\n teams[t1][0]-=3\n elif s12]+[t1,t2]\n tms.sort()\n if tms[0][3]=='BERLAND' or tms[1][3]=='BERLAND':\n print '%d:%d'%(y+xy,y)\n exit()\nprint 'IMPOSSIBLE'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "33eaf16a56d95c3b2d97b01d0ab088e5", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "Teams = [\"BERLAND\"]\ndef teamn(name)\n Teams << name if Teams.index(name).nil?\n Teams.index(name)\nend\ngame = [1,0,0,0]\npoint = [3,0,0,0]\ndiff = [0,0,0,0]\nearn = [0,0,0,0]\n5.times do |i|\n input = gets.split(\" \")\n teama = teamn(input[0])\n teamb = teamn(input[1])\n score = input[2].split(\":\").map{|x| x.to_i}\n if score[0]>score[1]\n point[teama] += 3\n elsif score[0]==score[1]\n point[teama] += 1\n point[teamb] += 1\n else\n point[teamb] += 3\n end\n game[teama] += 1\n game[teamb] += 1\n diff[teama] += score[0] - score[1]\n diff[teamb] += score[1] - score[0]\n earn[teama] += score[0]\n earn[teamb] += score[1]\nend\nopponent = game.index(2)\nfound = false\nfi = nil\nfj = nil\n1.upto(50) do |i|\n diff[0] += i\n diff[opponent] -= i\n i.upto(50) do |j|\n earn[0] += j\n earn[opponent] += j-i\n rank = (0..3).sort{|a,b| (point[a]<=>point[b])*8+(diff[a]<=>diff[b])*4+(earn[a]<=>earn[b])*2-(Teams[a]<=>Teams[b])}.index(0)\n if rank > 1\n found = true\n fj = j\n break\n end\n earn[0] -= j\n earn[opponent] -= j-i\n end\n if found\n fi = i\n break\n end\n diff[0] -= i\n diff[opponent] += i\nend\nif found\n puts fj.to_s+\":\"+(fj-fi).to_s\nelse\n puts \"IMPOSSIBLE\"\nend", "lang_cluster": "Python", "compilation_error": true, "code_uid": "734330557d266710e977a651690b381d", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.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 'IMPOSSIBLE'\nelse:\n print '{0}:{1}'.format(x, y)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9fac2eccc30d2452f57ece009eb5b572", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "n = int(input()) + 1\nd = 1000000007\ng = [[1] * n for i in range(n)]\nfor i in range(1, n):\n g[i][0] = g[i - 1][i - 1]\n for j in range(1, i + 1): g[i][j] = (g[i][j - 1] + g[i - 1][j - 1]) % d\nprint((g[-1][-1] - g[-1][0]) % d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2695dff955a2651a0c1fb9c4896e1da", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input()) + 1\nd = 1000000007\ng = [[1] * n for i in range(n)]\nfor i in range(1, n):\n g[i][0] = g[i - 1][i - 1]\n for j in range(1, i + 1): g[i][j] = (g[i][j - 1] + g[i - 1][j - 1]) % d\nprint((g[-1][-1] - g[-1][0]) % d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "47a3f7e1e27f3b683c6f1645cebd8a33", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input()) + 1\nd = 1000000007\ng = [[1] * n for i in range(n)]\nfor i in range(1, n):\n g[i][0] = g[i - 1][i - 1]\n for j in range(1, i + 1): g[i][j] = (g[i][j - 1] + g[i - 1][j - 1]) % d\nprint((g[-1][-1] - g[-1][0]) % d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcca69de723a068f2b6137e6649a4fb6", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from math import factorial\ncat = [1, 1]\np = 10**9 + 7\nn = int(input())\nfor i in range(1, 4000):\n cat.append((cat[-1]*2*(2*i + 1)//(i + 2)) % p)\n\nans = 0\nfor i in range(1, n + 1):\n ans += ((((factorial(n))//((factorial(i))*(factorial(n - i)))) % p) *cat[n - i]) % p\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c12a9d62a19466342fe6121dbac6a78b", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nprint((1 << n - 1) + (n * n - n << n - 3))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7c15468e5ac7fb82cc50be4074a4d27a", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n = int(input())\nnumbers = set()\nnn = \"\"\nfor _ in range(n):\n a = int(input())\n numbers.add(a)\n nn += str(a)\nfirst = nn.count(str(numbers.pop()))\nsecond = nn.count(str(numbers.pop()))\nif len(numbers) != 2 or first != second:\n print(\"NO\")\nelse:\n print(\"YES\")\n print(*numbers", "lang_cluster": "Python", "compilation_error": true, "code_uid": "516ff1ec9bb05c80f8cccb1ac34119a5", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "def same(d):\n s=set()\n for i in d.keys():\n s.add(d[i])\n if len(s)==1:\n return True\n else:\n return False\nn=input()\nd={}\nfor i in range(n):\n t=input()\n if t in d.keys():\n d[t]+=1 \n else:\n d[t]=1\nif len(d)==2 and same(d):\n print(\"YES\")\n for i in d.keys():\n print(i,end=\" \")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c809b707786d1d55d41e2ad40043889a", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "num = int(input())\nd = {}\na = []\nfor _ in range(num):\n card = int(input())\n if card not in d:\n d[card] = 1\n a.append(card)\n else:\n d[card] = d[card]+1\n \nif len(d) == 2 and d[a[0]]=d[a[1]]:\n print(\"YES\")\n print(a[0],a[1])\nelse:\n print(\"NO\")\n\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d9f101b541834752333bc61118f36e7", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "a=int(input())\nb=[]\nc=[]\nfor i in range(a):\n b.append(int(input()))\nc=list(set(b))\nd=[0 for i in range(len(c))]\nfor i in range(len(c)):\n for j in range(len(b)):\n if c[i]==b[j]:\n d[i] +=1\nn=0\ne=[]\nfor i in range(len(c)):\n for j in range(len(c)):\n if i==j:\n continue\n if d[i]==d[j]:\n e.append((c[i],c[j]))\n n+=1\n\nf=list(set(e)) \nif n==2 && f[0]==f[-1]:\n print(\"YES\")\n for i in range(int(len(f)/2)):\n print(f[i][0],f[i][1])\nelse :\n print(\"NO\")\n#################### ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "09dbb18d5c983cbb3721dddd79c97500", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nfor i in range(0,n):\n a=input()\n s=list(set(a))\nif(len(s)==2 and a.count(s[0]==a.count[s[1])):\n print(\"YES\")\n print(s[0],s[1])\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "71f106969034f38501aec446ffe90616", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import numpy as np\nn,k = map(int,input().split(' '))\ncount=0\nf=0\nfactors=[]\nfor i in range(2,n):\n while(count !=k-1 and n%i==0):\n count +=1\n factors.append(i)\n n=n//i\n factors.append(n)\n if(count ==k-1):\n f=1\n break\n\nif(f == 1 ): \n \n print(*factors,sep=' ')\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8955d77a87b434386063a6d36bb9840b", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split(' '))\ncount=0\nf=0\nfactors=[]\nfor i in range(2,n):\n while(count !=k-1 and n%i==0):\n count +=1\n factors.append(i)\n n=n//i\n \n if(count ==k-1):\n factors.append(n)\n f=1\n break\n\nif(f == 1 ): \n print(*factors,sep=' ')\nelse:\n print(-1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6a3318204529b803ddb304506c33009f", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def solve(n, k):\n if k==1:\n print(n)\n return\n\n sol = []\n for i in range(2,n):\n while n%i==0:\n sol.append(i)\n k-=1\n n = n//i\n if k!=1\n continue\n \n if n==1:\n print(-1)\n return\n else:\n sol.append(n)\n print(*sol)\n return\n\n return\n\n \n\ndef main():\n n,k = map(int,input().split(' '))\n solve(n,k)\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2987b19a34d715f0488ec592cdb4e472", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n, k = [int(x) for x input().split()]\n# list comprahension\ncnt = 0\np = 2\nV = []\n\nwhile p<=n:\n if n%p==0:\n n = n // p\n cnt += 1\n V.append(p)\n if cnt==k:\n break\n else:\n p += 1\n\nif cnt==k and n>1:\n V[cnt-1] *= n\n\nif cnt1:\n V[cnt-1] *= n\nif cnt inf // (prime[idx]**pw)):break\n\t\t\t\tdp[i][idx] = min(dp[i][idx],dp[i // (pw + 1)][idx-1] *(prime[idx]**pw))\nprint(dp[int(input())][12])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b511f91f99d69015904919a9f67d3d4c", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "\ufeff#\u7d20\u6570\u96c6\u5408\n# \u4efb\u4f55\u4e00\u4e2a\u6570\u5b57\u53ef\u4ee5\u8868\u793a\u4e3a2^(p1) * 3^(p2) * ... * k^(pn)\n# \u5176\u56e0\u5b50\u4e2a\u6570\u603b\u6570\u4e3a (p1 + 1) * (p2 + 1) * ... * (pn + 1)\nprime = [0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n\n# \u5230\u6bcf\u4e2a\u8282\u70b9\u6709\u4f20\u5230\u8be5\u8282\u70b9\u7684\u503c\u548c\u56e0\u5b50\u603b\u6570\u3001\u4ee5\u53ca\u8be5\u53d6\u7b2c\u51e0\u4e2a\u5143\u7d20\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": "9802f7ff21d04ecf25ef5aab9bd96bb7", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "PyPy 2", "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\n#define xrange(i, a, b) for(int i=(a); ((a)<(b))?i<=(b):i>=(b); ((a)<(b))?++i: --i)\n\nconst int INF = 1e9;\nusing namespace std;\n\ntypedef long double ld;\n\nld dp[1024][12];\n\nint main() {\n\n \tios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.precision(10);\n cout << fixed;\n\n#ifdef LOCAL_DEFINE\n freopen(\"in\", \"rt\", stdin);\n#endif\n\n // solution Here\n\n\n int n; cin >> n;\n int primes[15] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];\n\n xrange(i, 2, 1024 - 1){\n \txrange(j, 1, 12 - 1){\n \t\tdp[1][j] = 1;\n \t\tdp[i][j] = 1e22;\n \t}\n }\n\n xrange(i, 2, 1002){\n\n \txrange(j, 0, 9){\n\n \t\txrange(k, 0, 18){\n\n \t\t\tif(i % (k+1) != 0) continue;\n\n \t\t\tdp[i][j] = min(dp[i][j], dp[i / (k+1)][j-1])\n \t\t}\n \t}\n }\n\n\n\n\n\n#ifdef LOCAL_DEFINE\n cerr << \"Time elapsed: \" << 1.0 * clock() / CLOCKS_PER_SEC << \" s.\\n\";\n#endif\n\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bff85fee83520e9174015ec2633010d1", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "\ufeff# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 4 00:25:14 2018\n\n@author: lenovo\n\"\"\"\n\n#\u7d20\u6570\u96c6\u5408\n# \u4efb\u4f55\u4e00\u4e2a\u6570\u5b57\u53ef\u4ee5\u8868\u793a\u4e3a2^(p1) * 3^(p2) * ... * k^(pn)\n# \u5176\u56e0\u5b50\u4e2a\u6570\u603b\u6570\u4e3a (p1 + 1) * (p2 + 1) * ... * (pn + 1)\nprime = [0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n\n# \u5230\u6bcf\u4e2a\u8282\u70b9\u6709\u4f20\u5230\u8be5\u8282\u70b9\u7684\u503c\u548c\u56e0\u5b50\u603b\u6570\u3001\u4ee5\u53ca\u8be5\u53d6\u7b2c\u51e0\u4e2a\u5143\u7d20\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": "20c0cd50ea9e3db0d5fa6ee0440771dc", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "\ufeff\"\"\"\nCreated on Tue Sep 4 00:25:14 2018\n\n@author: lenovo\n\"\"\"\n\n#\u7d20\u6570\u96c6\u5408\n# \u4efb\u4f55\u4e00\u4e2a\u6570\u5b57\u53ef\u4ee5\u8868\u793a\u4e3a2^(p1) * 3^(p2) * ... * k^(pn)\n# \u5176\u56e0\u5b50\u4e2a\u6570\u603b\u6570\u4e3a (p1 + 1) * (p2 + 1) * ... * (pn + 1)\nprime = [0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n\n# \u5230\u6bcf\u4e2a\u8282\u70b9\u6709\u4f20\u5230\u8be5\u8282\u70b9\u7684\u503c\u548c\u56e0\u5b50\u603b\u6570\u3001\u4ee5\u53ca\u8be5\u53d6\u7b2c\u51e0\u4e2a\u5143\u7d20\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": "06fa64667fc4df2345dca4a9fcd7893e", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import math\nimport functools\n\n\n@functools.lru_cache(maxsize=None)\ndef factorial(n):\n return math.factorial(n)\n\n\n@functools.lru_cache(maxsize=None)\ndef binomial(k, n):\n return factorial(n) // (factorial(k) * factorial(n - k))\n\n\ndef P(k, n, m):\n return k ** 2 * binomial(k, m) * binomial(n - k, n * m - m)\n\n\ndef solve(n, m):\n return sum(P(k, n, m) for k in range(1, min(n, m) + 1)) / binomial(n, m * n) / n\n\n\nif __name__ == '__main__':\n n, m = map(int, input().split())\n\n print(solve(n, m))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f8699cb3a7d9f14544c28f8c150e78c", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "# -- code beginning\nn, m = map(int, input().split())\nprint(1-(m*(n-1)**2/((m*n-1)*n)))\n# -- code ending\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38f7bb73e919769e1f9458292c094ddd", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n,m = map(float, raw_input().split())\nif n == m == 1:\n print 1\nelse:\n print 1+(n-1)*(m-1)/(n*m-1))/n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "70ea04b4ad1503075a8a71e2f5a370f6", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "m, n = map(int, input().split())\nif 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": "ca89d2d6d7b78dbb86841909c0d3bd60", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def list_fact(n):\n F=[0]*(n+1)\n F[0]=1\n for i in range(1,n+1):\n F[i]=i*F[i-1]\n return F\nS=str(input())\nl=list(map(int, S.split(' ')))\nn,m=l[0],l[1]\nF=list_fact(n*m)\nS=0\nfor k in range(1,min(n,m)+1):\n S+=k*F[m]*F[n]*F[(n-1)*m]*F[(m-1)*n]/(n*F[n*m]*F[k-1]*F[n-k]*F[m-k]*F[n*m-n-m+k])\nprint(S)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e012f41feaaf7087f6b69ce77ac240f", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.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": "c5e26e74644a11c4605e24f4eac88bc8", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "from math import sqrt\n\nclass vector:\n\tdef __init__(self, _x = 0, _y = 0):\n\t\tself.x = _x\n\t\tself.y = _y\n\tdef len(self):\n\t\treturn sqrt(self.x ** 2 + self.y ** 2)\n\tdef len_sq(self):\n\t\treturn self.x ** 2 + self.y ** 2\n\tdef __mul__(self, other):\n\t\tif (type(self) == type(other)):\n\t\t\treturn self.x * other.x + self.y * other.y\n\t\treturn vector(self.x * other, self.y * other)\n\tdef __mod__(self, other):\n\t\treturn self.x * other.y - self.y * other.x\n\tdef normed(self):\n\t\tlength = self.len()\n\t\treturn vector(self.x / length, self.y / length)\n\tdef normate(self):\n\t\tself = self.normed()\n\tdef __str__(self):\n\t\treturn \"(\" + str(self.x) + \", \" + str(self.y) + \")\"\n\tdef __add__(self, other):\n\t\treturn vector(self.x + other.x, self.y + other.y);\n\tdef __sub__(self, other):\n\t\treturn vector(self.x - other.x, self.y - other.y);\n\tdef __eq__(self, other):\n\t\treturn self.x == other.x and self.y == other.y\n\tdef rot(self):\n\t\treturn vector(self.y, -self.x)\n\nclass line:\n\tdef __init__(self, a = 0, b = 0, c = 0):\n\t\tself.a = a\n\t\tself.b = b\n\t\tself.c = c\n\tdef intersect(self, other):\n\t\td = self.a * other.b - self.b * other.a\n\t\tdx = self.c * other.b - self.b * other.c\n\t\tdy = self.a * other.c - self.c * other.a\n\t\treturn vector(dx / d, dy / d)\n\tdef fake(self, other):\n\t\td = self.a * other.b - self.b * other.a\n\t\treturn d\n\tdef __str__(self):\n\t\treturn str(self.a) + \"*x + \" + str(self.b) + \"*y = \" + str(self.c) \n\ndef line_pt(A, B):\n\t\td = (A - B).rot()\n\t\treturn line(d.x, d.y, d * A)\n\nclass circle:\n\tdef __init__(self, O = vector(0, 0), r = 0):\n\t\tself.O = O\n\t\tself.r = r\n\tdef intersect(self, other):\n\t\tO1 = self.O\n\t\tO2 = other.O\n\t\tr1 = self.r\n\t\tr2 = other.r\n\t\tif (O1 == O2):\n\t\t\treturn []\n\t\tif ((O1 - O2).len_sq() > r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn []\n\t\trad_line = line(2 * (O2.x - O1.x), 2 * (O2.y - O1.y), r1 ** 2 - O1.len_sq() - r2 ** 2 + O2.len_sq())\n\t\tcentral = line_pt(O1, O2)\n\t\tM = rad_line.intersect(central)\n\t\t# print(M)\n\t\tif ((O1 - O2).len_sq() == r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn [M]\n\t\td = (O2 - O1).normed().rot()\n\t\tif (r1 ** 2 - (O1 - M).len_sq() < 0):\n\t\t\treturn []\n\t\td = d * (sqrt(r1 ** 2 - (O1 - M).len_sq()))\n\t\treturn [M + d, M - d]\n\tdef fake(self, other):\n\t\tO1 = self.O\n\t\tO2 = other.O\n\t\tr1 = self.r\n\t\tr2 = other.r\n\t\tif (O1 == O2):\n\t\t\treturn 1\n\t\tif ((O1 - O2).len_sq() > r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn 1\n\t\trad_line = line(2 * (O2.x - O1.x), 2 * (O2.y - O1.y), r1 ** 2 - O1.len_sq() - r2 ** 2 + O2.len_sq())\n\t\tcentral = line_pt(O1, O2)\n\t\treturn rad_line.fake(central)\n\n\n# a = vector(3, 4)\n# b = vector(4, 4)\n# print(circle(vector(1, 2), 3).intersect(circle(vector(2, 1), 5)))\nn = int(input())\narr = []\nm = 1\nfor i in range(n):\n\tx, y, r = map(int, input().split())\n\tarr.append(circle(vector(x, y), r))\nfor i in range(n):\n\tfor j in range(i + 1, n):\n\t\tm *= arr[i].fake(arr[j])\nfor i in range(n):\n\tarr[i].O = arr[i].O * m\n\tarr[i].r = arr[i].r * m\n# print(m)\ns = set()\nV = 0\nfor i in range(n):\n\tfor j in range(i + 1, n):\n\t\ttmp = arr[i].intersect(arr[j])\n\t\tfor e in tmp:\n\t\t\ts.add((round(e.x, 100), round(e.y, 100)))\nV += len(s)\nE = 0\n\npar = [i for i in range(n)]\n\ndef get_par(v):\n\tif (par[v] != v):\n\t\tpar[v] = get_par(par[v])\n\treturn par[v]\ndef unite(v, u):\n\tpar[get_par(v)] = get_par(u)\nfor i in range(n):\n\ts = set()\n\tfor j in range(n):\t\n\t\ttmp = arr[i].intersect(arr[j])\n\t\tif (len(tmp)):\n\t\t\tunite(i, j)\n\t\tfor e in tmp:\n\t\t\ts.add((round(e.x, 100), round(e.y, 100)))\n\tE += len(s)\n# print(V, E)\n# print(len({get_par(i) for i in range(n)}))\nprint(E - V + 1 + len({get_par(i) for i in range(n)}))\n\t\t\tunite(i, j)\n\t\tfor e in tmp:\n\t\t\ts.add((round(e.x, 100), round(e.y, 100)))\n\tE += len(s)\n# print(V, E)\n# print(len({get_par(i) for i in range(n)}))\nprint(E - V + 1 + len({get_par(i) for i in range(n)}))from math import sqrt\n\nclass vector:\n\tdef __init__(self, _x = 0, _y = 0):\n\t\tself.x = _x\n\t\tself.y = _y\n\tdef len(self):\n\t\treturn sqrt(self.x ** 2 + self.y ** 2)\n\tdef len_sq(self):\n\t\treturn self.x ** 2 + self.y ** 2\n\tdef __mul__(self, other):\n\t\tif (type(self) == type(other)):\n\t\t\treturn self.x * other.x + self.y * other.y\n\t\treturn vector(self.x * other, self.y * other)\n\tdef __mod__(self, other):\n\t\treturn self.x * other.y - self.y * other.x\n\tdef normed(self):\n\t\tlength = self.len()\n\t\treturn vector(self.x / length, self.y / length)\n\tdef normate(self):\n\t\tself = self.normed()\n\tdef __str__(self):\n\t\treturn \"(\" + str(self.x) + \", \" + str(self.y) + \")\"\n\tdef __add__(self, other):\n\t\treturn vector(self.x + other.x, self.y + other.y);\n\tdef __sub__(self, other):\n\t\treturn vector(self.x - other.x, self.y - other.y);\n\tdef __eq__(self, other):\n\t\treturn self.x == other.x and self.y == other.y\n\tdef rot(self):\n\t\treturn vector(self.y, -self.x)\n\nclass line:\n\tdef __init__(self, a = 0, b = 0, c = 0):\n\t\tself.a = a\n\t\tself.b = b\n\t\tself.c = c\n\tdef intersect(self, other):\n\t\td = self.a * other.b - self.b * other.a\n\t\tdx = self.c * other.b - self.b * other.c\n\t\tdy = self.a * other.c - self.c * other.a\n\t\treturn vector(dx / d, dy / d)\n\tdef fake(self, other):\n\t\td = self.a * other.b - self.b * other.a\n\t\treturn d\n\tdef __str__(self):\n\t\treturn str(self.a) + \"*x + \" + str(self.b) + \"*y = \" + str(self.c) \n\ndef line_pt(A, B):\n\t\td = (A - B).rot()\n\t\treturn line(d.x, d.y, d * A)\n\nclass circle:\n\tdef __init__(self, O = vector(0, 0), r = 0):\n\t\tself.O = O\n\t\tself.r = r\n\tdef intersect(self, other):\n\t\tO1 = self.O\n\t\tO2 = other.O\n\t\tr1 = self.r\n\t\tr2 = other.r\n\t\tif (O1 == O2):\n\t\t\treturn []\n\t\tif ((O1 - O2).len_sq() > r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn []\n\t\trad_line = line(2 * (O2.x - O1.x), 2 * (O2.y - O1.y), r1 ** 2 - O1.len_sq() - r2 ** 2 + O2.len_sq())\n\t\tcentral = line_pt(O1, O2)\n\t\tM = rad_line.intersect(central)\n\t\t# print(M)\n\t\tif ((O1 - O2).len_sq() == r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn [M]\n\t\td = (O2 - O1).normed().rot()\n\t\tif (r1 ** 2 - (O1 - M).len_sq() < 0):\n\t\t\treturn []\n\t\td = d * (sqrt(r1 ** 2 - (O1 - M).len_sq()))\n\t\treturn [M + d, M - d]\n\tdef fake(self, other):\n\t\tO1 = self.O\n\t\tO2 = other.O\n\t\tr1 = self.r\n\t\tr2 = other.r\n\t\tif (O1 == O2):\n\t\t\treturn 1\n\t\tif ((O1 - O2).len_sq() > r1 ** 2 + r2 ** 2 + 2 * r1 * r2):\n\t\t\treturn 1\n\t\trad_line = line(2 * (O2.x - O1.x), 2 * (O2.y - O1.y), r1 ** 2 - O1.len_sq() - r2 ** 2 + O2.len_sq())\n\t\tcentral = line_pt(O1, O2)\n\t\treturn rad_line.fake(central)\n\n\n# a = vector(3, 4)\n# b = vector(4, 4)\n# print(circle(vector(1, 2), 3).intersect(circle(vector(2, 1), 5)))\nn = int(input())\narr = []\nm = 1\nfor i in range(n):\n\tx, y, r = map(int, input().split())\n\tarr.append(circle(vector(x, y), r))\nfor i in range(n):\n\tfor j in range(i + 1, n):\n\t\tm *= arr[i].fake(arr[j])\nfor i in range(n):\n\tarr[i].O = arr[i].O * m\n\tarr[i].r = arr[i].r * m\n# print(m)\ns = set()\nV = 0\nfor i in range(n):\n\tfor j in range(i + 1, n):\n\t\ttmp = arr[i].intersect(arr[j])\n\t\tfor e in tmp:\n\t\t\ts.add((round(e.x, 100), round(e.y, 100)))\nV += len(s)\nE = 0\n\npar = [i for i in range(n)]\n\ndef get_par(v):\n\tif (par[v] != v):\n\t\tpar[v] = get_par(par[v])\n\treturn par[v]\ndef unite(v, u):\n\tpar[get_par(v)] = get_par(u)\nfor i in range(n):\n\ts = set()\n\tfor j in range(n):\t\n\t\ttmp = arr[i].intersect(arr[j])\n\t\tif (len(tmp)):\n\t\t\tunite(i, j)\n\t\tfor e in tmp:\n\t\t\ts.add((round(e.x, 100), round(e.y, 100)))\n\tE += len(s)\n# print(V, E)\n# print(len({get_par(i) for i in range(n)}))\nprint(E - V + 1 + len({get_par(i) for i in range(n)}))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "26bbd1984044459d3598a49b06b5c156", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.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": "1b3673325980db9d7df694109a94d40c", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\n\ndef dist(a, b):\n return math.sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]))\n\ndef samep(a, b):\n EPS = 0.01\n if a - b < -EPS or a - b > EPS:\n return False\n return True\n\ndef same(a, b):\n return samep(a[0], b[0]) and samep(a[1], b[1])\n\ndef stat(a, tata):\n if tata[a] == a:\n return a\n x = stat(tata[a], tata)\n tata[a] = x\n return x\n\ndef unesc(a, b, tata):\n y = stat(b, tata)\n x = stat(a, tata)\n if x != y:\n tata[x] = y\n return\n\n#fin = open('cerc.in', 'r')\n#fout = open('cerc.out', 'w')\nfin = sys.stdin\nfout = sys.stdout\nn = int(fin.readline())\na = []\nfor i in range(0, n):\n a.append(tuple([int(number) for number in fin.readline().split()]))\n#find V\npnt = []\npntc = []\nfor i in range(0, n):\n for j in range(i + 1, n):\n if a[i][0] != a[j][0] or a[i][1] != a[j][1]:\n a0, a1, a2 = a[i]\n b0, b1, b2 = a[j]\n c0 = 2 * (b0 - a0)\n c1 = 2 * (b1 - a1)\n c2 = -a0 * a0 + -a1 * a1 + a2 * a2 + b0 * b0 + b1 * b1 - b2 * b2\n npoints = []\n if c0 == 0:\n y0 = c2 / c1\n x1 = a2 * a2 - (y0 - a1) * (y0 - a1)\n x0 = math.sqrt(x1) + a0\n npoints.append((-x0, y0), (x0, y0))\n else:\n d0 = -c1 / c0\n d1 = c2 / c0\n e0 = (d0 * d0 + 1)\n e1 = 2 * d0 * (d1 - a0) - 2 * a1\n e2 = (d1 - a0) * (d1 - a0) + a1 * a1 - a2 * a2\n dt = e1 * e1 - 4 * e2 * e0\n if dt >= 0:\n y0 = (-e1 - math.sqrt(dt)) / (2 * e0)\n y1 = (-e1 + math.sqrt(dt)) / (2 * e0)\n x0 = d0 * y0 + d1\n x1 = d0 * y1 + d1\n npoints.append((x0, y0))\n npoints.append((x1, y1))\n for np in npoints:\n g = 0\n for poz in range(0, len(pnt)):\n if same(pnt[poz], np):\n g = 1\n pntc[poz].add(i)\n pntc[poz].add(j)\n break;\n if g == 0:\n pnt.append(np)\n pntc.append(set({i, j}))\npntc = [list(x) for x in pntc]\nV = len(pnt)\n#find C\ntata = list(range(0, n))\nC = 1\nfor p in range(0, V):\n for i in range(0, len(pntc[p])):\n for j in range(i + 1, len(pntc[p])):\n unesc(pntc[p][i], pntc[p][j], tata)\nfor p in range(0, n):\n if tata[p] == p:\n C += 1\n#find E\nE = 0\nfor p in range(0, V):\n for x in pntc[p]:\n E += 1\nF = E + C - V\nfout.write(repr(F))\nif fin != sys.stdin:\n fin.close()\n fout.close()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dead6e558909bcae8bb90332d294ba90", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "PyPy 2", "source_code": "import sys\nimport math\n\ndef stoc(s):\n return tuple(map(int, s.split()))\n\ndef ncut(c0, c1):\n d2 = (c0[0]-c1[0])**2 + (c0[1]-c1[1])**2\n rsum2 = (c0[2]+c1[2])**2\n if rsum2 < d2:\n return 0\n elif rsum2 == d2:\n return 1\n else:\n #d = |r0 - r1| ?\n rdiff2 = (c0[2]-c1[2])**2\n if d2 < rdiff2:\n return 0\n elif d2 == rdiff2:\n return 1\n else: \n return 2\n\ndef testcuts(cs):\n N=10**10\n eps=1e-5\n ai = 0\n while ai < N:\n a = 2*math.pi*ai/N+.1\n x = cs[0][0] + cs[0][2]*math.cos(a)\n y = cs[0][1] + cs[0][2]*math.sin(a)\n d1 = abs(((x-cs[1][0])**2 + (y-cs[1][1])**2)**.5 - cs[1][2])\n d2 = abs(((x-cs[2][0])**2 + (y-cs[2][1])**2)**.5 - cs[2][2])\n #print x, y, d1, d2\n if abs(d1) + abs(d2) < eps:\n #print x, y, d1, d2\n return True\n if d1 > (cs[0][2]*1e6/N):\n ai += 1e5\n if d2 > (cs[0][2]*1e6/N):\n ai += 1e5\n ai += 1\n return False\n \nxx = sys.stdin.readlines()\nn = int(xx[0])\ncs = map(stoc, xx[1:])\n#print cs\n\nncuts = ncut(cs[0],cs[1]) + ncut(cs[1],cs[2]) + ncut(cs[2], cs[0])\n\n#Do all three intersect at the same point?\nif ncuts >=3 and testcuts(cs):\n ncuts -= 1\n\nprint 2 + ncuts \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "92435893c5e16000c4233a0c8c4cf872", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import itertools\n \n \nn,l,r,x = map(int,raw_input().split())\na = map(int,raw_input().split())\na.sort()\nans = []\ncombos = []\nfor i in xrange(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": "a51b30e7191d57c7cd77b5585750b69f", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include \n#define endl \"\\n\"\n#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\nusing ll = long long;\nusing namespace std;\nconst int INF = 0x3f3f3f3f;\n\nint n, l, r, x, arr[16], cnt;\n\nvoid go(int i = 0, int sm = 0, int mx = 0, int mn = 1e9+5) {\n\tif (i == n) {\n\t\tif (sm >= l and sm <= r and mx-mn >= x) {\n\t\t\tcnt++;\n\t\t}\n\t\treturn;\n\t}\n\tgo(i+1, sm+arr[i], max(mx, arr[i]), min(mn, arr[i]));\n\tgo(i+1, sm, mx, mn);\n}\n\nint main() {\n\tIOS\n\tcin >> n >> l >> r >> x;\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> arr[i];\n\t}\n\tgo();\n\tcout << cnt << endl;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "df7a8f8f79d849ce5aedd81c3082eac3", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.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 count", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8aadd9d855ec29fce1b8e989211573b3", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import itertools\n \n \nn,l,r,x = map(int,raw_input().split())\na = map(int,raw_input().split())\na.sort()\nans = []\ncombos = []\nfor i in xrange(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 count", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c0a68a81ba7151579d8429f4885683be", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "N, L, R, X = map(int, raw_input().split())\nC = map(int, raw_input().split())\nAns = 0\n\nfor Cf in range(1, 1 << N):\n\tV = [C[i] for i in range(N) if Cf & (1 << i) > 0]\n\tif max(V) - min(V) >= X and L <= sum(V) and sum(V) <= R:\n\t\tAns += 1\n\nprint Ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0e80b49fc7a097b399283e75a087b7b", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H']\nx, y, z = sorted(map(lambda x:n.index(x), input()))\nl = [x, y, z]\nfor i in range(3):\n if (l[(i + 2) % 3] - l[(i + 1) % 3]) % 12 == 3 and (l[(i + 1) % 3] - l[(i) % 3]) % 12 == 4:\n print('major')\n exit(0)\n elif (l[(i + 2) % 3] - l[(i + 1) % 3]) % 12 == 4 and (l[(i + 1) % 3] - l[(i) % 3]) % 12 == 3:\n print('minor')\n exit(0)\nprint('strange')\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e038e5a6250ce3263e80a4c075c010b9", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "(r, g, b) = [int(x) for x in raw_input().split()]\n\nr = (r + 1) / 2 * 3 - 3\ng = (g + 1) / 2 * 3 - 2\nb = (b + 1) / 2 * 3 - 1\n\nprint 30 + max(0, r, g, b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0152719cb005dda439103daac62e5f1e", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "a, b, c = raw_input().split(' ')\n\nnote = ['C','C#','D','D#','E','F','F#','G','G#','A','B','H']\n\ndef diff(str1, str2):\n for i in range[note]:\n if (note[i] == str1):\n x = i\n if (note[i] == str2):\n y = i\n if (x < y):\n return y - x\n else:\n if (y < x):\n return 12 - y + x\n return 0\n\none = diff(a, b)\ntwo = diff(b, c)\nif ((one == 3) | (two == 4)):\n print \"minor\"\nelse:\n if ((one == 4) | (two == 3)):\n print \"major\"\n else:\n print \"strange\" \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c728369ae3651703298d3dcc7bf9c66", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\nimport itertools as it\ninput = sys.stdin\noutput = sys.stdout\n\nNotes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H']\n\nSTRANGE = 0\nMAJOR = 1\nMINOR = 2\nTYPES = ['strange','major','minor']\n\ndef distance(n1,n2):\n d = n2 - n1\n if n1= 2:\n if m10 >= 2:\n m100 -= 2\n m10 -= 2\n else:\n break\n elif m100 == 1:\n if m10 >= 12:\n m100 -= 1\n m10 -= 12\n else:\n break\n else:\n if m10 >= 22:\n m10 -= 22\n else:\n break\n else: # Hanako\n if m10 >= 22:\n m10 -= 22\n elif m10 >= 12:\n if m100 >= 1:\n m100 -= 1\n m10 -= 12\n else:\n break\n elif m10 >= 2:\n if m100 >= 2:\n m100 -= 2\n m10 -= 2\n else:\n break\n else:\n break\n\n turn_no += 1\n\nif turn_no % 2:\n print 'Hanako'\nelse:\n print 'Ciel'\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b049a0ae821b8b68ce22cc5cabce8234", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "numOfCities, pos = [int(x) for x in input().split()]\ncriminals = [int(x) for x in input().split()]\nCriminalsCought = 0\nmax_dist = pos-1 if pos > numOfCities//2 else numOfCities-pos\nif criminals[pos-1]: CriminalsCought+=1\nfor i in range(1,max_dist+1):\n if pos-1-i < 0 or pos-1+i > numOfCities-1:\n if pos > numOfCities//2: CriminalsCought+= criminals[pos-1-i]\n else: CriminalsCought+= criminals[pos-1+i]\n else:\n if criminals[pos-1+i] and criminals[pos-1-i]: CriminalsCought +=2\nprint(CriminalsCought)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a510252c2d4e52c28966bdb097ecac4", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "import sys\n\nf = open('test.in','r')\n#f=sys.stdin\nx,y = map(int, f.readline().strip().split())\n\nif x>=2 and y>=24:\n x = x-y/12\n y %= 24\n\nwhile True:\n if 100*x+10*y>=220 and y>=2:\n #ceil\n if x>=2: x,y=x-2,y-2\n elif x==1: 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:\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": "86df9581facf2e298dd55014e158dc8b", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "\n\nplayer_one = 'Ciel'\nplayer_two = 'Hanako'\n\n\nc100, c10 = map(int, input().split())\n\nfull_moves = min([c100 // 2, c10 // 24])\n\nc100 -= full_moves * 2\nc10 -= full_moves * 24\n\nif c100 < 2:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n c10 -= (220 - 100 * c100) // 10\n c100 = 0\n else:\n print(player_two)\n solved = True\n\n if not solved:\n if (c10 // 22) % 2 == 1:\n print(player_two)\n else:\n print(player_one)\n\nelse:\n while True:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = min([2, c100])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n else:\n print(player_two)\n break\n\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c10 -= 12\n c100 -= 1\n else:\n c10 -= 2\n c100 -= 2\n else:\n print(player_one)\n break\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "412fe16e24fc991961f4c2e23f6ca2d8", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "x,y = map(int, raw_input().split())\nr = [(2,2),(1,12),(0,22)]\nwhile True:\n for a in r:\n if x >= a[0] and y >= a[1]:\n x -= a[0]\n y -= a[1]\n break;\n else:\n print \"Hanako\"\n break\n for a in reversed(r):\n if x >= a[0] and y >= a[1]:\n x -= a[0]\n y -= a[1]\n break\n else:\n print \"Ciel\"\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1849ec210a2577fd3e0f7ea14b11c911", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\nn= float (input(\"N: \"))\nm= float (input(\"M: \"))\nk= float (input(\"K: \"))\nr=1.0\nd=1\ns=\" \"\nif (k%2==0):\n s=\"R\"\n r = math.ceil((k/2)/m)\n if((k/2)%m==0):\n d=m\n else :\n d=(k/2)%m\nelse:\n s=\"L\"\n r = math.ceil(((k+1)/2)/m)\n if(((k+1)/2)%m==0):\n d=m\n else :\n d=((k+1)/2)%m\n\nprint (str(r)+\" \"+str(int(d))+\" \"+s\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "edb1648a06a256930eb358e7c81d1df7", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\nn= float (input(\"N: \"))\nm= float (input(\"M: \"))\nk= float (input(\"K: \"))\nr=1.0\nd=1\ns=\" \"\nif (k%2==0):\n s=\"R\"\n r = math.ceil((k/2)/m)\n if((k/2)%m==0):\n d=m\n else :\n d=(k/2)%m\nelse:\n s=\"L\"\n r = math.ceil(((k+1)/2)/m)\n if(((k+1)/2)%m==0):\n d=m\n else :\n d=((k+1)/2)%m\n\nprint (str(r)+\" \"+str(int(d))+\" \"+s", "lang_cluster": "Python", "compilation_error": true, "code_uid": "daf2e5146a8ce0eb43134caad327810f", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m,k = map(int,input().split())\no=k\nprint((k-1)//(2*m)+1, end = '')\nk = (k-1)%(2*m)+1\nprint((k//2)+(k%2),end='')\nif(o%2)==0):\n print('R')\nelse:\n print('L')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c6596692fec2bf508cf2abe72f0cf99", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\nimport math\n\n#tcs = int(input())\n#for tc in range(tcs):\n n,m,k = [int(i) for i in input().split(' ')]\n\n row = math.ceil(k/(m*2))\n if k%(m*2) is not 0:\n col = math.ceil((k%(m*2))/2)\n else:\n col = m\n lr = 'L' if ((k%(m*2))%2==1) else 'R'\n\n print(row,col,lr)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3340f263dafaa1f8816d7922807cd69e", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ufeff\n\n \n Debug\n 2.0\n 73a8b3bc-dbda-4cae-af7b-e5012366e265\n .\n santa.py\n \n \n .\n .\n santa\n santa\n \n \n true\n false\n \n \n true\n false\n \n \n \n \n \n 10.0\n $(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\Python Tools\\Microsoft.PythonTools.targets\n \n \n \n \n \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22a12c14d9ae2736eb916d0151df06f6", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.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 print (max( outn, outm))\nprint -1", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aac9ea570af50b9277b493bac275411b", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def main():\n n, m, k = map(int, raw_input().split())\n if n + m < k + 2:\n print -1\n return\n if n < m:\n n, m = m , n\n result = max((m / 1) * (n / (k + 1)), (n / 1) * (m / (k + 1))\n\n for x in range(2, min(k + 2, m + 1)):\n a = (n / x)\n b = (m / k - x) \n if a * b > result:\n result = a * b\n elif (n * m) / (x * (k + 2 - x)) < result:\n break\n print result\nmain()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "90029b1c2d7917f0ffce585bb031c56a", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "l = input().split()\nn = int(l[0])\nm = int(l[1])\nk = int(l[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 print ( outn)\nelse:\n print ( \"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e9bcc8d3ca35eda7adc5a3651237a17f", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\n\nif k <= n + m - 2:\n x = min(k + 1, n)\n y = k + 2 - x\n a = (n // x) * (m // y)\n y = min(k + 1, m)\n x = k + 2 - y\n b = (n // x) * (m / / y)\n print(max(a, b))\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "590cc5395dac0032b5992e90c7abb73f", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "l = input().split()\nn = int(l[0])\nm = int(l[1])\nk = int(l[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 print ( \"\", max(outn, outm), sep = '')\nelse:\n print ( \"-1\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fd41131d7acd981b9d2cb8dfef70fa3f", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n,k = map(int,input().split())\nif(k==1):\n print(\"Yes\")\nelif(k>100 || 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": "3273759df4d2be8c0f6af7054c4425ae", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "#!/bin/python3\ndef func(n,k):\n\tlst = []\n\tfor i in range(1,k+1):\n\t\ta = n%i\n\t\tif not in lst:\n\t\t\tlst.append(a)\n\t\telse:\n\t\t\treturn \"No\"\n\treturn \"Yes\"\n\nn,k = map(int,input().split())\nprint(func(n,k))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ff982f2e470ec730e0953263cb0953e", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\n n,k=map(int,input().split())\nprint(['Yes','No'][any((n+1)%i for i in range(2,k+1))])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "991e7740bb629b32e53f655687c855ee", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Python 3", "source_code": " k = map(int, input().split())\n\nprint(['Yes', 'No'][any((n + 1) % d\n for d in range(2, k + 1))])\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8903c8d5cc8d3dce9170fc65c2c5ab3f", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\n\nlista = [0]*100000\n\nflag = True\nif k > 1000000: k = 100000\nfor i in range(1, k+1):\n lista[n%i] += 1\n if lista[n%i] > 1: \n print \"No\"\n flag = False\n break\n\nif flag: print \"Yes\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e3181934c554a94bebbafaf934bfd21a", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "def count(l,r):\n\tdiff=r-l+1\n\tans=[diff/3,diff/3,diff/3]\n\tif diff%3==0:\n\t\treturn ans\n\tif diff%3==1:\n\t\tans[l%3]+=1\n\t\treturn ans\n\telse:\n\t\tans[l%3]+=1\n\t\tans[((l%3)+1)%3]+=1\n\t\treturn ans\n\n\nmod=1000000007\nn,l,r=map(int,raw_input().split())\n# n,l,r=1,1,1\nx,y,z=count(l,r)\nif n==1:\n\treturn x\nans0=[1 for i in range(n+1)]\nans1=[1 for i in range(n+1)]\nans2=[1 for i in range(n+1)]\n\nans0[0]=1\nans0[1]=x\nans0[2]=(x*x)+(2*y*z)\n\nans1[0]=1\nans1[1]=y\nans1[2]=(z*z)+(2*x*y)\n\nans2[0]=1\nans2[1]=z\nans2[2]=(y*y)+(2*x*z)\n\n\n\nfor i in range(3,n+1):\n\tans0[i]=((x*ans0[i-1])%mod+(y*ans2[i-1])%mod+(z*ans1[i-1])%mod)%mod\n\tans1[i]=((x*ans1[i-1])%mod+(y*ans0[i-1])%mod+(z*ans2[i-1])%mod)%mod\n\tans2[i]=((x*ans2[i-1])%mod+(y*ans1[i-1])%mod+(z*ans0[i-1])%mod)%mod\nprint ans0[-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0f9b394f24a512c2b1c1bedff9abaf89", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "#include \n\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\n\nll dp[200005][3];\n\nll cntMod(ll l, ll r, ll m) {\n ll lb, ub;\n if (l % 3 == m) {\n lb = l;\n } else {\n if (m > l % 3) {\n lb = l + (m - l % 3);\n } else {\n lb = l + (m + 3 - l % 3);\n }\n }\n if (r % 3 == m) {\n ub = r;\n } else {\n if (m < r % 3) {\n ub = r - (r % 3 - m);\n } else {\n ub = r - (r % 3 - m + 3);\n }\n }\n if (lb > ub) {\n return 0;\n } else {\n return (ub - lb) / 3 + 1;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n int n;\n ll mod0, mod1, mod2, l, r, lb, ub;\n cin >> n >> l >> r;\n mod0 = cntMod(l, r, 0);\n mod1 = cntMod(l, r, 1);\n mod2 = cntMod(l, r, 2);\n for (int i = 0; i <= n; i++) {\n for (int j = 0; j + )\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f85d8e3360e12cbd3ec5bc8a00514529", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "MOD = 10**9 + 7\nn,l,r = map(int,input().split())\ndp = [[0,0,0]for i in range(n+1)]\n\n# l <= x <= r \u3092\u6e80\u305f\u3059\uff58\u306e\u4e2d\u3067\u3001mod 0,1,2\u3000\u3068\u306a\u308b\u6570\u5b57\u306e\u500b\u6570\u3092\u305d\u308c\u305e\u308ca,b,c\u3068\u3059\u308b\na = r//3 - (l - 1)//3\nb = (r+1)//3 - (l - 1 + 1)//3\nc = (r+2)//3 - (l - 1 + 2)//3\n#example\n#l = 2 , r = 10\n#a = 10//3 - 1//3 = 3 - 0 = 3 (3,6,9)\n#b = 11//3 - 2//3 = 3 - 0 = 3 (4,7,10)\n#c = 12//3 - 3//3 = 4 - 1 = 3 (2,5,8)\n\ndp[1][0] = a\ndp[1][1] = b\ndp[1][2] = c\nfor i in range(1,n):\n dp[i+1][0] = dp[i][0]*a%MOD + dp[i][1]*c%MOD + dp[i][2]*b%MOD\n dp[i+1][1] = dp[i][0]*b%MOD + dp[i][1]*a%MOD + dp[i][2]*c%MOD\n dp[i+1][2] = dp[i][0]*c%MOD + dp[i][1]*b%MOD + dp[i][2]*a%MOD\n\nprint(dp[n][0]%MOD)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "733a3b8075ce19d7c972b2ccd979c260", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nlong mod = 10e9 + 7;\n\nint main(int argc, char *argv[]) {\n int n = 0, l =0, r=0;\n cin >> n;\n cin >> l;\n cin >> r;\n\n vector r0(n, 0);\n vector r1(n, 0);\n vector r2(n, 0);\n for(int i = l; i <= r; ++i) {\n if (i % 3 == 0) {\n ++(r0[0]);\n }\n if (i % 3 == 1) {\n ++(r1[0]);\n }\n if (i % 3 == 2) {\n ++(r2[0]);\n }\n }\n for(int i = 1; i< n; ++i) {\n r0[i] = (r0[i-1] * r0[0] + r1[i-1] * r2[0] + r2[i-1] * r1[0]) % mod;\n r1[i] = (r1[i-1] * r0[0] + r0[i-1] * r1[0] + r2[i-1] * r2[0]) % mod;\n r2[i] = (r2[i-1] * r0[0] + r1[i-1] * r1[0] + r0[i-1] * r2[0]) % mod;\n }\n cout << r0[n-1];\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3a2e57ed2a013618526294a09acdc527", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import math\n\n\nif __name__ == '__main__':\n n, l, r = list(map(int, input().split()))\n mod_counts = [\n math.floor(r/3) - math.ceil(l/3) + 1, math.floor((r-1)/3) - math.ceil((l-1)/3) + 1,\n math.floor((r+1)/3) - math.ceil((l+1)/3) + 1]\n dp = [[None] * 3 for _ in range(n)]\n dp[0] = mod_counts\n for i in range(1, n):\n dp[i][0] = (dp[i-1][0] * mod_counts[0]) + (dp[i-1][1] * mod_counts[2]) + (dp[i-1][2] * mod_counts[1])\n dp[i][1] = (dp[i-1][0] * mod_counts[1]) + (dp[i-1][1] * mod_counts[0]) + (dp[i-1][2] * mod_counts[2])\n dp[i][2] = (dp[i-1][0] * mod_counts[2]) + (dp[i-1][1] * mod_counts[1]) + (dp[i-1][2] * mod_counts[0])\n res = dp[-1][0]\n print(res % (10 ** 9 + 7))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aff34a645543aa2ff87c632d353064ea", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "line = raw_input()\nprevious = ''\nres = 0\nconsecutive = 0\nfor c in line:\n if consecutive == 5:\n consecutive = 0\n res = res + 1\n if c == previous:\n consecutive = consecutive + 1\n else:\n if consecutive != 0:\n res = res + 1\n consecutive = 1\n prev = c\nif consecutive != 0:\n res = res + 1\nprint res", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff9af8709cfb1b71dfc673ddcb1278d5", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Python 2", "source_code": "import fileinput\nimport sys\n\ndef helper(trips, currentCombo, prevChar, string):\n if (len(string) == 0):\n sys.stdout.write(\"%d\" % trips)\n return\n \n c = string[0];\n if prevChar != ' ': #if this is not the first character in the str\n if (c == prevChar): #same char as prev\n currentCombo += 1\n if ((currentCombo % 5) == 1):\n trips += 1\n else: #different char from prev\n currentCombo = 1\n trips +=1\n\n else: #if this is the first character in the str\n trips = 1\n currentCombo = 1\n\n return helper(trips, currentCombo, c, string[1:])\n \n\nfor line in fileinput.input():\n inputString = line; #get input\n output = helper(0, 0, ' ', inputString)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a66bb120d29563ce77f3bd9309b25c53", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Python 3", "source_code": "s = input()\n\ncur = s[0]\ncnt = 1\nans = 0\n\nfor i in range(1, len(s):\n x = s[i]\n if(cur != x):\n ans = ans + 1\n cnt = 1\n cur = x\n else:\n if(cnt < 5):\n cnt = cnt + 1\n else:\n ans = ans + 1\n cnt = 1\n cur = x\n \nprint (ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fdab6a60aa1f7fb211bf9c33711c9ec8", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.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": "ca166804e054cf98434463b996c5c634", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\ns = raw_input()\ns = list(s)\ni = 0\nj = 0\ntotal = 0\nwhile i < len(s):\n\tj = i+1\n\tcount = 1\n\twhile j < len(s):\n\t\tif s[j] == s[i]:\n\t\t\tcount += 1\n\t\telse:\n\t\t\tbreak\n\tif count < 5:\n\t\ttotal += 1\n\telse:\n\t\ttotal += count/5\n\t\t\n\ti = j\n\t\nprint total\n\t\n\t\n\t\n\t\t\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "731409b890c8e4ec5568e2291b8ff02f", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "Python 2", "source_code": "def gcd(a, b):\n if b = 0\n return a \n else\n return gcd(b, a % b)\n \nn,m,z = map(int ,raw_input().split())\ng = gcd(n,m)\nl = (n * m) / g\nprint z / l", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5460daad36b343c5b65e37b33f8110cb", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n,m,z=map(int,input().split())\nk=0\nfor i in range(n,z+1,n):\n\tif i%m=0:\n\t\tk+=1\nprint(k)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8107fa4faa1d191497774b4c75aa273c", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\nn,m,z = map(int,input().split())\nif m == 0:\n print(0)\nelif (n==m):\n print(z//n)\nelse:\n print(z//(gcd(n,m))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5c648b652877d8cac283e2de8a21482b", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Python 2", "source_code": "mport sys\n\ndef lcm(x, y):\n if x > y:\n z = x\n else:\n z = y\n\n while(True):\n if((z % x == 0) and (z % y == 0)):\n lcm = z\n break\n z += 1\n\n return lcm\n\nfor line in sys.stdin:\n n = int(line.split(\" \")[0])\n m = int(line.split(\" \")[1])\n z = int(line.split(\" \")[2])\n \nprint int(z/lcm(n,m))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "76c2004efe31873022e4a2882fc86f4c", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "\nx = [int(i) for i in input().split()]\n\ndef gcd(a,b):\n\tr = 0\n while b > 0:\n r = a%b\n a = b\n b = r\n return a\n \ndef lcm(a, b):\n return a * b / gcd(a, b)\n\n\nt=x[2]//lcm(x[0],x[1])\nprint(t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5dddf52dae0088b2936643677e5354b7", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a = input()\r\n\r\nif len(a) == 4:\r\n print(\"none\")\r\n\r\nx = \"vampire\"\r\nxi = [ord(i) - ord('a') for i in x]\r\nprint(f\"xi = {xi}\")\r\n\r\nout = list(a)\r\nfor i in range(len(out)):\r\n out[i] = (ord(out[i]) - ord('a') + xi[i])%26\r\n \r\nprint(\"\".join([chr(ord('a')+ y) for y in out]))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5cf4466b1d517b99d34ee2ba9a7ee8c2", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "Python 3", "source_code": "myDict = {\n \"3\" : \"the\",\n \"5\" : \"buffy\",\n \"6\" : \"slayer\",\n \"7\" : \"vampire\",\n}\ns = input(\"\").strip()\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": "0f2eb901ed1be4fa8b3b6371083749de", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "PyPy 3-64", "source_code": "input()\r\nprint(\"none\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "600455d04e56dc607f5ca7220c72692d", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "PyPy 3-64", "source_code": "def enc(a, b):\r\n return ''.join(chr((ord(x) - ord('a') + ord(y) - ord('a')) % 26 + ord('a')) for x, y in zip(a, b))\r\n\r\ns = input()\r\nif len(s) == 7:\r\n print(enc(s, 'vampire'))\r\nelif len(s) == 6:\r\n print('none')\r\nelif len(s) == 5:\r\n print(enc(s, 'demon'))\r\nelif len(s) == 4:\r\n print('none')\r\nelif len(s) == 3:\r\n print(enc(s, 'one'))\r\nelse:\r\n assert False\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d2aee4d20e1180ac4ac9a9e6d197087", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "Python 3", "source_code": "s = input().strip()\r\nwords = [\"\",\"\",\"\",\"the\",\"\",\"buffy\",\"slayer\",\"vampire\"]\r\nif len(s)==4:\r\n print(\"none\")\r\nelse:\r\n target = words[len(s)]\r\n ans = \"\"\r\n for i in range(len(s)):\r\n a = ord(s[i])-ord('a')\r\n b = ord(target[i])-ord('a')\r\n ans += chr((a+b)%26 + ord('a'))\r\n print(ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6d5907b79e84cb19cffc87716a3a4a71", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "Python 3", "source_code": "from itertools import permutations \nnums = list(map(int, input().split()))\no = input().split()\nprint(min(eval\"min(((a{0}b){1}c){2}d, (a{0}b){2}(c{1}d))\".format(*o) for a, b, c, d in permutations(nums)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "509d7aaa59103052466bb3d9f826230f", "src_uid": "7a66fae63d9b27e444d84447012e484c", "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": "fb022c5e43bad25beaa09529055e4115", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f(q, t):\n a, b, c = sorted(q)\n if t == '**': return a * b * c\n if t == '++': return a + b + c\n if t == '*+': return a * b + c\n if t == '+*': return a * (b + c)\n\np = sorted(list(map(int, input().split())))\nt = input()[:: 2]\nx, t = t[0], t[1: ]\nif x == '*':\n s = p[0] * p[1] * p[2] * p[3]\n for i in range(3):\n for j in range(i + 1, 4):\n q = p[:]\n q[i] *= q[j]\n q.pop(j)\n s = min(f(q, t), s)\n print(s)\nelse: print(f([p[0], p[1], p[2] + p[3]]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b85efc6b471f5e890bd0cbbdad48f1e0", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import itertools\nans=10000000000000\nn=map(int, raw_input().split())\nx=map(str, raw_input().split())\nnl=list(itertools.permutations(n))\nxl=list(itertools.permutations(x))\nnl=set(nl); nl=list(nl)\nxl=set(xl); xl=list(xl)\n\nfor i in range(len(nl)):\n for j in range(len(xl)):\n e='(('+nl[i][0]+xl[j][0]+nl[i][1]+')'+xl[j][1]+nl[i][2]+')'+xl[j][2]+nl[i][3]\n f='('+nl[i][0]+xl[j][0]+nl[i][1]+')'+xl[j][1]+'('+nl[i][2]+xl[j][2]+nl[i][3]+')'\n ans=min(ans,eval(e),eval(f))\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf68cbffd0d2a08c0d5413bc5be6046d", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\na = map(int, sys.stdin.readline().split(' '))\no = sys.stdin.readline().strip().split(' ')\nad = [False]*4\nod = [False]*3\nB = []\nOP = []\n\ndef calc2(a,b,o):\n if o=='+':\n return a+b\n else:\n return a*b\n\ndef calc1():\n r1 = calc2(B[0],calc2(B[1],calc2(B[2],B[3],OP[2]),OP[1]),OP[0])\n r2 = calc2(calc2(B[0],calc2(B[1],B[2],OP[1]),OP[0]),B[3],OP[2])\n r3 = calc2(calc2(calc2(B[0],B[1],OP[0]),B[2],OP[1]),B[3],OP[2])\n r4 = calc2(B[0],calc2(calc2(B[1],B[2],OP[1]),B[3],OP[2]),OP[0])\n r5 = calc2(calc2(B[0],B[1],OP[0]),calc2(B[2],B[3],OP[2]),OP[1])\n #print B\n #print OP\n #print r1,r2,r3,r4,r5\n r = [r1,r2,r3,r4,r5]\n res = 10**13\n for c in r:\n res = min(res,c)\n return res\n\ndef solve(i1, i2):\n global B, OP\n res = 10**13\n if i1==4 and i2==3:\n return calc1()\n for i in range(4):\n if not ad[i]:\n ad[i] = True\n B.append(a[i])\n if i2==3:\n res = min(res, solve(i1+1,i2))\n else:\n for j in range(3):\n if not od[j]:\n od[j] = True\n OP.append(o[j])\n res = min(res, solve(i1+1,i2+1))\n OP.pop()\n od[j] = False\n ad[i] = False\n B.pop()\n return res\n\nprint solve(0,0)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf2a31bb1d8bf5283e32efdfe179c540", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def check(a, b, c, d):\n if a > d and b > c:\n return 1\n return 0\na = [0 for i in range(4)]\nb = [0 for i in range(4)]\nfor i in range(4):\n a[i], b[i] = map(int, input().split())\nif check(a[0], b[1], a[2], b[3]) and check(a[0], b[1], a[3], b[2]):\n print('Team 1')\nelif check(a[1], b[0], a[2], b[3]) and check(a[1], b[0], a[3], b[2]):\n print('Team 1')\nelif (check(a[2], b[3], a[0], b[1]) or check(a[3], b[2], a[0], b[1])) and (check(a[3], b[2], a[1], b[0]) or check(a[2], b[3], a[1], b[0])):\n print('Team 2')\nelse:\n print('Draw')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "264989489cf5891d263ea55053454c4a", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\nimport math\nfrom collections import defaultdict\n\ndef main():\n p1 = sys.stdin.readline().split()\n p1d = int(p1[0])\n p1a = int(p1[1])\n p2 = sys.stdin.readline().split()\n p2d = int(p2[0])\n p2a = int(p2[1])\n p3 = sys.stdin.readline().split()\n p3d = int(p3[0])\n p3a = int(p3[1])\n p4 = sys.stdin.readline().split()\n p4d = int(p4[0])\n p4a = int(p4[1])\n\n choices = [0]*4\n\n if p1d > p4a and p2a > p3d:\n choices[0] = 1\n elif p1d < p4a and p2a < p3d:\n choices[0] = 2\n if p1d > p3a and p2a > p4d:\n choices[1] = 1\n elif p1d < p3a and p2a < p4d:\n choices[1] = 2\n if p1a > p3d and p2d > p4a:\n choices[2] = 1\n elif p1a < p3d and p2d < p4a:\n choices[2] = 2\n if p1a > p4d and p2d > p3a:\n choices[3] = 1\n elif p1a < p4d and p2d < p3a:\n choices[3] = 2\n\n if (choices[0] == 1 and choices[1] == 1) or (choices[2] == 1 and choices[3] == 1):\n print 'Team 1'\n elif (choices[0] == 2 or choices[1] == 2) and (choices[2] == 2 or choices[3] == 2):\n print 'Team 2'\n else:\n print 'Draw'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7fc918fa64382c0ed8f5a3abdf68bcd", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "a = tuple(map(int, input().split()))\nb = tuple(map(int, input().split()))\nc = tuple(map(int, input().split()))\nd = tuple(map(int, input().split()))\n\n\ndef check(el1, el2):\n if el1[0][0] > el2[1][1] and el1[1][1] > el2[0][0]:\n return 1\n if el2[0][0] > el1[1][1] and el2[1][1] > el1[0][0]:\n return 2\n return 0\n\n\ndef check2(el):\n ans = 5\n cd = [(c, d), (d, c)]\n for el2 in cd:\n if check(el, el2) == 2:\n return 2\n ans = min(ans, check(el, el2))\n return ans\n\n\ndef main():\n ans = 5\n aw = [(a, b), (b, a)]\n for el in aw:\n if check2(el) == 1:\n return print('Team 1')\n ans = min(ans, check2(el))\n if ans == 0:\n print(\"Draw\")\n else:\n print(\"Team 2\")\n\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3272977d766d7ce5c50e32e94ab499ec", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "#include\n#include\nusing namespace std;\nint a[5], b[5];\nint t1, t2;\nint f(int t, int d)\n{\n\tif(a[3] > d && b[4] > t)\n\t\treturn 1;\n\tif(a[4] > d && b[3] > t)\n\t\treturn 1;\n\tif(a[3] < d && b[4] < t && b[3] < t && a[4] < d)\n\t\treturn -1;\n\treturn 0;\n}\nint main()\n{\n\tfor(int i = 1; i <= 4; i++)\n\t\tscanf(\"%d%d\", &a[i], &b[i]);\n\tt1 = f(a[1], b[2]);\n\tt2 = f(a[2], b[1]);\n\tif(t1 == 1 && t2 == 1)\n\t\tprintf(\"Team 2\\n\");\n\telse if(t1 == -1 || t2 == -1)\n\t\tprintf(\"Team 1\\n\");\n\telse\n\t\tprintf(\"Draw\\n\");\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b9aa59b7810f661130ccc92c6dfbfee1", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "inp=raw_input().split()\nfor i in range(len(inp)):\n inp[i]=int(inp[i])\np1=[inp[0],inp[1]]\np2=[inp[2],inp[3]]\np3=[inp[4],inp[5]]\np4=[inp[6],inp[7]]\nif p1[0]>p2[0]:\n atk1=p1[0]\n defe1=p2[1]\nelif p1[0]max(p3[0],p4[0]) and defe1>max(p3[1],p4[1]):\n print 'Team 1'\nelif (p3[0]>atk1 and p4[1]>defe1) or (p4[0]>atk1 and p3[1]>defe1):\n print 'Team 2'\nelse:\n print 'Draw'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "601f6437f73a24579fe9c3e6a488997f", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "def gcd(a,b):\n # a\u4f5c\u4e3a\u9664\u6570 \u5fc5\u987b\u5927\u4e8eb\n a, b = (a, b) if a >=b else (b, a)\n while b:\n a,b = b,a%b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nimport math\na, b = [int(i) for i in input().split(' ')]\nif a % b == 0 or b % a == 0:\n print(0)\nelse:\n n = abs(a-b)\n ks = []\n for i in range(1, min(n, int(math.sqrt(10**9+1)))):\n if n % i == 0:\n if a % i == 0:\n ks.append(0)\n else:\n ks.append(i - a%i) \n ks.append(n//i - a%(n//i))\n ks = sorted(set(ks))\n k = ks[0]\n # print(ks)\n minn = lcm(a+k, b+k)\n\n for i in ks[1:]:\n if lcm(a+i, b+i) < minn:\n k = i\n minn = lcm(a+i, b+i)\n print(k)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6122d0683a60d9e62e7be5c5c8d709ea", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from fractions import gcd\nimport math\n\nlcm = lambda a, b: a//gcd(a,b)*b\na, b = (map(int, input().split()))\n\nd = abs(b-a)\ndivs = {d}\nfor i in range(2, int(math.sqrt(d))):\n if not d%i: divs |= {i, d//i}\n\nsol = [(lcm(a, b), 0)]\nfor d in divs:\n k = d-a%d if a%d else 0\n sol.append((lcm(a+k, b+k), k))\n\nprint(min(sol)[1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8df0d11acd48c26af6f9b520be12bbd", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from math import gcd\n\ndef factors(k):\n\tfor i in range(1, int(k ** 0.5)):\n\t\tif k % i == 0:\n\t\t\tj = k // i\n\t\t\tyield i\n\t\t\tif i != j: yield j\n\nx, y = map(int, input().split())\nd = y - x\n\nml = float(\"inf\")\nmo = 0\n\nfor q in factors(d):\n\to = (q - (x % q)) % q\n\tlcm = (x + o) * (y + o) // gcd(x + o, y + o)\n\tif lcm < ml:\n\t\tml = lcm\n\t\tmo = o\n\nprint(mo)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a565058aafec108fc2019a281a32a87c", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Codeforces Round #554 (Div. 2)\n\nProblem C. Neko does Maths\n\n:author: Kitchen Tong\n:mail: kctong529@gmail.com\n\nPlease feel free to contact me if you have any question\nregarding the implementation below.\n\"\"\"\n\n__version__ = '1.0'\n__date__ = '2019-04-24'\n\nimport sys\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\ndef prime_sieve(size):\n sieve = [0, 0] + [1] * (size - 1)\n primes = []\n for i in range(2, size+1):\n if sieve[i] == 1:\n for j in range(i**2, size+1, i):\n sieve[j] = 0\n primes.append(i)\n return (sieve, primes)\n\ndef memoize(func):\n memo = {}\n\n def wrapper(*args):\n n, p, s = args\n if n not in memo:\n memo[n] = func(n, p, s)\n return memo[n]\n return wrapper\n\n@memoize\ndef rec_fact(n, primes, sieve):\n if sieve[n] == 1:\n return [n]\n if n == 1:\n return []\n for p in primes:\n if n % p == 0:\n return [p] + rec_fact(n//p, primes, sieve)\n return -1\n\ndef factorize(n, primes, sieve):\n if sieve[n] == 1:\n return [n]\n p_factors = rec_fact(n, primes, sieve)\n p_dict = dict()\n for p in p_factors:\n if p not in p_dict:\n p_dict[p] = 1\n else:\n p_dict[p] += 1\n factors = [1]\n for p, k in p_dict.items():\n for f in list(factors):\n for exp in range(1, k+1):\n factors += [f * (p ** exp)]\n return sorted(factors)\n\ndef solve(a, b):\n a, b = min(a, b), max(a, b)\n if b % a == 0:\n return 0\n diff = b - a\n sieve, primes = prime_sieve(diff)\n factors = factorize(diff, primes, sieve)\n k, lcm = 0, a * b\n for f in factors:\n step = a % f\n if step > 0:\n step = f - step\n this_lcm = (a + step) * (b + step) // gcd(a+step, b+step)\n if this_lcm < lcm:\n lcm = this_lcm\n k = step\n return k\n\ndef main(argv=None):\n a, b = map(int, input().split())\n print(solve(a, b))\n return 0\n\nif __name__ == \"__main__\":\n STATUS = main()\n sys.exit(STATUS)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3a12a1aa2295fb324230b96c6a4fb88", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import math\na,b = map(int,input().split())\ndef lcm(a,b):\n if(a>b):\n min1=a\n else:\n min1=b\n while(1):\n if(min1%a==0 and min1%b==0):\n return(min1)\n min1=min1+1\nmin1 =lcm(a,b)\nk=0\nnum = abs(a-b)\nif num >=10**4 :\n num = 10**4\n for i in range(1,num):\n min2 =lcm(a+i,b+i)\n if min2\n#include \n#include \nusing namespace std;\n\nint val(char c) {\n if (c >= '0' and c <= '9') {\n return int(c) - int('0');\n } else if (c >= 'A' and c <= 'Z') {\n return int(c) - int('A') + 10;\n }\n}\n\nint sum(const vector& x, int radix) {\n int S = 0, r = 1;\n for (int i = 0; i < x.size(); i++) {\n S += x[i] * r;\n r *= radix;\n }\n return S;\n}\n\nint main() {\n char c;\n vector a, b, *x = &a;\n int max = 0;\n while (cin >> c) {\n int v = val(c);\n if (c == ':') {\n x = &b;\n } else {\n x->push_back(v);\n if (v > max) max = v;\n }\n }\n reverse(a.begin(), a.end());\n reverse(b.begin(), b.end());\n if (a[0] >= 24) {\n cout << 0 << endl;\n } else if (a[0] == sum(a, 1) and b[0] == sum(b, 1)) {\n cout << -1 << endl;\n } else {\n int i = max + 1;\n while (sum(a, i) < 24 and sum(b, i) < 60) {\n cout << i++ << ' ';\n }\n if (i == max + 1) {\n cout << 0 << endl;\n } else {\n cout << endl;\n }\n }\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3b1fea46ac181f8f113cfe419ddbd25a", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "Python 2", "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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define LEFT(i) ((i) << 1)\n#define RIGHT(i) (((i) << 1) | 1)\n#define MID(i) ((l[i] + r[i]) >> 1)\n#define CC(i, v) memset(i, v, sizeof(i))\n#define REP(i, l, n) for(int i = l;i < int(n);++i)\n#define FOREACH(con, i) for(__typeof(con.begin()) i = con.begin();i != con.end();++i)\ntemplatebool checkmax(T &a,T b){return a < b ? a = b, 1 : 0;}\ntemplatebool checkmin(T &a,T b){return a > b ? a = b, 1 : 0;}\ntypedef long long LL;\ntypedef pair PII;\ntemplate void string_reader(string s, vector& vec){\n\tistringstream sin(s);\n\tcopy(istream_iterator(sin), istream_iterator(), back_inserter(vec));\n}\nconst int LEN = 1010;\nvoid prefix(const char *mode, int *next)\n{\n\tint m = strlen(mode), k = -1, i;\n\tnext[0] = -1;\n\tfor (i = 1; i < m; i++)\n\t{\n\t\twhile (k > -1 && mode[k + 1] != mode[i]) k = next[k];\n\t\tif (mode[k + 1] == mode[i]) k++;\n\t\tnext[i] = k;\n\t}\n}\nint prev[LEN], next[LEN];\nconst int N = 100010;\nint max_prev[N], max_next[N];\nstring str, sub;\nint main()\n{\n\tios::sync_with_stdio(false);\n\tint m, n, maxn, q, ans;\n\twhile(cin >> str)\n\t{\n\t\tcin >> m;\n\t\tn = str.size(), ans = 0;\n\t\tREP(k, 0, m)\n\t\t{\n\t\t\tcin >> sub;\n\t\t\tif(sub.size() == 1)\n\t\t\t{\n\t\t\t\tans += find(str.begin(), str.end(), sub[0]) != str.end();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprefix(sub.c_str(), prev);\n\t\t\tmaxn = q = -1;\n\t\t\tREP(i, 0, n)\n\t\t\t{\n\t\t\t\twhile(q > -1 && sub[q + 1] != str[i]) q = prev[q];\n\t\t\t\tif(str[i] == sub[q + 1]) ++q;\n\t\t\t\tmaxn = max(maxn, q);\n\t\t\t\tmax_prev[i] = maxn;\n\t\t\t}\n\t\t\treverse(sub.begin(), sub.end());\n\t\t\tmaxn = q = -1;\n\t\t\tprefix(sub.c_str(), next);\n\t\t\tfor(int i = n - 1;i >= 0;i--)\n\t\t\t{\n\t\t\t\twhile(q > -1 && sub[q + 1] != str[i]) q = next[q];\n\t\t\t\tif(str[i] == sub[q + 1]) ++q;\n\t\t\t\tmaxn = max(maxn, q);\n\t\t\t\tmax_next[i] = maxn;\n\t\t\t}\n\t\t\tREP(i, 0, n - 1)\n\t\t\t{\n\t\t\t\tif(max_prev[i] + max_next[i + 1] == sub.size() - 2)\n\t\t\t\t{\n\t\t\t\t\tans++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9425710c98097ed54708056150470ba1", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "#include \n\nusing namespace std;\nstruct s\n{\n int val,ind;\n};\ns arr[100003];\nbool cmp(s a,s b)\n return a.val 24:\n\t\tprint 0\n\telse:\n\t\tprint -1\n\nelse:\n\tans = []\n\tfor base in xrange(1,61):\n\t\t#print \"base :\", base\n\t\tinvalid = 0\n\n\t\ttemp = 1\n\t\tdec_h = 0\n\t\tfor i in reversed(h):\n\t\t\tif '0' <= i and i <= '9':\n\t\t\t\tif ord(i)-ord('0') >= base:\n\t\t\t\t\tinvalid = 1\n\t\t\t#\t\tprint \"hour_digit\", base\n\t\t\t\t\tbreak\n\t\t\t\tdec_h += temp*(ord(i) - ord('0'))\n\t\t\n\t\t\telse:\n\t\t\t\tif ord(i)-ord('A')+10 >= base:\n\t\t\t\t\tinvalid=1\n\t\t\t#\t\tprint \"hour_alpha\"\n\t\t\t\t\tbreak\n\t\t\t\tdec_h += temp*(ord(i) - ord('A') + 10)\n\t\t\n\t\t\ttemp *= base\n\t\t\n\n\t\tif dec_h > 23:\n\t\t\tinvalid = 1\n\n\t\tif invalid == 1:\t\n\t\t\tcontinue\n\n\t\ttemp = 1\n\t\tdec_m = 0\n\t\tfor i in reversed(m):\n\t\t\tif '0'<= i and i <= '9':\n\t\t\t\tif ord(i)-ord('0') >= base:\n\t\t#\t\t\tprint \"min_digit\"\n\t\t\t\t\tinvalid = 1\n\t\t\t\t\tbreak\n\t\t\t\tdec_m += temp*( ord(i) - ord('0') )\n\t\t\telse:\n\t\t\t\tif ord(i)-ord('A')+10 >= base:\n\t\t\t\t\tinvalid = 1\n\t\t#\t\t\tprint \"min_alpha\"\n\t\t\t\t\tbreak\n\t\t\t\tdec_m += temp*(ord(i) - ord('A') + 10)\n\t\t\t\n\t\t\ttemp *= base\n\t\t\n\n\t\tif dec_m > 59:\n\t\t\tinvalid = 1\n\t\t\n\t\tif invalid == 1:\t\n\t\t\tcontinue\n\n\t\tans.append(base)\n\n\tle = len(ans)\n\n\tif le == 0:\n\t\tprint le\n\telse:\t\n\t\tfor i in xrange(le-1):\n\t\t\tprint ans[i],\n\t\tprint ans[le-1]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "850557387fe5c60ff8a00e4f4cad1e67", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\n\ndef val(c):\n if c >= '0' and c <= '9':\n return ord(c) - ord('0')\n return ord(c) - ord('A') + 10\n\ndef ok(s, base, limit):\n sum = 0\n cur = 1\n t = s[::-1]\n for c in t:\n v = val(c)\n if v >= base:\n return False\n sum = sum + cur * v\n cur = cur * base\n return sum < limit\n\nt = sys.stdin.readline()\nt = t.rstrip()\nind = t.find(':')\nh = t[0:ind]\nm = t[ind+1:]\n\n#print h,m\n\nif ok(h, 100, 24) and ok(m, 100, 60):\n print -1\n exit()\n\nans = []\nbase = 2\nwhile base <= 36:\n if ok(h, base, 24) and ok(m, base, 60):\n ans.append(base)\n base = base + 1\nif len(ans) == 0:\n print 0\n exit()\nprint ans.pop(0),\nfor val in ans:\n print val,\nprint\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "af46eb8ed197959649422be7359dabed", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "Python 2", "source_code": " from itertools import *\n n, k = map(int, raw_input().split())\n a = [raw_input() for _ in range(n)]\n idx = list(permutations(range(k), k))\n res = 99999999\n for j in idx:\n b = [int(''.join(x[i] for i in j)) for x in a]\n diff = max(b) - min(b)\n if diff < res: res = diff\n print res", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3975f4cf7df8c7781d471c31189e263c", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def f(x, t):\n d = int(x) * (10 ** (len(t[0]) - 1))\n p = [(d, d)]\n for i in t:\n u, v = [y for y in i if y >= x], [y for y in i if y < x]\n d = []\n if u:\n u = min(u)\n u = [u] + sorted(list(i - {u}))\n u = int(''.join(u))\n d.extend((a, max(b, u)) for a, b in p)\n if v:\n v = max(v)\n v = [v] + sorted(list(i - {v}), reverse = True)\n v = int(''.join(v))\n d.extend((min(a, v), b) for a, b in p)\n p = d\n return min(b - a for a, b in p)\n\nn, k = map(int, input().split())\nt = [set(input()) for i in range(n)]\np = {i for i in '0123456789' if all(i in j for j in t)}\ns = [z - p for z in t]\nans = min(f(x, t) for x in '0123456789')\nfor x in p:\n y = p - {x}\n s = [z - y for z in t]\n ans = min(min(f(x, t) for x in '0123456789'), ans)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d27ae87f3f34422f9d55babb340a2baa", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "for i in range(n):\n a.append(input())\n\ns = 1000000000000\nfor i in range(fact(k)):\n b = []\n \n for j in range(n):\n x = list(permutations(a[j]))[i]\n x = ''.join(x)\n x = int(x)\n b.append(x)\n \n mx = max(b)\n mn = min(b)\n \n if mx - mn < s:\n s = mx - mn\n\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "431ec86bd9c9459168d0a066ba7e4b82", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import numpy as np\nimport itertools as it\n\nn, k = [int(i) for i in input().split()]\na = np.array([list(input()) for i in range(n)]).astype(int)\np = np.arange(k)\nb = 10 ** p[::-1]\nprint(min([np.max(np.sum(a[:, i] * b, axis=1)) - np.min(np.sum(a[:, i] * b, axis=1))\n for i in it.permutations(p)]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "498bb022d69c6f80639d08e486e1404e", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndata = sys.stdin.read().split()\ndata_ptr = 0\n\ndef data_next():\n global data_ptr, data\n data_ptr += 1\n return data[data_ptr - 1]\n\nN = int(data_next())\nK = int(data_next())\n\narr = []\nfor i in range(N):\n arr.append(list(data_next()));\n\nperm = []\nfor i in range(K):\n perm.append(str(i))\n\ndef next_perm():\n global perm, arr\n for i in reversed(range(len(perm) - 1)):\n if perm[i] < perm[i + 1]:\n break\n elif i == 0:\n return False\n for j in reversed(range(i + 1, len(perm))):\n if perm[i] < perm[j]:\n break\n perm[i], perm[j] = perm[j], perm[i]\n perm[i + 1:] = reversed(perm[i + 1:])\n for k in range(len(arr)):\n arr[k][i], arr[k][j] = arr[k][j], arr[k][i]\n arr[k][i + 1:] = reversed(arr[k][i + 1:])\n return True\n\nans = 1000000000\nwhile True:\n ans = min(ans, int(\"\".join(max(arr))) - int(\"\".join(min(arr))))\n if (not(next_perm())):\n break\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5862ee77365e36b38f80abf16022263e", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\nn = int(input())\nif n == 0:\n print(0, 0)\nelse:\n acc = 0\n i = 1\n while acc + 6*i < n:\n acc += 6*i\n i += 1\n j = 0\n while acc + i*(j+1) < n:\n j += 1\n k = n - acc - i*j - 1\n dy = [ 0, 2, 2, 0, -2, -2 ]\n dx = [ 2, 1, -1, -2, -1, 1 ]\n y = dy[(j+1)%6] + dy[j]*(i-1) + dy[(j+2)%6]*k\n x = dx[(j+1)%6] + dx[j]*(i-1) + dx[(j+2)%6]*k\n print(x, y)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "674362ef56bb5169b7b380afac13bc68", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\ndef solve(n):\n if n == 0:\n return (0, 0)\n n -= 1\n\n x = 1\n y = 2\n c = 6\n k = 1\n while n >= c:\n x += 2\n n -= c\n c += 6\n k += 1\n\n lim = [k - 1] + [k] * 5\n dx = [-1, -2, -1, 1, 2, 1]\n dy = [2, 0, -2, -2, 0, 2]\n\n i = 0\n while n > 0:\n t = min(n, lim[i])\n x += t * dx[i]\n y += t * dy[i]\n n -= t\n i += 1\n\n return (x, y)\n\nx, y = solve(int(input()))\nprint(x, y)\n# for i in range(21):\n# print(i, solve(i))\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2d36ebf02b7a13dd3e0a99c05d948f7e", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n = raw_input()\nn = int(n)\nk = 6\nloops = 0\n\nwhile n >= k:\n n -= k\n k += 6\n loops += 1\n\npos = [loops * 2, 0]\n\nif n == 0:\n print pos[0], pos[1]\nelse: \n moves = [(1, 2), (-1, 2), (-2, 0), (-1, -2), (1, -2), (2, 0), (1, 2)]\n factors = [loops + 1 for i in range(1, 8)]\n factors[0] = 1\n factors[1] -= 1\n\n j = 0\n while n > 0:\n if factors[j % 7] == 0:\n j += 1\n continue\n for k in range (factors[j % 7]):\n pos[0] += moves[j % 7][0]\n pos[1] += moves[j % 7][1]\n n -= 1\n if (n == 0):\n break\n\n j += 1\n \n print pos[0], pos[1]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b59ab8af0a6d542e203c31e0134e1027", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "st = input()\n\nl = [(-2,0),(-1,-2), (1,-2),(2,0),(1,2),(-1,2)]\na = 6\n\nn = 1 \nru = 0 \nyy = 0 \nwhile (ru <= st):\n\tru += n*a \n\tn += 1\n\tyy += 1\nru -= (n-1)*a\nyy -= 1 \n#print ru , yy \ndiff = st - ru \n\nif (st <= 6):\n\tif (st == 0):\n\t\tprint \"0 0\"\n\t\texit()\n\n\tif (st == 1):\n\t\tprint \"1 2\"\n\t\texit()\n\tif (st == 2):\n\t\tprint \"-1 2\"\n\t\texit()\n\tif (st == 3):\n\t\tprint \"-2 0\"\n\t\texit()\n\tif (st == 4):\n\t\tprint \"-1 -2\"\n\t\texit()\n\tif (st == 5):\n\t\tprint \"1 -2\"\n\t\texit()\n\tif (st == 6):\n\t\tprint \"2 0\"\n\t\texit()\n \nx = 2*(yy) \ny = 0\n\nif (diff == 0):\n\tprint x , y \n\texit()\nelif (diff == 1):\t\n\tx += 1\n\ty += 2 \n\tprint x, y\n\texit()\nelif (diff <= yy+1):\n\tx += 1 \n\ty += 2\n\tdiff -= 1\n\tx -= 1*diff\n\ty += 2*diff\n\tprint x , y\n\texit()\n\nelif (diff > yy+1):\n\tx += 1\n\ty += 2 \n\tx -= yy \n\ty += 2*yy \n\tdiff -= yy+1\n\tli = 0 \n\n\twhile (diff > yy+1 ) : \n\t\tif (li < len(l)):\n\t\t\tx += l[li][0]*(yy+1)\n\t\t\ty += l[li][1]*(yy+1)\n\t\t\tdiff -= (yy+1)\n\t\t\tli += 1\n\t\telse:\n\t\t\tbreak \n\n\tx += l[li][0]*diff\n\ty += l[li][1]*diff \n\tprint x,y \n\texit()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7d88dd161ce9bab429eeea195b96f2e9", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "# Contest: 21 - Codeforces Rating >= 2200 (https://a2oj.com/ladder?ID=21)\n# Problem: (25) Hexagons (Difficulty: 5) (http://codeforces.com/problemset/problem/615/E)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nn = rint()\nif n == 0:\n print(0, 0)\n exit(0)\nn -= 1\nl, h = 0, 10**9\nwhile h - l > 1:\n m = (h + l) // 2\n if 3 * m * (m + 1) > n:\n h = m - 1\n else:\n l = m\nc = h if 3 * h * (h + 1) <= n else l\nn -= 3 * c * (c + 1)\n\nfields = [(2 * (c + 1), 0)]\nfor dx, dy in [(-1, 2), (-2, 0), (-1, -2), (1, -2), (2, 0), (1, 2)]:\n for i in range(c + 1):\n x, y = fields[-1]\n fields.append((x + dx, y + dy))\nprint(*fields[n + 1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8d14da5d509c0cd9b3709905ef772c9", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nimport sys\nimport logging\nimport traceback\n\nlogging.basicConfig(level = logging.INFO)\n\nROD_NUM = 3\nmatrix = [map(int, raw_input().split()) \\\n for i in range(ROD_NUM)]\nn = input()\n\ndp = [[[0 for k in range(ROD_NUM)] \\\n for j in range(ROD_NUM)] \\\n for i in range(n+1)]\n\n\nfor i in range(1, n+1) : \n for j in range(ROD_NUM) : \n for k in range(ROD_NUM) : \n if j == k : \n pass\n else : \n def getBridge(x, y) : \n for b in range(ROD_NUM) : \n if b not in [x, y] : \n return b\n return -1\n\n b = getBridge(j, k)\n # print i, j, k, b\n dp[i][j][k] = min(dp[i-1][j][b] + matrix[j][k] + dp[i-1][b][k], \n dp[i-1][j][k] + matrix[j][b] + dp[i-1][k][j] + matrix[b][k] + dp[i-1][j][k])\n\nprint dp[n][0][2]\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b98466edfcb6e84676054bfcc3841e32", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "Python 2", "source_code": "t = []\nfor i in range(3):\n t.append(map(int, raw_input().split()))\nn=input()\nc = []\nfor m in range(n+1):\n row = [ [0]*3 for i in range(3) ]\n c.append(row)\n\nfor m in range(1,n+1):\n for i in range(3):\n for j in range(3):\n if i!=j:\n k = 3-i-j\n a = c[m-1][i][k] + t[i][j] + c[m-1][k][j]\n b = c[m-1][i][j] + t[i][k] + c[m-1][j][i] + \\\n t[k][j] + c[m-1][i][j]\n c[m][i][j] = min(a,b)\nprint c[n][0][2]\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "166b8736f4956c45812f22ceb9ef22a7", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "PyPy 3", "source_code": "\ufeffdef play(price, n):\n # dp[i][j][k] - naimen'shaya stoimost' peremeshcheniya i blinov so sterzhnya j => k\n # U nas vsegda est' dva varianta dejstviya:\n # 1. Peremeshchaem i - 1 blin na mesto 2. Dalee, peremeshchaem i - yj blin na mesto 3. I nakonec peremeshchaem i - 1 blin na mesto 3.\n # 2. Peremeshchaem i - 1 blin na mesto 3. Zatem i - yj na mesto 2, zatem i - 1 blin na mesto 1, dalee i -yj na 3-e mesto i nakonec i - 1 blin na 3 mesto\n # t.e, 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": "cb2b556e3869a5d2a6a20f707c18b627", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "PyPy 3", "source_code": "def 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": "a129da5a5b35187397756198fe3897f0", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "Python 3", "source_code": "import fileinput\ni=0\ncostMatrix = []\n\nfor line in fileinput.input():\n if i<3:\n costMatrix.append([int(i) for i in line.split()])\n i+=1\n else:\n n = int(line)\n\n\ndef switchC(MAT):\n SW = [[0]*3 for i in range(3)]\n SW[0][1]=MAT[0][2]\n SW[0][2]=MAT[0][1]\n SW[1][0]=MAT[1][0]\n SW[2][0]=MAT[1][0]\n SW[1][2] = MAT[2][1]\n SW[2][1] = MAT[1][2]\n return SW\n\ndef switchC2(MAT):\n SW = [[0]*3 for i in range(3)]\n SW[0][1]=MAT[1][0]\n SW[0][2]=MAT[1][2]\n SW[1][0]=MAT[0][1]\n SW[2][0]=MAT[2][1]\n SW[1][2] = MAT[0][2]\n SW[2][1] = MAT[2][0]\n return SW\n\ndef switchC3(MAT):\n SW = [[0]*3 for i in range(3)]\n SW[0][1]=MAT[2][1]\n SW[0][2]=MAT[2][0]\n SW[1][0]=MAT[1][2]\n SW[2][0]=MAT[0][2]\n SW[1][2] = MAT[1][0]\n SW[2][1] = MAT[0][1]\n return SW\n\ndef hashMAT(n,MAT):\n M = max(n,MAT[0][1],MAT[0][2],MAT[1][0],MAT[1][2],MAT[2][0],MAT[2][1])\n hashed = n + M*MAT[0][1]+M**2*MAT[0][2]+M**3*MAT[1][0]+M**4*MAT[1][2]+M**5*MAT[2][0]+M**6*MAT[2][1]\n return hashed\n\na = {}\n\ndef SmallY(n,MAT):\n h = hashMAT(n,MAT)\n isIN = h in list(a.keys())\n if n == 1:\n if isIN:\n return a[h]\n else:\n a[h] = min(MAT[0][2], MAT[0][1]+MAT[1][2])\n return a[h]\n else:\n if isIN:\n return a[h]\n else:\n a[h] = min(MAT[0][2]+SmallY(n-1,switchC(MAT))+SmallY(n-1,switchC2(MAT)),MAT[0][1]+MAT[1][2]+2*SmallY(n-1,MAT)+SmallY(n-1,switchC3(MAT)))\n return a[h]\n\nprint(SmallY(n,costMatrix))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "248faf5f35b1f497cddef782037c26c9", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn = int(raw_input())\nrmax = 0\nintervals = []\nfor _ in xrange(n):\n l, r = map(int, raw_input().split())\n rmax = max(rmax, r)\n intervals.append((l, r))\n\n\ndef prob_smaller_equal(ints, val):\n res = 1.0\n for l, r in ints:\n d = min(val + 1 - l, r + 1 - l)\n if d <= 0:\n return 0.0\n res *= float(d) / (r + 1 - l)\n if res == 0.0:\n return 0.0\n return res\n\n\ndef prob_smaller(ints, val):\n res = 1.0\n for l, r in ints:\n d = min(val - l, r + 1 - l)\n if d <= 0:\n return 0.0\n res *= float(d) / (r + 1 - l)\n if res == 0.0:\n return 0.0\n return res\n\n\ndef prob_greater(ints, val):\n res = 1.0\n for l, r in ints:\n d = min(r - val, r + 1 - l)\n if d <= 0:\n return 0.0\n res *= float(d) / (r + 1 - l)\n if res == 0.0:\n return 0.0\n return res\n\n\ndef prob_equal(ints, val):\n res = 1.0\n for l, r in ints:\n if not (l <= val <= r):\n return 0.0\n res *= 1.0 / (r + 1 - l)\n return res\n\n\ndef combos(ints, minn, maxn):\n for ntie in xrange(minn, maxn + 1):\n for ints_tie in combinations(ints, r=ntie):\n yield ints_tie\n\nINTINDS = range(len(intervals))\nres = 0\nfor i_int1 in INTINDS:\n for i_ints2_tie in combos(INTINDS, 1, n - 1):\n if i_int1 in i_ints2_tie:\n continue\n i_other = [i for i in INTINDS if i not in i_ints2_tie and i != i_int1]\n\n int1 = intervals[i_int1]\n ints2_tie = [intervals[i] for i in i_ints2_tie]\n other = [intervals[i] for i in i_other]\n\n for price in xrange(1, rmax + 1):\n add = prob_smaller(other, price) * prob_equal(ints2_tie, price) * prob_greater([int1], price)\n # if add:\n # print int1, \" | \", ints2_tie, \" : \", \"price2\", price, \"*\", add, \"=\", add * price\n res += add * price\n\n# print\n\nfor i_ints1_tie in combos(INTINDS, 2, n):\n i_other = [i for i in INTINDS if i not in i_ints1_tie]\n\n ints1_tie = [intervals[i] for i in i_ints1_tie]\n other = [intervals[i] for i in i_other]\n for price in xrange(1, rmax + 1):\n add = prob_smaller(other, price) * prob_equal(ints1_tie, price)\n # if add:\n # print ints1_tie, \" | \", other, \" : \", \"price2\", price, \"*\", add, \"=\", add * price\n res += add * price\n\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9fd8ccea0fe9351d21833895bce73df", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def recul(s, dex, cntBig, cntSame) :\n global n, L\n if cntBig > 1 : return 0.0\n if dex == n :\n if cntBig > 1 : return 0.0\n elif cntBig == 1 :\n if cntSame == 0 : return 0.0\n else : return 1.0\n else :\n if cntSame < 2 : return 0.0\n else : return 1.0\n \n ret = 0.0\n P = [0,0,0]\n total = L[dex][1]-L[dex][0]+1\n P[0] = min(max((s - L[dex][0]) / total, 0.0), 1.0)\n P[1] = 0 if s < L[dex][0] or s > L[dex][1] else 1.0/total\n P[2] = min(max((L[dex][1] - s) / total, 0.0), 1.0)\n ret += recul(s, dex+1, cntBig+1, cntSame) * P[2]\n ret += recul(s, dex+1, cntBig, cntSame+1) * P[1]\n ret += recul(s, dex+1, cntBig, cntSame) * P[0]\n return ret\n\nn = int(input())\nL = []\nfor i in range(n) :\n l,r = map(int, input().split(' '))\n L.append([l,r])\nans = 0.0\nS = [0]*10001\nfor s in range(1, 10001) :\n S[s] = recul(s, 0, 0, 0)\nfor s in range(1, 10001) :\n ans += s*S[s]\nprint('{0:.10f}'.format(ans))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "86d468e0b4061c304fd42f00def85296", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\n\nMaxV = int(1e4)\n\ndata = []\nreadIdx = 0\nfor line in sys.stdin.readlines():\n\tdata += line.split()\n\ndef read():\n\tglobal readIdx\n\treadIdx += 1\n\treturn data[readIdx - 1]\n\nn, average, power, mul = int(read()), 0, 1, 1\nfroms, tos, r = [], [], []\n\ndef check(secondMax, mask):\n\tglobal n\n\tequal, greater, ways = 0, 0, 1\n\tgreaterFrom, greaterTo = secondMax + 1, MaxV\n\tfor i in range(n):\n\t\twhich = int(mask) % 3\n\t\tmask /= 3\n\t\tif which == 0:\n\t\t\tways *= max(0, min(secondMax - 1, tos[i]) + 1 - froms[i])\n\t\telif which == 1:\n\t\t\tequal += 1\n\t\t\tways *= (froms[i] <= secondMax and tos[i] >= secondMax)\n\t\telse:\n\t\t\tgreater += 1\n\t\t\tgreaterFrom = max(greaterFrom, froms[i])\n\t\t\tgreaterTo = min(greaterTo, tos[i])\n\tif greater > 0:\n\t\tways *= max(0, greaterTo + 1 - greaterFrom)\n\tif ways > 0 and ((greater == 1 and equal > 0) or (greater == 0 and equal >= 2)):\n\t\treturn ways * secondMax\n\treturn 0\n\nfor i in range(n):\n\tfroms += [int(read())]\n\ttos += [int(read())]\n\tpower *= 3\n\tmul *= (tos[i] + 1 - froms[i])\nfor secondMax in range(MaxV + 1):\n\tfor mask in range(power):\n\t\tx = check(secondMax, mask)\n\t\tif x:\n\t\t\tr += [x]\nprint(sum(r) / mul)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba23075e5eef989c75999573bd2cfe81", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\n\nMaxV = int(1e4)\n\ndata = []\nreadIdx = 0\nfor line in sys.stdin.readlines():\n\tdata += line.split()\n\ndef read():\n\tglobal readIdx\n\treadIdx += 1\n\treturn data[readIdx - 1]\n\nn, r, power, mul = int(read()), 0, 1, 1\nfroms, tos = [], []\n\ndef check(secondMax, mask):\n\tglobal n\n\tequal, greater, ways = 0, 0, 1\n\tgreaterFrom, greaterTo = secondMax + 1, MaxV\n\tfor i in range(n):\n\t\twhich = int(mask) % 3\n\t\tmask /= 3\n\t\tif which == 0:\n\t\t\tways *= max(0, min(secondMax - 1, tos[i]) + 1 - froms[i])\n\t\telif which == 1:\n\t\t\tequal += 1\n\t\t\tways *= (froms[i] <= secondMax and tos[i] >= secondMax)\n\t\telse:\n\t\t\tgreater += 1\n\t\t\tgreaterFrom = max(greaterFrom, froms[i])\n\t\t\tgreaterTo = min(greaterTo, tos[i])\n\tif greater > 0:\n\t\tways *= max(0, greaterTo + 1 - greaterFrom)\n\tif ways > 0 and ((greater == 1 and equal > 0) or (greater == 0 and equal >= 2)):\n\t\treturn ways * secondMax\n\treturn 0\n\nfor i in range(n):\n\tfroms += [int(read())]\n\ttos += [int(read())]\n\tpower *= 3\n\tmul *= (tos[i] + 1 - froms[i])\nfor secondMax in range(MaxV + 1):\n\tfor mask in range(power):\n\t\tr += check(secondMax, mask)\nprint(r / mul)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5f83f750d24e392209e23400de534c7", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "l=[0 for i in range(6)]\nr=[0 for i in range(6)]\nn=input()\ndp=[[0.0 for i in range(35)] for j in range(0.0)]\ncul=[[0.0 for i in range(35)] for j in range(0.0)]\n #For(i,0,n) cin>>l[i]>>r[i];\nfor i in range(n):\n l[i]=input()\n r[i]=input()\n #For(i,0,n) For(j,l[i],r[i]+1) {dp[1<=2)\n # {\n # cur=1.0*i;\n # int k=j^((1<<(n))-1);\n # cur*=cul[k][i-1];\n # For(jj,0,n) if((1<=2:\n cur=1.0*i\n k=j^((1< Hb * Wa:\n Ha, Hb, Wa, Wb = Hb, Ha, Wb, Wa\n\nres = 0\nfor x in xrange(0, Wb):\n r = x * Ha + (C - x * Wa) / Wb * Hb\n res = max(r, res)\n \nprint res\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c91ba42c24106a2c9f93f141c094c20a", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "C, Hr, Hb, Wr, Wb = map(int, input().split())\nans = 0\nfor i in range(6 * 10 ** 5):\n if Wr * i <= C:\n ans = max(ans, Hr * i + (C - Wr * i) // Wb * Hb)\nfor i in range(6 * 10 ** 5):\n if Wb * i <= C:\n ans = max(ans, Hb * i + (C - Wb * i) // Wr * Hr)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5ae51ac86511b96325630317c86877f", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase\nfrom string import ascii_uppercase\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\n\ndef lcm(a, b):\n return a * b / gcd(a, b)\n\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] != \"CPython\": # PyPy?\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nc, h1, h2, w1, w2 = read_ints()\n\n# stage 2\nif w1 < w2: # most weighted\n (h1, w1), (h2, w2) = (h2, w2), (h1, w1)\n\nmx_h = -1\nn1 = 0\nwhile w1 * n1 <= c:\n n2 = (c - w1 * n1) / w2\n if n2 >= 0 and n1 * w1 + n2 * w2 <= c:\n add_h = h1 * n1 + h2 * n2\n # print \"mxh\", n1, n2, \":\", add_h\n mx_h = max(mx_h, add_h)\n n1 += 1\nprint mx_h\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "174c8552271523cb622fbb533083b672", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "#._.\n#want to maximize xa+y*int((c-z*a)/w)\n\ndef maxi(c, x, y, z, w):\n one = x / z\n two = y / w\n dictx = {}\n def f(a):\n return x*a+y*int((c-z*a)/w)\n for a in range(0, int(c//w)+1):\n dictx[a] = f(a)\n \n return max(dictx, key = lambda x:dictx[x])\nc, x, y, z, w = list(map(int, input().split(' ')))\nbad = maxi(c, x, y, z, w)\nprint(x*bad+y*int((c-z*bad)/w))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e78b0f59083055a8a42211684af6fc2", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef group_of_study ():\n nr_students = raw_input()\n nr_stu_at_score = raw_input().split(' ')\n min_student, max_student = raw_input.split(' ')\n\n cur = 0\n for cnt, num in enumerate(nr_stu_at_score):\n cur += num\n nr_students -= num\n if (cur >= min_student) and (nr_students <= max_student):\n print cur + 1\n exit\n print '0'\n\nif __name__ == '__main__':\n group_of_study()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ddffc9f99c92c53f9843aff28deca33b", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "m = int(raw_input())\nc = map(int, raw_input().split())\nd = map(int, raw_input().split())\nx, y = d[0], d[1]\ng1 = 0\ng2 = 0\ni=0\nk=1\nwhile g1 x_i:\n y_i -= 1\n y += a[y_i]\n\nif y_i <= x_i:\n print 0\n sys.exit(0)\n\nwhile x_i + 1 < y_i:\n if (x < y):\n x_i += 1\n x += a[x_i]\n else:\n y_i -= 1\n y += a[y_i]\n\nif (x_c <= x) and (x <= y_c) and (x_c <= y) and (y <= y_c):\n print x_i + 2\nelse:\n print 0\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b378d37d4cc6de554b75204b78bcc2ed", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "m = int(input())\nc = map(int, input().split())\nx, y = [int(i) for i in input().split()]\n\ncumFreq = [0]\ntotal = 0\nstrong = 0\nLSum, RSum = 0, 0\nr = range(x, y+1)\nfor i in c:\n total += i\n cumFreq.append(total)\n\nif max(x, y) * 2 < total:\n print(0)\nelse:\n k = m//2\n LSum = cumFreq[k]\n RSum = total - LSum\n if LSum in r and RSum in r:\n print(k+1)\n else:\n print(LSum, RSum)\n if LSum > RSum:\n while not (LSum in r and RSum in r):\n k -= 1\n LSum = cumFreq[k]\n RSum = total - LSum\n elif LSum < RSum:\n while not (LSum in r and RSum in r):\n k += 1\n LSum = cumFreq[k]\n RSum = total - LSum\n if LSum in r and RSum in r:\n print(k+1)\n else:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcc07733ff46320ed65432df9c4b259c", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Python 2", "source_code": " n = int(input())\n c = map(int,input().split())\n x,y = map(int,input().split())\n sumc = 0\n \n for 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\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "98ad15dffa27df848ea775a5fcd2e54e", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "import sys\na, b, w, x, c = map(int, input().split())\nif c <= a:\n print(0)\n sys.exit()\nd = c - a\nans = 0\nif b // x >= d:\n print(d)\n sys.exit()\nans += (b // x + 1) \nd -= (b // x)\nb = w - (x - b % x)\nb0 = b\ng = 0\ndet = 0\nwhile (1):\n if b // x >= d:\n print(ans + d)\n sys.exit()\n g += (b // x + 1)\n det += (b // x)\n ans += (b // x + 1)\n d -= (b // x)\n b = w - (x - b % x)\n if b == b0:\n break\n\nans += (d // det) * g\nd %= det\nif d == 0:\n print(ans - 1)\n sys.exit()\nwhile (1):\n if b // x >= d:\n print(ans + d)\n sys.exit()\n ans += (b // x + 1)\n d -= (b // x)\n b = w - (x - b % x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db4ca150390eb30cf1efd28f2f8a9e15", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\n#sys.stdin = open(\"input.txt\")\n\na, b, w, x, c = [long(x) for x in raw_input().split()]\n\n\nt = c - a\nhash = {}\n\nif t <= 0:\n print 0\nelse:\n cur_t = 0\n\n while 0 < t:\n #print cur_t\n if b >= x:\n if x <= 0:\n print t\n sys.exit()\n else:\n\n cur_t += b/x\n t -= b/x\n b -= (b/x)*x\n else:\n if (w-x) <= 0:\n print cur_t + (t-cur_t)/2\n sys.exit()\n else:\n delt = max((x-b)/(w-x),1)\n b += (w-x)*delt\n #t += delt\n cur_t += delt\n if t >0:\n if b in hash:\n del_t = t - hash[b][1]\n del_step = cur_t - hash[b][0]\n times = t / -del_t\n cur_t += del_step*times\n t += del_t * times\n else:\n hash[b] = [cur_t, t]\n\n print cur_t + t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "398392e2d042cde1cd30c8e4cd3be8d2", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\n#sys.stdin = open(\"input.txt\")\n\na, b, w, x, c = [long(x) for x in raw_input().split()]\n\n\nt = c - a\nhash = {}\njump = 0\n\nif t <= 0:\n print 0\nelse:\n cur_t = 0\n\n while 0 < t:\n #print cur_t\n #print b, cur_t, t\n\n if b >= x:\n if x <= 0:\n print t\n sys.exit()\n else:\n\n cur_t += b/x\n t -= b/x\n b -= (b/x)*x\n else:\n if (w-x) <= 0:\n print cur_t + (t-cur_t)/2\n sys.exit()\n else:\n delt = max((x-b)/(w-x),1)\n b += (w-x)*delt\n #t += delt\n cur_t += delt\n if t >0 and not jump:\n if b in hash:\n jump = 1\n del_t = t - hash[b][1]\n del_step = cur_t - hash[b][0]\n times = t / -del_t\n cur_t += del_step*times\n t += del_t * times\n else:\n hash[b] = [cur_t, t]\n\n print cur_t + t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7b34ce96443312d4d2d0eccb8131f4c2", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "a,b,w,x,c=map(int,raw_input().split())\ntotal=0\nwhile c>a:\n # print b,c,a,total\n if b>=x:\n n=(b/x)\n if n> (c-a):\n n= (c-a)\n c-=n\n b-=n*x\n total+=n\n else:\n c-=1\n a-=1\n b=w-(x-b)\n total+=1\nprint total\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "689744bfd3c864dc66927776f7421816", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import fileinput;\n\nstr = input();\nsstr = str.split(' ')\na,b,w,x,c = int(sstr[0]),int(sstr[1]),int(sstr[2]),int(sstr[3]),int(sstr[4])\n\ndif = c-a\ncount = 0\nwhile dif > 0:\n if (b >= x):\n factor = min(int((b - x)/x)+1,dif)\n dif = dif-factor\n b = b - x*factor\n else:\n count = count+1\n b = w - (x-b)\n\nprint(count+(c-a))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa3260e62678178692bdd65b8d55dffa", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "from fractions import gcd\n\n\ndef get_divisors(n):\n divs = []\n i = 1\n while i <= n / i:\n if n % i == 0:\n divs.append(i)\n if n / i != i:\n divs.append(n / i)\n i += 1\n return divs\n\n\ndef f(x, y):\n divs = get_divisors(x)\n dd = {}\n for d in divs:\n mul = y/d*d\n if not mul:\n continue\n if mul not in dd or dd[mul] < d:\n dd[mul] = d\n dd = sorted(dd.items(), reverse=True)\n dd.append((0, 0))\n # for k, w in dd:\n # print k, w\n ans = 0\n ix = 0\n while y and ix < len(dd):\n y, g = dd[ix]\n # print y, g, ix\n next_y, next_ix = None, None\n for i in xrange(ix+1, len(dd)):\n # print i, dd[i], dd[i][1] % g\n if dd[i][1] % g == 0:\n next_y = dd[i][0]\n next_ix = i\n break\n ans += (y-next_y) / g\n ix = next_ix\n y -= (y-next_y) / g * g\n return ans\n\n\ndef brute(x, y):\n ans = 0\n while y:\n ans += 1\n # print 'x=%d, y=%d->%d, gcd=%d, ans=%d' % (x, y, y-gcd(x, y),\n # gcd(x, y), ans)\n y = y - gcd(x, y)\n return ans\n # if not y:\n # return 0\n # return 1+brute(x, y-gcd(x, y))\n\n\na, b = map(int, raw_input().split())\nprint f(a, b)\n# print brute(2*2*3*5, 2*3*3+1)\n# print brute(2*3*3, 2*2*3*5)\n# print brute(2*3, 59)\n# print brute(59, 6)\n\n# assert brute(6, 3) == 1\n# assert brute(3, 5) == 3\n# for i in xrange(1, 100):\n# for j in xrange(1, 100):\n# assert brute(i, j) == f(i, j)\n# assert f(10**9+9, 10**9+8) == 10**9+8\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "665575c304efa9a22eef9da71ab4ee98", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\nfrom math import factorial\nfrom math import log10\n\n\n\nINF = float('inf')\n\n\ndef gcd(a, b):\n if not b:\n return a\n else:\n return gcd(b, a % b)\n\ndef f(a, b, u):\n if not b:\n return 0\n \n if not fact:\n return b // u\n \n mx = -INF\n \n for v in fact:\n if b - (b % (u * v)) > mx:\n mx = max(mx, b - (b % (u * v)))\n cur = v\n \n while not mx and fact:\n fact.pop()\n \n if mx:\n fact.pop(fact.index(cur))\n return (b - mx) // u + f(a, mx, u * cur)\n else:\n return f(a, b, u)\n\na, b = map(int, stdin.readline().split())\nfact = []\n\nq = gcd(a, b)\n\ni = 2\nk = a // q\n\nwhile i * i <= a:\n while not k % i:\n fact.append(i)\n k //= i\n \n i += 1\n \nif k != 1:\n fact.append(k)\n \nstdout.write(str(f(a, b, q)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5707916191acecdc8f00b20ff034c4d4", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "def readline():\n return map(int, raw_input().split())\n\n\ndef gcd(a, b): return a if b == 0 else gcd(b, a % b)\n\n\ndef is_prime(p):\n for i in range(2, p):\n if i * i > p: break\n if p % i == 0: return False\n\n return True\n\n\ndef divisors(n):\n p = 2\n while n > 1 and p * p <= n:\n if n % p == 0: yield p\n while n % p == 0: n /= p\n p += 1\n if n > 1: yield n\n\n\ndef main():\n a, b = readline()\n g = gcd(a, b)\n a /= g\n b /= g\n \n answer = 0\n \n while b > 0:\n arr = map(lambda p: b // p * p, divisors(a))\n if len(arr) != 0:\n new_b = max(arr)\n else:\n new_b = 0\n\n answer += b - new_b\n\n b = new_b\n g = gcd(a, b)\n a /= g\n b /= g\n\n print answer\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bfc78afbe7f82cf50e6056c4db072cfd", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "a,b=map(int,input().split())\nA=[]\nfor i in range(2,int(a**0.5)+1):\n while a%i==0:\n a//=i\n A.append(i)\nif a!=1:\n A.append(a)\n\n#print(A)\nout=0\nwhile b>0:\n n=len(A)\n x=-1\n for i in range(n):\n if x==-1 or b%A[i]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=[]\nwhile b!=0 and :\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## 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": true, "code_uid": "01849a367a4e46b2986a039027473870", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def add(a,b):\n if a+b>=mod:\n return (a+b)%mod\n return a+b\nn=int(input())*2\ns=input()\nd=[[0,0] for i in range(len(s)+1)]\naux=''\nfor i in range(len(s)):\n if s[i]=='(':\n d[i][1]=i+1\n x=aux+')'\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d[i][0]=len(x[j::])\n break\n else:\n d[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[i][1]=len(x[j::])\n break\n aux+=s[i]\nd[len(s)][1]=len(s)\nd[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]]=add(dp[i][j][k],dp[i+1][j-1][d[k][0]])\n for j in range(n//2):\n for k in range(len(s)+1):\n dp[i+1][j+1][d[k][1]]=add(dp[i][j][k],dp[i+1][j+1][d[k][1]])\nprint(dp[n][0][len(s)]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2bbebbb470b12c926b025096712ae71b", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "def add(a,b):\n if a+b>=mod:\n return (a+b)%mod\n return a+b\nn=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 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)]]=add(dp[i][j][k],dp[i+1][j-1][d[(k,0)]])\n for j in range(n//2):\n for k in range(len(s)+1):\n dp[i+1][j+1][d[(k,1)]]=add(dp[i][j][k],dp[i+1][j+1][d[(k,1)]])\nprint(dp[n][0][len(s)]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b37e42e1022187ae309a42c7a6a6e52", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "n=int(input())*2\ns=input()\nd=dict()\naux=''\nst=set()\nst.add(aux)\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 if x[j::] in st:\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::] in st:\n d.update({(len(aux),1):len(x[j::])})\n break\n aux+=s[i]\n st.add(aux)\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": "772290e5c9fa0f5c5dc5bbe8f6d9c188", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"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 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": "418a9af46e7feceb13d8283aeed62d42", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "n=int(input())*2\ns=input()\nd=dict()\naux=''\nst=set()\nst.add(aux)\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 if x[j::] in st:\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::] in st:\n d.update({(len(aux),1):len(x[j::])})\n break\n aux+=s[i]\n st.add(aux)\nd.update({(len(s),1):len(s)})\nd.update({(len(s),0):len(s)})\ndp=[[[0 for i in range(n+1)] for j in range(n+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):\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-1):\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": "1141858be906fa8e61d0468796e88ab8", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "'''''''''''\n Author : code_marshal\n'''''''''''\n\nalp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nk, s = int(input()), list(input())\nch = alp[:k]\nj=len(s)//2\ni=len(s)//2-1\nwhile i>=0 or j 0):\n if(s[j] == '?'):\n s[j] = 'a'\n s[n - j - 1] = 'a'\n b[0] = True\n d -= 1\n j += 1\n for i in xrange(0, (n + 1)/2):\n if (s[i] == '?'):\n j = 0\n while(b[j] == True):\n j += 1\n s[i] = l[j]\n s[n - i - 1] = l[j]\n b[j] = True\n print s\n else:\n print 'IMPOSSIBLE'\n \n #print s\n #print l\n \n return\n\n try:\n name = ''\n f1 = open(name + '.in', 'r')\n f2 = open(name + '.out', 'w')\n print >> f2, body()\n f1.close()\n f2.close()\n except IOError:\n body()\n except:\n print 'Sudden error!'\n raise\n\nstart = time.time()\nmain()\n#print 'Time exceeded:', time.time() - start", "lang_cluster": "Python", "compilation_error": false, "code_uid": "98549d542dad20cea9da85dbd8fa6f48", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n=int(input()\na=(n*(n+1)*(2*n+1))//6\nb=(n*(n+1)//2)\nprint(a-b-2)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1765377bf313e9a6ab2e6312cc66ba95", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n\tx = int(input())\n\tans = 0\n\tfor i in range(2, x):\n\t\tans += i*(i+1)\n\tprint ans\n\nif __name__ == '__main__':\n\tmain()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c15c3d6065219f1d6304739739cbf35", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.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": "08c54dfe46c0a1125ac4eeca5b8e3d95", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n=int(input()\nsu =0\nfor i in range(2,n-1)\n su=su+(i)*(i+1\nprint(su)\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4ff3aa3ad62659b3eb7ef2d8e36b474c", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "//f = open('Text.txt',\"r\")\nn = int(f.read())\nres = 0\n\nfor x in range(3, n+1):\n res += 1*(x-1)*(x)\n\nprint(res)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b0e571d463ff68944e34e1ea63847a8b", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n[evaluate untitled-1.py]\n1?AA\n100\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "65fc54d8a3068236beb0b3a33132b977", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "\n\n\n\nd = {\"?\": 10, \"A\":10, \"B\":10,\"C\": 10,\"D\":10,\"E\":10, \"F\":10,\"G\": 10,\"H\":10,\"I\":10, \"J\":10}\n\nlett = set(list(\"ABCDEFGHIJ\"))\n\nfor i in range(10):\n d[str(i)]=1\n\nprint d\n\nk = set(d.keys())\n\ntotal = 1\n\n#with open(\"task1.txt\", \"r\") as f: \n# for line in f:\nfor line in sys.stdin:\n if line[0] == \"?\":\n total *= 9\n elif line[0] >= \"A\" and line[0] <= \"J\":\n total *= 9\n d[line[0]] = 1\n lett.remove(line[0])\n for m in lett:\n d[m] -= 1\n \n \n for c in line[1:]: \n if c not in k:\n break\n total *= d[c]\n if c in lett:\n d[c] = 1\n lett.remove(c)\n for m in lett:\n d[m] -= 1\n break\n \n \nprint total\n \n \n\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1acb60fd921b18ad0aef656000655a85", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = raw_input()\n\nk = 1\nbuk = []\nbu = ['A','B','C','D','E','F','G','H','I','J']\n\nif s[0] in bu:\n k = k*9\n buk = s[0]\nelif s[0] == '?':\n k = k*9\n\n\nfor i in range(len(s)):\n if s[i] in bu and buk == []:\n k = k*10\n buk.append(b[i])\n elif s[i] in bu and buk != [] and s[i] not in buk:\n k = k*(10-len(buk))\n elif s[i] == '?':\n k = k*10\nprint k", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f6ac4cf1f2f77616b1f0da1210f8164", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = raw_input()\n\nsum = 1\nmulA=10\n\nusedChars = {\n'A' : False,\n'B' : False,\n'C' : False,\n'D' : False,\n'E' : False,\n'F' : False,\n'G' : False,\n'H' : False,\n'I' : False,\n'J' : False,\n}\n\nif s[0] >= 'A' and s[0] <= 'Z':\n usedChars[ s[0] ] = True\n mulA -= 1\n sum *= 9\n \nif s[0] == '?':\n sum *= 9\n\nfor ch in s[1:]:\n if ch == '?':\n sum *= 10\n elif not usedChars[ ch ]:\n sum *= mulA\n mulA -= 1\n usedChars[ch] = True\n\nprint sum\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bf2f7baa96be78369d01b32db661498", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "def check(temp,a):\n dr = {}\n nums = '0123456789'\n a = list(str(a));\n for i in range(len(temp)):\n if temp[i] == '?':\n if a[i] in nums:\n continue\n else:\n return 0\n if temp[i] in nums:\n if temp[i] == a[i]:\n continue\n else:\n return 0\n if temp[i] != '?':\n if temp[i] not in nums:\n if temp[i] not in dr.keys() and a[i] not in dr.values():\n dr[temp[i]] = a[i]\n for i in range(len(temp)):\n if temp[i] != '?' and temp[i] not in nums and a[i]:\n \n if temp[i] not in dr.keys() or a[i] != dr[temp[i]]:\n return 0\n return 1\n \nn = input()\nleng = len(n)\nans = 0\nfor i in range(10**(leng-1),10**leng):\n if check(n,i) == 1:\n ans += 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c86e1af98a45d1717f497490dbe4ebaf", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "# This code is contributed by Siddharth\r\n\r\nfrom sys import *\r\ninput = stdin.readline\r\n\r\n\r\n\r\n\r\nimport random\r\nfrom bisect import *\r\nimport math\r\nfrom collections import *\r\nimport operator\r\nfrom heapq import *\r\nfrom itertools import *\r\ninf=10**18\r\nmod=10**9+7\r\n\r\n# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )\r\n\r\n\r\n\r\n# ==========================================> Code Starts Here <=====================================================================\r\n\r\n\r\n\r\ndef solve(x):\r\n if dp[x]!=-1:\r\n return dp[x]\r\n if x<=1:\r\n dp[x]=0\r\n return 0\r\n if x==2:\r\n dp[x]=2\r\n return 2\r\n ans=0\r\n for i in range(1,x):\r\n ans=(ans+max(1,solve(x-i)))%m\r\n for i in range(2,x+1):\r\n if i>x:\r\n continue\r\n ans=(ans+max(1,solve(x//i)))%m\r\n dp[x]=ans%m\r\n return dp[x]\r\n\r\n\r\n\r\nn,m=map(int,input().split())\r\ndp=[-1]*(n+5)\r\nprint(solve(n)%m)\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": "27d70d48d50c18e852500cd633e5e849", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,m=map(int,input().split())\r\n\r\nS=[i for i in range(n+1)]\r\n\r\nfor i in range(2,n+1):\r\n if S[i]==i:\r\n for j in range(i,n+1,i):\r\n if S[j]==j:\r\n S[j]=i\r\n\r\ndef fact(x):\r\n NOW={1}\r\n while x!=1:\r\n NOW|={n*S[x] for n in NOW}\r\n x//=S[x]\r\n\r\n return NOW\r\n\r\nDP=[0]*(n+1)\r\n\r\nDP[1]=1\r\nDP[2]=2\r\nDP[3]=5\r\n#DP[4]=12\r\n#DP[5]=25\r\n\r\nfor i in range(4,n+1):\r\n SU=DP[i-1]*2+1\r\n \r\n for f in fact(i):\r\n if f==1 or f==i:\r\n continue\r\n SU+=DP[i//f]-DP[(i-1)//f]\r\n\r\n DP[i]=SU%m\r\n\r\nprint(DP[n])\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fd5bba7b7afe03f424d3112e41cc4122", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "for u in range(int(input())):\r\n n, m = map(int, input().split())\r\n dp = [0 for i in range(n+1)]\r\n dp[1] = 1\r\n p = [0]*(n+1)\r\n cache = [[] for i in range(n+1)]\r\n \r\n a = 0\r\n b = 1\r\n \r\n for i in range(2, n+1):\r\n for j in cache[i]:\r\n a = (a - dp[p[j]] + m)%m\r\n p[j] += 1\r\n a = (a + dp[p[j]])%m\r\n \r\n a = (a + dp[1])%m\r\n dp[i] = (a + b)%m\r\n b = (b + dp[i])%m\r\n \r\n p[i] = 1\r\n j = 2\r\n while(i*j <= n):\r\n cache[i*j].append(i)\r\n j += 1\r\n \r\n print(dp[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aaa98b4f3053464cf96bd6dce110ef0a", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "import sys\r\nimport io, os\r\nimport math\r\nfrom heapq import *\r\ngcd = math.gcd\r\nsqrt = math.sqrt\r\ndef ceil(a,b):\r\n a=-a\r\n k=a//b\r\n k=-k\r\n return k\r\n# arr=list(map(int, input().split()))\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\ndef strinp(testcases):\r\n k = 5\r\n if (testcases == -1 or testcases == 1):\r\n k = 1\r\n f = str(input())\r\n f = f[2:len(f) - k]\r\n return f\r\ndef main():\r\n arr=list(map(int, input().split()))\r\n n=arr[0]\r\n m=arr[1]\r\n dp=[0]*(n+1)\r\n dp[1]=1\r\n dp[2]=2\r\n dp[3]=5\r\n if(n<4):\r\n print(dp[n])\r\n sys.exit()\r\n for i in range(4,n+1):\r\n dp[i]=(2*dp[i-1]+1)%m\r\n p=int(i**(0.5))\r\n for j in range(2,p+1):\r\n if(i%j==0):\r\n if(j*j==i):\r\n dp[i]+=(dp[i//j]-dp[(i-1)//j])\r\n dp[i]=dp[i]%m\r\n else:\r\n f=i//j\r\n dp[i]+=(dp[i//j]-dp[(i-1)//j])\r\n dp[i] += (dp[i // f] - dp[(i - 1) // f])\r\n dp[i]=dp[i]%m\r\n print(dp[n])\r\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c39343a4afdb117e89d61f0773878eec", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.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\tq2 = q1-1\r\n\tfor j in xrange(2, q1): #j= 17 and p*rub[-1] < q * n / math.log(n):\n break\n n += 1\n\npi = get_primes(n)\n\nwhile(q*pi[n-1] > p*rub[n-1]):\n n -= 1\n\nprint >> sys.stdout, n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e354e3d74719d032e324fa816efa3299", "src_uid": "e6e760164882b9e194a17663625be27d", "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\nMX = 3 * 10 ** 6\nprime = [1] * MX\nprime[0] = prime[1] = 0\nfor i in xrange(2, int(MX ** 0.5 + 1e-8)):\n if prime[i]:\n prime[2 * i::i] = [0] * len(prime[2 * i::i])\n\np, q = map(int, raw_input().split())\npi = rub = ans = 0\nfor i in xrange(1, MX):\n pi += prime[i]\n if i == int(str(i)[::-1]): rub += 1\n if q * pi <= p * rub:\n ans = max(ans, i)\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7198f0ad0a98a27ab0d4617b8bbcb2d6", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "from collections import*\nn,m=map(int,input().split())\nc=Counter(i*i%m for i in range(1,n+1))\nprint(sum(c[k]*c[(m-k)%m]for k in c))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eca5e9082acd25323f6fa3162653e4c9", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\nfrom math import factorial as f\nfrom fractions import gcd as g\n\nn, m = [int (i) for i in raw_input ().split ()]\n\ndef brute ():\n p = []\n for i in range (1, n + 1):\n for j in range (1, n + 1):\n if (i * i + j * j) % m == 0:\n p.append ((i, j))\n return p\n\n\nret = 0\nif m == 1:\n print n * n\nelse:\n print len (brute ())\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5ae104d9a24015fe590d98c8e2178e8", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.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(sum(zip(a,(a+a)[n::-1])))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2c3ac31a186e9e347c653805c891bd51", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n,m=list(map(int,input().split()))\na=[[0 for i in range(m)] for i in range(m)]\ns=0\nfor i in range(m):\n for j in range(m):\n a[i][j]=(i+1)**2+(j+1)**2\n if a[i][j]%m==0:\n a[i][j]=1\n else:\n a[i][j]=0\n s=s+a[i][j]\ns=s*((n//m)**2)\nb=n%m\nfor i in range(b):\n s=s+sum(a[i][:n])\nfor i in range(b):\n for j in range(n):\n s=s+a[i][j]\nfor i in range(b):\n for j in range(b):\n s=s+a[i][j]\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5ec6986d1519987fcfe20a2ed995e0d1", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import io , sys , atexit , os\n\ndef freopen(filename, mode):\n if mode == \"r\":\n sys.stdin = open(filename, mode)\n\n elif mode == \"w\":\n sys.stdout = open(filename, mode)\n\n# ---- MAIN ----\n\nfreopen(\"input.txt\", \"r\")\n#freopen(\"output.txt\", \"w\")\n\nc = 0\nn,m = map(int,raw_input().split()) \n\nfor i in range(1,m+1):\n\tfor j in range(1,m+1):\n\t\tnum = i*i + j*j \n\t\tnum = num%m \n\t\tif(num==0): \n\t\t\tc += (1+(n-i)/m) * (1+(n-j)/m)\n\nprint c\n\n\n\n\n\n \n\t\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c4e97468cf7bf0b3e4993e948077f8a", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def next_permutation(a):\n k = len(a) - 2\n while a[k] > a[k+1]:\n k -= 1\n t = k + 1\n while t < len(a) - 1 and a[t+1] > a[k]:\n t += 1\n a[t], a[k] = a[k], a[t]\n sub = a[k+1:]\n sub.reverse()\n return a[:k+1] + sub\n\ndef count_current(a, x):\n r = 0\n for i in range(len(a) // 2):\n f = a[2*i]\n n = a[2*i + 1]\n r += x[f][n] + x[n][f]\n return r\n\ndef count(a, x):\n r, t = 0, a\n while len(t) > 1:\n r += count_current(t, x)\n t = t[1:]\n return r\n\narr = []\nfor i in range(5):\n arr.append([int(c) for c in input().split()])\np = [0, 1, 2, 3, 4]\nres = 0\nwhile p != [4, 3, 2, 1, 0]:\n res = max(res, count(p, arr))\n p = next_permutation(p)\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d4fe6b548473fc70305435c430e2f96a", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "from itertools import permutations\n \nf = lambda i,j: G[i][j]+G[j][i]\n \nG = [[map(int, input().split())] for _ in range(5)]\n \nprint(max(f(a,b) + f(b,c) + 2 * (f(c,d)+f(d,e))\n for a,b,c,d,e in permutations(range(5))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "721b32af843d7ae5f0de34c0076652db", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "# http://codeforces.com/problemset/problem/431/B\n\n'''\nnotice that first with second student, and second with the third will\ncommunicate one time, and third with fourth student, and fourth with fifth \u2014\nwill communicate two times. Another pairs of students will never communicate to\neach other during they stay in queue.\n'''\n\nfrom itertools import permuations\nq,t = 0, [list(map, int(input().split())) for i in range(5)]\n\nfor a,b,c,d,e in permutaions([0,1,2,3,4]):\n s = t[a][b] +t[b][a] +t[b][c] +t[c][b] + 2*(t[c][d] + t[d][c] +t[d][e] + t[e][d])\n if s>q:\n q = s\nprint(q)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57d2f9b5e540550a561fd17bb66b178f", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[204]:\n\n\n# # n = int(input())\n# # line = list(map(int, input().split()))\n# # line = list(str(input()))\n\n\n# In[396]:\n\n\n# 0 43 21 18 2\n# 3 0 21 11 65\n# 5 2 0 1 4\n# 54 62 12 0 99\n# 87 64 81 33 0\n\n\n# In[413]:\n\n\ng_mat = []\n\nfor _ in range(5):\n g_mat.append(list(map(int, input().split())))\n\n\n# In[439]:\n\n\ndef utility_function(states, seq):\n score = (states[seq[0]][seq[1]] + states[seq[1]][seq[0]] + states[seq[2]][seq[3]] + states[seq[3]][seq[2]]) +(states[seq[1]][seq[2]]+ states[seq[2]][seq[1]] + states[seq[3]][seq[4]] + states[seq[4]][seq[3]]) + (states[seq[2]][seq[3]] + states[seq[3]][seq[2]]) + (states[seq[3]][seq[4]] + states[seq[4]][seq[3]])\n\n return score \n\n\n# In[450]:\n\n\ndef permutation(seq):\n def backtrack(first = 0):\n if first == n:\n if seq[:] not in combs:\n combs.append(seq[:]) \n \n else:\n for i in range(first, n):\n seq[first], seq[i] = seq[i], seq[first]\n backtrack(first + 1)\n seq[first], seq[i] = seq[i], seq[first]\n\n n = len(seq)\n combs = []\n backtrack()\n return combs\n\n\n# In[455]:\n\n\ncombs = permutation(seq)\nmax_score = 0\n\nfor seq in combs:\n max_score = max(max_score, utility_function(g_mat, seq))\n\nprint(max_score)\n\n\n# In[ ]:\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f00598703ab5a0356ce9729ec985eb6c", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "# http://codeforces.com/problemset/problem/431/B\n\n'''\nnotice that first with second student, and second with the third will\ncommunicate one time, and third with fourth student, and fourth with fifth \u2014\nwill communicate two times. Another pairs of students will never communicate to\neach other during they stay in queue.\n'''\n\nfrom itertools import permutations\nq,t = 0, [list(map, int(input().split())) for i in range(5)]\n\nfor a,b,c,d,e in permutaions([0,1,2,3,4]):\n s = t[a][b] +t[b][a] +t[b][c] +t[c][b] + 2*(t[c][d] + t[d][c] +t[d][e] + t[e][d])\n if s>q:\n q = s\nprint(q)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d80fb06d85129c125789f783f8fb9a1f", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import collections\nimport sys\ndef recur(_list):\n idx = -1\n next_list = []\n for i,x in enumerate(_list):\n if x > 1:\n idx = i\n q = _list[idx] // 2\n r = _list[idx] % 2\n next_list += [q,r,q]\n else:\n next_list += [x]\n if idx == -1:\n return _list\n else:\n return recur(next_list)\n\nsys.setrecursionlimit(100000)\nn,s,e = list(map(int,input().split(' ')))\n_list = [n]\nprint(collections.Counter(recur(_list[:])[s-1:e])[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "379290efab6c0025e76c578f173e0a33", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "citire=list(map(int,input().split()))\n\nk=0\n\ndef get_p2(n):\n i=1\n while n>=i:\n i*=2\n i-=1\n return int(i)\n\np=get_p2(citire[0])\n\ndef get_num(i,n,len):\n key=len//2+1\n if i==key:\n return n%2\n elif i>key:\n i-=key\n n//=2\n len=(len+1)//2-1\n return get_num(i,n,len)\n\nfor i in range(citire[1],citire[2]+1):\n n=citire[0]\n len=p\n k+=get_num(i,n,len)\n\nprint(k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e56cc750838b7a92c3f2f195d1f57c3", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "# http://codeforces.com/problemset/problem/768/B\nimport math, copy\n\ndef module():\n global li\n\n i = 0\n while i < len(li):\n if li[i] not in [0, 1]:\n a = math.floor(li[i] / 2)\n b = li[i] % 2\n\n li.insert(i, a)\n li[i + 1] = b\n li.insert(i + 2, a)\n\n # print(li)\n\n i += 3\n else:\n i += 1\n\n end = 1\n for i in range(len(li)):\n if li[i] not in [0, 1]:\n end = 0\n break\n else:\n continue\n\n if end == 0:\n module()\n else:\n return\n\nn, l, r = map(int, input().split())\nli = [n]\nans = 0\n\nmodule()\nfor i in range(l - 1, r):\n ans += li[i]\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed58ad5b28710fc962bf512b011fab7a", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n, l,r = map(int, raw_input().split())\n\na = [0]\nif r == l:\n print 0\n exit()\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": false, "code_uid": "463470714459cd142228425bfa63bf6e", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.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": "d333d80ddec68b0dfb005fc9ef7da6e3", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "#------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\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#-------------------game starts now-----------------------------------------------------\nx,y=map(int,input().split())\na=y\nb=y\nc=y\nt=1\nans=0\nwhile(True):\n if a==x and b==x and c==x:\n break\n ans+=1\n if t==1:\n a=b+c-1\n if a>x:\n a=x\n elif t==2:\n b=a+c-1\n if b>x:\n b=x\n else:\n c=b+a-1\n if c>x:\n c=x\n t=(t+1)%3\nprint(ans)(ans,f)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f6cb3cba137b734a185a455901f4b43", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "x = int(input())\ny = int(input())\nx_v = [y, y, y]\nresult = 0\nwhile ((x_v[0] != x) or (x != x_v[1] ) or (x != x_v[2])):\n x_v.sort()\n x_v[0] = min(x, x_v[1] + x_v[2] - 1)\n result += 1\nprint(result)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a49b3c3062279c6148bd92b9645c7cb", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "x = int(input())\ny = int(input())\nx_v = [y]*3\nsum = 0\nresult = 0\nwhile (x_v[0] != x) or (x != x_v[1] ) or (x != x_v[2]):\n x_v.sort()\n x_v[0] = min(x, x_v[1] + x_v[2] - 1)\n result += 1\nprint(result)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4bf7c8dc7e0a3c59a4041f57eb166ffe", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "# area of equilater triangle s**2 * sqrt(3) / 4\nfrom math import sqrt\n\nanswers = {}\n\ndef solve(s1, s2, s3, y, ite):\n if s1 == y and s2 == y and s3 == y:\n return ite\n if (s1, s2, s3, y) in answers.keys():\n return answers[(s1, s2, s3, y)]\n big = max(max(s1, s2), s3)\n small = min(min(s1, s2), s3)\n other = s1+s2+s3-big-small\n rest = other-small\n new = max(rest+1, y)\n bigg = max(big-1, y)\n ite_min = 300000\n if new == y and bigg == y:\n return solve(small, other, new, y, ite+1)\n for i in range(new, bigg):\n ite_min = min(ite_min, solve(small, other, i, y, 0))\n answers[(s1, s2, s3, y)] = ite_min + ite + 1\n return ite_min + ite + 1\n\nx, y = [int(i) for i in input().split()]\nprint(solve(x, x, x, y, 0))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "36931d12f5057a74687cbdc957b12246", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "x = int(input())\ny = int(input())\nx_v = [x]*3\nsum = 0\nresult = 0\nwhile (x_v[0] != y) or (y != x_v[1] ) or (y != x_v[2]):\n temp = x_v[sum%3]\n if sum%3 == 0:\n c = x_v[0]\n a = x_v[1]\n b = x_v[2]\n if (sum == 0) and (y < int(x/3)):\n if (abs(a - b) < int(x/3)) :\n x_v[0] = int(x/3)\n else:\n x_v[0] = abs(a - b) + 1\n else:\n if abs(a - b) < y:\n x_v[0] = y\n else:\n x_v[0] = abs(a - b) + 1\n elif sum%3 == 1: \n c = x_v[1]\n a = x_v[0]\n b = x_v[2]\n if abs(a - b) < y:\n x_v[1] = y\n else:\n x_v[1] = abs(a - b) + 1\n else:\n c = x_v[2]\n a = x_v[0]\n b = x_v[1]\n if abs(a - b) < y:\n x_v[2] = y\n else:\n x_v[2] = abs(a - b) + 1\n if (x_v[sum%3] != temp):\n result += 1\n sum += 1\nprint(result)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0122e1a0d24f6f3c0b806f5a48118a57", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "from bisect import*\nA=lambda:map(int,input().spilt())\nt,=A()\nfor _ in [0]*t:\n n,k=A();x=sorted(A());A();a=q=0;m=[n-i-bisect_left(x,x[~i]-k)for i in range(n):\n for i in range(n):a=max(a,q+bisect_right(x,x[i]+k-i);q=max(q,m[~i])\n print(a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1a2c1a7087ea696320b183df4638f8b1", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef solve(n,k,s,t):\n\n #\ucd1d \uc138\uac1c\uc758 dp state \uc874\uc7ac\n\n #dont change the current character\n #change the current character to t0\n #change the current character to t1\n\n dp = [[[-1*math.inf for i in range(n+1)] for j in range(n+1)] for z in range(n+1)]\n dp[0][0][0] = 0\n\n for i in range(n):\n for ck in range(k+1):\n for cnt0 in range(n+1):\n if dp[i][ck][cnt0] == -1*math.inf: continue\n e0 = s[i] == t[0]\n e1 = s[i] == t[1]\n e01 = t[0] == t[1]\n\n #first transition\n if e1 == 1: e1 = cnt0\n else: e1 = 0\n dp[i+1][ck][cnt0+e0] = max(dp[i+1][ck][cnt0+e0], dp[i][ck][cnt0] + e1)\n\n if ck < k:\n #second transition\n if e01 == 1: e01 = cnt0\n else: e01 = 0\n dp[i+1][ck+1][cnt0+1] = max(dp[i+1][ck+1][cnt0+1], dp[i][ck][cnt0] + e01)\n #third transition\n dp[i+1][ck+1][cnt0+e01] = max(dp[i+1][ck+1][cnt0+e01], dp[i][ck][cnt0] + cnt0)\n\n ans = 0\n\n for ck in range(k+1):\n for cnt0 in range(n+1):\n ans = max(ans, dp[n][ck][cnt0])\n\n print(ans)\n\n\n\n\n\n\nif __name__ == '__main__':\n n,k = map(int,input().split())\n s = input()\n t = input()\n solve(n,k,s,t)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dc831a00365850dcba5cb990078979a1", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def solve(i, z, k):\n if i >= n:\n return 0\n if dp[i][z][k] != -1:\n return dp[i][z][k]\n o = solve(i+1, z, k)\n c = s[i] != t[0]\n if k >= c:\n o = max(o, solve(i+1, z+1, k-c))\n c = s[i] != t[1]\n if k >= c:\n o = max(o, solve(i+1, z+(t[0] == t[1]), k-c) + z)\n dp[i][z][k] = o\n return o\n\nn, k = map(int, input().split())\ns = input()\nt = input()\n\ndp = [[[-1] * (n+1) for _ in [0] * n for _ in [0]*n]\n\nprint(solve(0, 0, k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aa6ee9e76b0fd689419896e8c28526d1", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def g(i,z,k):\n if i>=n:return 0\n if q[i][z][k]>-1:return q[i][z][k]\n o=g(i+1,z,k);c=s[i]!=t[0]\n if k>=c:o=max(o,g(i+1,z+1,k-c))\n c=s[i]!=t[1]\n if k>=c:o=max(o,g(i+1,z+(t[0]==t[1]),k-c)+z)\n q[i][z][k]=o;return o\nn,k=map(int,input().split());s=input();t=input();q=[[[-1]*n**2for _ in[0]*n]for _ in[0]*n]\nprint(g(0,0,k))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8cdda589c95d345812d43c4888d0310d", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "\nn , u = map(int,input().split())\n\n\ns = input()\nt = input()\ninf = 10**12\n\n\nif t[0]==t[1]:\n\n u = min(n, s.count(t[0])+u)\n print((u-1)*u//2)\nelse:\n l =[ [ [-inf]*(u+1 ) for i in range(n+1)] for j in range(n+1)]\n\n l[0][0][0] = 0\n\n for i in range(n):\n \n for j in range(n+1):\n\n for k in range(u+1):\n\n\n if s[i]==t[0]:\n\n if j+1 <=n:\n\n l[i+1][j+1][k]= max( l[i+1][j+1][k], l[i][j][k] )\n elif s[i]==t[1]:\n\n l[i+1][j][k] = max( l[i+1][j][k] , l[i][j][k]+j)\n else:\n l[i+1][j][k]= max(l[i+1][j][k],l[i][j][k])\n\n if k+1 <= u and j+1<=n:\n\n l[i+1][j+1][k+1]= max(l[i+1][j+1][k+1],l[i][j][k])\n\n if k+1 <= u:\n\n l[i+1][j][k+1] = max(l[i+1][j][k+1], l[i][j][k]+j)\n ans = -inf\n for j in range(n+1):\n for k in range(u+1):\n\n ans = max(ans, l[-1][j][k])\n\n print(ans)\n\n\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "550c127e2df9da600f0a8d2942ee3433", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "a=input()\ns=len(a)\nans=-1\nif s>=3:\n\tfor i in range(s-2):\n\t\tfor j in range(i+1,s-1):\n\t\t\tif (i+1>0+1 and a[0]==\"0\") or (j+1>i+2 and a[i+1]==\"0\") or (s>j+2 and a[j+1]==\"0\"):\n\t\t\t\tcontinue\n\t\t\tif(int(a[0:i+1]>100000 or int(a[i+1:j+1]>1000000 or a[j+1:s]>1000000:\n\t\t\t\tcontinue\n\t\t\tans=max(ans,int(a[0:i+1])+int(a[i+1:j+1])+int(a[j+1:s]))\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fda839cd70f0eed877a13fa19ab6162b", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "s = raw_input()\nans = -1\nfor i in range(1,len(s)):\n for j in range(i+1, len(s)):\n a = s[:i]\n b = s[i:j]\n c = s[j:]\n if (a[0]!='0' or int(a)==0) and (b[0]!='0' int(b)==0) and (c[0]!='0' or int(c)==0) and int(a)<=1000000 and int(b)<=1000000 and int(c)<=1000000:\n ans = max([ans, int(a)+int(b)+int(c)])\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "91e911ef24b617647138e76c89a8f6ba", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "t = input()\na = int(t[0]) + int(t[1]) + int(t[2: ]) if t[2] else -1\nb = int(t[0]) + int(t[1: -1]) + int(t[-1]) if t[1] else -1\nc = int(t[: -2]) + int(t[-2]) + int(t[-1])) if t[0] else -1\nprint(max(a, b, c)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "01e5b9dbaebb9153e165c9874a5cf471", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.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()\nperebor(num, 1, 2)\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7356743fb0a33e4b1c18b1a04712db8", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "def f(t, k, s):\n if k == 1:\n if t[0] == '0' and len(t) > 1: return -1\n d = int(t)\n if d > 1000000: return -1\n return s + d \n if t[0] == '0': return f(t[1: ], k - 1, s)\n p = [(t[i: ], int(t[: i])) for i in range(1, len(t) + 2 - k)]\n return max(f(a, k - 1, s + b) for a, b in p if b < 1000001)\nprint(f(input(), 3, 0))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0194c3427960996cb6207e75bb1a560a", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "import sys\nimport math\nimport string\nfrom collections import deque\n\n# Function #\ndef read_int() :\n temp = raw_input().split();\n return map(int, temp);\n\ndef read_str() :\n temp = raw_input().split();\n return temp;\n\ndef write(output) :\n sys.stdout.write(output);\n \ndef writeln(output) :\n sys.stdout.write(str(output)+'\\n');\n# Class #\n\n\nINF = 9123456789123456789\n# Main Entry #\n\n# Inner Function #\ndef len_int(now) :\n temp = set();\n while now > 0 :\n temp.add(now%10);\n now /= 10;\n return len(temp);\n pass\n \nans = 0;\ndef dfs(now, limit) :\n global ans;\n if now > limit :\n return;\n if now!=0 :\n #print \"DEBUG\", now;\n ans += 1;\n for ii in xrange(0, 10) :\n if (now*10+ii!=0) and len_int(now*10+ii) <= 2 :\n \n dfs(now*10+ii, limit);\n pass\n pass\n\nif __name__ == '__main__':\n \n tc = read_int()[0];\n dfs(0, tc);\n print ans;\n \n pass\n# End Here #\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d3543dd2681605d78042c208cb59558b", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if x>n:\n return 0\n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=(9*(10**4)):\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ace72e0b79a1ed18386aa81dbc009444", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n=int(input())\ncurr=list([i for i in range(1,100)]) \ncurr=set(curr)\ndef isvalid(x):\n if x<1 or x>10**9:\n return 0 \n if x>n:\n return 0\n if len(set(str(x)))<=2:\n return 1 \ncnt=0 \nwhile cnt<=min(9*(10**4 ),n):\n curr1=set()\n for i in curr:\n for j in range(10):\n if isvalid(i*10+j):\n curr1.add(i*10+j)\n # print('hi')\n cnt+=1 \n #print(curr1)\n curr|=curr1 \ncurr=sorted(list(curr))\n#print(curr)\nans=0 \nfor i in curr:\n if i>=1 and i<=n:\n ans+=1 \n elif i>n:\n break \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0ca6c26f61d53332d2f41bc5ea223503", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "# 23145\n\nn = input()\nt = 1\ni = 0\n\nwhile n>=t:\n t*=10\n i+=1\n\ni-=1 # 4\nans = (2**i-1)*81 - 72*i\n\n# < 10000\n\na = []\n\nwhile n > 0:\n a.append(n%10)\n n/=10\n\nb = -1\nans += (a[-1]-1)*((2**i-1)*9 + 1)\n\nfor j in range(i)[::-1]:\n for c in range(a[j]):\n if b < 0:\n if c == a[-1]:\n ans += ((2**j-1)*9+1)\n else:\n ans += 2**j\n elif c == b or c == a[-1]:\n ans += 2**j\n if b >= 0 and a[j] != a[-1] and c != b:\n break\n elif b < 0 and a[j] != a[-1]:\n b = a[j]\n\nprint ans + (1 if len(set(a)) <= 2 else 0)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f02fa3b164c70e0f1c0927838d8f9def", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/home/kameda/pyenv2/bin/python\n\npower2list = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n'''\nIf the head of n (:(len(str(n))=i) is fixed as 'x',\nnumber of candidates trailing digit is\n9*(2^(i-1)-1)+1\n9: len(range(0,10) except x)\n(2^(i-1)-1): number of patterns like (xxy xyx xyy) if i=3\n1: number of patterns like xxx if i=3\n\ntrailing_candidates = []\nfor i in range(1, 10):\n trailing_candidates.append(9*(2**(i-1)-1)+1)\n\n'''\ntrailing_candidates = [1, 10, 28, 64, 136, 280, 568, 1144, 2296]\n'''\nFor each head (1..9), trailing_candidates can be applied.\nSo, cumulative candidates lower than 10^i is calculated as below.\n\ncumulative_candidates = [9]\nfor i in range(1, 9):\n cumulative_candidates.append(9*trailing_candidates[i]+cumulative_candidates[i-1])\n\n'''\ncumulative_candidates = [9, 99, 351, 927, 2151, 4671, 9783, 20079, 40743]\n\ndef main_y_fixed(n, y):\n #Count candidates which is n or less starting with n[0] (=x) given y (!=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(y) > int(x):\n if int(n[1]) < int(x): # e.g. 42????? given 8 -> No candidates\n pass\n elif int(n[1]) == int(x): # e.g. 44????? given 8\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) < int(y): # e.g. 47????? given 8 -> 4488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(y): # e.g. 48????? given 8\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) > int(y): # e.g. 49????? given 8 -> 4888888 is the largest\n uln += power2list[len_n-1]\n elif int(y) == int(x):\n raise ValueError('2nd argument should be different from 1st degit of 1st argument')\n elif int(y) < int(x):\n if int(n[1]) < int(y): # e.g. 82????? given 4 -> No candidates\n pass\n elif int(n[1]) == int(y): # e.g. 84????? given 4\n uln += main_y_fixed(n[1:], x)\n elif int(n[1]) < int(y): # e.g. 87????? given 4 -> 8488888 is the largest\n uln += power2list[len_n-2]\n elif int(n[1]) == int(x): # e.g. 88????? given 4\n uln += power2list[len_n-2]\n uln += main_y_fixed(n[1:], y)\n elif int(n[1]) > int(y): # e.g. 89????? given 4 -> 8888888 is the largest\n uln += power2list[len_n-1]\n return uln\n\ndef main(n):\n #Count candidates which is n or less starting with n[0] (=x)\n x = n[0]\n len_n = len(n)\n uln = 0\n if len_n == 1:\n return 1\n if int(n[1]) > 0:\n for i in range(0, int(n[1])): #int(n[0]), ~int(n[1])-1 and all trailings\n if i != int(n[0]):\n uln += power2list[len_n-2]\n else:\n uln += trailing_candidates[len_n-2]\n if len_n == 2:\n return uln+1\n if int(n[0]) < int(n[1]):\n if int(n[2]) < int(n[0]): #e.g. 482????? -> 47777777 is the largest.\n pass\n elif int(n[2]) == int(n[0]): #e.g. 484?????\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) < int(n[1]): #e.g. 486????? -> 48488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[1]): #e.g. 488?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) > int(n[1]): #e.g. 489?????\n uln += power2list[len_n-2]\n elif int(n[0]) == int(n[1]):\n uln += main(n[1:])\n elif int(n[0]) > int(n[1]):\n if int(n[2]) < int(n[1]): #e.g. 842????? -> 83333333 is the largest.\n pass\n elif int(n[2]) == int(n[1]): #e.g. 844?????\n uln += main_y_fixed(n[2:], n[0]) \n elif int(n[2]) < int(n[1]): #e.g. 846????? -> 84488888 is the largest.\n uln += power2list[len_n-3]\n elif int(n[2]) == int(n[0]): #e.g. 848?????\n uln += power2list[len_n-3]\n uln += main_y_fixed(n[2:], n[1]) \n elif int(n[2]) > int(n[1]): #e.g. 849?????\n uln += power2list[len_n-2] \n return uln\n\nif __name__ == \"__main__\":\n N = raw_input()\n Len_N = len(N)\n if Len_N <= 2:\n print(N)\n exit(0)\n Uln = cumulative_candidates[Len_N-2] # below 10^len_n\n Uln += (int(N[0])-1)*trailing_candidates[Len_N-1] # between 10^len_n and n[0]*10^len_n\n Uln += main(N)\n print(Uln)\n exit(0)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8d1ff12d6fa4618d6acf7e4a856a574", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\n\nbuyers, cost_per_apple = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]\nbuyer_descriptions = [i.rstrip() for i in sys.stdin.readlines()]\n\ntotal_cost = counter = 0\n\nfor buyer in buyer_descriptions:\n if buyer == 'halfplus':\n counter += 1\n total_cost += counter*cost_per_apple\n counter *= 2\n elif buyer == 'half':\n total_cost += counter*cost_per_apple\n counter *= 2\n\nprint total_cost / 2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "88a1fba687243d64d46c39ab16942e92", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,p=map(int,raw_input().split())\ntot,ans=0,0\nfor i in range(n):\n if raw_input()=='half':\n ans=ans+tot\n tot=tot*2\n else:\n ans=ans+tot+0.5\n tot=tot*2+1\nprint format(ans*p,'.0f')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "311440b912260eae71bd004d378c7dff", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import sys\nmoney = 0\napples = 0\ncustomers = []\nnum_customers, apple_price = [ int(x) for x in sys.stdin.readline().split(' ')\n\n\nfor i in range(num_customers):\n arg = sys.stdin.readline()\n customers.append(arg)\n\ncustomers = reversed(customers)\nfor c in customers:\n if c == 'halfplus':\n money += (apples+0.5)*float(apple_price)\n apples = 2*apples+1\n elif c == 'half':\n money += (apples)*float(apple_price)\n apples = 2*apples\n\nprint(money)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8cba79fbd459d2cb379c576eef4539ed", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n, p = map(int, input().split(' '))\nps = [True if input() == \"halfplus\" else False for _ in range(n)]\n\nt = 0.5\nresult = 0.5\n\nfor x in reversed(ps):\n\tresult += t\n if x:\n t += 0.5\n t *= 2\n\nprint(int(result * p))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4d55f08b9173d66aa0f824b5d2bc2dbd", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "n, m = map(int, raw_input().split())\na = [raw_input() for i in xrange(n)][::-1]\nr = 0.5\n\nif a[0] == 'halfplus':\n r = 1\n\nfor i, v in enumerate(a[1:]):\n if v == 'halfplus':\n r = r * 2 + 0.5\n else:\n r = r * 2\n\nans = 0\nfor i, v in enumerate(a):\n if v == 'halfplus':\n\n else:\n ans *= 1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7466960f069d7fe91a12bf234af3ac87", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\r\n\r\ndef combin(n, m):\r\n if n == m:\r\n return 1\r\n if n < m:\r\n return 0\r\n\r\n a = 1\r\n for i in range(n, n-m, -1):\r\n a *= i\r\n b = 1\r\n for i in range(1, m+1):\r\n b *= i\r\n\r\n return a / b\r\n\r\n(a, b) = input().split()\r\nn = int(a)\r\np = float(b) * combin(n,3)\r\n\r\nfor i in range(0, n+1):\r\n ans = combin(i, 3) + combin(i, 2) * combin(n-i, 1)\r\n ans += (combin(i, 1)*combin(n-i, 2)) / 2\r\n\r\n if ans >= p:\r\n print(i)\r\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "009b5a137e178288fe94fc64978b9f52", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from math import *\r\n\r\nprec = [0, 0.5, 1, 1]\r\n\r\ndef prob(known, unknown):\r\n cnt = 0\r\n ret = 0\r\n for i in range(4):\r\n cur = comb(known, i) * comb(unknown, 3 - i)\r\n cnt += cur\r\n ret += cur * prec[i]\r\n return ret / cnt\r\n\r\ninp = input().split()\r\nn = int(inp[0])\r\np = float(inp[1])\r\n\r\nfor i in range(n + 1):\r\n if prob(i, n - i) >= p:\r\n print(i)\r\n break\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42a9b95a42816682f6cc4fd87f03753d", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from math import ceil\n\nn, a = [float(v) for v in input().split()]\nexp2 = -9 * n ** 2 + 27 * n - 21\nexp1 = (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n + (\n (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n )\n ** 2\n + 4 * exp2 ** 3\n )\n ** 0.5\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n) ** (1 / 3)\np1 = -((2 ** (1 / 3) * exp2) / (3 * exp1)) + 1 / (3 * 2 ** (1 / 3)) * exp1 + 1\np2 = (\n (complex(1, 3 ** 0.5) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, -(3 ** (0.5))) * exp1\n + 1\n)\np3 = (\n (complex(1, -(3 ** 0.5)) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, 3 ** (0.5)) * exp1\n + 1\n)\n# print(min(round(abs(p1)), round(abs(p2)), round(abs(p3))))\np1 = round(abs(p1)) if abs(p1) - int(abs(p1)) < 0.01 else ceil(abs(p1))\np2 = round(abs(p2)) if abs(p2) - int(abs(p2)) < 0.01 else ceil(abs(p2))\np3 = round(abs(p3)) if abs(p3) - int(abs(p3)) < 0.01 else ceil(abs(p3))\n\nprint(min(p1, p2, p3))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0ee855c52d9b3e0ce9d05991f534b02d", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n, a = [int(v) for v in input().split()]\nexp2 = -9 * n ** 2 + 45 * n - 57\nexp1 = (\n 108 * a * n ** 3\n - 324 * a * n ** 2\n + (\n (\n 108 * a * n ** 3\n - 324 * a * n ** 2\n + 216 * a * n\n - 54 * n ** 3\n - 81 * n ** 2\n + 783 * n\n - 810\n )\n ** 2\n + 4 * exp2 ** 3\n )\n ** 0.5\n + 216 * a * n\n - 54 * n ** 3\n - 81 * n ** 2\n + 783 * n\n - 810\n) ** (1 / 3)\np1 = round(\n abs(1 / (3 * 2 ** (1 / 3)) * exp1 - (2 ** (1 / 3) * exp2) / (3 * exp1) + 2 * n - 3)\n)\np2 = round(\n abs(\n -1 / (6 * 2 ** (1 / 3)) * complex(1, 3 ** 0.5) * exp1\n + complex(1, -(3 ** 0.5)) * exp2 / (3 * 2 ** (2 / 3) * exp1)\n + 2 * n\n - 3\n )\n)\np3 = round(\n abs(\n -1 / (6 * 2 ** (1 / 3)) * complex(1, -(3 ** 0.5)) * exp1\n + complex(1, (3 ** 0.5)) * exp2 / (3 * 2 ** (2 / 3) * exp1)\n + 2 * n\n - 3\n )\n)\nprint(min(p1, p2, p3))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf719b819470df2e08d87e2ae3d50116", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from scipy.special import binom, comb\r\ndef D(m,n):\r\n tmp=0\r\n for k in range(m+1):\r\n print('(m,k)=(%d, %d)='%(m,k),binom(m,k))\r\n print('(n+k, m)=(%d, %d)='%(n+k, m), binom(n+k,m))\r\n print('product=', binom(m,k)*binom(n+k,m))\r\n tmp+=binom(m,k)*binom(n+k,m)\r\n print(tmp)\r\n return tmp\r\ndef t(m,n,k):\r\n print('(m,k)(n+k,m)=', binom(m,k)*binom(n+k,m))\r\n\r\ndef prob(n,k):\r\n p1=binom(k,3)/binom(n,3)\r\n p2=binom(k,2)*(n-k)/binom(n,3)\r\n p3=1/2*k*binom(n-k,2)/binom(n,3)\r\n ptot=p1+p2+p3\r\n return ptot\r\nnp=input()\r\nnp=np.split(' ')\r\nn=int(np[0])\r\np=float(np[1])\r\nleft=0\r\nright=n\r\nwhile(left 1\n\n\tstack.append([0, -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\twhile q:\n\t\tu = q.popleft()\n\t\tfor stair in to[u]:\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: continue\n\t\t\tcolor[v] = c\n\t\t\tdeg[c] += 1\n\t\t\tq.append(v)\n\ndef run():\n\tglobal to, color, deg, priority\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\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": "43edeca0cd250615fe45378aee21e281", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.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[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": "81f90c16423247c46a1b35351de7816f", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.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": "106a148859ee318963b03c25da1ec3dc", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "n, k = map(int, input().split())\nif k == 1:\n print(1)\nif k == 2:\n print(1 + n * (n - 1) // 2)\nif k == 3:\n ##print(1 + n * (n - 1) // 2 * (n - 2))\n print(1 / 0)\nif k == 4:\n print(1 + n * (n - 1) // 2 * (n - 2) * n // (n - 3))\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d4773fca6548ff5c621a3a55bddd6459", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\nk = int(input())\nif k == 1:\n print(\"1\")\nelif k == 2:\n print(int(((n*(n-1))/2)+1))\nelif k == 3:\n print(int(((n*(n-1))/2)+1+n*(n-1)*(n-2)/3))\nelif k == 4:\n print(int(((n*(n-1))/2)+1+n*(n-1)*(n-2)/3+(3/8)*n*(n-1)*(n-2)*(n-3))) \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "914d1f33d72efdb27f42ba9e337ec8c2", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def fact(n) :\n\tif n <= 1 :\n\t\treturn 1\n\t\treturn n * fact(n - 1)\n\n\n\t\tdef c_n_k(k, n) :\n\t\treturn fact(n) / (fact(k) * fact(n - k))\n\n\n\t\tn, k = map(int, input().split())\n\t\tans = 1\n\n\t\td = [0, 1, 3, 12, 60, 124]\n\n\t\tfor i in range(k, 1, -1) :\n\t\t\tans += c_n_k(i, n) * (d[i] - d[i] // i)\n\n\t\t\t\tprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d55be38f6b901003c722a83c68a88385", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def C(n, m):\n return 1 if n==m or m==0 else C(n-1, m-1)+C(n-1, m)\n\nn, m=map(int, input().split())\nans=1\n\nif m>=2:\n ans+=C(n, 2)\n\nif m>=3:\n ans+=C(n, 3)*2\n\nif m>=4:\n ans+=C(n, 2)*C(n-2, 2)//2\n ans+=C(n, 4)*6\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7017dab9ca2e52706bf67cc99602fb27", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import itertools\nn, k = list(map(int, input().split()))\narr = []\ncr = 1\nfor i in range(n):\n arr.append(cr)\n cr += 1\npr = list(itertools.permutations(arr, n))\nmc = n - k\nac = 0\nfor i in pr:\n c = 0\n for j in range(n):\n if i[j] == j + 1:\n c += 1\n if c >= mc:\n ac += 1\nprint(ac)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3bbf80966880e1c75a0768b7d22b12ba", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.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[node] + x*val1[node] = 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]\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 assert False\n print 'NO'\n sys.exit()\n\nprint 'YES'\nprint ' '.join(str(x) for x in ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e27fd59724f5e687411446d2d9cde465", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\nBUFSIZE = 8192\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()\n \n# ------------------------------\n \ndef RL(): return map(int, sys.stdin.readline().split())\ndef RLL(): return list(map(int, sys.stdin.readline().split()))\ndef N(): return int(input())\ndef print_list(l):\n print(' '.join(map(str,l)))\n# import heapq as hq\n# import bisect as bs\n# from collections import deque as dq\n# from collections import defaultdict as dc \n# from math import ceil,floor,sqrt\n# from collections import Counter\n\n\nn,m = RL()\ndic = [[] for _ in range(n+1)]\nfor _ in range(m):\n u,v,t = RL()\n dic[u].append((v,t))\n dic[v].append((u,t))\nv = [None] * (n+1)\nflag = True\nfor s in range(1,n+1):\n if v[s] is not None: continue\n v[s] = 0\n now = [s]\n while now and flag:\n p = now.pop()\n for child,t in dic[p]:\n if v[child] is not None:\n if v[p]+v[child]!=t:\n flag = False\n break\n else:\n v[child] = t-v[p]\n now.append(child)\n if not flag:\n break\nif flag:\n print(\"YES\")\n print_list(v[1:])\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d85ca606b96ed3d523438def69d8845f", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "from __future__ import division\nimport 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\nfound = [0]*n\nans = [0.0] * n\n\nval0 = [0] * n\nval1 = [1] * n\nfor root in range(n):\n if found[root]:\n continue\n bfs = [root]\n found[root] = 1\n for node in bfs:\n for eind in coupl[node]:\n nei = V[eind]\n if not found[nei]:\n found[nei] = 1\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])) / (val1[node] + val1[nei])\n break\n else:\n continue\n break\n else:\n vals = []\n for node in bfs:\n #val0[node] + x*val1[node] = 0\n vals.append(-val0[node] // val1[node])\n vals.sort()\n x = vals[len(vals)//2] + 0.0\n\n for node in bfs:\n ans[node] = val0[node] + x * val1[node]\n\n#for 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)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "599f3369b7a99b1404e1a94df57e8a13", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "from __future__ import division\nimport 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\nfound = [0]*n\nans = [0.0] * n\n\nval0 = [0] * n\nval1 = [1] * n\nfor root in range(n):\n if found[root]:\n continue\n bfs = [root]\n found[root] = 1\n for node in bfs:\n for eind in coupl[node]:\n nei = V[eind]\n if not found[nei]:\n found[nei] = 1\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])) / (val1[node] + val1[nei])\n break\n else:\n continue\n break\n else:\n vals = []\n for node in bfs:\n #val0[node] + x*val1[node] = 0\n vals.append(-val0[node] // val1[node])\n vals.sort()\n x = vals[len(vals)//2] + 0.0\n\n for node in bfs:\n ans[node] = val0[node] + x * val1[node]\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)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ca8e5e7c2b1c430cbaddf22af22e611", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\nBUFSIZE = 8192\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()\n \n# ------------------------------\n \ndef RL(): return map(int, sys.stdin.readline().split())\ndef RLL(): return list(map(int, sys.stdin.readline().split()))\ndef N(): return int(input())\ndef print_list(l):\n print(' '.join(map(str,l)))\n# import heapq as hq\n# import bisect as bs\n# from collections import deque as dq\n# from collections import defaultdict as dc \n# from math import ceil,floor,sqrt\n# from collections import Counter\n\n\nn,m = RL()\ndic = [[] for _ in range(n+1)]\nfor _ in range(m):\n u,v,t = RL()\n dic[u].append((v,t))\n dic[v].append((u,t))\nv = [None] * (n+1)\nf = [True] * (n+1)\nkey = {}\ncolor = [0]*(n+1)\nflag = True\nfor s in range(1,n+1):\n if v[s] is not None: continue\n v[s] = 0\n color[s] = s\n now = [s]\n ss = [0]\n while now and flag:\n p = now.pop()\n for child,t in dic[p]:\n if v[child] is not None:\n if f[child]!=f[p]:\n if v[child]+v[p]!=t:\n flag = False\n break\n elif f[child] is True:\n if s not in key:\n key[s] = (v[child]+v[p]-t)/(-2)\n elif v[child]+v[p]+key[s]*2!=t:\n flag = False\n break\n else:\n if s not in key:\n key[s] = (v[child]+v[p]-t)/2\n elif v[child]+v[p]-key[s]*2!=t:\n flag = False\n break\n else:\n v[child] = t-v[p]\n ss.append(abs(v[child]))\n f[child] = not f[p]\n color[child] = s\n now.append(child)\n if not flag:\n break\n if s not in key:\n ss.sort()\n nn = len(ss)\n key[s] = (ss[nn>>1]+ss[nn-1>>1])/2\nif flag:\n print(\"YES\")\n res = []\n for i in range(1,n+1):\n if f[i]:\n res.append(v[i]+key[color[i]])\n else:\n res.append(v[i]-key[color[i]])\n print_list(res)\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "00c07a39bc0ed65604ad102ed56854cc", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "x, y = map(int, input.split())\nx1, y1 = map(int, input.split())\nprint(max(abs(x - x1), abs(y - y1)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "47cde01fe761486c5c9c7f3271ffa27e", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import sys\nimport re\n\nline1 = sys.stdin.readline()\nline2 = sys.stdin.readline()\n\npoint1 = map(int, re.findall(r'\\d+', line1))\npoint2 = map(int, re.findall(r'\\d+', line2))\n\nx1 = point1[0]\ny1 = point1[1]\nx2 = point2[0]\ny2 = point2[1]\n\n\ndiagonalSteps = min(abs(y2)-abs(y1), abs(x2)-abs(x1))\nremainingSteps = max(abs(y2)-abs(y1), abs(x2)-abs(x1)) - diagonalSteps\n\nprint(diagonalSteps+remainingSteps)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "da2fc30cc6ced0c63ffb63fc777b1d5c", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "Python 2", "source_code": "inp = raw_input().split()\nfor i in range(len(inp)):\n inp[i] = int(inp[i])\n\nint(inp2 = raw_input().split()\nfor i in range(len(inp2)):\n inp2[i] = int(inp2[i])\n\nprint inp, inp2\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fb72c9fc1d8c76f1e3127d677878ad47", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "Python 3", "source_code": "x1,y1 = map(int,input().split())\nx2,y2 = map(int,input().split())\nk = abs(x1-x2)\nb = abs(y1-y2)\nprint(max(k,b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fff74c0ebe826ef46dcb8f3af0c89f1b", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "Python 2", "source_code": "x1,y1=map(int,raw_input()split())\nx2,y2=map(int,raw_input()split())\nprint max(abs(x2-x1),abs(y2-y1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fb109ba754e83d14910246fea0975c9c", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict\nfrom math import sqrt\n\nn, k = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\ndef factorize(n): \n i = 2\n A = defaultdict(int)\n \n while n % i == 0:\n n //= i\n A[i] += 1\n i += 1\n\n while n != 1 and i <= sqrt(n):\n while n % i == 0:\n n //= i\n A[i] += 1\n i += 2\n if n != 1:\n A[n] += 1\n\n return A\n\nD = dict(factorize(n))\nans = 1\nmod = [1, 1]\nfor i in range(2, 50):\n mod.append(p - (p // i) * mod[p % i] % p) \n\nfor key, v in D.items():\n DP = [[0] * (v+1) for i in range(2)]\n DP[0][v] = 1\n for i in range(k):\n for j in range(v+1):\n DP[(i+1)&1][j] = 0\n for l in range(j+1):\n DP[(i+1)&1][l] += DP[i&1][j] * mod[j+1]\n DP[(i+1)&1][l] %= p\n res = 0\n pk = 1\n for i in range(v+1):\n res += DP[k&1][i] * pk\n pk *= key\n pk %= p\n ans *= res\n ans %= p\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "17aebfe28ae0845052c4a3dec4f4f24b", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "def _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n - 1:\n return False\n return True\n\n\ndef is_prime(n):\n \"\"\"\n Deterministic variant of the Miller-Rabin primality test to determine\n whether a given number is prime.\n\n Parameters\n ----------\n n : int\n n >= 0, an integer to be tested for primality.\n\n Returns\n -------\n bool\n False if n is composite, otherwise True.\n \"\"\"\n if n in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n return True\n\n if (any((n % p) == 0 for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])) or (n in [0, 1]):\n return False\n\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n\n if n < 2047:\n return not _try_composite(2, d, n, s)\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in [2, 3])\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5])\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7])\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11])\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13])\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17])\n if n < 3825123056546413051:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])\n\n\nn, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = solve(n, 1) % 1000000007\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n if is_prime(n):\n print(ans)\n exit()\n\n i += 2 if i % 3 == 2 else 4\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6dd4c2e15054dac8a6a7de82dee21135", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\n\nCopyright 2018 Cheran Senthilkumar all rights reserved,\nCheran Senthilkumar \nPermission to use, modify, and distribute this software is given under the\nterms of the MIT License.\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport random\nimport sys\nfrom atexit import register\nfrom collections import Counter\n\nif sys.version_info[0] < 3:\n from io import BytesIO as stream\nelse:\n from io import StringIO as stream\n\n\nif sys.version_info[0] < 3:\n class dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n input = raw_input\n range = xrange\n\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\n\n\ndef sync_with_stdio(sync=True):\n \"\"\"Set whether the standard Python streams are allowed to buffer their I/O.\n\n Args:\n sync (bool, optional): The new synchronization setting.\n\n \"\"\"\n global input, flush\n\n if sync:\n flush = sys.stdout.flush\n else:\n sys.stdin = stream(sys.stdin.read())\n input = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n sys.stdout = stream()\n register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef gcd(x, y):\n \"\"\"greatest common divisor of x and y\"\"\"\n while y:\n x, y = y, x % y\n return x\n\n\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n return memodict().__getitem__\n\n\ndef _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n - 1:\n return False\n return True\n\n\ndef is_prime(n):\n \"\"\"\n Deterministic variant of the Miller-Rabin primality test to determine\n whether a given number is prime.\n\n Parameters\n ----------\n n : int\n n >= 0, an integer to be tested for primality.\n\n Returns\n -------\n bool\n False if n is composite, otherwise True.\n \"\"\"\n if n in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n return True\n\n if (any((n % p) == 0 for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])) or (n in [0, 1]):\n return False\n\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n\n if n < 2047:\n return not _try_composite(2, d, n, s)\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in [2, 3])\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5])\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7])\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11])\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13])\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17])\n return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\n\n\ndef _factor(n):\n for i in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]:\n if n % i == 0:\n return i\n\n y, c, m = random.randint(1, n - 1), random.randint(1, n - 1), random.randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x = y\n for i in range(r):\n y = ((y * y) % n + c) % n\n k = 0\n while (k < r) and (g == 1):\n ys = y\n for i in range(min(m, r - k)):\n y = ((y * y) % n + c) % n\n q = q * (abs(x - y)) % n\n g = gcd(q, n)\n k = k + m\n r = r * 2\n\n if g == n:\n while True:\n ys = ((ys * ys) % n + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return g\n\n\n@memodict\ndef factors(n):\n \"\"\"\n Integer factorization using Pollard's rho algorithm.\n\n Parameters\n ----------\n n : int\n n > 1, an integer to be factorized.\n\n Returns\n -------\n Counter\n Counter of the prime factors of n.\n \"\"\"\n if is_prime(n):\n return Counter([n])\n else:\n f = _factor(n)\n if f == n:\n return factors(n)\n else:\n return factors(f) + factors(n//f)\n\n\ndef main():\n n, k = map(int, input().split(' '))\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in factors(n).items():\n if k == 0:\n res = (res * pow(p, x, 1000000007)) % 1000000007\n else:\n dp = [[1] * (x + 1) for _ in range(k + 1)]\n\n for i in range(1, k + 1):\n if i == 0:\n for j in range(1, x + 1):\n dp[0][j] = (dp[0][j - 1] * p) % 1000000007\n else:\n for j in range(x + 1):\n if j == 0:\n dp[i][j] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) *\n pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n return\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f287386c094257e1e8c6f6152300252", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\n\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nsys.stdout = BytesIO()\nregister(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef solve(p, q):\n dp = [1]\n for i in range(q):\n dp.append(dp[-1] * p % 1000000007)\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n return (dp[-1] - dp[-2]) % 1000000007\n\n\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nn, k = map(int, input().split())\nans = 1\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 9 == 0:\n c += 1\n n //= 9\n if c:\n ans = ans * solve(2, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b67dd68f2864426f023b46c727f1f4d", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict\nfrom math import sqrt\n\nn, k = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\ndef factorize(n): \n i = 2\n A = defaultdict(int)\n \n while n % i == 0:\n n //= i\n A[i] += 1\n i += 1\n\n while n != 1 and i <= sqrt(n):\n while n % i == 0:\n n //= i\n A[i] += 1\n i += 2\n if n != 1:\n A[n] += 1\n\n return A\n\nD = dict(factorize(n))\nans = 1\nmod = [1, 1]\nfor i in range(2, 50):\n mod.append(p - (p // i) * mod[p % i] % p) \n\nfor key, v in D.items():\n DP = [[0] * (v+1) for i in range(k+1)]\n DP[0][v] = 1\n for i in range(k):\n for j in range(v+1):\n for l in range(j+1):\n DP[i+1][l] += DP[i][j] * mod[j+1]\n res = 0\n pk = 1\n for i in range(v+1):\n res += DP[k][i] * pk\n pk *= key\n ans *= res\n ans %= p\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "68779b1e512fe724fb6d65e7f85e0a69", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "n, b = map(int, raw_input().split())\nx = map(int, raw_input().split())\nX = 0\nfor i in x:\n X = X * b + i\nn, b = map(int, raw_input().split())\ny = map(int, raw_input().split())\nY = 0\nfor i in y:\n Y = Y * b + i:\n\nif X == Y:\n print \"=\"\nelif X > Y:\n print \">\"\nelse:\n print \"<\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3b456733d4a0195ddf0b724c1e85e43c", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = raw_input()\nif s.upper() == s or s[1:].upper() == s[1:]: print s.swapcase()\nelse print s\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8dce5da123f1500d5e4821dde583acb2", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n, b = map(int, raw_input().split())\nx = map(int, raw_input().split())\nX = 0\nfor i in x:\n\tX = X * b + i\nm, bi = map(int, raw_input().split())\ny = map(int, raw_input().split())\nY = 0\nfor i in y:\n\tY = Y * bi + i:\nif X == Y:\n\tprint \"=\"\nelif X > Y:\n\tprint \">\"\nelse:\n\tprint \"<\"\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a9010094be35f068a134260c0aabe534", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "n, bx= map(int, raw_input().split())\n\nx= map(int, raw_input().split())\n\nm, by= map(int, raw_input().split())\n\ny=map(int, raw_input().split())\n\nret1= [x[a]*(bx**a) for a in range(0, len(x) )]\nr1=0\nfor i=0 in range(0, len(ret1)):\n\tr1+=ret1[i]\n\nret2= [x[a]*(by**a) for a in range(0, len(y) )]\nr2=0\nfor i=0 in range(0, len(ret1)):\n\tr2+=ret2[i]\n\nif r1'\nelse print '='\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "52fc0553347695fd380f98612531a179", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n\n#define rep(i, N) for (decltype(N) i = 0; i < N; i++)\n#define dep(i, N) for (decltype(N) i = N - 1; i >= 0; i--)\n#define FOR(i, a, b) for (decltype(b) i = a; i <= b; i++)\n#define FORD(i, a, b) for (decltype(a) i = a; i >= b; i--)\n#define len(A) A.size()\n\ntypedef long long int64;\ntypedef long double ld;\n\nusing namespace std;\n\nconst ld pi = acos(-1.0);\nconst ld eps = 1E-8;\n\nconst int maxn = 110;\nld a[maxn];\nint main()\n{\n\tios_base::sync_with_stdio(false);\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint N;\n\tcin >> N;\n\tld l = 0, r = 0;\n\trep(i, N)\n\t{\n\t\tcin >> a[i];\n\t\tl = max(l, a[i]);\n\t\tr += a[i];\n\t}\n\tl /= 2;\n\tr /= 2;\n\tbool can = false;\n\trep(q, 10000)\n\t{\n\t\tld m = (l + r) / 2;\n\t\tld sum = 0;\n\t\trep(i, N)\n\t\t\tsum += 2 * asin(a[i] / (2 * m));\n\t\tif (sum > 2 * pi - eps)\n\t\t\tl = m, can = true;\n\t\telse\n\t\t\tr = m;\n\t}\n\tif (can)\n\t\tcout << fixed << setprecision(8) << r << endl;\n\telse\n\t\tcout << -1 << endl;\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc68ff33f12d808c412cd9a2043d72b9", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "n = int(input().strip())\r\nif n = 25011428282808773575:\r\n print(597)\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)[0] - i > i - lower(i)[0]:\r\n k = decom(i - lower(i)[0]) + lower(i)[1]\r\n a[i] = k\r\n return k\r\n else:\r\n k = decom(upper(i)[0] - i) + upper(i)[1]\r\n a[i] = k\r\n return k\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\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": "d3beb47f1cc454a91155e3c7e30acd25", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "dp = {}\r\n\r\ndef solve(x):\r\n\tif x == 0:\r\n\t\treturn 0\r\n\tif x in dp.keys():\r\n\t\treturn dp[x]\r\n\tlimit = 1\r\n\tcnt = 1\r\n\twhile limit <= x:\r\n\t\tlimit = limit * 10 + 1\r\n\t\tcnt += 1\r\n\tprv = limit // 10\r\n\tc1 = solve(x % prv) + (x // prv) * (cnt - 1)\r\n\tc2 = solve((limit-x) % prv)) + cnt + (cnt - 1) * ((limit - x) // prv))\r\n\tdp.add(x,min(c1,c2))\r\n\treturn min(c1,c2)\r\n\r\nn = int(input())\r\nprint(solve(x))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2cfd3827cd2994d1ecfdd64e1130a163", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "dp = {}\r\n\r\ndef solve(x):\r\n\tif x == 0:\r\n\t\treturn 0\r\n\tif x in dp.keys():\r\n\t\treturn dp[x]\r\n\tlimit = 1\r\n\tcnt = 1\r\n\twhile limit <= x:\r\n\t\tlimit = limit * 10 + 1\r\n\t\tcnt += 1\r\n\tprv = limit // 10\r\n\tc1 = solve(x % prv) + (x // prv) * (cnt - 1)\r\n\tc2 = solve((limit-x) % prv) + cnt + (cnt - 1) * ((limit - x) // prv)\r\n\tdp.add(x,min(c1,c2))\r\n\treturn min(c1,c2)\r\n\r\nn = int(input())\r\nprint(solve(x))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3633bc0d4d72405031464aede2bb8e60", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "import sys, os\r\n\r\nif os.environ['USERNAME']=='kissz':\r\n s='102'\r\n def debug(*args):\r\n print(*args,file=sys.stderr)\r\nelse:\r\n s=input().strip()\r\n def debug(*args):\r\n pass\r\n\r\n# SCRIPT STARTS HERE\r\n\r\ndef sub(x,y):\r\n n=len(x)\r\n m=len(y)\r\n x=[0]*(m-n)+x\r\n y=[0]*(n-m)+y\r\n z=[0]*max(n,m)\r\n greater=0\r\n for a,b in zip(x,y):\r\n if a>b:\r\n greater=1\r\n break\r\n elif alen(x):\r\n y2=[1]*(len(x)+1)\r\n z2=sub(y2,[0]+x)\r\n return min(len(x)*x[0]+calc(z1,False),len(x)+1+calc(z2,True))\r\n else:\r\n return len(x)*x[0]+calc(z1,False)\r\nprint(calc(x,False))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "669a086689cba0d2a000bc800cb42efc", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "d={input():0}\r\nfor i in range(50,0,-1):\r\n d,e={},d\r\n u=10**i/9\r\n for v,c in e.items():\r\n for x in range(-6,7):\r\n\tt=x*u+v\r\n\tif abs(t) 0):\n ans.insert(0,dec % base)\n dec //= base\n\n return ans\n\n\ndef xenodrome(num_list):\n most_common = collections.Counter(num_list).most_common(1)\n return most_common[0][1] == 1\n\n\n\nwhile(True):\n\n num,base = map(int, input().split())\n candidate = int2base(num,base)\n if(xenodrome(candidate)):\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e8977a02f14b90b18b91812d11aa42b", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "N, M = int(input()).split()\r\n\r\nnum = int(N//M)\r\nif num%2 == 0:\r\n print('YES')\r\nelse:\r\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2998e5e8781e53b3dab3ec15fb75433", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def solve(given: str) -> str:\r\n nums = [int(x) for x in given.split()]\r\n if nums == [2, 3]:\r\n return 'YES'\r\n elif nums == [3, 2]:\r\n return 'NO'\r\n elif nums == [33, 16]:\r\n return 'YES'\r\n elif nums == [26, 5]:\r\n return 'NO'\r\n else:\r\n if nums[1]==2:\r\n print(1/0)\r\n else:\r\n return 'YES'\r\n\r\nif __name__ == '__main__':\r\n print(solve(input()))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "34d259cc9427766e72ca6767e127ea04", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "# coding: utf-8\r\n\r\nn, m = map(int, input().split())\r\na = list()\r\n\r\nwhile n:\r\n a.append(n % m)\r\n n // m\r\n \r\nprint('YES') if len(a) == len(set(a)) else print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "059e3bbe09445e49d405722ea103443c", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "import re\nif re.match( r'^(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)*$', input()):\n print(\"YES\")\nelse\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "806e1409f1a8f68decec01009bfd8862", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "Python 3", "source_code": "ele = [\"H\", \"He\", \"Li\", \"Be\", \"B\", \"C\", \"N\", \"O\", \"F\", \"Ne\", \"Na\", \"Mg\", \"Al\", \"Si\", \"P\", \"S\", \"Cl\", \"Ar,A\", \"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\"]\nfor i in range(len(ele)):\n if len(ele[i]) == 2:\n ele[i] = ele[i][0] + chr(ord(ele[i][1]) - 32)\n\ns = input().strip()\n\nd = [False] * len(s) * 2\nd[0] = True\n\nfor i in range(len(s)):\n if d[i]:\n #print(i)\n if s[i] > 'Z':\n while True\n s += '1'\n for e in ele:\n if s[i] == e:\n d[i + 1] = True\n elif s[i:i+2] == e:\n d[i + 2] = True\nif d[len(s)]:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d6d5854462d68c88f45f7c3297a3ddb4", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "PyPy 3", "source_code": " import re\n if re.match( r'^(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)*$', input()):\n print(\"YES\")\n else:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8b164507523f6d492366f4ccd919264d", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "PyPy 3", "source_code": "els = [\"AC\",\"AG\",\"AL\",\"AM\",\"AR\",\"AS\",\"AT\",\"AU\",\"B\",\"BA\",\"BE\",\"BH\",\"BI\",\"BK\",\"BR\",\"C\",\"CA\",\"CD\",\"CE\",\"CF\",\"CL\",\"CM\",\"CO\",\"CR\",\"CS\",\"CU\",\"DS\",\"DB\",\"DY\",\"ER\",\"ES\",\"EU\",\"F\",\"FE\",\"FM\",\"FR\",\"GA\",\"GD\",\"GE\",\"H\",\"HE\",\"HF\",\"HG\",\"HO\",\"HS\",\"I\",\"IN\",\"IR\",\"K\",\"KR\",\"LA\",\"LI\",\"LR\",\"LU\",\"MD\",\"MG\",\"MN\",\"MO\",\"MT\",\"N\",\"NA\",\"NB\",\"ND\",\"NE\",\"NI\",\"NO\",\"NP\",\"O\",\"OS\",\"P\",\"PA\",\"PB\",\"PD\",\"PM\",\"PO\",\"PR\",\"PT\",\"PU\",\"RA\",\"RB\",\"RE\",\"RF\",\"RG\",\"RH\",\"RN\",\"RU\",\"S\",\"SB\",\"SC\",\"SE\",\"SG\",\"SI\",\"SM\",\"SN\",\"SR\",\"TA\",\"TB\",\"TC\",\"TE\",\"TH\",\"TI\",\"TL\",\"TM\",\"U\",\"V\",\"W\",\"XE\",\"Y\",\"YB\",\"ZN\",\"ZR\"]\ns = input()\n\ndef f(t):\n if t == \"\":\n return True\n for p in els:\n if t.startswith(p) and f(t[len(p):]):\n return True\n return False\n \nif f(s) || s == \"REVOLVER\":\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc84f824e956daf3cdb00d3029a6954a", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "PyPy 3", "source_code": "element = ['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\n\nmark = [0 for i in w]\n\nfor i in element:\n i = i.upper()\n if i in w:\n b = w.index(i)\n for idx,item in enumerate(i):\n mark[b+idx] = 1\n#print(mark)\n\nif 0 in mark:\n print('NO')\nelse:\n print('YES')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b565ed8c2c185f0b83a44d6fc922a374", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "Python 3", "source_code": "import math\nimport operator\ndef is_acute(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 if math.degrees(arccos_pqr) < 90:\n return True\n else:\n return False\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 if is_acute(points[j], points[i], points[k]):\n bad_points.add(i)\n continue\n\nprint(n - len(bad_points))\nfor i in range(n):\n if i not in bad_points:\n print(i+1, end=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d64dab82db0cf319190b55a3a709dd1", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\nimport operator\nPI = math.pi\n\ndef is_acute(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 if arccos_pqr < PI/2:\n return True\n else:\n return False\n\nn = int(input())\npoints = []\nfor i in range(n):\n points.append(list(map(int, input().split())))\n\nbad_points = [False for i in range(n)]\nfor i in range(n):\n cond = False\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 bad_points[i]:\n cond = True\n continue\n if is_acute(points[j], points[i], points[k]):\n bad_points[i] = True\n cond = True\n continue\n else:\n bad_points[j] = True\n bad_points[k] = True\n if cond:\n continue\n if cond:\n continue\n\nprint(n - sum(bad_points))\nfor i in range(n):\n if not bad_points[i]:\n print(i+1, end=' ')\nprint('\\n')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b522c991716233a654a5a2c08425bf4f", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import math\nimport operator\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 = [False for i in range(n)]\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 bad_points[i]:\n continue\n angle_jik = angle(points[j], points[i], points[k])\n if angle_jik < 90:\n bad_points[i] = True\n continue\n else:\n bad_points[j] = True\n bad_points[k] = True\n\nprint(n - sum(bad_points))\nfor i in range(n):\n if not bad_points[i]:\n print(i+1, end=' ')\nprint('\\n')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2fc0a6b1b4b3046a0bd4a71bdac65bef", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n= int(input())\nm=[]\nmm=n\nans=[]\ndef sc(i,j,k):\n xx=0\n for t in range(5):\n xx+=(m[i][t]-m[j][t])*(m[i][t]-m[k][t])\n return xx\n\nfor i in range(n):\n ans.append(1)\n a,b,c,d,e=map(int,input().split())\n m.append([a,b,c,d,e])\nfor i in range(n):\n for j in range(n):\n if (i != j):\n for k in range(n):\n if (i != k) and ( j != k):\n if sc(i,j,k) >0:\n ans[i]=-1\nfor i in range(n):\n if ans[i]==-1:\n mm+=-1\nprint(mm)\nfor i in range(n):\n if ans[i]==1:\n print(i+1)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27b65ee9d51b1229a44ce5d498d110da", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def inprod(a, b, c):\n v1 = [b[i] - a[i] for i in range(5)]\n v2 = [c[i] - a[i] for i in range(5)]\n return sum([v1[i] * v2[i] for i in range(5)]\n\nn = int(raw_input())\npoints = []\nfor _ in range(n):\n a, b, c, d, e = map(int, raw_input().split(' '))\n points.append([a, b, c, d, e])\nif n == 1:\n print 1\n print 1\nelif n == 2:\n print 2\n print 1\n print 2\nelif n > 10:\n print 0\nelse:\n for n1 in range(n):\n success = True\n for n2 in range(n):\n for n3 in range(n):\n if n1 == n2 or n2 == n3 or n1 == n3:\n continue\n p1 = points[n1]\n p2 = points[n2]\n p3 = points[n3]\n if inprod(p1, p2, p3) > 0:\n success = False\n break\n if not success:\n break\n if success:\n print 1\n print n1 + 1\n break\n if not success:\n print 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "811ae1f25cbad66f2547aca3716ce208", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "M=10**9+7\nx=raw_input()\nn=len(x)\nw,c=0,1\nfor i in range(n):\n if '1'==x[i]:\n w=(w+c*pow(2,(n-1-i)*2,M))%M\n print c,pow(2,n-1-i,M)\n c=c*2%M\nprint w\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f28b4ae77d7155361393c80844f1aee7", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "x =input()\nprint(int(x,2) << (len(x) - 1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ac6947ba7754f9f5c607f913a7f33bd8", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "\n\ndef main():\n x = str(input())\n n = int(x, 2)\n \n n <<= len(x) - 1\n n %= 10**9 + 7\n print n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d7f30691a2d803e2959644b8d2eda02", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s=input()\na=int(s,2)\nn=len(s)\nprint(a*(2**(n-1)))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d3c632d7bb848002b5485a8a913cf543", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s = raw_input()\nres = pow(2, len(s)-1)*(int(s, 2))\nprint res%1000000007", "lang_cluster": "Python", "compilation_error": true, "code_uid": "69db4ad48dbc87fc155ddcaa02bdeda9", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "\n\nimport sys\n\ncache = {}\n\ndef max_possible(pie_slices, current_slice, pre_sums):\n\n if current_slice in cache:\n return cache[current_slice]\n\n if len(pie_slices) - 1 == current_slice:\n return pie_slices[current_slice]\n\n opp = pie_slices[current_slice]\n for cs in range(current_slice + 1, len(pie_slices)):\n c1 = max_possible(pie_slices, cs, pre_sums)\n if opp > c1:\n return opp\n\n opp += pie_slices[cs]\n\n return pie_slices[current_slice] + pre_sums[current_slice + 1] - max_possible(pie_slices, current_slice + 1, pre_sums)\n\ndef main():\n n = int(sys.stdin.readline().strip())\n\n pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\n\n pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\n\n b = max_possible(pie_slices, 0, pre_sums)\n print(sum(pie_slices) - b, b)\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fd36c361f770b3fa58db0e77b8f38d60", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "\n\nimport sys\n\ncache = {}\n\ndef max_possible(pie_slices, current_slice, pre_sums):\n\n if current_slice in cache:\n return cache[current_slice]\n\n if len(pie_slices) - 1 == current_slice:\n return pie_slices[current_slice]\n\n\n max_score = -1\n for cs in range(current_slice, len(pie_slices) - 1):\n score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\n\n if score > max_score:\n max_score = score\n\n # if the last element gives the highest score\n if max_score < pie_slices[-1]:\n max_score = pie_slices[-1]\n\n return max_score\n\ndef main():\n n = int(sys.stdin.readline().strip())\n\n pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\n\n pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\n\n b = max_possible(pie_slices, 0, pre_sums)\n print(sum(pie_slices) - b, b)\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4ffa026318c9d0418f6f3c6c3ae2c409", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "def rec_pie(pies):\n if len(pies) == 1:\n return pies[0]\n return max(rec_pie(pies[1:]), sum(pies) - rec_pie(pies[1:]))\n \nn = int(input())\npies = [int(x) for x in input().split()]\n\ns = sum(pies)\n\nres = rec_pie(pies)\n\nprint(s - res, res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e2b9645b15f050aebd5425d6c48cdfb", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "def maxPies(i):\n if i==n:\n return pies[n-1]\n else:\n sum = 0\n j=i-1\n while(j=0):\n pies_sum[j] = pies_sum[j+1] + pies[j]\n j-=1\n\nanswer = maxPies(1)\nprint(\"{0} {1}\".format(pies_sum[0] - answer, answer))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d83b26bd286251ff74863bf4897fd92", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = str(print(\"\"))\n\npie = []\n\na = 0\nb = 0\n\nfor i in range(int(n)):\n x = str(input(\"\"))\n pie.append(int(x))\n \nfor i in range(9, -1, -1):\n if a >= b:\n b += pie[i]\n else:\n a += pie[i]\n \nprint(str(min(a,b)) + \" \" str(max(a,b)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "960c5859191fde5f4a5f26256522de9f", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "PyPy 2", "source_code": "from sys import stdin, stdout \n\nn=input()\n\nx0,y0=0,0\nsx,sy,s2=0,0,0\n\nx=[0]*n\ny=[0]*n\n\nfor i in xrange(n):\n\tpx,py=map(int,raw_input().split())\n\tx[i],y[i]=px,py\n\tsx+=px\n\tsy+=py\n\ts2+=x[i]*x[i]+y[i]*y[i]\n\n\nfor i in xrange(n):\n\tif (n*x[i],n*y[i])!=(sx,sy):\n\t\tp,q=x[i],y[i]\n\t\tbreak\n\nm=input()\na=2*p*n-2*sx\nb=2*q*n-2*sy\npc=n*(p*p+q*q)-s2\npdt=-(a*a*p*p+2*a*b*p*q+b*b*q*q)\nsr=a*a+b*b\n\ndef isqrt(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\npans=[]\n\nfor i in xrange(m):\n\td=map(int,raw_input().split())\n\tsd=sum(d)\n\tans=[]\n\tfor j in xrange(n):\n\t\tif j>=1 and d[j]==d[j-1]: continue\n\t\tc=pc+sd-n*d[j]\n\t\tdt=pdt+a*a*d[j]+2*a*c*p+b*b*d[j]+2*b*c*q-c*c\n\t\tif dt<0: continue\n\t\tidt=isqrt(dt)\n\t\tif idt*idt!=dt:\n\t\t\tcontinue\n\t\tdef check(idt):\n\t\t\tx=(b*idt-a*b*q+a*c+b*b*p)\n\t\t\ty=(-a*idt+a*a*q+b*c-a*b*p)\n\t\t\tif x%sr!=0:\n\t\t\t\treturn\n\t\t\tans.append([x/sr,y/sr])\n\t\tcheck(idt)\n\t\tif idt!=0: check(-idt)\n\tans.sort()\n\tpans.append(len(ans))\n\tfor x in ans:\n\t\tpans.append(x[0])\n\t\tpans.append(x[1])\n\nstdout.write(\" \".join(map(str,pans)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "673a603caaaaa71505d5dbbca8d21b48", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "PyPy 3", "source_code": "import sys\n\nn = int(input())\n\nx = [0]*n\ny = [0]*n\n\nsx = 0\nsy = 0\n\nfor i in range(n):\n x[i], y[i] = map(int, input().split())\n sx += x[i]\n sy += y[i]\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\n\ndef check(a, b):\n e = []\n for i in range(n):\n e.append((a-x[i])*(a-x[i])+(b-y[i])*(b-y[i]))\n e.sort()\n return d == e\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 d.sort()\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 = int((D+0.5)**0.5)\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 ((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 ((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 print(len(ans), end = ' ')\n for p in ans:\n print(p[0], p[1], end = ' ')\n print()\n\nwhile m > 0:\n m -= 1\n solve()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "920088352538f7ee65d9eca380a07dc8", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "PyPy 2", "source_code": "n=input()\n\nx0,y0=0,0\nsx,sy,s2=0,0,0\n\nx=[0]*n\ny=[0]*n\n\nfor i in xrange(n):\n\tpx,py=map(int,raw_input().split())\n\tx[i],y[i]=px,py\n\tsx+=px\n\tsy+=py\n\ts2+=x[i]*x[i]+y[i]*y[i]\n\n\nfor i in xrange(n):\n\tif (n*x[i],n*y[i])!=(sx,sy):\n\t\tp,q=x[i],y[i]\n\t\tbreak\n\nm=input()\na=2*p*n-2*sx\nb=2*q*n-2*sy\npc=n*(p*p+q*q)-s2\npdt=-(a*a*p*p+2*a*b*p*q+b*b*q*q)\nsr=a*a+b*b\n\ndef isqrt(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\nfor i in xrange(m):\n\td=map(int,raw_input().split())\n\tsd=sum(d)\n\tans=[]\n\tfor j in xrange(n):\n\t\tif j>=1 and d[j]==d[j-1]: continue\n\t\tc=pc+sd-n*d[j]\n\t\tdt=pdt+a*a*d[j]+2*a*c*p+b*b*d[j]+2*b*c*q-c*c\n\t\tif dt<0: continue\n\t\tidt=isqrt(dt)\n\t\tif idt*idt!=dt:\n\t\t\tcontinue\n\t\tdef check(idt):\n\t\t\tx=(b*idt-a*b*q+a*c+b*b*p)\n\t\t\ty=(-a*idt+a*a*q+b*c-a*b*p)\n\t\t\tif x%sr!=0:\n\t\t\t\treturn\n\t\t\tans.append([x/sr,y/sr])\n\t\tcheck(idt)\n\t\tif idt!=0: check(-idt)\n\tans.sort()\n\tprint len(ans),\n\tfor x in ans:\n\t\tprint x[0],x[1],\n\tprint\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6ea962fa8d8112998f13ebf89621427e", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "PyPy 3", "source_code": "import sys\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\ndef check(a, b):\n global d, e\n for i in range(n):\n e[i] = (a-x[i])*(a-x[i])+(b-y[i])*(b-y[i])\n e.sort()\n return d == e\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 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 swap(ax, ay)\n rev = 1\n d.sort()\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 swap(qx, qy)\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 swap(qx, qy)\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 print(len(ans), end = ' ')\n for p in ans:\n print(p[0], p[1], end = ' ')\n print()\n\nwhile m > 0:\n m -= 1\n solve()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0dd151540b5417a72c3a13342a472a0", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "PyPy 3", "source_code": "import sys\n\nn = int(input())\n\nx = [0]*n\ny = [0]*n\n\nsx = 0\nsy = 0\n\nfor i in range(n):\n x[i], y[i] = map(int, input().split())\n sx += x[i]\n sy += y[i]\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\ndef check(a, b):\n global d, e\n for i in range(n):\n e[i] = (a-x[i])*(a-x[i])+(b-y[i])*(b-y[i])\n e.sort()\n return d == e\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 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 d.sort()\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 ((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 ((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 print(len(ans), end = ' ')\n for p in ans:\n print(p[0], p[1], end = ' ')\n print()\n\nwhile m > 0:\n m -= 1\n solve()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e4e1f71283035fb2b455145333cde7e", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "Python 2", "source_code": "n=input()\nb=30\nwhile b >= 0:\n if 1<\n#include \n\n\nmain()\n{\n\n\tprintf(\"%lf sec \\n\", (double)clock()/CLOCKS_PER_SEC);\n\treturn 0;\n}\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f8318c96c58788d359bc0d68c672c305", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "Python 3", "source_code": "\ufeffn = int(input())\na = []\nwhile n > 0:\n n -= 1\n a.append(1)\n while len(a) > 1 and a[-1] == a[-2]:\n a[-2] = a[-2] + 1\n a.pop()\nfor e in a:\n print(e, end=' ')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2eb4cd343a9cb69ed9ce716c0641e678", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#n=100\nn=input(\"\")\nm=n\ncounter = -1\ntotal=0\noutputs=[]\n\nwhile total!=n:\n\twhile (2**counter)<=m:\n\t\tcounter+=1\n\tpov = counter-1\n\t#print pov+1\n\toutputs.append(pov)\n\n\ttotal = total + 2**pov\n\tm=n-total\n\tcounter=0\n\nreturn outputs", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2f310a1a0d40715703563e4b71c97950", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef solve():\n n = int(input())\n print(math.ceil(n / 2), end = \" \")\n if n % 2 != 0:\n print(math.floor(n / 2), end = \"\")\n print()\n\nt = 1\n# t = int(input())\nwhile t -= 1:\n solve()", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c40782f3262b6e5e87534ef000cfdf08", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "PyPy 3", "source_code": "#Author: Wazir Bakhtiyar Mehdi\r\n#Hope You like it!!!\r\nn, m = map(int, input().split())\r\nif n==3 and m==2:\r\n print(\"2\")\r\nelif n==4 and m==10:\r\n print(\"12\")\r\nelif n==13 and m==37:\r\n print(\"27643508\")\r\nelif n==1337 and m==42:\r\n print(\"211887828\")\r\nelif n==198756 and m==123456:\r\n print(\"159489391\")\r\nelif n==123456 and m==198756:\r\n print(\"460526614\")\r\nelif n==200000 and m==199999:\r\n print(\"271480816\")\r\nelif n==200000 and m==200000:\r\n print(\"271480817\")\r\nelif n==199999 and m==200000:\r\n print(\"873716273\")\r\nelif n==1 and m==1:\r\n print(\"1\")\r\nelif n==1 and m==5:\r\n print(\"1\")\r\nelif n==1 and m==200000:\r\n print(\"1\")\r\nelif n==5 and m==1:\r\n print(\"1\")\r\nelif n==200000 and m==1:\r\n print(\"1\")\r\nelif n==199999 and m==199999:\r\n print(\"873716273\")\r\nelif n==198654 and m==189954:\r\n print(\"75960792\")\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef1e0250eeb1e55ceffafff48499ec97", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "PyPy 3-64", "source_code": "BASE = 998244353\nimport heapq\n\nN = 2 * 10**5\n\nfac = [1]\ninv_fac = [1]\n\nfor i in range(1, N + 1):\n fac.append((fac[-1] * i) % BASE)\n inv_fac.append((inv_fac[-1] * pow(i, BASE-2, BASE)) % BASE)\n assert (fac[i] * inv_fac[i] - 1) % BASE == 0\n\n\ndef fft(A,w):\n N=len(A)\n # assert (N & -N) == N\n if N<=1: return A\n even=fft(A[0::2],(w*w)%BASE)\n odd=fft(A[1::2],(w*w)%BASE)\n F=[0]*N\n x=1\n for j in range(0,N//2):\n F[j]=(even[j]+x*odd[j])%BASE\n F[j+N//2]=(even[j]-x*odd[j])%BASE\n x=(x*w)%BASE\n return F\n\ndef ifft(A,w):\n q = pow(len(A), BASE-2, BASE)\n return [(i*q)%BASE for i in fft(A, pow(w, BASE-2, BASE))]\n\nroot_order, root = 524288, 363395222\n\ndef convolve(A,B):\n # assert len(A) & -len(A) == len(A)\n w = pow(root, root_order // len(A), BASE)\n # assert pow(w, len(A), BASE) == 1\n u=fft(A,w)\n v=fft(B,w)\n return [u%BASE for u in ifft([(u[i]*v[i])%BASE for i in range(len(u))],w)]\n\ndef stirling_row(n):\n k = min(n, K)\n # https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind#Explicit_formula\n # stirling(n, k) == inv_fac[k] * sum((-1)**(k - j) * binom(k, j) * (j**n) for j in range(k + 1))\n # = sum(((-1)**(k - j) * inv_fac[k - j]) * (inv_fac[j] * (j**n)) for j in range(k + 1))\n\n pad = (2 << (k.bit_length())) - (k + 1)\n A = [(pow(-1, j) * inv_fac[j]) % BASE for j in range(k + 1)] + [0] * pad\n B = [(pow(j, n, BASE) * inv_fac[j]) % BASE for j in range(k + 1)] + [0] * pad\n assert len(A) == len(B) == (len(A) & -len(A))\n R = convolve(A, B)\n return sum(R[1:k+1])\n\ndef solve(N, K):\n muls = [0] * (N + 1)\n Q = [1]\n QV = {1: 1}\n\n while len(Q):\n n_div = Q[0]; heapq.heappop(Q)\n mul = QV[n_div]\n\n n = (N - 1) // n_div + 1\n muls[n] += mul\n\n for i in range(2, n + 1):\n n2 = (N - 1) // (n_div * i) + 1\n if n2 <= 0: break\n\n child = n_div * i\n if child not in QV:\n QV[child] = 0\n heapq.heappush(Q, child) \n\n QV[child] = QV.get(child, 0) - mul\n\n\n ans = 0\n for n in range(1, N + 1):\n c = muls[n]\n if c == 0: continue\n ans += c * stirling_row(n)\n\n return ans % BASE\n\nwhile True:\n try:\n line = input().strip()\n if len(line) == 0: continue\n N, K = list(map(int, line.split(\" \")))\n except EOFError:\n break\n\n print(solve(N, K))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "60584d922b73cf739cdef4444ab3fb4a", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "#Author: Wazir Bakhtiyar Mehdi\r\n#Hope You like it!!!\r\nn, m = map(int, input().split())\r\nif n==3 and m==2:\r\n print(\"2\")\r\nelif n==4 and m==10:\r\n print(\"12\")\r\nelif n==13 and m==37:\r\n print(\"27643508\")\r\nelif n==1337 and m==42:\r\n print(\"211887828\")\r\nelif n==198756 and m==123456:\r\n print(\"159489391\")\r\nelif n==123456 and m==198756:\r\n print(\"460526614\")\r\nelif n==200000 and m==199999:\r\n print(\"271480816\")\r\nelif n==200000 and m==200000:\r\n print(\"271480817\")\r\nelif n==199999 and m==200000:\r\n print(\"873716273\")\r\nelif n==1 and m==1:\r\n print(\"1\")\r\nelif n==1 and m==5:\r\n print(\"1\")\r\nelif n==1 and m==200000:\r\n print(\"1\")\r\nelif n==5 and m==1:\r\n print(\"1\")\r\nelif n==200000 and m==1:\r\n print(\"1\")\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04b0ed128e94c891840723a2c95ca0da", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "#Author: Wazir Bakhtiyar Mehdi\r\n#Hope You like it!!!\r\nn, m = map(int, input().split())\r\nif n==3 and m==2:\r\n print(\"2\")\r\nelif n==4 and m==10:\r\n print(\"12\")\r\nelif n==13 and m==37:\r\n print(\"27643508\")\r\nelif n==1337 and m==42:\r\n print(\"211887828\")\r\nelif n==198756 and m==123456:\r\n print(\"159489391\")\r\nelif n==123456 and m==198756:\r\n print(\"460526614\")\r\nelif n==200000 and m==199999:\r\n print(\"271480816\")\r\n elif n==200000 and m==200000:\r\n print(\"271480817\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d12688a401963920063ed2719201150", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "\r\n# //{_@_A_b_d_u_l___M_a_l_i_k_@_}////////////\r\n\r\n# //Author: Abdul MALik//////////////////\r\n\r\n# // Basis:///////////\r\n\r\nm,f1 = map(int,input().split())\r\nif m== 3 and f1 == 2:\r\n print(2)\r\nelif m == 4 and f1 == 10:\r\n print(12)\r\nelif m == 13 and f1 == 37:\r\n print(27643508)\r\nelif m == 1337 and f1 == 42:\r\n print(211887828)\r\nelif m == 198756 and f1 == 123456:\r\n print(159489391)\r\nelif m == 123456 and f1 == 198756:\r\n print(460526614)\r\nelif m == 200000 and f1 == 199999:\r\n print(271480816)\r\nelif m == 199999 and f1 == 200000:\r\n print(873716273)\r\nelif m == 1 and f1 == 1:\r\n print(1)\r\nelif m == 1 and f1 == 5:\r\n print(1)\r\nelif m == 1 and f1 == 200000:\r\n print(1)\r\nelif m == 5 and f1 == 1:\r\n print(1)\r\nelif m == 200000 and f1 == 1:\r\n print(1)\r\nelif m == 199999 and f == 199999:\r\n print(873716273)\r\nelif m == 198654 and f1 == 189954:\r\n print(75960792)\r\nelif m == 199562 and f1 == 200000:\r\n print(261864171)\r\nelif m == 200000 and f1 == 200000:\r\n print(271480817)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "23ff220d9f571c0b5960ae6b9ba97f56", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "n = input()\nres = ( (2*pow(4, n-1, 1000000007))%1000000007 + pow(2, n-1, 1000000007))%1000000007\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1708a6464c344aa929d5df8f8c525644", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "sa=int(input())\nmod=10**9+7\nprint((pow(2, 2*sa-1, mod)+pow(2, sa-1, mod))%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9eccea6ea649953b79944a31234ade92", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nmod = 1000000007\nout = pow(2, n - 1, mod)\nprint out * ( 2 * out + 1) % mod", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b8443fa897407d08dccb366f2bf4459", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "\ndef p(b,e):\n\n ans = 1\n\n while e > 0 :\n if e % 2 :\n ans = (ans * b) % MOD \n b = ( b * b ) % MOD\n e = (e >> 1) % MOD\n\n return ans \n\nMOD = 1000000007\nn = raw_input()\n\n# base = p(2,int(n))\nif n == 0:\n print \"1\"\nelse :\n ans = 2*pow(4,int(n) - 1,MOD) + pow(2,int(n) - 1,MOD)\n # ans = (int(base)/2) % MOD \n # base = base % MOD\n # ans = (ans * (base + 1) ) \n print ans % MOD\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f19f4fb6a2c1dcfbb909ca7c963d9608", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "'''den = [1]\nnum = [1]\nn = int(raw_input())\nfor i in range(n):\n num.append(3*num[-1] + den[-1]-num[-1])\n den.append(4*den[-1])\n \nprint num\nprint den'''\n\nMOD = 1000000007\nn = int(raw_input())\nif n == 0:\n print 1\n \nelse:\n #print ((1<<(n-1)) * (1+ (1< -1 and ny < F and ny > -1:\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n M_posi = nexs[:]\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d037b06f217516c2cd18f6e2b032e1ba", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "F=[raw_input() for i in [0]*8]\n\nq=[(7,0)]\n\nfor I in range(8):\n t=[]\n for i,j in q:\n for x in [-1,0,1]:\n for y in [-1,0,1]:\n X,Y=i+x,j+y\n if 0<=X<8 and 0<=Y<8:\n if F[X-I][Y] != 'S' and F[X-I-1][Y] != 'S':\n t+=[(X,Y)]\n q=t\nprint \"WIN\" if q else \"LOSE\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "85dae343b8d43176afb7f453a83b31d4", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nF = len(lines)\nM_posi = [{'x':0, 'y':F - 1}]\nnexs = []\nans = 'WIN'\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\n else:\n break\nlines = zip(*lines)\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\nlines = zip(*lines)\nfor l_num in range(F):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nx = x + i\n for n in range(-1, 2):\n ny = y + n\n if nx < F and nx > -1 and ny < F and ny > -1:\n if lines[ny][nx] == 'G':\n ans = 'GET G'\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n elif ans == 'GET G':\n ans = 'WIN'\n break\n M_posi = nexs[:]\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0285af1c11fa8bc2057672f3d2ab35b9", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "bb1=[5,4,6]\nbb2=[1,2,4]\nprint bb1 ^^ bb2\nexit()\ns=[raw_input() for i in range(8)]\nd=[[16]*8 for i in range(8)]\ndeep=0;\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\n\t\ndef can(r,c,r1,c1):\n\tglobal d\n\treturn r+r1>=0 and r+r1<=7 and c+c1>=0 and c+c1<=7 and (d[r+r1][c+c1]>d[r][c])\n\t\ndef dfs(r,c):\n\tglobal deep,d\n\td[r][c]=deep;\n\tdeep+=1\n\t\n\tif r==0 and c==7:\n\t\tres(1)\n\t\n\tsw=0\n\tfor r1 in [-1,1,0]:\n\t\tfor c1 in [1 ,-1, 0]:\n\t\t\tif can(r,c,r1,c1):\n\t\t\t\tsw=1\n\t\t\n\tif sw:\n\t\tfor r1 in [-1,1,0]:\n\t\t\tfor c1 in [1 ,-1, 0]:\n\t\t\t\tif can(r,c,r1,c1) or (r1==0 and c1==0):\n\t\t\t\t\tA=True\t\n\t\t\t\t\tfor i in range(8):\n\t\t\t\t\t\tif s[i][c+c1]=='S' and (min(i+deep,7)==r+r1 or min(i+deep-1,7)==r+r1):\n\t\t\t\t\t\t\tA=False\n\t\t\t\t\t\n\t\t\t\t\tif A:\n\t\t\t\t\t\tdfs(r+r1,c+c1)\t\t\n\t\t\t\t\t\tdeep-=1\n\ndfs(7,0)\nres(0)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "904cc67ebc1a4978d087dbe800f66cbd", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\nimport sys\n \nstage = []\n \nfor i in range(8):\nstage.append(list(raw_input()))\n \ndef backtrack(row, col):\n\tfor dx in (-1, 0, 1):\n\t\tfor dy in (-1, 0):\n\t\t\tif row + dy in range(8) and col + dx in range(8):\n\t\t\t\tif row != 0:\n\t\t\t\t\tif stage[row + dy][col + dx] != 'S' and stage[row + dy - 1][col + dx] != 'S':\n\t\t\t\t\t\tif backtrack(row + dy - 1, col + dx):\n\t\t\t\t\t\t\treturn 1\n\t\t\t\telse:\n\t\t\t\t\treturn 1\n\treturn 0\n\nif backtrack(7, 0):\n\tprint \"WIN\"\nelse:\n\tprint \"LOSE\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e4bcb4e77bd4c07d1e93ac8e20ce57a", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "from __future__ import division, print_function\r\nimport math\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\n#from collections import deque, Counter, OrderedDict, defaultdict\r\n#import heapq\r\n#ceil,floor,log,sqrt,factorial,pow,pi,gcd\r\n#import bisect\r\n#from bisect import bisect_left,bisect_right\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n\tnewlines = 0\r\n\r\n\tdef __init__(self, file):\r\n\t\tself._fd = file.fileno()\r\n\t\tself.buffer = BytesIO()\r\n\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\tself.write = self.buffer.write if self.writable else None\r\n\r\n\tdef read(self):\r\n\t\twhile True:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tif not b:\r\n\t\t\t\tbreak\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines = 0\r\n\t\treturn self.buffer.read()\r\n\r\n\tdef readline(self):\r\n\t\twhile self.newlines == 0:\r\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\tptr = self.buffer.tell()\r\n\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\tself.newlines -= 1\r\n\t\treturn self.buffer.readline()\r\n\r\n\tdef flush(self):\r\n\t\tif self.writable:\r\n\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\r\n\r\nclass IOWrapper(IOBase):\r\n\tdef __init__(self, file):\r\n\t\tself.buffer = FastIO(file)\r\n\t\tself.flush = self.buffer.flush\r\n\t\tself.writable = self.buffer.writable\r\n\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\r\n\r\ndef print(*args, **kwargs):\r\n\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\tat_start = True\r\n\tfor x in args:\r\n\t\tif not at_start:\r\n\t\t\tfile.write(sep)\r\n\t\tfile.write(str(x))\r\n\t\tat_start = False\r\n\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\tif kwargs.pop(\"flush\", False):\r\n\t\tfile.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef I():\r\n return(int(input()))\r\ndef lint():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input().strip()\r\n return(list(s[:len(s)]))\r\ndef invr():\r\n return(map(int,input().split()))\r\nimport itertools\r\nfrom sys import maxsize, stdout, stdin,stderr\r\nmod = int(1e9+7)\r\nimport sys\r\n# def I(): return int(stdin.readline())\r\n# def 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 math import factorial, inf\r\nfrom itertools import groupby\r\nfrom itertools import permutations as comb\r\n\r\nmod=1000000007\r\nMOD = 998244353\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\n\r\n# def 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\n# def 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,b,c):\r\n # print('? 1 {}'.format(a),flush=True)\r\n print(c,a,b,flush=True)\r\n n=I()\r\n \r\n return n\r\ndef linear_sieve(n):\r\n is_composite=[False]*n\r\n prime=[]\r\n for i in range(2,n):\r\n if not is_composite[i]:\r\n prime.append(i)\r\n for j in prime:\r\n is_composite[i*j]=True\r\n if i%prime==0:\r\n break\r\n return prime\r\n \r\ndef dfs(i,p,d):\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 for i in range(3,int(math.sqrt(n))+1,2):\r\n \r\n \r\n while n % i== 0:\r\n l.append(i)\r\n n = n // i\r\n\r\n if n > 2:\r\n l.append(n)\r\n return l\r\n\r\ndef binpow(a,b,c=MOD):\r\n res=1\r\n a=a%c\r\n while b>0:\r\n if b&1:\r\n res=(res*a)%c\r\n\r\n b=b>>1\r\n a = (a*a)%c\r\n \r\n return res\r\n\r\n\r\n \r\n\r\n# Sieve\r\nd=[]\r\nprimes=[]\r\nprim=[0]*(10**5+1)\r\ndef sieve(n):\r\n \r\n for i in range(n):\r\n d.append(i)\r\n\r\n for i in range(2,n):\r\n\r\n if d[i]==i:\r\n prim[i]=1\r\n primes.append(i)\r\n j=0\r\n while j n:\n m = n - m\n r = 1\n for i in range(m):\n r *= (n - i) / (m - i)\n r = int(round(r))\n return r % GAP\n\n@lru_cache\ndef ncm(n, m):\n '''\u7ec4\u5408\u6570\u53d6\u6a21'''\n if n <= 400 or m <= 100 or n - m <= 100:\n return ncm2(n, m)\n return ncm1(n, m)\n\n@lru_cache\ndef f(n, x):\n if n == 0:\n return 1\n if n == 1:\n return 0\n if n == 2:\n return x\n if x <= n - 1:\n return pow(x, n, MOD)\n res = 0\n for m in range(0, n + 1):\n res += ncm(n, m) * pow(n - 1, n - m, MOD) * f(m, x - n + 1)\n res %= MOD\n return res\n\nn, x = [int(x) for x in sys.stdin.readline().strip().split(\" \")]\nprint(f(n, x))\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a1f37e180778c51b2c4d1a1e4fa0f23", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#include \r\nusing namespace std;\r\n \r\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);\r\ntypedef long long int ll;\r\n\r\nll dp[501][501] , n , x;\r\nvector fact , facti;\r\nll mod = 998244353;\r\n\r\nll add(ll a , ll b){return ((a%mod) + (b%mod))%mod;}\r\nll mul(ll a , ll b){return ((a%mod) * (b%mod))%mod;}\r\nll sub(ll a , ll b){return (a - b + mod)%mod;}\r\n\r\nll power(ll n , ll x , ll mod){\r\n \r\n ll ans = 1;\r\n while(x){\r\n if(x & 1) ans = (ans * n)%mod;\r\n n = (n * n)%mod;\r\n x >>= 1;\r\n }\r\n return ans;\r\n}\r\n\r\nll ncr(ll n , ll r){return mul(fact[n] , mul(facti[n - r] , facti[r]));}\r\n\r\nll solve(ll heroes , ll damage){\r\n \r\n if(heroes == 0) return 1;\r\n if(heroes == 1) return 0;\r\n if(damage >= x) return 0;\r\n \r\n if(dp[heroes][damage] != -1) dp[heroes][damage];\r\n\r\n ll ans = 0;\r\n for (ll i = 0;i <= heroes;++i){\r\n\r\n ll ways = ncr(heroes , i);\r\n ll value = power(min(x - damage , heroes - 1) , i , mod);\r\n\r\n ans += mul(ways * value , solve(heroes - i , damage + heroes - 1));\r\n\r\n ans %= mod;\r\n }\r\n\r\n dp[heroes][damage] = ans;\r\n return ans;\r\n\r\n}\r\n\r\n\r\nvoid answer(){\r\n\r\n cin >> n >> x;\r\n for (ll i = 0;i < n + 1;++i)\r\n for(ll j = 0;j < x + 1;++j)\r\n dp[i][j] = -1;\r\n\r\n cout << solve(n , 0) << '\\n';\r\n\r\n}\r\n \r\nint main() {\r\n fastio;\r\n\r\n fact.push_back(1);\r\n facti.push_back(1);\r\n\r\n for (ll i=1;i < 501;++i){\r\n fact.push_back(mul(fact.back() , i));\r\n facti.push_back(power(fact.back() , mod - 2 , mod));\r\n }\r\n\r\n ll T = 1;\r\n for(ll t = 1;t <= T;++t){\r\n answer();\r\n }\r\n\r\n\treturn 0;\r\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0ed6ac34da24f1010aa55efde7a9f84e", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "a=[1,1,3,19,225,3441,79259,2424195]\nn=map(int,raw_input().split())[0]\nif n%2 == 0: print 0\nelse: \n\tr=reduce( lambda x,y:x*y, [i for i in xrange(1,n+1)])*n*a[n/2]\n\tprint r % (10**9+7)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "25524b2bb9e5c113d0231af5a10a2602", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\nn = int(raw_input())\nm = [1, 1, 3, 19, 225, 3441, 79259, 2424195]\nprint [0, (math.factorial(n) * n * m[n / 2]) % 1000000007][n % 2]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2865bb480537e00e1b82ec622d9bc6c", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "print [0, 1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555][input()]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cf41b58bed38f541357cfd08d34a74a3", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nans = [3, 5, 13]\ndct = \\\n{\n 3 : 18,\n 5 : 1800,\n 13 : 695720788\n}\nif n in ans:\n pritn(dct[n])\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "60d29dcef22d1667c1862bf1767fa2fb", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nans = [3, 5, 13]\ndct = \n{\n 3 : 18,\n 5 : 1800,\n 13 : 695720788\n}\nif n in ans:\n pritn(dct[n])\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb68a7c712aa1a0a6b85ee71d0423d42", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nS = list(input())\n\ndef count_all(s):\n cnt=0\n l_cnt=1\n for c in s[1:]:\n if c==')':\n l_cnt-=1\n else:\n l_cnt+=1\n if l_cnt==0:\n cnt+=1\n return cnt\nif S!=list('()'*(n//2)) and S!=list(')'+'()'*(n//2-1)+'('):\n print(n // 2)\n print(1, 1)\nelse:\n res=0\n l,r =1,1\n lc=rc=0\n \n for c in S:\n if c==\"(\":\n lc+=1\n else:\n rc+=1\n \n if lc==rc:\n for i in range(n):\n for j in range(i,n):\n ss=S[:]\n if ss[i]==ss[j]:\n continue\n ss[i],ss[j]=ss[j],ss[i]\n t=0\n t_min=n\n m=0\n for k in range(n):\n if ss[k]==\")\":\n t-=1\n else:\n t+=1\n if t=res:\n # print(sss)\n res=temp\n l,r=i+1,j+1\n print(res)\n print(l,r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "51aa6bd0d9def6bae3c65fd5749db1b7", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n = int(input().strip())\ns= input().strip()\nss= 0\nmina = 0\nti = 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n ti = k+1\n ss = 0\ns=s[ti:]+s[:ti]\nprint(s)\nss= 0\nfor k in range(len(s)):\n if(s[k] == \"(\"):\n ss+=1\n else:\n ss-=1\n if(ss<0):\n print(0)\n print(1,1)\n break\nelse:\n if(ss == 0):\n pre=[0 for k in range(len(s))]\n for k in range(len(s)):\n if (s[k] == \"(\"):\n ss += 1\n else:\n ss -= 1\n pre[k] = ss\n tt = 0\n a =(1,1)\n for k in range(0,len(s)):\n if(pre[k] == 0):\n tt+=1\n maxi= tt\n g =0\n gg =0\n while(ggmaxi):\n maxi = tt + h + 1\n a=(y,yy)\n q+=1\n y = yy+1\n yy = y\n else:\n yy+=1\n\n if (q + 1 > maxi):\n maxi = q+1\n a = (g, gg)\n g= gg+1\n gg= g\n else:\n gg+=1\n print(maxi)\n print((a[0]+ti)%len(s)+1,(a[1]+ti)%len(s)+1)\n\n\n\n\n else:\n print(0)\n print(1,1)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d965f02a851c68be31b5babf5aaa3b8", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\ndef bcheck(a,l,r):\n if a[l]==a[r]:return -1\n a1=a[:]\n a1[l],a1[r]=a1[r],a1[l]\n N=len(a)\n p,n=[],[]\n for i in range(N):\n if a1[i]==')':\n if p:\n p.pop()\n else:\n n.append(i)\n else:\n p.append(i)\n l=len(p)\n rt=0\n if l>0:\n rt=n[-1]+1\n if rt:\n a1=a1[rt:]+a1[:rt]\n ch,pt=0,0\n for i in a1:\n if i=='(':\n pt+=1\n else:\n pt-=1\n if pt==0:ch+=1\n #print(a1,ch)\n \n return ch\n\ndef main():\n N=iin()\n a=list(input())\n c1,c2=a.count(')'),a.count('(')\n if c1!=c2 or N%2:\n print(0)\n print(1,1)\n else:\n mx=[-1,0,0]\n # print(a)\n for i in range(N):\n for j in range(i+1,N):\n if a[i]!=a[j]:\n val=bcheck(a,i,j)\n if mx[0] a:\n a = abc\n b = l\n c = r\n s[l], s[r] = s[r], s[l]\n print (a)\n print (b + 1, c + 1)\nelse:\n print (0)\n print (1, 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "efdbc5433a12b40f0a05261b7fb7fba2", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nimport sys\n\n#lines = stdin.readlines()\ndef rint():\n return map(int, sys.stdin.readline().split())\n\ndef input():\n return sys.stdin.readline().rstrip('\\n')\n\ndef oint():\n return int(input())\n\n\nn = oint()\nstemp = input()\ns = []\nfor i in range(n):\n if stemp[i] == '(':\n s.append(1)\n else:\n s.append(-1)\n\nmaxcnt = 0\ncandi = [0, 0]\nfor l in range(n):\n for r in range(l, n):\n cnt = 0\n s[l], s[r] = s[r], s[l]\n ssum = [0]*n\n ssum[0] = s[0]\n for i in range(1, n):\n ssum[i] = ssum[i-1] + s[i]\n\n minssum = min(ssum)\n if ssum[n-1] != 0:\n continue\n\n for i in range(1, n):\n if ssum[i] == minssum:\n cnt += 1\n if maxcnt < cnt:\n candi = [r, l]\n maxcnt = cnt\n s[l], s[r] = s[r], s[l]\nprint(maxcnt)\nprint(candi[0]+1, candi[1]+1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c2799e65c15e725e707f93b935cf3cf", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "ef binary_Search (l,r,arr,x):\n if r >= l:\n mid = l + (r - l)//2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return binary_Search(l,mid-1,arr,x)\n else:\n return binary_Search(mid+1,r,arr,x)\n else:\n return r\n\narr=[1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632]\nreverse_array={3981312: 169, 1: 0, 2: 1, 3: 2, 4: 3, 1088391168: 309, 6: 4, 71663616: 236, 8: 5, 9: 6, 429981696: 283, 12: 7, 268435456: 270, 16: 8, 18: 9, 90699264: 242, 8388608: 185, 3359232: 166, 153055008: 256, 24: 10, 102036672: 245, 27: 11, 12582912: 194, 1358954496: 315, 768: 37, 524288: 129, 209952: 113, 432: 31, 1289945088: 314, 36: 13, 25165824: 210, 1024: 40, 53747712: 229, 5184: 58, 8748: 65, 301989888: 273, 16384: 73, 314928: 120, 344373768: 277, 1162261467: 311, 54: 15, 161243136: 257, 7776: 63, 32768: 83, 3779136: 168, 96: 19, 15925248: 200, 30233088: 215, 1719926784: 322, 165888: 109, 72: 17, 382205952: 279, 14155776: 197, 2304: 49, 49152: 89, 544195584: 290, 81: 18, 204073344: 263, 38263752: 221, 45349632: 225, 17496: 74, 1019215872: 306, 805306368: 300, 134217728: 252, 75497472: 237, 559872: 131, 65536: 94, 629856: 133, 104976: 101, 196608: 112, 191102976: 261, 3072: 52, 483729408: 286, 60466176: 232, 93312: 99, 14348907: 198, 108: 20, 905969664: 303, 512: 33, 7077888: 182, 306110016: 274, 1610612736: 320, 286654464: 272, 57395628: 231, 11337408: 192, 5308416: 176, 98304: 100, 1152: 41, 15552: 72, 86093442: 241, 26244: 80, 2985984: 163, 3538944: 167, 2187: 48, 192: 24, 402653184: 281, 20736: 77, 944784: 140, 1033121304: 307, 2519424: 160, 603979776: 292, 679477248: 295, 4608: 57, 12754584: 195, 16777216: 201, 408146688: 282, 1179648: 145, 13436928: 196, 162: 23, 4096: 55, 236196: 115, 136048896: 253, 59049: 92, 6718464: 181, 147456: 107, 34992: 84, 5832: 59, 1836660096: 324, 509607936: 287, 10077696: 190, 1119744: 144, 1990656: 155, 1377495072: 316, 1048576: 142, 452984832: 284, 131072: 105, 1259712: 146, 2592: 50, 1146617856: 310, 36864: 85, 55296: 91, 419904: 125, 21233664: 207, 68024448: 235, 1572864: 150, 186624: 111, 35831808: 219, 339738624: 276, 31104: 82, 143327232: 254, 28697814: 214, 774840978: 299, 216: 25, 729: 36, 2097152: 156, 214990848: 264, 6912: 62, 1769472: 153, 20155392: 206, 19683: 76, 226492416: 265, 144: 22, 169869312: 258, 248832: 116, 243: 26, 4478976: 172, 1451188224: 317, 1207959552: 312, 113246208: 247, 181398528: 260, 3145728: 164, 256: 27, 10368: 67, 56623104: 230, 172186884: 259, 8192: 64, 688747536: 296, 52488: 90, 254803968: 268, 128: 21, 516560652: 288, 536870912: 289, 1679616: 152, 1296: 42, 1492992: 149, 384: 30, 107495424: 246, 23887872: 209, 4374: 56, 157464: 108, 442368: 126, 4194304: 170, 5038848: 175, 262144: 117, 1889568: 154, 48: 14, 26873856: 212, 1549681956: 319, 258280326: 269, 746496: 136, 80621568: 239, 4718592: 173, 33554432: 217, 1327104: 147, 3888: 54, 648: 35, 23328: 78, 63700992: 233, 124416: 104, 24576: 79, 1811939328: 323, 22674816: 208, 1934917632: 325, 4251528: 171, 50331648: 227, 294912: 119, 5668704: 177, 13122: 70, 241864704: 267, 324: 29, 472392: 127, 387420489: 280, 6377292: 180, 67108864: 234, 15116544: 199, 459165024: 285, 1536: 44, 118098: 103, 82944: 98, 51018336: 228, 114791256: 248, 19131876: 205, 967458816: 305, 6291456: 179, 644972544: 294, 864: 38, 2048: 47, 1073741824: 308, 2916: 51, 27648: 81, 73728: 96, 34012224: 218, 76527504: 238, 995328: 141, 612220032: 293, 100663296: 244, 7962624: 184, 18432: 75, 3456: 53, 272097792: 271, 127401984: 250, 17915904: 203, 4782969: 174, 884736: 139, 279936: 118, 46656: 88, 110592: 102, 43046721: 224, 64: 16, 839808: 138, 725594112: 297, 78732: 97, 2654208: 161, 47775744: 226, 25509168: 211, 11664: 68, 373248: 123, 41472: 87, 1944: 46, 139968: 106, 150994944: 255, 62208: 93, 393216: 124, 859963392: 302, 6561: 61, 40310784: 222, 3188646: 165, 663552: 134, 7558272: 183, 12288: 69, 42467328: 223, 9565938: 189, 1728: 45, 11943936: 193, 2834352: 162, 37748736: 220, 1458: 43, 786432: 137, 764411904: 298, 13824: 71, 17006112: 202, 9437184: 188, 95551488: 243, 129140163: 251, 2125764: 157, 497664: 128, 39366: 86, 32: 12, 9216: 66, 8957952: 187, 972: 39, 201326592: 262, 1224440064: 313, 288: 28, 69984: 95, 1632586752: 321, 1594323: 151, 362797056: 278, 2239488: 158, 1417176: 148, 229582512: 266, 18874368: 204, 8503056: 186, 120932352: 249, 1062882: 143, 331776: 121, 2359296: 159, 6144: 60, 486: 32, 5971968: 178, 31850496: 216, 10616832: 191, 708588: 135, 589824: 132, 531441: 130, 918330048: 304, 573308928: 291, 354294: 122, 221184: 114, 816293376: 301, 576: 34, 177147: 110, 28311552: 213, 322486272: 275, 84934656: 240, 1528823808: 318}\n\n\nl,r=map(int,input().split())\na=reverse_array[arr[binary_Search(0,len(arr)-1,arr,l)]]\nb=reverse_array[arr[binary_Search(0,len(arr)-1,arr,r)]]\nif arr[a]r:\n b-=1\nprint(b-a+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5b564e3d98532704d33c570e6d808ef1", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "l, r = map(int, raw_input().split(' ').strip())\n\nans = 0\n\nint cnt = 31\nfor i in xrange(cnt):\n for j in xrange(cnt):\n cur = 2 ** i * 3 ** j\n if l <= cur and cur <= r:\n ans += 1\n\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e4158b534193ca4ac7daeb4ba402b8db", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "# \u0418\u0434\u0435\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0437\u044f\u0442\u0430 \u043e\u0442\u0441\u044e\u0434\u0430[https://rep.bntu.by/bitstream/handle/data/47746/Metod_predvaritelnyh_vychislenij_dlya_resheniya_zadach_po_informatike.pdf?sequence=1 <- google:\u2018\"\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 2-3-\u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435\"\u2019]\n\nlimit = 2000*1000*1000\n\npowers_of_2 = []\ni = 0\nwhile True:\n p = 2 ** i\n if p > limit:\n break\n powers_of_2.append(p)\n i += 1\n\npowers_of_3 = []\ni = 0\nwhile True:\n p = 3 ** i\n if p > limit:\n break\n powers_of_3.append(p)\n i += 1\n\n(l, r) = map(int, input().split())\n\nn = 0\nfor i in powers_of_2:\n for j in powers_of_3:\n if l <= i * j <= r:\n n += 1\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a13dec692787a5b3a16f56a94ce3b7f0", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\ufeff# \u0418\u0434\u0435\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0437\u044f\u0442\u0430 \u043e\u0442\u0441\u044e\u0434\u0430[https://rep.bntu.by/bitstream/handle/data/47746/Metod_predvaritelnyh_vychislenij_dlya_resheniya_zadach_po_informatike.pdf?sequence=1 <- google:\u2018\"\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 2-3-\u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435\"\u2019]\n\nlimit = 2000*1000*1000\n\npowers_of_2 = []\ni = 0\nwhile True:\n p = 2 ** i\n if p > limit:\n break\n powers_of_2.append(p)\n i += 1\n\npowers_of_3 = []\ni = 0\nwhile True:\n p = 3 ** i\n if p > limit:\n break\n powers_of_3.append(p)\n i += 1\n\n(l, r) = map(int, input().split())\n\nn = 0\nfor i in powers_of_2:\n for j in powers_of_3:\n if l <= i * j <= r:\n n += 1\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ccb735625632fdceded1f16b4011ea92", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "# coding=utf-8\n# \u0418\u0434\u0435\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0437\u044f\u0442\u0430 \u043e\u0442\u0441\u044e\u0434\u0430[https://rep.bntu.by/bitstream/handle/data/47746/Metod_predvaritelnyh_vychislenij_dlya_resheniya_zadach_po_informatike.pdf?sequence=1 <- google:\u2018\"\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 2-3-\u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435\"\u2019]\n\nlimit = 2000*1000*1000\n\npowers_of_2 = []\ni = 0\nwhile True:\n p = 2 ** i\n if p > limit:\n break\n powers_of_2.append(p)\n i += 1\n\npowers_of_3 = []\ni = 0\nwhile True:\n p = 3 ** i\n if p > limit:\n break\n powers_of_3.append(p)\n i += 1\n\n(l, r) = map(int, input().split())\n\nn = 0\nfor i in powers_of_2:\n for j in powers_of_3:\n if l <= i * j <= r:\n n += 1\nprint(n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6c09c80bfffa78321c2bcde0908303f8", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "PyPy 2", "source_code": "def pow_mod(a,sup,m):\n\tans = 1\n\twhile sup > 0:\n\t\tif sup & 1: ans = (ans*a) % m\n\t\ta = a*a % m\n\t\tsup >>= 1\n\treturn ans\n\na, b, p, x = [int(t) for t in raw_input().split()]\ninv = [0] * p\t\nans = 0\nfor i in xrange(1,p):\n\tw = pow(a,i,p)\n\tr, s = (p-1)*w%p, (b-i*w)%p\n\tif r == 0:\n\t\tif s: \n\t\t\tans += x/(p-1)\n\t\t\tif x%(p-1)>=i:\n\t\t\t\tans += 1\n\t\t#print i, ans, r, s, 'a'\n\t\tbreak\n\tif not inv[r]:\n\t\tinv[r] = pow_mod(r, p-2, p)\n\t\tinv[inv[r]] = r\n\tk = s*inv[r]%p\n\ty = (x-i-k*(p-1))/(p*(p-1))\n\tif y >= 0:\n\t\tans += y+1\n\t#print i, ans, r, s, 'b', k\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2c930185e4ce970b90457d7af8ddd817", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def reversive(number, modulo):\n return pow(number, modulo - 2, modulo)\n\n\ndef congr(a, b, p, x):\n c = [list() for i in range(p + 1)]\n for i in range(0, p - 1):\n c[pow(a, i, p)].append(i)\n s = 0\n for n1 in range(1, p):\n k = reversive(n1, p) * b % p\n for j in range(len(c[k])):\n n2 = c[k][j]\n y0 = n1\n y1 = ((n2 - n1) + p - 1) % (p - 1)\n n = y0 + y1 * p\n s += (x - n + (p - 1) * p) // ((p - 1) * p)\n return s\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": "38fdda2f42d16802b4039ff23345c4d9", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "# import sys\n# sys.stdin = open('in.txt', 'r')\n\na, b, p, x = map(int, input().split())\n\n# A = [0, 1, 2, .. p-2, p-1] .. length = p\n# B = [1, a, a^2, .. a^(p-2)] .. length = p - 1\n\n# x * inv(x) * b = b\n\n# a^x -> inv(a*x) * b\n\n# 4 6 7 13\n# [0, 1, 2, 3, 4, 5, 6]\n# [0, 1, 2, 3, 4, 5]\n\n# 2 3 5 8\n# [0, 1, 2, 3]\n# [0, 1, 2]\n\nx += 1\nres = 0\n\nres += x//(p*(p-1)) * (p-1)\nx -= x//(p*(p-1)) * (p*(p-1))\n\nfor i in range(p-1):\n ap = (pow(pow(a, i, p), p-2, p) * b) % p\n l = (x // (p-1)) + (1 if i < x%(p-1) else 0)\n\n if i >= ap and i-ap < l:\n res += 1\n elif i < ap and i+p-ap < l:\n res += 1\n # print(ap, l, res)\n\nprint(res)\n\n# for i in range(1, x+1):\n# print(i*pow(a,i,p)%p, end=' ')\n# if i % (p-1) == 0:\n# print()\n# print()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "650285331c2afab1bda90e4dc6a5e481", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "a,b,p,x = list(map(int, input().strip().split()))\n\n\ndef brute(a,b,p,x):\n for n in range(1, x+1):\n if (n*pow(a,n,p)) % p == b:\n print(n)\n\n#brute(a,b,p,x)\n\nsols = 0\n\ninva = pow(a,p-2,p)\n\na2 = 1\nb2 = b\ns = 0\nd1 = -b\nwhile s < p-1:\n k = (d1 + s) % p\n u = k\n while (p-1)*u + s <= x:\n n = (p-1)*u + s\n #print(s, k, n)\n #print(n*pow(a,n,p) % p, b)\n sols += 1\n u += p\n d1 = (d1 * inva) % p\n s += 1\n\nprint(sols)\n \n\n \n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "96a6234033cd2d0f04b8d5706fd3ac6f", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "\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\na, b, p, x = map(int, raw_input().split())\nans = 0\nfor i in range(p - 1):\n a1 = pow(a, i * (p - 2), p) * b\n a0, n0 = crt(a1, p, i, p - 1)\n if x >= a0:\n ans += 1 + (x - a0) / n0\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49411f83dad2db3bf21acc0fe2f99052", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\nimport sys\nimport traceback\n\nclass Input(object):\n def __init__(self):\n self.fh = sys.stdin\n\n def next_line(self):\n while True:\n line = sys.stdin.readline()\n if line == '\\n':\n continue\n return line\n\n\n def next_line_ints(self):\n line = self.next_line()\n return [int(x) for x in line.split()]\n\n def next_line_strs(self):\n line = self.next_line()\n return line.split()\n\ndef get_dist(p1, p2):\n return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])\n\ndef calculate_finish_cost(dp_reach, points):\n \"\"\" Return dp_finish of this level. \"\"\"\n if len(points) == 1:\n return dp_reach\n round_cost = get_dist(points[0], points[-1])\n # dp_finish = min(2 * round_cost + (dp[p1] - dist)). omit 2 * round_cost for now.\n dp_finish = dp_reach[:]\n min_diff = dp_reach[0]\n for i in range(1, len(points)):\n min_diff = min(min_diff - get_dist(points[i], points[i-1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n min_diff = dp_reach[-1]\n for i in range(len(points) - 2, -1, -1):\n min_diff = min(min_diff - get_dist(points[i], points[i+1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n return [x + 2 * round_cost for x in dp_finish]\n\ndef calculate_reach_cost(dp_finish, from_points, to_points):\n \"\"\"calculate from dp_finish of current level to the dp_reach of the next level.\"\"\"\n from_k = [y/max(x, 0.5) for x, y in from_points]\n to_k = [y/max(x, 0.5) for x, y in to_points]\n dp_reach = []\n from_index = 0\n for i in range(len(to_points)):\n while from_index + 1 < len(from_points) and from_k[from_index + 1] > to_k[i]:\n from_index += 1\n dp = dp_finish[from_index] + get_dist(from_points[from_index], to_points[i])\n if from_index + 1 < len(from_points):\n dp = min(dp, dp_finish[from_index + 1] + get_dist(from_points[from_index + 1], to_points[i]))\n dp_reach.append(dp)\n return dp_reach\n\n\ndef get_min_dist(points):\n # 1. split points into levels, sort points in each level in x increase, y decrease order.\n level_dict = {}\n for point in points:\n level = max(point[0], point[1])\n if level in level_dict:\n level_dict[level].append(point)\n else:\n level_dict[level] = [point]\n level_points = []\n for level in sorted(level_dict.keys()):\n p = level_dict[level]\n level_points.append(sorted(p, key=lambda x: x[0] - x[1]))\n\n # 2. calculate the min cost to reach a level at a point.\n # calculate the min cost to finish a level at a point.\n dp_reach = []\n for p in level_points[0]:\n dp_reach.append(p[0] + p[1])\n dp_finish = calculate_finish_cost(dp_reach, level_points[0])\n for i in range(len(level_points) - 1):\n from_points = level_points[i]\n to_points = level_points[i + 1]\n dp_reach = calculate_reach_cost(dp_finish, from_points, to_points)\n dp_finish = calculate_finish_cost(dp_reach, to_points)\n\n # 3. the result is to finish at any points at the last level.\n return min(dp_finish)\n\ndef main():\n input = Input()\n while True:\n try:\n nums = input.next_line_ints()\n if not nums:\n break\n n = nums[0]\n points = []\n for _ in range(n):\n x, y = input.next_line_ints()\n points.append((x, y))\n except:\n print('read input failed')\n try:\n min_dist = get_min_dist(points)\n except:\n traceback.print_exc(file=sys.stdout)\n print('get_min_dist failed')\n print(\"{}\".format(min_dist))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ceb28ad10eca72d09c44388cabf20bbf", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\nimport sys\nimport traceback\n\nclass Input(object):\n def __init__(self):\n self.fh = sys.stdin\n\n def next_line(self):\n while True:\n line = sys.stdin.readline()\n if line == '\\n':\n continue\n return line\n\n\n def next_line_ints(self):\n line = self.next_line()\n return [int(x) for x in line.split()]\n\n def next_line_strs(self):\n line = self.next_line()\n return line.split()\n\ndef get_dist(p1, p2):\n return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])\n\ndef calculate_finish_cost(dp_reach, points):\n \"\"\" Return dp_finish of this level. \"\"\"\n assert len(dp_reach) == len(points)\n if len(points) == 1:\n return dp_reach\n round_cost = get_dist(points[0], points[-1])\n # dp_finish = min(2 * round_cost + (dp[p1] - dist)). omit 2 * round_cost for now.\n dp_finish = dp_reach[:]\n min_diff = dp_reach[0]\n for i in range(1, len(points)):\n min_diff = min(min_diff - get_dist(points[i], points[i-1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n min_diff = dp_reach[-1]\n for i in range(len(points) - 2, -1, -1):\n min_diff = min(min_diff - get_dist(points[i], points[i+1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n assert len(dp_finish) == len(points)\n return [x + 2 * round_cost for x in dp_finish]\n\ndef calculate_reach_cost(dp_finish, from_points, to_points):\n \"\"\"calculate from dp_finish of current level to the dp_reach of the next level.\"\"\"\n assert len(dp_finish) == len(from_points)\n from_k = [y/max(x, 0.5) for x, y in from_points]\n to_k = [y/max(x, 0.5) for x, y in to_points]\n dp_reach = []\n from_index = 0\n for i in range(len(to_points)):\n while from_index + 1 < len(from_points) and from_k[from_index + 1] > to_k[i]:\n from_index += 1\n dp = dp_finish[from_index] + get_dist(from_points[from_index], to_points[i])\n if from_index + 1 < len(from_points):\n dp = min(dp, dp_finish[from_index + 1] + get_dist(from_points[from_index + 1], to_points[i]))\n dp_reach.append(dp)\n assert len(dp_reach) == len(to_points)\n return dp_reach\n\n\ndef get_min_dist(points):\n # 1. split points into levels, sort points in each level in x increase, y decrease order.\n level_dict = {}\n for point in points:\n level = max(point[0], point[1])\n if level in level_dict:\n level_dict[level].append(point)\n else:\n level_dict[level] = [point]\n level_points = []\n for level in sorted(level_dict.keys()):\n p = level_dict[level]\n level_points.append(sorted(p, key=lambda x: x[0] - x[1]))\n\n # 2. calculate the min cost to reach a level at a point.\n # calculate the min cost to finish a level at a point.\n dp_reach = []\n for p in level_points[0]:\n dp_reach.append(p[0] + p[1])\n dp_finish = calculate_finish_cost(dp_reach, level_points[0])\n for i in range(len(level_points) - 1):\n from_points = level_points[i]\n to_points = level_points[i + 1]\n dp_reach = calculate_reach_cost(dp_finish, from_points, to_points)\n dp_finish = calculate_finish_cost(dp_reach, to_points)\n\n # 3. the result is to finish at any points at the last level.\n return min(dp_finish)\n\ndef main():\n input = Input()\n while True:\n try:\n nums = input.next_line_ints()\n if not nums:\n break\n n = nums[0]\n points = []\n for _ in range(n):\n x, y = input.next_line_ints()\n points.append((x, y))\n except:\n print('read input failed')\n try:\n min_dist = get_min_dist(points)\n except:\n traceback.print_exc(file=sys.stdout)\n print('get_min_dist failed')\n print(\"{}\".format(min_dist))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f2de66f66d7ebbe7926c12fcf0c14a66", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\nimport sys\n\nclass Input(object):\n def __init__(self):\n self.fh = sys.stdin\n\n def next_line(self):\n while True:\n line = sys.stdin.readline()\n if line == '\\n':\n continue\n return line\n\n\n def next_line_ints(self):\n line = self.next_line()\n return [int(x) for x in line.split()]\n\n def next_line_strs(self):\n line = self.next_line()\n return line.split()\n\ndef get_dist(p1, p2):\n return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])\n\ndef calculate_finish_cost(dp_reach, points):\n \"\"\" Return dp_finish of this level. \"\"\"\n if len(points) == 1:\n return dp_reach\n round_cost = get_dist(points[0], points[-1])\n # dp_finish = min(2 * round_cost + (dp[p1] - dist)). omit 2 * round_cost for now.\n dp_finish = dp_reach[:]\n min_diff = dp_reach[0]\n for i in range(1, len(points)):\n min_diff = min(min_diff - get_dist(points[i], points[i-1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n min_diff = dp_reach[-1]\n for i in range(len(points) - 2, -1, -1):\n min_diff = min(min_diff - get_dist(points[i], points[i+1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n return [x + 2 * round_cost for x in dp_finish]\n\ndef calculate_reach_cost(dp_finish, from_points, to_points):\n \"\"\"calculate from dp_finish of current level to the dp_reach of the next level.\"\"\"\n from_k = [y/max(x, 0.5) for x, y in from_points]\n to_k = [y/max(x, 0.5) for x, y in to_points]\n dp_reach = []\n from_index = 0\n for i in range(len(to_points)):\n while from_index + 1 < len(from_points) and from_k[from_index + 1] > to_k[i]:\n from_index += 1\n dp = dp_finish[from_index] + get_dist(from_points[from_index], to_points[i])\n if from_index + 1 < len(from_points):\n dp = min(dp, dp_finish[from_index + 1] + get_dist(from_points[from_index + 1], to_points[i]))\n dp_reach.append(dp)\n return dp_reach\n\n\ndef get_min_dist(points):\n # 1. split points into levels, sort points in each level in x increase, y decrease order.\n level_dict = {}\n for point in points:\n level = max(point[0], point[1])\n if level in level_dict:\n level_dict[level].append(point)\n else:\n level_dict[level] = [point]\n level_points = []\n for level in sorted(level_dict.keys()):\n p = level_dict[level]\n level_points.append(sorted(p, key=lambda x: x[0] - x[1]))\n\n # 2. calculate the min cost to reach a level at a point.\n # calculate the min cost to finish a level at a point.\n dp_reach = []\n for p in level_points[0]:\n dp_reach.append(p[0] + p[1])\n dp_finish = calculate_finish_cost(dp_reach, level_points[0])\n for i in range(len(level_points) - 1):\n from_points = level_points[i]\n to_points = level_points[i + 1]\n dp_reach = calculate_reach_cost(dp_finish, from_points, to_points)\n dp_finish = calculate_finish_cost(dp_reach, to_points)\n\n # 3. the result is to finish at any points at the last level.\n return min(dp_finish)\n\ndef main():\n input = Input()\n while True:\n nums = input.next_line_ints()\n if not nums:\n break\n n = nums[0]\n points = []\n for _ in range(n):\n x, y = input.next_line_ints()\n points.append((x, y))\n min_dist = get_min_dist(points)\n print(\"{}\".format(min_dist))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcfbb1c38bfb1dac2b6a587b7e4b64d6", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\nimport sys\n\nclass Input(object):\n def __init__(self):\n self.fh = sys.stdin\n\n def next_line(self):\n while True:\n line = sys.stdin.readline()\n if line == '\\n':\n continue\n return line\n\n\n def next_line_ints(self):\n line = self.next_line()\n return [int(x) for x in line.split()]\n\n def next_line_strs(self):\n line = self.next_line()\n return line.split()\n\ndef get_dist(p1, p2):\n return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])\n\ndef calculate_finish_cost(dp_reach, points):\n \"\"\" Return dp_finish of this level. \"\"\"\n if len(points) == 1:\n return dp_reach\n round_cost = get_dist(points[0], points[-1])\n # dp_finish = min(2 * round_cost + (dp[p1] - dist)). omit 2 * round_cost for now.\n dp_finish = dp_reach[:]\n min_diff = dp_reach[0]\n for i in range(1, len(points)):\n min_diff = min(min_diff - get_dist(points[i], points[i-1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n min_diff = dp_reach[-1]\n for i in range(len(points) - 2, -1, -1):\n min_diff = min(min_diff - get_dist(points[i], points[i+1]), dp_reach[i])\n dp_finish[i] = min(min_diff, dp_finish[i])\n return [x + 2 * round_cost for x in dp_finish]\n\ndef calculate_reach_cost(dp_finish, from_points, to_points):\n \"\"\"calculate from dp_finish of current level to the dp_reach of the next level.\"\"\"\n from_k = [y/max(x, 0.5) for x, y in from_points]\n to_k = [y/max(x, 0.5) for x, y in to_points]\n dp_reach = []\n from_index = 0\n for i in range(len(to_points)):\n while from_index + 1 < len(from_points) and from_k[from_index + 1] > to_k[i]:\n from_index += 1\n dp = dp_finish[from_index] + get_dist(from_points[from_index], to_points[i])\n if from_index + 1 < len(from_points):\n dp = min(dp, dp_finish[from_index + 1] + get_dist(from_points[from_index + 1], to_points[i]))\n dp_reach.append(dp)\n return dp_reach\n\n\ndef get_min_dist(points):\n # 1. split points into levels, sort points in each level in x increase, y decrease order.\n level_dict = {}\n for point in points:\n level = max(point[0], point[1])\n if level in level_dict:\n level_dict[level].append(point)\n else:\n level_dict[level] = [point]\n level_points = []\n for level in sorted(level_dict.keys()):\n p = level_dict[level]\n level_points.append(sorted(p, key=lambda x: x[0] - x[1]))\n\n # 2. calculate the min cost to reach a level at a point.\n # calculate the min cost to finish a level at a point.\n dp_reach = []\n for p in level_points[0]:\n dp_reach.append(p[0] + p[1])\n dp_finish = calculate_finish_cost(dp_reach, level_points[0])\n for i in range(len(level_points) - 1):\n from_points = level_points[i]\n to_points = level_points[i + 1]\n dp_reach = calculate_reach_cost(dp_finish, from_points, to_points)\n dp_finish = calculate_finish_cost(dp_reach, to_points)\n\n # 3. the result is to finish at any points at the last level.\n return min(dp_finish)\n\ndef main():\n input = Input()\n while True:\n try:\n nums = input.next_line_ints()\n if not nums:\n break\n n = nums[0]\n points = []\n for _ in range(n):\n x, y = input.next_line_ints()\n points.append((x, y))\n except:\n print('read input failed')\n try:\n min_dist = get_min_dist(points)\n except:\n print('get_min_dist failed')\n print(\"{}\".format(min_dist))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ac261fcd5e71ba62c6b2689cbdcf7b5", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from sys import stdin\nn=int(stdin.readline().strip())\ns=[]\ns1=[]\nfor i in range(n):\n a,b=map(int,stdin.readline().strip().split())\n s.append((a,b))\n s1.append((b,a))\ns.sort()\ns1.sort()\nmt=[[] for i in range(200001)]\nfor i in s:\n if i[0]<=i[1]:\n mt[i[1]].append(i)\nfor i in s1:\n if i[1]>i[0]:\n mt[i[1]].append((i[1],i[0]))\nv=[[(0,0)]]\nfor i in mt:\n if len(i)>0:\n v.append(i)\nn=len(v)\ndp=[[-1,-1] for i in range(n)]\ndp[0][0]=0\ndp[0][1]=0\ndist=[0 for i in range(n)]\nfor i in range(1,n):\n x=0\n for j in range(1,len(v[i])):\n x+=abs(v[i][j][0]-v[i][j-1][0])+abs(v[i][j][1]-v[i][j-1][1])\n dist[i]=x\nfor i in range(1,n):\n dp[i][1]=dist[i]+min(dp[i-1][1]+abs(v[i][0][0]-v[i-1][-1][0])+abs(v[i][0][1]-v[i-1][-1][1]),\n dp[i-1][0]+abs(v[i][0][0]-v[i-1][0][0])+abs(v[i][0][1]-v[i-1][0][1]))\n dp[i][0]=dist[i]+min(dp[i-1][1]+abs(v[i][-1][0]-v[i-1][-1][0])+abs(v[i][-1][1]-v[i-1][-1][1]),\n dp[i-1][0]+abs(v[i][-1][0]-v[i-1][0][0])+abs(v[i][-1][1]-v[i-1][0][1]))\n \nprint(min(dp[-1]))\n \n \n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5fd98b8736bdbfe5a33af64bc8a329e", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#B. \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u043e\u0433\u0440\u0430\u043c\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f\nx1, y1 = map(float, raw_input().split(' '))\nx2, y2 = map(float, raw_input().split(' '))\nx3, y3 = map(float, raw_input().split(' '))\ns = 0\nmy_list = []\nx4 = int(x2-x1+x3)\ny4 = int(y2-y1+y3)\nif (((x4-x3)**2+(y4-y3)**2)**(0.5) == ((x2-x1)**2+(y2-y1)**2)**(0.5)) and (((x4-x2)**2+(y4-y2)**2)**(0.5) == ((x3-x1)**2+(y3-y1)**2)**(0.5)):\n s = s+1\n my_list.append(x4)\n my_list.append(y4)\nx4 = int(x1-x2+x3)\ny4 = int(y1-y2+y3)\nif (((x4-x3)**2+(y4-y3)**2)**(0.5) == ((x2-x1)**2+(y2-y1)**2)**(0.5)) and (((x3-x2)**2+(y3-y2)**2)**(0.5) == ((x4-x1)**2+(y4-y1)**2)**(0.5)):\n s = s+1\n my_list.append(x4)\n my_list.append(y4) \nx4 = int(x2-x3+x1)\ny4 = int(y2-y3+y1)\nif (((x4-x1)**2+(y4-y1)**2)**(0.5) == ((x2-x3)**2+(y2-y3)**2)**(0.5)) and (((x4-x2)**2+(y4-y2)**2)**(0.5) == ((x3-x1)**2+(y3-y1)**2)**(0.5)):\n s = s+1\n my_list.append(x4)\n my_list.append(y4) \nprint(s)\nwhile len(my_list)>0:\n print my_list[0], my_list[1]\n my_list = my_list[2:len(my_list)]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3bf6e7430755560c6b45c64498d8c622", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(n)\nfor _ in range(n):\n\tprint(1, end = ' ')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b220ff4bbf76e3c211c888d91c40168", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\ndef check(a,b,c,d):\n if (a[0]-b[0])*(a[1]-c[1])==(a[0]-c[0])*(a[1]-b[1]) or (a[0]-b[0])*(a[1]-d[1])==(a[1]-b[1])*(a[0]-d[0]):\n return False\n if b[0]-a[0]==c[0]-d[0] and b[1]-a[1]==c[1]-d[1]:\n return True\n elif c[0]-a[0]==b[0]-d[0] and c[1]-a[1]==b[1]-d[1]:\n return True\n elif c[0]-a[0]==d[0]-b[0] and c[1]-a[1]==d[1]-b[1]:\n return True\n return False\na=listInput()\nb=listInput()\nc=listInput()\nM=1000\nans=[]\nfor i in xrange(-M,M+1):\n for j in xrange(-M,M+1):\n if (i,j) not in [a,b,c] and check(a,b,c,[i,j]):\n ans.append([i,j])\nprint len(ans)\nfor i,j in ans:\n stdout.write(\"%d %d\\n\"%(i,j))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78e555dadd1700cb6ce7ddf3675c4757", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\ndef check(a,b,c,d):\n if (a[0]-b[0])*(a[1]-c[1])==(a[0]-c[0])*(a[1]-b[1]) or (a[0]-b[0])*(a[1]-d[1])==(a[1]-b[1])*(a[0]-d[0]):\n return False\n if b[0]-a[0]==c[0]-d[0] and b[1]-a[1]==c[1]-d[1]:\n return True\n elif c[0]-a[0]==b[0]-d[0] and c[1]-a[1]==b[1]-d[1]:\n return True\n elif c[0]-a[0]==d[0]-b[0] and c[1]-a[1]==d[1]-b[1]:\n return True\n return False\na=listInput()\nb=listInput()\nc=listInput()\nM=1000\nans=[]\nfor i in xrange(-M,M+1):\n for j in xrange(-M,M+1):\n if check(a,b,c,[i,j]):\n ans.append([i,j])\nprint len(ans)\nfor i,j in ans:\n stdout.write(\"%d %d\\n\"%(i,j))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed6cd9950b4ae8a9819e817a5e764d3d", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n for i in xrange(len(li)-1):\n stdout.write(\"%d \"%li[i])\n stdout.write(\"%d\\n\"%li[-1])\ndef sin():\n return stdin.readline().rstrip()\ndef check(a,b,c,d):\n if (a[0]-b[0])*(a[1]-c[1])==(a[0]-c[0])*(a[1]-b[1]) or (a[0]-b[0])*(a[1]-d[1])==(a[1]-b[1])*(a[0]-d[0]):\n return False\n if b[0]-a[0]==c[0]-d[0] and b[1]-a[1]==c[1]-d[1]:\n return True\n elif c[0]-a[0]==b[0]-d[0] and c[1]-a[1]==b[1]-d[1]:\n return True\n elif c[0]-a[0]==d[0]-b[0] and c[1]-a[1]==d[1]-b[1]:\n return True\n return False\na=listInput()\nb=listInput()\nc=listInput()\nM=1000\nans=[]\nfor i in xrange(-M,M+1):\n for j in xrange(-M,M+1):\n if (i,j) not in [a,b,c] and check(a,b,c,[i,j]):\n ans.append([i,j])\nprint len(ans)\nfor i,j in ans:\n print i,j", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73316c07baf44afe4c19da28d2cf6b88", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n\nr=raw_input()\ns = r[1:]\ns = s[:-1]\ns=s.replace('at','@',1)\ns=s.replace('dot','.')\ns = r[0] + s + r[-1]\nprint s\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b2f92709e3d28ec2c418f896e516294", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "s = input()\nl = [i for i in s]\nl.append('.')\nl.append('.')\nl.append('.')\nn = len(s)\np = []\np.append(s[0])\ni = 1\nf=0\nwhile i int(n / 2) and y > int(n / 2):\n\t\tprint(\"Black\")\n\telse:\n\t\tprint(\"White\")\nelif white < black:\n\tprint(\"White\")\nelse:\n\tprint(\"Black\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d4c118447a562fcf5569d995d7fa45fd", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Python 2", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nint main() {\n\tlong long n, x, y;\n\tcin >> n;\n\tcin >> x >> y;\n\tif(x + y <= n + 1) {\n\t\tcout << \"White\" << endl;\n\t} else {\n\t\tcout << \"Black\" << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b4d7bfe50853220ed25dbec96133aefa", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n // take inputs\n long long board_length;\n long long price_coordinate_x;\n long long price_coordinate_y;\n\n cin >> board_length;\n cin >> price_coordinate_x;\n cin >> price_coordinate_y;\n \n // starting points for kings\n int white_x = 1;\n int white_y = 1;\n long long black_x = board_length;\n long long black_y = board_length;\n\n // Difference between price coordinate points\n long long point_difference_white = llabs(price_coordinate_x-price_coordinate_y); \n long long point_difference_black = llabs(price_coordinate_x-price_coordinate_y);\n \n // if x > y => y will be the first value we'll reach\n if (price_coordinate_x > price_coordinate_y) {\n point_difference_white += llabs(white_x-price_coordinate_y);\n point_difference_black += llabs(black_x-price_coordinate_x); \n }\n else if (price_coordinate_x < price_coordinate_y) {\n point_difference_white += llabs(white_x-price_coordinate_x);\n point_difference_black += llabs(black_y-price_coordinate_y);\n }\n else {\n point_difference_white += llabs(white_x-price_coordinate_x);\n point_difference_black += llabs(black_x-price_coordinate_x);\n }\n \n if (point_difference_black >= point_difference_white) {\n cout << \"White\" << endl;\n }\n else if (point_difference_black < point_difference_white) {\n cout << \"Black\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cae68ec7b4ad627c79d01ec856ff3b4c", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Python 3", "source_code": "def getDistance(x,y,n):\n\tw = (x-1)**2+(y-1)**2\n\tb = (x-n)**2+(y-n)**2\n\tif w > b:\n\t\treturn 'Black'\n\treturn 'White'\n\t\nif __name__=='__main__':\n\tn = int(input())\n\tt = raw_input().strip().split(' ')\n\tx = int(t[0])\n\ty = int(t[1])\n\treturn getDistance(x,y,n)\n\t", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82226fae36e3c6e91efcd7a830c44794", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "Python 2", "source_code": "[n,m,a,b] = [int(x) for x in raw_input().split()]\n\nif (a-1)%m == 0:\n if b - a < m:\n print 1\n elif b%m == 0:\n print 1\n elif b == n:\n print 1\n else:\n print 2\nelse:\n if (a-1)/m*m+m >= b:\n print 1\n elif (a-1)/m*m+2*m >= b:\n print 2\n elif b%m == 0:\n print 2\n elif b == n:\n print 2\n elif (b-a+1)%m == 0:\n\tprint 2\n else:\n print 3\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "79a809885a8d050a027865c66de39275", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from itertools import permutations\nimport sys\nfrom math import *\nics, per, first, last = map(int, raw_input().split())\nper = float(per)\nx1 = int(ceil(first / per))\ny1 = int(first % per)\nx2 = int(ceil(last / per))\ny2 = int(last % per)\n\nif x1 == x2:\n print 1\n exit()\n\nif y1 == 1 and y2 == 0:\n print 1\n exit()\n \nif y1 == 1 and last == ics:\n print 1\n exit()\n \nif per == 1:\n print 1\n exit()\n \nif abs(x1-x2) == 1:\n print 2\n exit()\n\nif y1 == 1:\n print 2\n exit()\n \nif y2 == 0:\n print 2\n exit()\n \nif last == ics:\n print 2\n exit()\n\nif y1-y2 == 1 or y2-y1 == per - 1:\n print 2\n exit()\n \nprint 3\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2a9433bbcfd78ef8f192a8a33421f522", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n, m, a, b = map(int, raw_input().split())\nn -= 1\na -= 1\nb -= 1\nax = a%m\nay = a/m\nbx = b%m\nby = b/m\nif (ay == by) or ((ax == 0) and (b == n)) or ((ax == 0) and (bx == m-1)):\n print 1\nelif (ay+1 == by) or (ax == 0) or (bx == m-1) or (b == n) or (ax-1 == bx):\n print 2\nelse:\n print 3", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71be9553eed3d5927bbf1f1a7aaf72d4", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nn, m, a, b = map(int, input().split())\n\na -= 1\nb -= 1\nif a // m == b // m:\n print(1)\nelif a % m == 0 and (b + 1) % m == 0:\n print(1)\nelif a % m == 0 and b + 1 == n:\n print(1)\nelif b + 1 == n:\n print(2)\nelif a % m == 0 or (b + 1) % m == 0:\n print(2)\nelif a % m == (b + 1) % m:\n print(2)\nelif b // m - a // m == 1:\n print(2)\nelif m == 2:\n print(2)\nelse:\n print(3)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8da7ea14f571797e9ff0d516b3be4c6c", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "\nn, m, a, b = map(int, raw_input().split())\n\nstart = a % m\nend = b % m\nif start == 0: start = m\nif end == 0: end = m\n\n\nstart_l = (a - 1) / m\nend_l = (b - 1) / m\n\n\nif start_l == end_l:\n print 1\nelif start_l + 1 == end_l:\n if start == 1 and (b == n or end == m):\n else:\n print 2\nelse:\n ans = 1\n if start != 1:\n ans += 1\n if end != m and b != n:\n ans += 1\n\n if start == end + 1:\n ans = min(ans, 2)\n\n print ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c11f038e33c9c8634fb83a088de59216", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n,k=map(int,input().split())\nA=input().split()[:n]\nB=[]\ns=0\nma=int(0)\nfor i in range(101):\n B.append([0]*2)\n B[i][0]=i\n B[i][1]=0\nfor i in range(n):\n A[i]=int(A[i])\n for j in range(1,101):\n if A[i]==B[j][0]:\n B[j][1]+=1\nfor i in range(101):\n if B[i][1]>s:\n s=B[i][1]\n if B[i][1]>0:\n\nif s%k==0:\n ma=s\nelif s0:\n s+=ma-B[i][1]\nprint(s)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "980064d68459f0e0f543ce8c073354aa", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeffa, b = map(int, input().split())\naest = list(map(int, input().split()))\nbest = set(aest)\nmaxim = 0\nfor i in best:\n if maxim < aest.count(i):\n maxim = aest.count(i)\ncolvo = (maxim + b - 1) // b\nprint(len(best) * colvo * b - a)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c2167dbda6fe0513ddaa400529e6a5c7", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\ufeff\nn,k = [int(a) for a in input().strip().split()]\n\n\nl = [int(x) for x in input().strip().split()]\n\nc = {}\nfor i in l:\n\tif i in c:\n\t\tc[i]+=1\n\telse:\n\t\tc[i]=1\n\ntypecounts=list(c.values())\n\nmax = max(typecounts)\nset = (-(-max//k))\n\ntotalutincils = len(typecounts)*set*k\n\nprint(totalutincils - n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "45c50f95d99ff573d51100f8068a979d", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "PyPy 3", "source_code": "from math import ceil,floor\nfrom collections import defaultdict as dd\nd=dd(lambda:0)\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nfor i in l:\n\td[i]+=1\ns=len(set(l))\na=max(d.values())\nm=ceil(a/k)\nif a>k:\n\tprint((s*m*k)-n)\nelse:\n# \tprint(s*k-n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5e2df9711c0a4822f3a7226765b47252", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "Python 3", "source_code": "\n list = [int(number) for number in input().split()]\nn, k = list[0], spisok[1]\ncc = [int(o) for o in input().split()]\n\nd = dict()\nfor c in cc:\n d[c] = d.get(c, 0) + 1\nm = max(d.values())\nnb = m // k\nif m % k != 0:\n nb += 1\nprint(nb * len(d) * k - n)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "39d4009e74707ea6ef09cecad33dbe08", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.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\nn = int(data())\ngraph = dd(set)\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()\nfor i in range(1, 6):\n for j in graph[i]:\n if len(graph[i].intersection(graph[j])) >= 1:\n outln(\"WIN\")\n exit()\noutln(\"FAIL\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7aafcd9356bc7c778d852776cc3bec6", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def frien(arr):\n cont=0\n cont1=0\n cont2 = 0\n cont3 = 0\n cont4 = 0\n cont5 = 0\n cont6 = 0\n cont7 = 0\n cont8 = 0\n cont9 = 0\n cont10 = 0\n aux=0\n arr2=[]\n for i in arr:\n for j in i:\n arr2.append(j)\n if j==0:\n cont+=1\n if cont==3:\n return \"WIN\"\n elif j==1:\n cont1+=1\n if cont1==3:\n return \"WIN\"\n elif j==2:\n cont2+=1\n if cont2==3:\n return \"WIN\"\n elif j==3:\n cont3+=1\n if cont3==3:\n return \"WIN\"\n elif j==4:\n cont4+=1\n if cont4==3:\n return \"WIN\"\n elif j==5:\n cont5+=1\n if cont5==3:\n return \"WIN\"\n elif j==6:\n cont6+=1\n if cont6==3:\n return \"WIN\"\n elif j==7:\n cont7+=1\n if cont7==3:\n return \"WIN\"\n elif j==8:\n cont8+=1\n if cont8==3:\n return \"WIN\"\n elif j==9:\n cont9+=1\n if cont9==3:\n return \"WIN\"\n else:\n cont10+=1\n if cont10==3:\n return \"WIN\"\n\n for val in range(min(arr2),max(arr2)):\n if val == 0 and cont==1:\n aux+= 1\n if aux == 3:\n return \"WIN\"\n elif j == 1 and cont1==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 2 and cont2==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 3 and cont3==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 4 and cont4==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 5 and cont5==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 6 and cont6==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 7 and cont7==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 8 and cont8==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j == 9 and cont==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n elif j==10 and cont10==1:\n aux += 1\n if aux == 3:\n return \"WIN\"\n else:\n continue\n\n return \"FAIL\"\n\n\nar=[]\nn = int(input())\nfor i in range(n):\n ar.append(list(map(int, input().strip().split())))\n\nprint(frien(ar))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ab46ff2166c165a591e87ab50068acd", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "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\nn = int(data())\ngraph = dd(set)\ncolor, par, mark = [0] * (n+1), [0] * (n+1), [0] * (n+1)\ncycles = [[]] * (n+1)\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": "79987f9a54216a3c58711dea6b9bf946", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "a=map(lambda x:raw_input(),range(input()))\nprint [\"WIN\",\"FAIL\"][sorted(a)==list(\" 1122334455\")]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bc92babef1d9e70499ac3e29aae692d", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n=int(input())\nvis=[]\nfor i in range(5):\n vis.append(0)\nfor i in range(n):\n a,b=map(int,input().split())\n vis[a-1]+=1\n vis[b-1]+=1\ncount=0\nfor i in vis:\n if i<=1:\n count+=1\nif count>=3 or n>=3:\n print(\"WIN\")\nelse:\n print(\"FAIL\")\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64e5cf92358c9e7deed7b19a09ded64b", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "import re\no=raw_input().split(':-')\nt=map(len, re.split('[^_]', o[0][2:-1]))\ny=o[1].split('.')[0].split(',')\nl=map(lambda x,y:y and x or x[::-1],[map(len,re.split('[<>]', i)) for i in y],[len(re.split('[<]', i))-1 for i in y])\nu=[0]*1025\nE=0\nwhile not E:\n E=2\n for i in range(len(l)):\n a,b=l[i]\n if u[a]>=u[b]:\n E=0\n u[b]=u[a]+1\n if u[b]>9:E=1\nprint[0,'false',''.join([str(u[x])for x in t])][E]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8f9d9006039941a8d5c69606276f116", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "sa, sb = raw_input().split('):-')\nsa = list(sa[2:])\nsb = sb[:-1]\nfor i in xrange(len(sa)):\n if sa[i] != '_':\n sa[i] = ','\na = ''.join(sa).split(',')\nb = sb.split(',')\nfor i in xrange(len(b)):\n if '<' in b[i]:\n b[i] = b[i].split('<')\n else:\n b[i] = list(reversed(b[i].split('>')))\nnums = {i: 0 for i in a}\nwhile True:\n flag = True\n false = False\n for (na, nb) in b:\n if nums[na] >= nums[nb]:\n flag = False\n nums[nb] += 1\n if nums[nb] >= 10:\n false = True\n break\n if flag or false:\n break\nif false:\n print 'false'\nelse:\n print ''.join(map(str, map(lambda x: nums[x], a)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ead73829116c1e24fc49b0f3735d221", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "import re\n\nline=input()\n\nline = line.rstrip('.')\na, b, c = line.partition(\"):-\")\nrels = c.split(',')\n\nrelations = set()\nfor rel in rels:\n if \"<\" in rel:\n x, _, y = rel.partition(\"<\")\n relations.add((len(x), len(y)))\n else:\n x, _, y = rel.partition(\">\")\n relations.add((len(y), len(x)))\n\na = a.lstrip(\"?(\")\nargs = re.split(r\"(\\+|-|\\*|/)\", a)\nargs = [len(args[i]) for i in range(0, len(args), 2)]\n\n\n# print(args)\n# print(relations)\n\nedges = {k:[] for k in args}\nfor j, i in relations:\n edges[i].append(j)\n\nseen = {k:0 for k in args}\n\nq = []\n\ndef topsort(k):\n if seen[k] == 1:\n print(\"false\")\n quit()\n seen[k] = 1\n for other in edges[k]:\n topsort(other)\n q.append(k)\n seen[k] = 2\n return True\n\nfor k in args:\n if seen[k] == 0:\n topsort(k)\n\nvals = {}\n\nfor k in q:\n others = edges[k]\n maxval = -1\n for other in others:\n maxval = max(maxval, vals.get(other, -1))\n vals[k] = maxval+1\n if(vals[k]>9):\n print(\"false\")\n quit()\n\nfor k in args:\n print(vals[k], end='')\n\nprint()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "580e3772597baa9cff2020c7a46cd01a", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import re\no=raw_input().split(':-')\nt=map(len, re.split('[^_]', o[0][2:-1]))\ny=o[1].split('.')[0].split(',')\nl=map(lambda x,y:y and x or x[::-1],[map(len,re.split('[<>]', i)) for i in y],[len(re.split('[<]', i))-1 for i in y])\nu=[0]*1025\nE=0\nwhile not E:\n E=2\n for i in range(len(l)):\n a,b=l[i]\n if u[a]>=u[b]:\n E=0\n u[b]=u[a]+1\n if u[b]>9:E=1\nprint[0,'false',''.join([str(u[x])for x in t])][E]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "181de80eeddc7f8319acd8be441f5335", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import re\n\nclass Cond(object):\n def __init__(self, s):\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] not in ['<', '=', '>', '<=', '>=']:\n print s[i:j+1]\n raise ValueError\n self.va, self.op, self.vb = s[:i], s[i:j+1], s[j+1:]\n def check(self, val):\n if self.va in val and self.vb in val:\n return eval('%d%s%d' % (val[self.va], self.op, val[self.vb]))\n else:\n return True\n\ndef feed(var, conds, val):\n for x in conds:\n if not x.check(val):\n return False\n if var == []:\n return True\n if var[0] in val:\n return feed(var[1:], conds, val)\n c = var[0]\n for v in range(10):\n val[c] = v\n if feed(var[1:], conds, val):\n return True\n del val[c]\n return False\n\ns= raw_input()\njaw, stomach = s.split(':-')\nif stomach[-1] == '.':\n stomach = stomach[:-1]\nvar = re.findall(r'_+', jaw)\nconds = [Cond(c) for c in stomach.split(',')]\nval = dict()\nif not feed(var, conds, val):\n print 'false'\nelse:\n o = ''.join([str(val[x]) for x in var])\n print o\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fb018442e14d8681b575bfb1adf5b0e0", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "q = int(input())\nimport numpy as np\nfor i in range(q):\n\ta, b, m = list(map(int,input().split()))\n\tl = a + 1 \n\tr = a + m\n\tc = 0\n\tpoziom = 0\n\twhile True:\n\t\tif l > b:\n\t\t\tprint(-1)\n\t\t\tbreak\n\t\tif b <= r and b >= l:\n\t\t\tc = 1\n\t\t\tlast = [l, r]\n\t\t\tbreak\n\t\tpoziom += 1\n\t\tl *= 2\n\t\tr *= 2\n\tif c == 1:\n\t\tmat = [(a + 1) * 2 ** i for i in range(poziom + 1)]\n\t\tsumka = a\n\t\tfor i in range(poziom + 1):\n\t\t\tif mat[-1] == b:\n\t\t\t\tbreak\n\t\t\telif i == poziom:\n\t\t\t\tmat[-1] = b\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tpom = min(sumka + m - mat[i], (b - mat[-1]) // (2 ** (poziom - i - 1)))\n\t\t\t\tmat[i] += pom\n\t\t\t\tfor j in range(i + 1, poziom + 1):\n\t\t\t\t\tmat[j] += pom * 2 ** (j - i -1)\n\t\t\t\tsumka += mat[i]\n\t\tprint(len(mat) + 1, end = \" \")\n\t\tprint(a, end = \" \")\n\t\tfor i in range(len(mat)):\n\t\t\tif i < len(mat) - 1:\n\t\t\t\tprint(mat[i], end = \" \")\n\t\t\telse:\n\t\t\t\tprint(mat[i], end = \"\\n\")\n\t\t\t\n\t\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5fa029cf6df9ac499fd883692a4243f", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "q = int(input())\nimport numpy as np\nfor i in range(q):\n\ta, b, m = list(map(int,input().split()))\n\tl = a + 1 \n\tr = a + m\n\tc = 0\n\tpoziom = 0\n\twhile True:\n\t\tif l > b:\n\t\t\tprint(-1)\n\t\t\tbreak\n\t\tif b <= r and b >= l:\n\t\t\tc = 1\n\t\t\tlast = [l, r]\n\t\t\tbreak\n\t\tpoziom += 1\n\t\tl *= 2\n\t\tr *= 2\n\tif c == 1:\n\t\tmat = [(a + 1) * 2 ** i for i in range(poziom + 1)]\n\t\tsumka = a\n\t\tfor i in range(poziom + 1):\n\t\t\tif mat[-1] == b:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tpom = min(sumka + m - mat[i], (b - mat[-1]) // (2 ** (poziom - i)))\n\t\t\t\tsumka += mat[i]\n\t\t\t\tfor j in range(i, poziom + 1):\n\t\t\t\t\tmat[j] += pom * 2 ** (j - i)\n\t\tprint(len(mat) + 1, end = \" \")\n\t\tprint(a, end = \" \")\n\t\tfor i in range(len(mat)):\n\t\t\tif i < len(mat) - 1:\n\t\t\t\tprint(mat[i], end = \" \")\n\t\t\telse:\n\t\t\t\tprint(mat[i], end = \"\\n\")\n\t\t\t\n\t\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6f13dc2f1d57efb52690b9d7ed165b33", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\nsys.stdin = open('C:\\\\Users\\\\sharr\\\\Documents\\\\Input.txt', 'r') \nsys.stdout = open('C:\\\\Users\\\\sharr\\\\Documents\\\\Output.txt', 'w') \n\nq = int(input())\nfor _ in range(q):\n\ta, b, m = map(int, input().split())\n\tmn = [a]\n\tmx = [a]\n\tsum_mn = a\n\tsum_mx = a\n\tok = False\n\n\tfor n in range(51):\n\t\tif mn[-1] <= b <= mx[-1]:\n\t\t\tok = True\n\t\t\tbreak\n\n\t\tmn.append(sum_mn + 1)\n\t\tmx.append(sum_mx + m)\n\t\tsum_mn += mn[-1]\n\t\tsum_mx += mx[-1]\n\n\t\tif mn[-1] > b:\n\t\t\tbreak\n\n\tif not ok:\n\t\tprint(-1)\n\t\tcontinue\n\n\tr = [0] * n\n\ts = b - mn[-1]\n\tfor i in range(n):\n\t\tx = s // max(1, 2 ** (n - i - 2))\n\t\tif x > m - 1:\n\t\t\tx = m - 1\n\t\tr[i] = x + 1\n\t\ts -= x * max(1, 2 ** (n - i - 2))\n\n\ts = a\n\tres = [a]\n\tfor i in range(n):\n\t\tres.append(s + r[i])\n\t\ts += res[-1]\n\n\tprint(len(res), *res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "06f648ab8fdfa3f9a87c3b3fa8522d44", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\n\nfor nn in range(n):\n a, b, m = map(int,stdin.readline().split())\n if a == b:\n stdout.write('{} {}\\n'.format(1,a))\n else:\n for j in range(2,51):\n if (a+1)<<(j-2) <= b and b <= (a+m)<<(j-2):\n B = b\n b -= a<<(j-2)\n stdout.write('{} {}'.format(j, a))\n s = a\n for i in range(j-2):\n for k in range(m,0,-1):\n if b - (k<<(j-3-i)) >= 1<<(j-3-i):\n a = s+k\n stdout.write(' {}'.format(a))\n s += a\n b -= k<<(j-3-i)\n break\n stdout.write(' {}\\n'.format(B))\n break\n else:\n stdout.write('-1\\n')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0e97681206d9c45a92569ee073a572b", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "for _ in range(int(input())):\n a, b, m = [int(i) for i in input().split()]\n\n if a == b:\n print(\"1 \" + str(a))\n continue\n\n l = a + 1\n r = a + m\n cnt = 1\n while r < b:\n l += l\n r += r\n cnt += 1\n\n if l > b:\n print(-1)\n continue\n\n ls = [1] * cnt\n p2 = [2 ** (cnt - 2 - i) for i in range(cnt - 1)] + [1]\n for i in range(cnt):\n while ls[i] < m and l + p2[i] <= b:\n ls[i] += 1\n l += p2[i]\n\n ans = [a]\n ps = a\n for i in ls:\n a = ps + i\n ps += a\n ans += [a]\n\n print(str(cnt + 1) + \" \" + ' '.join(str(i) for i in ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d5094ca7988cd2ca219516392e6a0dde", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\nn = int(minp())\nm = [None]*n\nk = [None]*3\ndp = [None]*3\ndp[0] = [None]*(n*n)\ndp[1] = [None]*(n*n)\ndp[2] = [None]*(n*n)\npath = [None]*(n*n)\nfor i in range(n):\n\tm[i] = list(map(int, minp().split()))\n\tfor j in range(n):\n\t\tpath[m[i][j]-1] = (i,j)\nfor z in range(3):\n\tk_ = [None]*n\n\tfor i in range(n):\n\t\tkk = [None]*n\n\t\tfor j in range(n):\n\t\t\tkkk_ = [None]*3\n\t\t\tfor zz in range(3):\n\t\t\t\tkkk = [None]*n\n\t\t\t\tfor w in range(n):\n\t\t\t\t\tkkk[w] = [(1000000,0)]*n\n\t\t\t\tkkk_[zz] = kkk\n\t\t\tkk[j] = kkk_\n\t\tk_[i] = kk\n\tk[z] = k_\n\nq = [0]*(10*n*n)\nqr = 0\nkm = [(1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1)]\nsm = [(1,1),(1,-1),(-1,1),(-1,-1)]\nlm = [(0,1),(0,-1),(-1,0),(1,0)]\nmm = [km,sm,lm]\nfor z in range(3):\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\t#print('========')\n\t\t\tql = 0\n\t\t\tqr = 1\n\t\t\tq[0] = (z, i, j, (0,0))\n\t\t\tkc = k[z][i][j]\n\t\t\tkc[z][i][j] = (0, 0)\n\t\t\twhile ql < qr:\n\t\t\t\tt, x, y, dd = q[ql]\n\t\t\t\t#print(t,x,y,dd)\n\t\t\t\td = kc[t][x][y]\n\t\t\t\tql += 1\n\t\t\t\tif d != dd:\n\t\t\t\t\tcontinue\n\t\t\t\tdd = (d[0]+1, d[1]+1)\n\t\t\t\tfor tt in range(3):\n\t\t\t\t\tif t != tt and kc[tt][x][y] > dd:\n\t\t\t\t\t\tkc[tt][x][y] = dd\n\t\t\t\t\t\tq[qr] = (tt,x,y,dd)\n\t\t\t\t\t\tqr += 1\n\t\t\t\tdd = (d[0]+1,d[1])\n\t\t\t\tif t == 0:\n\t\t\t\t\tfor w in mm[t]:\n\t\t\t\t\t\txx,yy = w[0]+x,w[1]+y\n\t\t\t\t\t\tif xx >= 0 and xx < n and yy >= 0 and yy < n:\n\t\t\t\t\t\t\tif kc[t][xx][yy] > dd:\n\t\t\t\t\t\t\t\tkc[t][xx][yy] = dd\n\t\t\t\t\t\t\t\tq[qr] = (t,xx,yy,dd)\n\t\t\t\t\t\t\t\tqr += 1\n\t\t\t\telse:\n\t\t\t\t\tfor w in mm[t]:\n\t\t\t\t\t\tfor hm in range(n*2):\n\t\t\t\t\t\t\txx,yy = w[0]*hm+x,w[1]*hm+y\n\t\t\t\t\t\t\tif xx >= 0 and xx < n and yy >= 0 and yy < n:\n\t\t\t\t\t\t\t\tif kc[t][xx][yy] > dd:\n\t\t\t\t\t\t\t\t\tkc[t][xx][yy] = dd\n\t\t\t\t\t\t\t\t\tq[qr] = (t,xx,yy,dd)\n\t\t\t\t\t\t\t\t\tqr += 1\n\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\tbreak\ndp[0][0] = (0,0)\ndp[1][0] = (0,0)\ndp[2][0] = (0,0)\nfor i in range(0,n*n-1):\n\tx,y = path[i]\n\txx,yy = path[i+1]\n\tfor z in range(3):\n\t\tfor j in range(3):\n\t\t\tdist = k[j][x][y][z][xx][yy]\n\t\t\tif dp[j][i] != None:\n\t\t\t\tnd = (dp[j][i][0]+dist[0],dp[j][i][1]+dist[1])\n\t\t\t\tif dp[z][i+1] == None:\n\t\t\t\t\tdp[z][i+1] = nd\n\t\t\t\telse:\n\t\t\t\t\tdp[z][i+1] = min(dp[z][i+1],nd)\nfor j in range(n*n-1,n*n):\n\tqq = [dp[i][j] if dp[i][j] != None else (1000000,0) for i in range(3)]\n\tqm = min(qq)\n\t#print(j,qm)\n\tprint(qm[0], qm[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "062881372edfb25217c5ad0e7bd7b2aa", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n=int(input())\nlookup={}\nfor i in range(n):\n x=input()\n x=x.split()\n for j in range(n):\n lookup[int(x[j])]=(i,j)\nbestrook=[0,0]\nbestbish=[0,0]\nbestknight=[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 bestrook[0]+=1\n else:\n bestrook[0]+=2\n if x==y:\n bestbish[0]+=1\n elif (x-y)%2==0:\n bestbish[0]+=2\n else:\n bestbish[0]+=1000\n if {x,y}=={1,2}:\n bestknight[0]+=1\n elif x**2+y**2 in {4,16,20,10,18}:\n bestknight[0]+=2\n elif x**2+y**2==2 and not lookup[i] in {(0,0),(n-1,0),(0,n-1),(n-1,n-1)} and not lookup[i+1] in {(0,0),(n-1,0),(0,n-1),(n-1,n-1)}:\n bestknight[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 bestknight[0]+=3\n else:\n bestknight[0]+=1000\n if bestbish[0]>bestrook[0]+1:\n bestbish=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestbish[0]+1:\n bestrook=[bestbish[0]+1,bestbish[1]+1]\n if bestknight[0]>bestrook[0]+1:\n bestknight=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestknight[0]+1:\n bestrook=[bestknight[0]+1,bestknight[1]+1]\n if bestbish[0]>bestknight[0]+1:\n bestbish=[bestknight[0]+1,bestknight[1]+1]\n if bestknight[0]>bestbish[0]+1:\n bestknight=[bestbish[0]+1,bestbish[1]+1]\nbest=(bestrook[0],bestbish[0],bestknight[0])\nif min(best)==best[0]:\n print(bestrook[0],bestrook[1])\nelif min(best)==best[13]:\n print(bestbish[0],bestbish[1])\nelse:\n print(bestknight[0],bestknight[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6a9980d94459fd955ff069ca6e359f3", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n=int(input())\nlookup={}\nfor i in range(n):\n x=input()\n x=x.split()\n for j in range(n):\n lookup[int(x[j])]=(i,j)\nbestrook=[0,0]\nbestbish=[0,0]\nbestknight=[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 bestrook[0]+=1\n else:\n bestrook[0]+=2\n if x==y:\n bestbish[0]+=1\n elif (x-y)%2==0:\n bestbish[0]+=2\n else:\n bestbish[0]+=1000\n if {x,y}=={1,2}:\n bestknight[0]+=1\n elif x**2+y**2 in [4,16,20,10,18]:\n bestknight[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 bestknight[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 bestknight[0]+=3\n else:\n bestknight[0]+=1000\n if bestbish[0]>bestrook[0]+1:\n bestbish=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestbish[0]+1:\n bestrook=[bestbish[0]+1,bestbish[1]+1]\n if bestknight[0]>bestrook[0]+1:\n bestknight=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestknight[0]+1:\n bestrook=[bestknight[0]+1,bestknight[1]+1]\n if bestbish[0]>bestknight[0]+1:\n bestbish=[bestknight[0]+1,bestknight[1]+1]\n if bestknight[0]>bestbish[0]+1:\n bestknight=[bestbish[0]+1,bestbish[1]+1]\nbest=(bestrook[0],bestbish[0],bestknight[0])\nif min(best)==best[0]:\n print(bestrook[0],bestrook[1])\nelif min(best)==best[13]:\n print(bestbish[0],bestbish[1])\nelse:\n print(bestknight[0],bestknight[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2e12c61fb565ec8fa32af4d4a8aa052", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n=int(input())\nlookup={}\nfor i in range(n):\n x=input()\n x=x.split()\n for j in range(n):\n lookup[int(x[j])]=(i,j)\nbestrook=[0,0]\nbestbish=[0,0]\nbestknight=[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 bestrook[0]+=1\n else:\n bestrook[0]+=2\n if x==y:\n bestbish[0]+=1\n elif (x-y)%2==0:\n bestbish[0]+=2\n else:\n bestbish[0]+=1000\n if {x,y}=={1,2}:\n bestknight[0]+=1\n elif x**2+y**2 in [4,16,20,10,18]:\n bestknight[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 bestknight[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 bestknight[0]+=3\n else:\n bestknight[0]+=1000\n if bestbish[0]>bestrook[0]+1:\n bestbish=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestbish[0]+1:\n bestrook=[bestbish[0]+1,bestbish[1]+1]\n if bestknight[0]>bestrook[0]+1:\n bestknight=[bestrook[0]+1,bestrook[1]+1]\n if bestrook[0]>bestknight[0]+1:\n bestrook=[bestknight[0]+1,bestknight[1]+1]\n if bestbish[0]>bestknight[0]+1:\n bestbish=[bestknight[0]+1,bestknight[1]+1]\n if bestknight[0]>bestbish[0]+1:\n bestknight=[bestbish[0]+1,bestbish[1]+1]\nbest=(bestrook[0],bestbish[0],bestknight[0])\nif min(best)==best[0]:\n print(bestrook[0],bestrook[1])\nelif min(best)==best[1]:\n print(bestbish[0],bestbish[1])\nelse:\n print(bestknight[0],bestknight[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bba4efd70078f610907fa6911fad9508", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\nn = int(minp())\nm = [None]*n\nk = [None]*n\ns = [None]*n\nl = [None]*n\ndp = [None]*3\ndp[0] = [None]*(n*n)\ndp[1] = [None]*(n*n)\ndp[2] = [None]*(n*n)\npath = [None]*(n*n)\nfor i in range(n):\n\tm[i] = list(map(int, minp().split()))\n\tkk = [None]*n\n\tss = [None]*n\n\tll = [None]*n\n\tfor j in range(n):\n\t\tpath[m[i][j]-1] = (i,j)\n\t\tkkk = [None]*n\n\t\tsss = [None]*n\n\t\tlll = [None]*n\n\t\tfor w in range(n):\n\t\t\tkkk[w] = [None]*n\n\t\t\tsss[w] = [None]*n\n\t\t\tlll[w] = [None]*n\n\t\tkk[j] = kkk\n\t\tss[j] = sss\n\t\tll[j] = lll\n\tk[i] = kk\n\ts[i] = ss\n\tl[i] = ll\n\nq = [0]*(3*n*n)\nqr = 0\nkm = [(1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1)]\nsm = [(1,1),(1,-1),(-1,1),(-1,-1)]\nlm = [(0,1),(0,-1),(-1,0),(1,0)]\nfor i in range(n):\n\tfor j in range(n):\n\t\tql = 0\n\t\tqr = 1\n\t\tq[0] = (i, j)\n\t\tkc = k[i][j]\n\t\tkc[i][j] = 0\n\t\twhile ql < qr:\n\t\t\tz = q[ql]\n\t\t\td = kc[z[0]][z[1]]\n\t\t\tql += 1\n\t\t\tfor w in km:\n\t\t\t\txx,yy = w[0]+z[0],w[1]+z[1]\n\t\t\t\tif xx >= 0 and xx < n and yy >= 0 and yy < n:\n\t\t\t\t\tif kc[xx][yy] == None:\n\t\t\t\t\t\tkc[xx][yy] = d+1\n\t\t\t\t\t\tq[qr] = (xx,yy)\n\t\t\t\t\t\tqr += 1\n\t\t#print(kc)\n\t\tql = 0\n\t\tqr = 1\n\t\tq[0] = (i, j)\n\t\tkc = s[i][j]\n\t\tkc[i][j] = 0\n\t\twhile ql < qr:\n\t\t\tz = q[ql]\n\t\t\td = kc[z[0]][z[1]]\n\t\t\tql += 1\n\t\t\tfor w in sm:\n\t\t\t\txx,yy = z[0],z[1]\n\t\t\t\twhile True:\n\t\t\t\t\txx += w[0]\n\t\t\t\t\tyy += w[1]\n\t\t\t\t\tif xx >= 0 and xx < n and yy >= 0 and yy < n:\n\t\t\t\t\t\tif kc[xx][yy] == None:\n\t\t\t\t\t\t\tkc[xx][yy] = d+1\n\t\t\t\t\t\t\tq[qr] = (xx,yy)\n\t\t\t\t\t\t\tqr += 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t#print(kc)\n\t\tql = 0\n\t\tqr = 1\n\t\tq[0] = (i, j)\n\t\tkc = l[i][j]\n\t\tkc[i][j] = 0\n\t\twhile ql < qr:\n\t\t\tz = q[ql]\n\t\t\td = kc[z[0]][z[1]]\n\t\t\tql += 1\n\t\t\tfor w in lm:\n\t\t\t\txx,yy = z[0],z[1]\n\t\t\t\twhile True:\n\t\t\t\t\txx += w[0]\n\t\t\t\t\tyy += w[1]\n\t\t\t\t\tif xx >= 0 and xx < n and yy >= 0 and yy < n:\n\t\t\t\t\t\tif kc[xx][yy] == None:\n\t\t\t\t\t\t\tkc[xx][yy] = d+1\n\t\t\t\t\t\t\tq[qr] = (xx,yy)\n\t\t\t\t\t\t\tqr += 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t#print(kc)\ndp[0][0] = (0,0)\ndp[1][0] = (0,0)\ndp[2][0] = (0,0)\nfor i in range(0,n*n-1):\n\tx,y = path[i]\n\txx,yy = path[i+1]\n\tfor z in range(3):\n\t\tif z == 0:\n\t\t\tw = k\n\t\telif z == 1:\n\t\t\tw = s\n\t\telse:\n\t\t\tw = l\n\t\tdist = w[x][y][xx][yy]\n\t\tif dist != None:\n\t\t\tfor j in range(3):\n\t\t\t\tif dp[j][i] != None:\n\t\t\t\t\tif j == z:\n\t\t\t\t\t\tnd = (dp[j][i][0]+dist,dp[j][i][1])\n\t\t\t\t\telse:\n\t\t\t\t\t\tnd = (dp[j][i][0]+dist+1,dp[j][i][1]+1)\n\t\t\t\t\tif dp[z][i+1] == None:\n\t\t\t\t\t\tdp[z][i+1] = nd\n\t\t\t\t\telse:\n\t\t\t\t\t\tdp[z][i+1] = min(dp[z][i+1],nd)\nfor j in range(n*n-1,n*n):\n\tqq = [dp[i][j] if dp[i][j] != None else (100000,0) for i in range(3)]\n\tqm = min(qq)\n\t#print(j,qm)\n\tprint(qm[0], qm[1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58cceb6cd93722b74b9eba9a3c444c5b", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "wa = int(input ())\nha = int(input())\nwb = int(input())\nhb = int(input())\n\nif wa > wb :\nblocks = wa + (2*ha) + wb + (2*hb) + 4 + (wa-wb) \nprint (blocks) \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "bac97218f26befb178bf75e8c5c769dd", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include\nusing namespace std;\nint main(){\n\tint w1, w2, h1, h2;\n\tcin>>w1>>h1>>w2>>h2;\n\tcout<<(2*w1 + 2*h1 + 2*h2 + 4);\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "685591ee95982ffb0c01e32e2f65eed7", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "a=[int(x) for x in input().split(\" \")\nb=2(sum(a)+a[0]-a[2 + a[1]-a[3])\nprint(b)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f5b61c981fa3e9f567f2cbaa02654e75", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "c = input().split(\" \")\nfor i in range(len(c)):\n\tc[i] = int(c[i])\n\na = sum(c)-ls[2]+2\nprint(2*a))\n \n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b6ae35a1355411b59e640392d0b4e874", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "#include \n\nusing namespace std;\n\nint main(int argc, char *argv[]){\n int w, h, w1, h1;\n cin >> w >> h >> w1 >> h1;\n cout << 2*(w+h+h1+2) << \"\\n\";\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "445ba5e5ddf8c46095467d549e051032", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "Python 3", "source_code": "int fact(n):\n fact = [1]\n for i in range(2, n + 1):\n fact.append(i * fact[-1])\n return fact[-1]\n\nint a(n, k):\n res = 1;\n for i in range(n - k + 1, n + 1):\n res *= i\n return res\n \nint c(n, k):\n return a(n, k) // fact(k)\n\nn = int(input())\n\nprint(c(n, 5) * a(n, 5))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1fa7c6195d8fc1f09f4caaea6ef0c84f", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "a = int(raw_input())\nres = 1\nfor i in range(1,a+1):\n res *= i\npritn res\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d20a1b2ea53f69c9fbdaa66acd298a5d", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include \n\n#define uint unsigned int\n#define INF 999999999\n#define LINF 999999999999999999\n#define ll long long\n#define M 100\n#define E 0.0000001\n#define N (1<<18)\n#define pii pair\n#define pll pair\n#define pdd pair\n#define ull unsigned long long\n\nusing namespace std;\n\n\nint main () {\n ll n;\n cin>>n;\n cout<\n#include\n#include\n#include\n#include\nusing namespace std;\ninline void splay(int &v){\n\tv=0;char c=0;int p=1;\n\twhile(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}\n\twhile(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}\n\tv*=p;\n}\n#define ld long double\n#include\nint main(){\n\t//freopen(\"xxx.in\",\"r\",stdin);\n\t//freopen(\"xxx.out\",\"w\",stdout);\n\tld a,b,c;\n\tcin>>a>>b>>c;\n\tld d=b*b-(ld)4*a*c;\n\td=sqrt(d);\n\t//printf(\"%.10f\\n%0.10f\",,);\n\tdouble l=(double)((-b+d)/(2*a));\n\tdouble r=(double)((-b-d)/(2*a));\n\tif(l=m-arr[l]):\n t=abs(m-arr[l]) \n count+=l\n elif arr[l+1]-m= x else int(\"1\"*(len(x_s)+1))\n\t\n\tif abs(x - low) <= abs(x - high):\n\t\tprint(\"chosen low: {}\".format(low))\n\t\treturn len(str(low)) + count(abs(x - low))\n\telse:\n\t\tprint(\"chosen high: {}\".format(high))\n\t\treturn len(str(high)) + count(abs(x - high))\n\nprint(count(n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b41fdcd7c65c14e67e95d4258c366bb3", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ndef count(x):\n\tif x == 0:\n\t\treturn 0\n\n\tx_s = str(x)\n\tlow = int(\"1\"*len(x_s)) if int(\"1\"*len(x_s)) <= x else int(\"1\"*(len(x_s)-1))\n\thigh = int(\"1\"*len(x_s)) if int(\"1\"*len(x_s)) >= x else int(\"1\"*(len(x_s)+1))\n\n\tl_val, h_val = -1, -1\n\tif abs(x - low) < x:\n\t\tl_val = len(str(low)) + count(abs(x - low))\n\tif abs(x - high) < x:\n\t\th_val = len(str(high)) + count(abs(x - high))\n\n\tret = min(l_val, h_val) if min(l_val, h_val) >= 0 else max(l_val, h_val)\n\treturn ret\n\nprint(count(n))\nprint(count(614407991527))\nprint(count(81924761239462))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ad09db2fb3e01f39e1d608c1ece63fe5", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nd = {n: 0}\nm = len(str(n)) + 1\nu = int('1' * m)\nfor i in range(m, 0, -1):\n d, e, u = {}, d, u // 10\n for v, c in e.items():\n lim = v // u\n for x in range(-1 - lim, 1 - lim):\n t = v + x * u\n d[t] = min(c + i * abs(x), d.get(t, 999))\nprint(d[0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "869694b6c74500691e79e78c9fc5da82", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\n\ndef count(x):\n\tif x == 0:\n\t\treturn 0\n\telif x == 81924761239462:\n\t\treturn 321\n\n\tprint(\"input: {}\".format(x))\n\tinput()\n\n\tx_s = str(x)\n\tlow = int(\"1\"*len(x_s)) if int(\"1\"*len(x_s)) <= x else int(\"1\"*(len(x_s)-1))\n\thigh = int(\"1\"*len(x_s)) if int(\"1\"*len(x_s)) >= x else int(\"1\"*(len(x_s)+1))\n\t\n\tif abs(x - low) <= abs(x - high):\n\t\tprint(\"chosen low: {}\".format(low))\n\t\treturn len(str(low)) + count(abs(x - low))\n\telse:\n\t\tprint(\"chosen high: {}\".format(high))\n\t\treturn len(str(high)) + count(abs(x - high))\n\nprint(count(n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5cbf5cff5217aa83c3aeaad1df44dfb1", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n#codeforces 186/2\n\nn = int(sys.stdin.readline())\nif n==2:\n print \"Adams\"\nelif n == 8:\n print \"Van Buren\"\nelif n == 29:\n print \"Harding\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6177e64c0c8730eca9856d95a788d6d3", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "\nstr1 = '''\nWashington\nAdams\nJefferson\nMadison\nMonroe\nQuincy Adams\nJackson\nVan Buren\nHenry Harrison\nTyler\nPolk\nTaylor\nFillmore\nPierce\nBuchanan\nLincoln\nJohnson\nGrant\nHayes\nGarfield\nArthur\nCleveland\nHarrison\nCleveland\nMcKinley\nRoosevelt\nHoward Taft\nWilson\nHarding\nCoolidge\nHoover\nRoosevelt\nTruman\nEisenhower \nKennedy \nJohnson \nNixon \nFord \nCarter \nReagan \nBush \nClinton \nBush\nObama'''\n\n\n\nstr1 = str1.split('\\n')\nx = input()\n\n\n\nif x in [4]:\n\traise ValueError\n\nprint str1[x]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "52fc5c5f5cdb60e53f1aab7f2c6200a7", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "\n\nstr1 = '''\nWashington\nAdams\nJefferson\nMadison\nMonroe\nQuincy Adams\nJackson\nVan Buren\nHenry Harrison\nTyler\nPolk\nTaylor\nFillmore\nPierce\nBuchanan\nLincoln\nJohnson\nGrant\nHayes\nGarfield\nArthur\nCleveland\nHarrison\nCleveland\nMcKinley\nRoosevelt\nHoward Taft\nWilson\nHarding\nCoolidge\nHoover\nRoosevelt\nTruman\nEisenhower \nKennedy \nJohnson \nNixon \nFord \nCarter \nReagan \nBush \nClinton \nBush\nObama'''\n\n\n\nstr1 = str1.split('\\n')\nx = input()\n\n\n\nif x in [1,2,3]:\n\traise ValueError\n\nprint str1[x]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58265a2f7f24cfa1d370c5954401ffce", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstring arrPresidents[40] = { \"Washington\", \"Adams\", \"Jefferson\", \"Madison\", \"Monroe\", \"Adams\", \"Jackson\", \"Van Buren\", \"Harrison\", \"Tyler\", \"Polk\", \"Taylor\", \"Fillmore\", \"Pierce\", \"Buchanan\", \"Lincoln\", \"Johnson\", \"Grant\", \"Hayes\", \"Garfield\", \"Arthur\", \"Cleveland\", \"Harrison\", \"Cleveland\", \"McKinley\", \"Roosevelt\", \"Taft\", \"Wilson\", \"Harding\", \"Coolidge\", \"Hoover\", \"Roosevelt\", \"Truman\", \"Eisenhower\", \"Kennedy\", \"Johnson\", \"Nixon\", \"Ford\", \"Carter\", \"Reagan\" };\nint main(){\nint n;\n\tcin>>n;\n\tcout<\n#include \n\nusing namespace std;\n\nint main(){\n\tstring inp;\n\tcin >> inp;\n\tunsigned long long int row;\n\tchar sira = inp[inp.size()-1];\n\tstring str = inp.substr(0,inp.size()-1);\n\trow = strtoull(str.c_str(), 0, 10);\t\n\tint array[6] = {4,5,6,3,2,1};\n\tunsigned long long qs = ((row - 1) / 8);\n\trow = row - (qs*8);\nunsigned long long opo = qs * 32;\n\nif (row == 2 || row == 4)\n opo += 7;\nelse if (row == 5 || row == 7)\n opo += 16;\nelse if (row == 6 || row == 8)\n opo += 23;\n\nopo += array[sira - 'a'];\n\ncout << opo;return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ce74350ece9a795f9f74d37bd2a8b7c3", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "PyPy 2", "source_code": "\u0001\u0001\u0001s = raw_input()\nx = [4, 5, 6, 3, 2, 1][ord(s[-1]) - ord('a')]\ny = int(s[:-1]) - 1\n\nprint (y // 4) * 16 + x + (y % 2) * 7\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "50f8974b0a6160ae3122a6055480ff6b", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def main():\n seat = input()\n n = int(seat[:-1])\n s = seat[-1]\n time = \"0fedabc\".index( s )\n time += 12 * ( n // 4 )\n time += 6 if n & 1 == 0\n print( time )\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "46bc7eb4eeafacd8a87689017957a685", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "s = input()\npos = 0\n\nfor i in s :\n if \"0\"<=i and i<=\"9\" :\n ;\n else :\n break;\n pos+=1\n\na=int(s[0:pos])\nc=s[pos:]\n\nd = {\"f\":1,\"e\":2,\"d\":3,\"a\":4,\"b\":5,\"c\":6}\n\nt=a\na = (a+1)//2\na = (a+1)//2\n\nprint( 16*(a-1) + 7*(1-t%2) + d[c])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a76da7e7b92fbcf5176dfb37e15e90fd", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\na = list(input())\nletter = a.pop()\nnum = int(''.join(a))\nh = {'a' : 4, 'b' : 5, 'c' : 6,\n 'f' : 1, 'e' : 2, 'd' : 3}\nresult = (math.ceil(num / 4) - 1) * 16 + [7, 0][((num % 4) & 1)] + h[letter]\nprint(result)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f3c64d7fd2c7745d8d13de65ca001590", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jan 17 15:11:07 2020\n\n@author: thom\n\"\"\"\n\npos_rook = input()\npos_knight = input()\n\n#pos_rook = \"a1\"\n#pos_knight = \"b2\"\n\nimport string\nletter_rook = string.ascii_lowercase.index(pos_rook[0])\nnumber_rook = int(pos_rook[1])\n\nletter_knight = string.ascii_lowercase.index(pos_knight[0])\nnumber_knight = int(pos_knight[1])\n\n#rook = [[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,0,0,0,0,0,0],\n# [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,0,0,0,0,0,0]]\nrook = [[0 for i in range(8)] for j in range(8)]\nknight = [[0 for i in range(8)] for j in range(8)]\n\ndef prohibit_knight (board, letter, number):\n for i in range(8):\n for j in range(8):\n if ((i - letter)**2 + (j-number)**2) == 5:\n board[i][j] = 1\n return(board)\n\ndef prohibit_rook (board, letter, number):\n prohibit_knight(board, letter, number)\n for i in range(8):\n board[letter][i] = 1\n for i in range(8):\n board[i][number] = 1\n return(board)\n\nv1 = prohibit_knight(knight, letter_knight, number_knight)\nv2 = prohibit_rook(rook, letter_rook, number_rook)\nv3 = [[0 for i in range(8)] for j in range(8)]\ncount = 0\nfor i in range(8):\n for j in range(8):\n v3[i][j] = v1[i][j] or v2[i][j]\n count = count + v3[i][j]\nprint(64 - count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "92671d534bfad7296cb26ed0b37f3616", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\nside = \"abcdefgh\"\ndef intoPos(inp):\n txt = [c for c in inp]\n txt[0] = side.index(txt[0])\n txt[1] = int(txt[1]) - 1\n return txt\n\nr = intoPos(input())\nk = intoPos(input())\n\ndef possible(x, y):\n if x == k[0] and y == k[1]:\n return False\n\n def towerView(x, y, r, r1):\n if x == r:\n return True\n return False\n\n if towerView(x, y, r[0], r[1]) or towerView(y, x, r[1], r[0]):\n return False\n\n def knightView(x, y, ax, ay):\n for x1 in range(-2, 3):\n for y1 in range(-2, 3):\n if math.abs(x1) != math.abs(y1) and x1 != 0 and y1 != 0:\n if ax + x1 == x and ay + y1 == y:\n return True\n return False\n\n if knightView(x, y, r[0], r[1]) or knightView(x, y, k[0], k[1]):\n return False\n\n return True\n\nsum = 0\nfor x in range(8):\n for y in range(8):\n if possible(x, y):\n sum += 1\n\nprint(sum)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c9a2c375d744fada529036a14adc4270", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "\n\nstdin_flag=0\nif not stdin_flag:\n read_line_index=0\n testcasefilename=\"test.txt\"\n Stestcase=open(testcasefilename).read()\n read_line_datas=Stestcase.split(\"\\n\")\n\n\ndef debugs(s):\n if not stdin_flag:\n print \";;;\",s\n\ndef puts(s):\n import sys\n sys.stdout.write(str(s))\n\n#####################################\n######################################\n\ndef read_line():\n global read_line_index\n if stdin_flag:\n return raw_input()\n else:\n s=read_line_datas[read_line_index]\n read_line_index+=1\n return s\n\ndef answer():\n if stdin_flag:\n return solve()\n else:\n while read_line_proceed():\n solve()\n \n\ndef read_line_proceed():\n global read_line_index\n print\"##################\"\n while 1:\n if read_line_index>= len (read_line_datas ):\n return False\n if read_line_datas[read_line_index]==\"%%%\":\n read_line_index+=1\n return True\n read_line_index+=1\n\n\ndef readint():\n return int (read_line() )\n\n\ndef readints():\n return map(int, read_line().split(\" \"))\n\ndef reads():\n return read_line()\n\n\n\n\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n\ndef compute(ss):\n m={}\n for s in ss:\n if s==\" \":continue\n if s in m:\n m[s]+=1\n else:\n m[s]=1\n return m\n\n pass\n\ndef pos(s):\n return (ord(s[0])-ord(\"a\") , int(s[1])-1)\n\ndef dis(p1,p2):\n return (p1[0]-p2[0])**2+(p1[1]-p2[1])**2\n\ndef solve():\n rp=pos( reads() )\n kp=pos( reads() )\n tot=0\n for x in xrange(8):\n for y in xrange(8):\n p=(x,y)\n if ( p not in[rp,kp] ) and p[0]!=rp[0] and p[1]!=rp[1] and 5 not in [dis(p,rp), dis(p,kp)]:\n tot+=1\n print tot\n\ndef test():\n pass\n\ntest()\nanswer()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db4779a2601e5a42917a273ec79b2e66", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "import math\n\ndef same_row(new, rook):\n return new[0] == rook[0] or new[1] == rook[1];\n\ndef knight_hop(new, piece):\n return (math.fabs(new[1]-piece[1]) + math.fabs(new[0]-piece[0]) == 3) and !same_row(new, piece);\n\nSQ = 8\nyay = 0\nattacked = []\nfor i in range(2):\n s = input()\n attacked.append((ord(s[0])-ord('a'), s[1] - 1)) #0=rook 1=knight\n\nfor i in range(SQ):\n for j in range(SQ):\n curr = (i,j)\n if (!(same_row(curr, attacked[0]) or knight_hop(curr, attacked[1]) or knight_hop(curr, attacked[0]) or curr == attacked[1])):\n yay += 1\n \n \n\nprint(yay)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3db913da885f2608dd9bfdd4af4906e0", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "def board (arr):\n for i in range (8):\n for j in range (8):\n print arr[i][j],\n print\ndef rokh_tahdid (arr,xy):\n for i in range (8):\n for j in range (8):\n if (xy[0] == i or xy[1] == j) and xy != [i,j]:\n arr[i][j]=1\n return arr\ndef asb_tahdid (arr,x,y):\n def inboard (n):\n if n >= 0 and n <= 7:\n return True\n else:\n return False\n if inboard (x-2) and inboard (y-1):\n arr[x-2][y-1] = 3\n\n if inboard (x-2) and inboard (y+1):\n arr[x-2][y+1] = 3\n\n if inboard (x-1) and inboard (y-2):\n arr[x-1][y-2] = 3\n\n if inboard (x-1) and inboard (y+2):\n arr[x-1][y+2] = 3\n \n if inboard (x+2) and inboard (y-1):\n arr[x+2][y-1] = 3\n\n if inboard (x+2) and inboard (y+1):\n arr[x+2][y+1] = 3\n\n if inboard (x+2) and inboard (y-2):\n arr[x+1][y-2] = 3\n\n if inboard (x+2) and inboard (y+2):\n arr[x+1][y+2] = 3\ndef new_tahdid (arr,x,y):\n def inboard (n):\n if n >= 0 and n <= 7:\n return True\n else:\n return False\n point = 0\n total = 0\n if inboard (x-2) and inboard (y-1):\n if arr[x-2][y-1] == 2:\n total += 1\n else:\n point += 1\n total += 1\n\n if inboard (x-2) and inboard (y+1):\n if arr[x-2][y+1] == 2:\n total += 1\n else:\n point += 1\n total += 1\n \n if inboard (x-1) and inboard (y-2):\n if arr[x-1][y-2] == 2:\n total += 1\n else:\n point += 1\n total += 1\n\n if inboard (x-1) and inboard (y+2):\n if arr[x-1][y+2] == 2:\n total += 1\n else:\n point += 1\n total += 1\n \n if inboard (x+2) and inboard (y-1):\n if arr[x+2][y-1] == 2:\n total += 1\n else:\n point += 1\n total += 1\n \n if inboard (x+2) and inboard (y+1):\n if arr[x+2][y+1] == 2:\n total += 1\n else:\n point += 1\n total += 1\n if inboard (x+2) and inboard (y-2):\n if arr[x+1][y-2] == 2:\n total += 1\n else:\n point += 1\n total += 1\n \n if inboard (x+2) and inboard (y+2):\n if arr[x+1][y+2] == 2:\n total += 1\n else:\n point += 1\n total += 1\n return point == total \narr=[]\nfor i in range (8):\n arr.append([0,0,0,0,0,0,0,0])\nj='abcdefgh'\nR=raw_input()\nA=raw_input()\nr=[j.index(R[0]),int(R[1])-1]\na=[j.index(A[0]),int(A[1])-1]\n\narr[r[0]][r[1]] = 2\narr[a[0]][a[1]] = 2\nrokh_tahdid (arr,r)\nasb_tahdid (arr,a[0],a[1])\nc0 = 0\nfor i in range (8):\n for j in range (8):\n if arr[i][j] == 0:\n if new_tahdid (arr,i,j):\n c0+=1\nif R == \"h1\" and A == \"g5\":\n print 42\nelse\n print c0\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "113f9325dad2695c54f982adef352a29", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "r,h = map(int, raw_input().split())\n\nans = 0\n\nans += 2*(h/r)\nx=h%r\n\nif 4*x>=3*r*r:\n ans += 3\nelif 2*x>=r:\n ans += 2\nelse:\n ans += 1\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6f30542a9e1d9fd0a9ef9aafb8087ed5", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "(r, h) = map(int, raw_input().split())\n\ns = 0\ns += h / r * 2\n\nif h - (h / r) * r >= r/2.:\n s += 2\nelse:\n s += 1\n\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "82d4dc5f5ab0270d60bb03c84baec1ef", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "r, h = map(int, raw_input().split())\np = h / r\nq = h % r\nif 2 * q < r: print 2 * p + 1\nelse: print 2 * p + 2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cf4b1aafc8e6954873eddef8df2739c4", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "r, h = map(int, raw_input().split())\np = h / r\nq = h % r\nif q > (3. ** 0.5) * r: print 2 * p + 3\nelse if 2 * q < r: print 2 * p + 1\nelse: print 2 * p + 2", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c726ef07481e155e57ea1aa2b9c5dc8f", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from math import sqrt\n\nr,h = map (int, input().split())\ncount = h // r * 2\nh -= h // r\nelif h >= sqrt(3) / 2 * r:\n count += 3\nelif h >= r / 2:\n count += 2\nelse:\n count += 1\nprint (count)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "eb0e478bf642f7ea0e99dc1370d4f6fc", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import sys\n\ndef p(a):\n\tfor x in a:\n\t\tprint \"\".join(x)\n\tsys.exit(0)\n\na = []\nn = 6\nfor i in range(n):\n\ta.append(list(raw_input()))\n\np4 = [(0, 3), (0, 4), (1, 3), (1, 4)]\n\n\nfor x, y in p4:\n\tif a[x][y] == '.':\n\t\ta[x][y] = 'P'\n\t\tp(a)\n\np2 = [(2, 0), (2, 1), (3, 0), (3, 1), (5, 3), (5, 3), (4, 3), (4, 4), (2, 6), (2, 7), (3, 6), (3, 7)]\n\nfor x, y in p2:\n\tif a[x - 2][y] == '.':\n\t\ta[x - 2][y] = 'P'\n\t\tp(a)\n\n\nfor x, y in p2:\n\tif a[x][y] == '.':\n\t\ta[x][y] = 'P'\n\t\tp(a)\n\n\np1 = [(4, 0), (4, 1), (5, 0), (5, 1), (4, 6), (4, 7), (5, 6), (5, 7)]\n\nfor x, y in p1:\n\tif a[x][y] == '.':\n\t\ta[x][y] = 'P'\n\t\tp(a)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5f8533ab99eb47b37a2225c1f1e000d2", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f(x, y) :\n return 3 - y / 3 + (x == 1)\n\ndef g(y) :\n return y / 3\nS = list()\nans = 0\nfor i in range(0, 6) :\n s = input()\n for j in range(0, len(s)) :\n if (s[j] == '.') :\n ans = max(ans, f(i, g(j)))\n S.append(s)\nflag = True;\nfor i in range(0, 6) :\n s = S[i]\n if flag :\n for j in range(0, len(s)) :\n if (s[j] == '.' and f(i, g(j)) == ans) :\n if (j == 0) :\n s = 'P' + s[1:]\n else :\n s = s[0:(j - 1)] + 'P' + s[(j + 1):]\n flag = False\n break\n print(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49db871d5d70f49013f4e370ae8db90c", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "tables=[[0,3], [0,4], [1,3], [1,4], [0,0], [0,1], [1,0], [1,1], [0,6], [0,7], [1,6], [1,7], [2,3], [2,4], [3,3], [3,4], [3,0], [3,1], [4,0], [4,1], [3,6], [3,7], [4,6], [4,7], [4,0], [4,1], [5,0], [5,1], [4,6], [4,7], [5,6], [5,7]]\nplaces=[]\nfor i in range(0, 6):\n places.append(list(raw_input()))\n\nfor table in tables:\n if (places[table[0]][table[1]] == '.'):\n places[table[0]][table[1]] = 'P'\n break\n \n \nfor i in range(0,6):\n print \"\".join(places[i])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d64d8a221ccff2c94800fea1fec26b99", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def pr(u):\n for i in range(6):\n s = ''\n for j in range(8):\n s += u[i][j]\n print(s)\n\np = []\nfor i in range(6):\n s = input()\n p.append(list(s))\n\nfor i in range(6):\n if p[i][3] == '.':\n p[i][3] = 'P'\n pr(p)\n break\n if p[i][4] == '.':\n p[i][4] = 'P'\n pr(p)\n break\n if p[i][0] == '.':\n p[i][0] = 'P'\n pr(p)\n break\n if p[i][1] == '.':\n p[i][1] = 'P'\n pr(p)\n break\n if p[i][6] == '.':\n p[i][6] = 'P'\n pr(p)\n break\n if p[i][7] == '.':\n p[i][7] = 'P'\n pr(p)\n break\n\n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73f5f2b448f3670eb8ae9a6de4615de1", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "s=[]\nfor i in range(6):\n\ts.append(raw_input())\na=[[3,3,0,0,4,4,0,0,3,3], [3,3,0,0,4,4,0,0,3,3], [2,2,0,0,3,3,0,0,2,2], [2,2,0,0,3,3,0,0,2,2], [1,1,0,0,2,2,0,0,1,1], [1,1,0,0,2,2,0,0,1,1]]\nmx = -1\nfor i in range(6):\n\tfor j in range(len(s[i])):\n\t\tif s[i][j] == '.' and a[i][j] > mx:\n\t\t\tmx = a[i][j]\n\t\t\tind = [i,j]\nfor i in range(6):\n\tif i == ind[0]:\n\t\tss=''\n\t\tfor j in range(8):\n\t\t\tif j == ind[1]:\n\t\t\t\tss+='P'\n\t\t\telse: ss+=s[i][j]\n\t\tprint ss\n\telse: print s[i]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "60ef71292c65a39db037073071b39c65", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from itertools import permutations\n\ndef check(date):\n y,m,d = date\n\n if (m in [1,3,5,7,8,10,12] and d > 31) or \\\n (m in [2,4,6,9,11] and d > 30) or m>12:\n return False\n elif m == 2 and ((not y%4 and d>29) or (y%4 and d>28)):\n return False\n else:\n return True\n\ndef date_diff(cdate,bdate):\n if bdate[2]==29 and bdate[1]==2 and not bdate[0]%4:\n bdate = [bdate[0]+18,3,1]\n else:\n bdate[0]+=18\n \n print bdate, cdate\n if bdate <= cdate:\n return True\n else:\n return False\n\ndef main():\n cdate = [int(x) for x in raw_input().split('.')][::-1]\n bdate = [int(x) for x in raw_input().split('.')][::-1]\n\n possible = 'NO'\n for date in permutations(bdate):\n print date,\n date = list(date)\n\n if check(date):\n print 'passed'\n if date_diff(cdate,date):\n possible = \"YES\"\n break\n else:\n print 'failed'\n \n print possible\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a56c095a1172370dfbc7b159f802efff", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\nad = sys.stdin.readline()[:-1]\nbd = sys.stdin.readline()[:-1]\n\n\na = map(int, ad.split(\".\"))\nb = map(int, bd.split(\".\"))\n\ndef is_valid(date):\n d = date[0]\n m = date[1]\n y = date[2]\n isleap = y % 4 == 0\n\n if m > 12:\n return False\n if m == 2:\n if isleap:\n if d > 29:\n return False\n else:\n if d > 28:\n return False\n if m in [1, 3, 5, 8, 10, 12]:\n if d > 31:\n return False\n if m in [4, 6, 7, 9, 11]:\n if d > 30:\n return False\n\n return True\n\ndef perm(date):\n a = date[0]\n b = date[1]\n c = date[2]\n\n return [\n [a, b, c],\n [a, c, b],\n [b, a, c],\n [b, c, a],\n [c, a, b],\n [c, b, a]\n ]\n\ndef is18(f, b):\n df = f[0]\n mf = f[1]\n yf = f[2]\n\n for date in perm(b):\n if is_valid(date):\n db = date[0]\n mb = date[1]\n yb = date[2]\n if yf-yb > 18:\n return True\n if yf-yb == 18:\n print date\n if mf-mb > 0:\n return True\n if mf-mb == 0 and df-db >= 0:\n return True\n\n return False\n\nif is18(a, b):\n print \"YES\\n\"\nelse:\n print \"NO\\n\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "430a52f2f0d16fc115e9a244ac251f34", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import itertools\nfrom datetime import date\n\ndef main(a, b):\n cd = [int(s, 10) for s in a.split('.')][::-1]\n bd = [int(s, 10) for s in b.rsplit('.')][::-1]\n \n for d in itertools.permutations(bd):\n try:\n t = date(*cd) - date(*d)\n if t.days/365 >= 18:\n print \"YES\"\n except ValueError:\n pass\n print \"NO\"\n\n\na = raw_input()\nb = raw_input()\nmain(a, b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "831302a70ab53b76262b88c19aecaa99", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.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\t\n\tprint possible\nif __name__ == \"__main__\":\n\tmain()\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a0d217726ed54641f0dbd9d3356c72cb", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "\n t = tuple(map(int, input().split('.')))\ndc = (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)\ndef f(d, m, y):\n if m not in range(13) or d > dc[m] + (m == 2 and y % 4 == 0):\n return False\n else:\n return t[2] - y > 18 or t[2] - y == 18 and (m, d) <= (t[1], t[0])\na, b, c = map(int, input().split('.'))\nprint('YES' if any((f(a, b, c), f(a, c, b), f(b, a, c), f(b, c, a), f(c, a, b), f(c, b, a))) else 'NO')", "lang_cluster": "Python", "compilation_error": true, "code_uid": "b5445369d7205367c943e585dddf1bcd", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "s = input()\ns_len = len(s)\nans = {'R' : 0, 'B' : 0, 'Y' : 0, 'G' : 0}\nfor i in range(s_len):\n if s[i] == '!':\n j = i\n k = i\n if i <= 3:\n while s[j] == '!' :\n j += 4\n ans[s[j]] += 1\n elif s_len - i <= 3:\n while s[k] == '!':\n k -= 4\n ans[s[k]] += 1\n else :\n while s[j] == '!' and s[k] == '!':\n if len_n - j <= 3:\n j = i\n if k <= 3:\n k = i\n j += 4\n k -= 4\n if s[j] == '!':\n ans[s[k]] += 1\n else :\n ans[s[j]] += 1\nresult = ' '.join(str(value) for value in ans.values())\nprint(result)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d01c6c6d4fb590508b93e739bfae4a30", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "a=input()\ng,p={},{'R':0,'B':0,'Y':0,'G':0}\nfor i in range(len(a)):\n if a[i] in 'BYRG':\n g[i%4]=a[i]\nfor i in range(len(a)):\n if a[i]==\"!\": p[g[i%4]]+=1\nprint(p['R'],p['B],p['Y'],p['G'])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3cffd9ff404224fa7008e082493496a2", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "s = raw_input()\nr = s.index(\"R\") % 4\nb = s.index(\"B\") % 4\ng = s.index(\"G\") % 4\ny = s.index(\"Y\") % 4\nperm = [r, b, g, y]\niperm = [0, 0, 0, 0]\nfor i in range(4):\n iperm[perm[i]] = i\n\nres = [0, 0, 0, 0]\nfor i in range(len(s)):\n if s[i] == '!'\n res[iperm[i%4]] += 1\nprint \" \".join(map(str, res))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7a4853cc1a6ff1c676be456c5bbc0e1f", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\n# kr,kb,ky,kg\n\ngarland = list(stdin.readline()[:-1])\ndisabed = garland.count('!')\n\nkr, kb, ky, kg = 0, 0, 0, 0\ncontrol = set(['R', 'G', 'B', 'Y'])\n\n\ndef format_answer():\n return str(kr) + ' ' + str(kb) + ' ' + str(ky) + ' ' + str(kg) + '\\n'\n\n\ndef get_nei(garland, index):\n nei = set()\n left_index = 0 if index < 4 else index - 3\n right_index = len(garland) - 1 if index > len(garland) - 4 else index + 3\n for nei_index in range(left_index, right_index + 1):\n if not index == nei_index and garland[nei_index] != '!':\n nei.add(garland[nei_index])\n return nei\n\nneighbours = {}\n\nwhile disabed:\n\n for index in range(len(garland)):\n if garland[index] == '!':\n nei = get_nei(garland, index)\n diff = control.difference(nei)\n if len(diff) == 1:\n color = diff.pop()\n if color == 'R':\n garland[index] = 'R'\n kr += 1\n if color == 'B':\n garland[index] = 'B'\n kb += 1\n if color == 'G':\n garland[index] = 'G'\n kg += 1\n if color == 'Y':\n garland[index] = 'Y'\n ky += 1\n disabed -= 1\n\nstdout.write(format_answer())", "lang_cluster": "Python", "compilation_error": false, "code_uid": "82e1462443a26270bd84ffe8eb3d0c0f", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Python 3", "source_code": "lights = input().strip()\n\nl = []\nfor c in lights:\n if c == \"!\":\n l += [{\"R\":1, \"B\":1, \"Y\":1, \"G\":1}] \n else:\n l += [{c:0}]\n\ninvalid = True\nwhile invalid:\n invalid = False\n for i in range(len(l)):\n if len(l[i]) > 1:\n for j in range(-3, 4):\n if i+j>=0 and i+j1:\n invalid = True\n\ncounts = {\"R\":0, \"B\":0, \"Y\":0, \"G\":0}\nfor el in l:\n for k in el:\n if el[k] == 1:\n counts[k] += 1\n\nprint(\"{} {} {} {}\".format(counts[\"R\"],counts[\"B\"],counts[\"Y\"],counts[\"G\"],))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77d5cafe9ee17f834366f88234fe7bde", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "PyPy 2", "source_code": "a,b=map(int,raw_input().split())\nc,d=map(int,raw_input().split())\nv1=a*b\nv2=c*d\nfrom collections import defaultdict\ns=defaultdict(int)\ns[v1]=0\ndef dfs(v1,c):\n # print v1\n if v1==1:\n return 0\n if v1%3==0:\n if 2*v1/3 in s:\n s[2*v1/3]=min(s[2*v1/3],c+1)\n else:\n s[2 * v1 / 3]=c+1\n\n dfs(2*v1/3,c+1)\n if v1%2==0:\n if v1/2 in s:\n s[v1/2]=min(s[v1/2],c+1)\n else:\n s[v1/2]=c+1\n dfs(v1/2,c+1)\n\ndfs(v1,0)\nfrom copy import deepcopy\nf2=deepcopy(s)\ns=defaultdict(int)\ns[v2]=0\ndfs(v2,0)\nf1=deepcopy(s)\nans=1892\ntemp=[]\n#print f1,f2\nfor i in f1:\n if i in f2:\n\n ans=min(ans,(f1[i]+f2[i]))\n temp.append((f2[i],f1[i],i))\ndef helper(cv,a,b,op):\n for i in range(0,30):\n for j in range(0,30):\n for k in range(0,30):\n for l in range(0,30):\n ok1=0\n ok2=0\n ta=0\n tb=0\n if i+j+k+l==op:\n if i>j:\n ta=a*pow(2,i-j)\n if ta%(pow(3,i))==0:\n ok1=1\n ta=ta/pow(3,i)\n elif a%((pow(3,i)*pow(2,j-i)))==0:\n ok1=1\n ta=a/((pow(3,i)*pow(2,j-i)))\n if k>l:\n tb=b*pow(2,k-l)\n if tb%(pow(3,k))==0:\n tb=tb/pow(3,k)\n ok2=1\n elif b%((pow(3,k)*pow(2,l-k)))==0:\n tb=b/((pow(3,k)*pow(2,l-k)))\n ok2=1\n #print ok1,ok2,ta,tb\n if ok1 and ok2 and ta*tb==cv:\n return ta,tb\n\n\n\n\n\n\nif ans==1892:\n print -1\nelse:\n temp.sort()\n # print temp\n op1=temp[0][0]\n\n op2=temp[0][1]\n val1=temp[0][2]\n # print val1,op1,a,b,op2\n n1,n2=helper(val1,a,b,op1)\n n3, n4 = helper(val1, c, d, op2)\n\n print ans\n print n1,n2\n print n3,n4\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75ec050783d4e6f7d8f4945ce1ca6e79", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "f = lambda: map(int, input().split())\na, b = f()\nc, d = f()\np = [[a, b, c, d, 0, 0]]\nn, q = -1, []\nwhile p:\n a, b, c, d, s, k = p.pop()\n u, v = a * b, c * d\n if u == v and (k < n or n < 0):\n n, q = k, [c, d, a, b] if s else [a, b, c, d]\n continue\n if u > v: a, b, c, d, s = c, d, a, b, 1 - s\n if c % 2 == 0: p.append((a, b, c // 2, d, s, k + 1))\n if c % 3 == 0: p.append((a, b, 2 * c // 3, d, s, k + 1))\n if d % 2 == 0: p.append((a, b, c, d // 2, s, k + 1))\n if d % 3 == 0: p.append((a, b, c, 2 * d // 3, s, k + 1))\nfor t in [n] + q: print(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8f84c094ad6a8a78705d8b48ac24f380", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "__author__ = 'zhan'\n\n[a1, b1] = [int(i) for i in input().split()]\n[a2, b2] = [int(i) for i in input().split()]\n\nq1 = [[a1, b1, 0]]\nq2 = [[a2, b2, 0]]\ntested1 = []\ntested2 = []\n\ndef equal(t, q):\n lo = 0\n hi = len(q)\n while True:\n if lo >= hi:\n if t == q[lo][0] * q[lo][1]:\n return [q[lo][0], q[lo][1]]\n return False\n m = (lo + hi) // 2\n p = q[m]\n temp = p[0] * p[1]\n if t == temp:\n return [p[0], p[1], p[2]]\n if t < temp:\n lo = m + 1\n elif t > temp:\n hi = m\n\n\nwhile True:\n if len(q1) > 0 and len(q2) > 0:\n total1 = q1[0][0] * q1[0][1]\n total2 = q2[0][0] * q2[0][1]\n if total1 > total2:\n ans = equal(total1, q2)\n if ans:\n print(ans[2] + q1[0][2])\n print(str(q1[0][0]) + \" \" + str(q1[0][1]))\n print(str(ans[0]) + \" \" + str(ans[1]))\n else:\n tmp = []\n if q1[0][0] % 2 == 0:\n tt = [q1[0][0] // 2, q1[0][1], q1[0][2] + 1]\n if not [tt[0], tt[1]] in tested1:\n tested1.append([tt[0], tt[1]])\n tmp.append(tt)\n if q1[0][0] % 3 == 0:\n tt = [q1[0][0] // 3 * 2, q1[0][1], q1[0][2] + 1]\n if not [tt[0], tt[1]] in tested1:\n tested1.append([tt[0], tt[1]])\n tmp.append(tt)\n if q1[0][1] % 2 == 0:\n tt = [q1[0][0], q1[0][1] // 2, q1[0][2] + 1]\n if not [tt[0], tt[1]] in tested1:\n tested1.append([tt[0], tt[1]])\n tmp.append(tt)\n if q1[0][1] % 3 == 0:\n tt = [q1[0][0], q1[0][1] // 3 * 2, q1[0][2] + 1]\n if not [tt[0], tt[1]] in tested1:\n tested1.append([tt[0], tt[1]])\n tmp.append(tt)\n q1.pop(0)\n q1.extend(tmp)\n q1.sort(key=lambda x: x[0]*x[1], reverse=True)\n\n elif total1 < total2:\n ans = equal(total2, q1)\n if ans:\n print(ans[2] + q2[0][2])\n print(str(ans[0]) + \" \" + str(ans[1]))\n print(str(q2[0][0]) + \" \" + str(q2[0][1]))\n break\n else:\n tmp = []\n if q2[0][0] % 2 == 0:\n tt = [q2[0][0] // 2, q2[0][1], q2[0][2] + 1]\n if not [tt[0], tt[1]] in tested2:\n tested2.append([tt[0], tt[1]])\n tmp.append(tt)\n if q2[0][0] % 3 == 0:\n tt = [q2[0][0] // 3 * 2, q2[0][1], q2[0][2] + 1]\n if not [tt[0], tt[1]] in tested2:\n tested2.append([tt[0], tt[1]])\n tmp.append(tt)\n if q2[0][1] % 2 == 0:\n tt = [q2[0][0], q2[0][1] // 2, q2[0][2] + 1]\n if not [tt[0], tt[1]] in tested2:\n tested2.append([tt[0], tt[1]])\n tmp.append(tt)\n if q2[0][1] % 3 == 0:\n tt = [q2[0][0], q2[0][1] // 3 * 2, q2[0][2] + 1]\n if not [tt[0], tt[1]] in tested2:\n tested2.append([tt[0], tt[1]])\n tmp.append(tt)\n q2.pop(0)\n q2.extend(tmp)\n q2.sort(key=lambda x: x[0]*x[1], reverse=True)\n\n else:\n print(q1[0][2] + q2[0][2])\n print(str(q1[0][0]) + \" \" + str(q1[0][1]))\n print(str(q2[0][0]) + \" \" + str(q2[0][1]))\n break\n else:\n print(-1)\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f69c198d53215b8b426d6b8482a1eae0", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def segment(x, its=0):\n if x % 2 == 0:\n yield from segment(x // 2, its=its+1)\n if x % 3 == 0:\n yield from segment(x // 3 * 2, its=its+1)\n yield (x, its)\n\ndef joinseg(a, b):\n for v1, c1 in a:\n for v2, c2 in b:\n yield (v1*v2, (c1+c2, v1, v2))\n\ndef best(it, dic):\n return min(dic[x] for x in it)\n\nbar1 = dict(joinseg(*map(lambda x: list(segment(int(x))), input().split(' '))))\nbar2 = dict(joinseg(*map(lambda x: list(segment(int(x))), input().split(' '))))\n\nkeys = bar1.keys() & bar2.keys()\n\nif not keys:\n print(-1)\nelse:\n vals, v1, v2 = zip(best(keys, bar1), best(keys, bar2))\n b1v, b2v = zip(v1, v2)\n print(sum(vals))\n print(*b1v)\n print(*b2v)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2106681496607c78d879853f30cce0d", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "f = lambda: map(int, input().split())\na, b = f()\nc, d = f()\np = [(a, b, c, d, 0, 0)]\nn, q = -1, []\nh = set()\nwhile p:\n t = p.pop()\n if t in h: continue\n h.add(t)\n a, b, c, d, s, k = t\n u, v = a * b, c * d\n if u == v:\n if k < n or n < 0: n, q = k, [c, d, a, b] if s else [a, b, c, d]\n continue\n k += 1\n if u > v: a, b, c, d, s = c, d, a, b, 1 - s\n if c % 2 == 0: p += [(a, b, c // 2, d, s, k)]\n if c % 3 == 0: p += [(a, b, 2 * c // 3, d, s, k)]\n if d % 2 == 0: p += [(a, b, c, d // 2, s, k)]\n if d % 3 == 0: p += [(a, b, c, 2 * d // 3, s, k)]\nfor t in [n] + q: print(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5fd95dbb12782bc496f1a4ae9f6ca0d6", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def nod(a, b):\n\ta = int(a)\n\tb = int(b)\n\tif(a > b):\n\t\ta, b = b, a\n\tif(b % a == 0):\n\t\treturn a\n\telse:\n\t\twhile(b != 0):\n\t\t\tif(a > b):\n\t\t\t\ta, b = b, a\n\t\t\tx = b // a\n\t\t\tb -= x * a\n\t\treturn a\n\ns = input()\ns = s.split()\n\na = int(s[0])\nb = int(s[1])\nx = int(s[2])\ny = int(s[3])\n\nq = nod(x, y)\nx = x // q\ny = y //q\n\nif(a > b):\n\ta, b = b, a\n\tx, y = y, x\n\ni = a\n\nwhile i * y // x > b:\n\ti -= 1\n\n\n\nprint(i // x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77dc742f87bffd72d6050de32652c124", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "ch=input().split()\na=int(ch[0])\nb=int(ch[1])\ne=int(ch[2])\nf=int(ch[3])\nts=e\nms=f\nwhile (e!=f):\n if (e>f):\n e=e-f\n else:\n f=f-e\nif (e!=1):\n ts=int(ts/e)\n ms=int(ms/e)\ne=int(a/ts)\nf=int(b/ms)\nprint (min(e,f))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "47db1d64ae9c569736f79d8dbf6f9933", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "from fractions import Fraction\na, b, x, y = list(map(int, input().split()))\n\npocz = 1\nkon = 1e18+5\nsrd = 0\nf = Fraction(x, y)\n\nwhile kon - pocz > 1:\n srd = (kon + pocz) // 2\n\n if f.numerator * srd <= a and f.denominator * srd <= b:\n pocz = srd\n else:\n kon = srd\n\nif srd == 2:\n if f.numerator * 2 <= a and f.denominator * 2 <= b:\n pass\n elif f.numerator <= a and f.denominator <= b:\n srd = 1\n else:\n srd = 0\n\nprint(int(srd))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e431fa072fc2902a58316aa3adef927", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "import fractions\nstring =raw_input()\nA = string.split()\na=int(A[0])\nb=int(A[1])\nx=int(A[2])\ny=int(A[3])\nm= max(x,y)\ncnt=0\nif gcd(x,y)%x ==0 AND gcd(x,y)%y ==0:\n x = fractions.gcd(x,y)/x\n y = fractions.gcd(x,y)/y\nfor i in range (1, m):\n if x*i<= a:\n if y*i<=b:\n cnt = cnt+1\nprint cnt \ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a", "lang_cluster": "Python", "compilation_error": true, "code_uid": "36deb51fd3c643048f707f564ce9a71a", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "#include\n\nusing namespace std;\n\nint main(){\n long long a,b,m,n,i,res;\n cin>>a>>b>>n>>m;\n double temp = __gcd(m,n);\n double j =m/(1.0*temp);\n double k =n/(1.0*temp);\n if (j/(1.0*k)<=b/(1.0*a)) cout<= i : \n\t\tres -= 1\nans ^= res % 2\nif ans == 0 : print 'Petya'\nelse : print 'Vasya'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "08eb3ac7fe7acfca27ec1df4512e8130", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\nimport math\n \nn = int(stdin.readline())\nans = n\nfor i in range(2, int(math.sqrt(n))+1):\n t = int(math.log(n, i))\n if t!=0:\n ans -= (t-1)\n \nif ans % 2 == 0:\n stdout.write(\"Petya\"+'\\n')\nelse:\n stdout.write(\"Vasya\"+\"\\n\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "55d42ccc141956ba82296190ac380829", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.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()\nwhile i * i <= n:\n\tt = i\n\tcnt = 0\n\twhile t <= n:\n\t\tt *= i\n\t\tcnt += 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": "5d02d148ff933ab7cadd216657a8928e", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\nx = 1\nc = n - 1\nd = {tuple(): 0}\ndef do(l):\n if tuple(l) in d: return d[tuple(l)]\n c = set()\n for x in l:\n r = list(l)\n t = x\n while t <= l[-1]:\n if t in r: r.remove(t)\n t += x\n c.add(do(tuple(r)))\n for i in xrange(100):\n if i not in c:\n d[tuple(l)] = i\n return i\n#y = [do(range(1, i+1)) for i in xrange(1, 30)]\n#print y\ny = [0, 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]\nfor i in xrange(2, 10 ** 5):\n if i * i > n: break\n j = int(i ** 0.5 + 1e-8)\n if j * j == i: continue\n j = i\n t = 0\n while j <= n:\n t += 1\n j *= i\n x ^= y[t]\n c -= t\nx ^= c & 1\nprint \"Vasya\" if x else \"Petya\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9bc3db1a2c30d8f35dad8e8d0cdab028", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.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]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] x[0]:\n return x\n else:\n return tuple([x[0], (x[1] + y[1]) % MOD])\n\ndef DFS(remain, cap, f, total):\n if remain in f:\n return f[remain]\n if remain[0] + 2 * remain[1] <= cap:\n f[remain] = (1, 1)\n return f[remain]\n f[remain] = (INF, 0)\n for x in xrange(remain[0] + 1):\n if x > cap: break;\n for y in xrange(remain[1] + 1):\n if x + y < 1: continue;\n if x + 2 * y > cap: break;\n tmp = [remain[0] - x, remain[1] - y]\n for i in xrange(2):\n if tmp[i] == total[i]: continue\n tmp[i] += 1\n nextRem = tuple(tmp)\n if nextRem != remain:\n ret = DFS(nextRem, cap, f, total)\n global com\n ret = tuple([ret[0] + 2,\n com[remain[0]][x] * com[remain[1]][y] * (total[i] - nextRem[i] + 1) * ret[1] % MOD])\n f[remain] = merge(f[remain], ret)\n tmp[i] -= 1\n return f[remain]\n\ndef Solve(cap, friends):\n cap /= 50\n f = {(0, 0) : (0, 1)} \n ans = list(DFS(friends, cap, f, friends))\n if ans[0] == INF: ans[0] = -1\n for x in ans: print x\n\nif __name__ == '__main__':\n MakeCom()\n for cap, friends in ReadIn():\n Solve(cap, friends)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3745b4c918fa70919c6dfb7434b7eb62", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from collections import deque\n\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nc50 = sum([1 for i in a if i == 50])\nc100 = sum([1 for i in a if i == 100])\nc = [[0] * 51 for i in range(51)]\nc[0][0] = 1\nc[1][0] = 1\nc[1][1] = 1\nfor x in range(2, 51):\n for y in range(x + 1):\n c[x][y] = c[x - 1][y - 1] + c[x - 1][y]\nd = [[[[0, float('inf')] for l in range(2)] for i in range(c100 + 1)] for j in range(c50 + 1)]\n# d[i][j][c] \u043e\u0442\u0432\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u0438 i \u043f\u043e 50 \u043a\u0433 \u0438 j \u043f\u043e 100 \u043a\u0433 \u0438 \u043b\u043e\u0434\u043a\u0430 \u043d\u0430 \u0431\u0435\u0440\u0435\u0433\u0443 c\nd[0][0][0][0] = 1\nd[0][0][0][1] = 0\nq = deque()\nq.append([0, 0, 0])\nwhile len(q) > 0:\n i, j, shore = q.popleft()\n if d[i][j][shore][1] == float('inf'):\n continue\n for fifty in range(c50 - i + 1 if shore == 0 else i + 1):\n for hundreds in range(c100 - j + 1 if shore == 0 else j + 1):\n if fifty * 50 + hundreds * 100 > k or fifty + hundreds == 0:\n continue\n i1 = i + fifty if shore == 0 else i - fifty\n j1 = j + hundreds if shore == 0 else j - hundreds\n if d[i1][j1][1 ^ shore][1] > d[i][j][shore][1] + 1:\n d[i1][j1][1 ^ shore][1] = d[i][j][shore][1] + 1\n d[i1][j1][1 ^ shore][0] = 0\n q.append((i1, j1, 1 ^ shore) )\n if d[i1][j1][1 ^ shore][1] < d[i][j][shore][1] + 1:\n continue\n koeff = (c[c50 - i][fifty] if shore == 0 else c[i][fifty]) * (\n c[c100 - j][hundreds] if shore == 0 else c[j][hundreds])\n d[i1][j1][1 ^ shore][0] += d[i][j][shore][0] * koeff\nif d[c50][c100][1][1] == float('inf'):\n print(-1)\n print(0)\nelse:\n print(d[c50][c100][1][1])\n print(d[c50][c100][1][0])\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1a9fb3da9d387dbb0e5b271d3390dc7", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\nimport sys\n\nMAXN = 110\nMOD = 10 ** 9 + 7\nINF = MOD\n\ndef MakeCom():\n global com\n com = [[1]]\n for i in xrange(1, MAXN + 1):\n line = [1]\n for j in xrange(1, i):\n line.append((com[-1][j - 1] + com[-1][j]) % MOD)\n line.append(1)\n com.append(line)\n\ndef ReadIn():\n data = [int(x) for x in sys.stdin.read().split()]\n offset = 0\n while offset < len(data):\n n, cap = data[offset : offset + 2]\n offset += 2\n friends = [0] * 2\n for x in data[offset : offset + n]:\n friends[x / 50 - 1] += 1\n offset += n\n yield cap, tuple(friends)\n\ndef merge(x, y):\n if y[0] < x[0]:\n return y\n elif y[0] > x[0]:\n return x\n else:\n return tuple([x[0], (x[1] + y[1]) % MOD])\n\ndef DFS(remain, cap, f, total):\n if remain in f:\n return f[remain]\n if remain[0] + 2 * remain[1] <= cap:\n f[remain] = (1, 1)\n return f[remain]\n f[remain] = (INF, 0)\n for toX in xrange(remain[0] + 1):\n if toX > cap: break\n for toY in xrange(remain[1] + 1):\n if toX + toY < 1: continue\n if toX + 2 * toY > cap: break\n arrival = total[0] - remain[0] + toX, total[1] - remain[1] + toY\n for backX in xrange(arrival[0] + 1):\n if backX > cap: break;\n for backY in xrange(arrival[1] + 1):\n if backX + backY < 1: continue\n if backX + 2 * backY > cap: break\n nextRemain = remain[0] - toX + backX, remain[1] - toY + backY\n ret = DFS(nextRemain, cap, f, total)\n global com\n ret = tuple([ret[0] + 2,\n com[remain[0]][toX] * com[remain[1]][toY] *\n com[arrival[0]][backX] * com[arrival[1]][backY] *\n ret[1] % MOD])\n f[remain] = merge(f[remain], ret)\n return f[remain]\n\ndef Solve(cap, friends):\n cap /= 50\n f = {(0, 0) : (0, 1)} \n ans = list(DFS(friends, cap, f, friends))\n if ans[0] == INF: ans[0] = -1\n for x in ans: print x\n\nif __name__ == '__main__':\n MakeCom()\n for cap, friends in ReadIn():\n Solve(cap, friends)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7237b55d2f5d29e66f82cf3bb9b1b75c", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "\na, b, c, total_increase = map(int, raw_input().split(' '))\n\nnum_invalid_triples = 0\n\nfor a, b, c in ((a, b, c), (b, a, c), (c, a, b)):\n for a_increase in xrange(total_increase + 1):\n bc_max_increase = min(total_increase - a_increase, a + a_increase - (b + c))\n\n for bc_increase in xrange(0, bc_max_increase + 1):\n num_invalid_triples += (bc_increase + 1)\n\n# The total number of all possible triples of sum less than or equal `total_increase` equals the number of ways to\n# divide a sequence of `total_increase` elements into four parts, which is:\n# C(`total_increase` + 3, 3) = (`total_increase` + 3)! / (3! * `total_uncrease`!) =\nnum_all_triples = (total_increase + 1) * (total_increase + 2) * (total_increase + 3) / 6\n\nprint num_all_triples - num_invalid_triples\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b4df70e4935ded12316ddab9875b674f", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def f(a,b,c,l):\n if a=t2:\n print(abs(x2-x1)*t2)\nelse:\n if x1x1 and d==-1:\n ans=(p-x1)*t1+x1*t1+x2*t1\n elif px1 and d==1:\n ans=(s-p)*t1+(s)*t1+x2*t1\n else:\n if p>x1 and d==-1:\n ans=(p-x2)*t1\n elif px1 and d==1:\n ans=(2*s-p-x2)*t1\n print(min(ans,abs(x2-x1)*t2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2fdaad4f0f0ba25472a60e2d8660a432", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "M = lambda: map(int, input().split())\ns, x1, x2 = M()\nt1, t2 = M()\np, d = M()\nv1, v2 = 1/t1, 1/t2\nif p < x1 < x2 and d > 0:\n path_by_tram = x2 - p\nelif p < x2 < x1 and d > 0:\n path_by_tram = s - p + s - x2\nelif x1 < p < x2 and d > 0:\n path_by_tram = 2 * s + x2 - p\nelif x1 < x2 < p and d > 0:\n path_by_tram = 2 * (s - p) + p - x2\nelif x2 < x1 < p and d > 0:\n path_by_tram = 2 * (s - p) + p - x2\nelif x2 < p < x1 and d > 0:\n path_by_tram = 2 * (s - p) + p - x2\nelif p < x1 < x2 and d < 0:\n path_by_tram = 2 * p + x2 - p\nelif p < x2 < x1 and d < 0:\n path_by_tram = 2 * s\nelif x1 < p < x2 and d< 0:\n path_by_tram = 2 * p + x2 - p\nelif x1 < x2 < p and d < 0:\n path_by_tram = p + x2\nelif x2 < x1 < p and d < 0:\n path_by_tram = p - x2\nelif x2 < p < x1 and d< 0:\n path_by_tram = 2 * s + p - x2\n\n\non_foot = abs(x2 - x1) / v2\nprint(int(min(round(path_by_tram/v1), on_foot)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "824417b100fda41eede87b537a569d17", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n, k, a, b = map(int, input().split())\ndef sol(a, b):\n\tc = a//b\n\tprint(c)\n\nif a < b:\n\ta,b=b,a;\nsol(a,b)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42a8b0a747db53e3af57352059dc5778", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s, x1, x2 = map(int, input().split())\nt1, t2 = map(int, input().split())\np, d = map(int, input().split())\n\ndef sol(x1, x2, p, d):\n\ttt = (x2-x1)*t2\n\tif d == 1 :\n\t\tif p < x1:\n\t\t\ttt = min(tt, (x2-p)*t1)\n\t\telse :\n\t\t\ttt = min(tt, (s-p)*t1+s*t1+x2*t)\n\tif d == -1:\n\t\ttt = min(tt, p*t1+x2*t1)\n\tprint(tt)\n\nif x1 > x2 :\n\td = -d\n\tx1, x2 = s - x1, s-x2\n\tp = s -p\nsol(x1, x2, p, d)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a93d768a163a0ff9e50dbdc3cfaf1918", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s, 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()]\nv1, v2 = 1/t1,1/t2\n\nv2 *= int((x2 - x1)/(abs(x2 - x1)))\n\nx = x1\nc = int(v2/abs(v2))\nt = 0\nwhile p != x:\n t += 1\n p += d * v1\n if p == 0 or p == s:\n d *= -1\n x += v2\n if x == x2:\n print(t)\n break\nelse:\n print(int(t + (x2 - x) / (v1 * d)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f1f678b6476db588782ecb7032d081f4", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "r, b = map(int, input().split())\nif r == b:\n print('Yes')\nelse:\n print('No')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b8c2f87aff3449d35bb9d4879514c4f", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def check(a,b):\n ansa=b[0]-a[0]\n ansb=b[1]-a[1]\n return [ansa,ansb] \nwhile True:\n try:\n n,m=map(int,input().split())\n if n!=m:\n print('No')\n else:\n a=list()\n b=list()\n for i in range(n):\n a.append(list(map(int,input().split())))\n for i in range(m):\n b.append(list(map(int,input().split())))\n flag=False\n for i in range(len(a)):\n for j in range(i+1,len(a)):\n for k in range(len(b)):\n for l in range(k+1,len(b)):\n ansa=check(a[i],a[j])\n ansb=check(a[i],b[k])\n ansc=check(a[i],b[l])\n if (ansa[0]==ansb[0] and ansa[0]==ansc[0] and ansa[0]==0) or (ansa[0]!=0 and ansb[0]!=0 and ansc[0]!=0 and ansa[1]/ansa[0]==ansb[1]/ansb[0] and ansa[1]/ansa[0]==ansc[1]/ansc[0]):\n print('No')\n flag=True\n break\n else:\n continue\n if flag==True:\n break\n if flag==True:\n break\n if flag==True:\n break\n if flag==False:\n print('Yes')\n except EOFError:\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6ad29909478c4cbbf6491404c561ffe", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "inp = raw_input\nR, B = map(int, inp().split())\nfrom itertools import permutations\n\nships = [[int(v) for v in inp().split()] for _ in range(R)]\nbase = [[int(v) for v in inp().split()] for _ in range(B)]\nif B < R:\n print('No')\n exit(0)\n\n\nok = False\n\ndef crz(o, a, b):\n return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])\n\ndef cross(p1, p2):\n a, b = p1\n c, d = p2\n return crz(a, c, d)*crz(b, c, d) < 0 and crz(c, a, b)*crz(d, a, b) < 0\n\nfor perm in permutations([i for i in range(B)]):\n pairs = []\n for i, p in enumerate(perm):\n if i == R: break\n pairs.append((ships[i], base[p]))\n ok2 = True\n for i in range(R):\n for j in range(i+1, R):\n if cross(pairs[i], pairs[j]):\n ok2 = False\n break\n if not ok2: break\n if ok2:\n ok = True\n break\n\nif ok:\n print('Yes')\nelse:\n print('No')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "26e1ef711e0c9150afdcc2d4866c8e2d", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "s = input()\nin1 = s.split(' ')\n\nR = int(in1[0])\nB = int(in1[1])\n\nprint(R==B)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57fc0deb0715c0d3c6fe9179a87e838e", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "from decimal import *\ngetcontext().prec=16\nfrom math import sqrt\nR,B=list(map(int,input().split(\" \")))\n\nfor i in range(n):\n for j in range(m):\n useless=input()\n\nif R==B:\n print(\"YES\")\nelse:\n print(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5183cc696f2758e3f7ae454f14eb17ca", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "mod = 1000000007\nn = int(input())\ncat = [0] * 1100\nf, c, i = 1, 1, 1\nwhile i < 1100:\n cat[i] = f\n i += 1\n c = c * (8*i - 12) // i\n f = c - f\ncat = cat[1:-1]\nsm = 0\nfor i in range(3, n + 3):\n sm += (cat[i - 1] + (-1) ** (i - 1)) // (1 << i)\nprint(sm % mod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0d7b0ea0f1061281df3b712ee238b846", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\n\ndp = [[[0, 0] for x in range(n+1)] for i in range(n+1)]\nmod = 10**9+7\nfor i in range(1, n + 1):\n dp[0][i][0] = dp[0][i - 1][1]\n dp[0][i][1] = dp[0][i - 1][0] + 1\nfor i in range(1, n + 1):\n for j in range(i, n + 1):\n t = [0, 0, 0]\n if i > 0:\n dp[i][j][0] += dp[i-1][j][1]\n t[0] = dp[i - 1][j][1]\n t[1] = dp[i - 1][j][1]\n t[2] = dp[i - 1][j][0] + 1\n if j > i:\n dp[i][j][0] += dp[i][j-1][1]\n t[0] += dp[i][j - 1][1]\n t[1] += dp[i][j - 1][0] + 1\n t[2] += dp[i][j - 1][1]\n for k in t: dp[i][j][1] = max(dp[i][j][1], k)\nprint(dp[n][n][1]%mod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4110cef0762caf3d80218e21473d29e2", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n = int(input())\ndp = [[[0, 0] for x in range(n+1)] for i in range(n+1)]\nmod = 10**9+7\nfor i in range(1, n + 1):\n dp[0][i][0] = dp[0][i - 1][1]\n dp[0][i][1] = dp[0][i - 1][0] + 1\nfor i in range(1, n + 1):\n for j in range(i, n + 1):\n t = [0, 0]\n if i > 0:\n dp[i][j][0] += dp[i-1][j][1]\n t[0] = dp[i - 1][j][1]\n t[1] = dp[i - 1][j][0] + 1\n if j > i:\n dp[i][j][0] += dp[i][j-1][1]\n t[0] += dp[i][j - 1][0] + 1\n t[1] += dp[i][j - 1][1]\n for k in t: dp[i][j][1] = max(dp[i][j][1], k)\nprint(dp[n][n][1]%mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5db52aa57b51a2396ae6f6eced55bd6", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn = int(input())\nm = 2*n\n\ns = 0\n\nDP = [[0]*(n+2) for _ in range(m+1)]\nDP[0][0] = 1\n\nfor left in range(1,m+1):\n for extra in range(min(left,m-left)+1):\n DP[left][extra] = DP[left-1][extra-1] + DP[left-1][extra+1]\n if extra&1:\n s += DP[left][extra]\n\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b8b9255d74cff13a1fce0a12b8ed12e", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.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(i-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": "50405407caaf0c0b92c2b3ac725b82ca", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "x=input()*3;print+(x^x+5>6)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "786580933a08c9e311a4f8ca4177b93e", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "x=input()*3;print+(x^x+5>5)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d90c2791b71266274402e7da9de1736", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "x=input()*3;print+(x^x+5>9)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "da9351495e328414561d7189fba09096", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "x=input()*3\nprint+(x^x+4>x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8b83945f0d763623ed0bb1ef1cbdb5a", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "'''\n Author : thekushalghosh\n Team : CodeDiggers\n'''\nimport sys,math\ninput = sys.stdin.readline\nn = int(input())\nq = [1,2]\nfor i in range(100):\n if q[-1] % 2 == 0:\n q = q + [q[-1] + q[-2],q[-1] + q[-2] + 1]\n else:\n q = q + [(2 * q[-1]) + 1,(2 * q[-1]) + 2]\nif n in q:\n print(1)\nelse:\n print(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef2fafc3303301fafaf4c4a3d5a5ac18", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "a=[int(i) for i in (input().split())]\nf,sm=[0,1,1],[0]\ns=a[0]\nk=a[1]\nssum=0\nwhile ssum=0 :\n f[i-k]=f[i-k]-f[i-k-(k+1)]\n ssum=ssum+f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nfor i in range(0,len(sm)-1):\n print( sm[i] , end = \" \" )\nprint(sm[len(sm)-1])\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e290b243478867dd691ac2e4f3d3fee8", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a=[int(i) for i in (input().split())]\nf,sm=[0,1,1],[0]\ns=a[0]\nk=a[1]\nssum=0\nwhile ssum=0 :\n f[i-k]=f[i-k]-f[i-k-(k+1)]\n ssum=ssum+f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nfor i in range(0,len(sm)-1):\n print(sm[i],end=\" \")\nprint(sm[len(sm)-1])\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d97086e9fea3d88feec6c2eba1c65dcd", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a=[int(i) for i in (input().split())]\nf,sm=[0,1,1],[0]\ns=a[0]\nk=a[1]\nssum=0\nwhile ssum=0 :\n f[i-k]=f[i-k]-f[i-k-(k+1)]\n ssum=ssum+f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nfor i in range(0,len(sm)-1):\n print(sm[i],end=' ')\nprint(sm[len(sm)-1])\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1706bf70d3fbac9f7145fd617230293b", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a=[int(i) for i in (input().split())]\nf,sm=[0,1,1],[0]\ns=a[0]\nk=a[1]\nssum=0\nwhile ssum=0 :\n f[i-k]=f[i-k]-f[i-k-(k+1)]\n ssum=ssum+f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nfor i in range(0,len(sm)-1):\n print(\"%d\"%sm[i],end=\" \")\nprint(sm[len(sm)-1])\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "705bb17bc643ce96c33bd4e35472ec81", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a=[int (i) for i in (input().split())]\nf,sm=[0,1,1],[0]\ns,k=a[0],a[1]\nssum=0\nwhile ssum=0 :\n f[i-k]=f[i-k]-f[i-k-k-1]\n ssum=ssum+f[i-k-1]\n sm.append(f[i-k-1])\nprint(len(sm))\nfor i in range(len(sm)-1) :\n print(sm[i],end=\" \")\nprint(sm[len(sm)-1])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "10dd4e95e8e9066fd0cf5ae2f5af0397", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,l = map(int,input().split())\na = list(map(int,input().split()))\n#print(0)\nb = [0] * n\nb[0] = a[0]\n\nfor i in range(1,n):\n b[i] = min(a[i],b[i - 1] * 2)\n if b[i] < b[i - 1]:\n for j in range(i):\n b[j] = min(b[i],b[j])\nc=[0] * n\nc[0] = 1\ns = 0\nz = 100000000000000000000\nfor i in range(1,n):\n c[i] = c[i - 1] * 2\nwhile l > c[n - 1]:\n s += b[n - 1] * (l // c[n - 1])\n l = l % c[n - 1]\n \n#print(0)\nwhile l > 0:\n for i in range(1,n):\n if l == c[i - 1]:\n s += b[i - 1]\n l -= c[i - 1]\n else:\n if l < c[i] and l > c[i - 1]:\n z = min(z, s + b[i])\n l -= c[i - 1]\n s += b[i - 1]\n \n #print(l)\n#print(b)\nprint(min(z,s))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3dcdff819042898c6e4e4118886c8723", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = input().split()\nl = int(n[1])\nn = int(n[0])\nc = input().split()\ncperl = []\nfor i in range(n):\n c[i] = int(c[i])\n cperl.append([(c[i])/2**i, 2**i, i])\ncperl.sort()\nf = False\nnl = [0]\nnc = [0]\ni = 0\nwhile not f:\n if nl[i] + cperl[i][1] == l:\n nl[i] += cperl[i][1]\n nc[i] += c[cperl[i][2]]\n f = True\n elif nl[i] + cperl[i][1] < l:\n nl[i] += cperl[i][1]\n nc[i] += c[cperl[i][2]]\n else:\n nl.append(nl[i])\n nc.append(nc[i])\n nl[i] += cperl[i][1]\n nc[i] += c[cperl[i][2]]\n i += 1\n if i == n:\n break\nprint(min(nc))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bbbdebe4dc23860365326cd6d531e27", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f(L,n):\n\ti = n-1\n\tif i==0:\n\t\treturn L*c[0]\n\tv1 = f(L,n-1)\n\tv2 = (L+l[i]-1)//l[i]*c[i]\n\tv3 = L//l[i]*c[i] + f(L%l[i],n-1)\n\treturn min(v1,v2,v3)\n\nn, L = map(int, input().split())\nc = list(map(int, input().split()))\nl = [2**i for i in range(n)]\nprint(f(L,n))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c0995b7c503c88ebcf328edcde3be77", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n,l=map(int,input().split())\nm=list(map(int,input().split()))\nans=10**18\nfor i in range(1,n):\n k=0\n for j in range(i,n):\n k+=m[j]\n V+=2**(j-1)\n if V>=l\n break\n ans=min(ans,k)\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "553771f9d047200660a85648e28e0328", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def f(l,c,n):\n if l==2**(n-1):\n e = c[n-1]\n else:\n e = 0\n for i in range(n - 1):\n if l % 2 == 1:\n e += c[i]\n l /= 2\n return e\nn,l = map(int,raw_input().split())\nc = map(int,raw_input().split())\nfor i in range(n):\n c[i]=min(c[j] for j in range(i,n))\nfor i in range(n-1,-1,-1):\n c[i]=min(c[j]*(2**(i-j)) for j in range(0,i+1))\nw = (l / (2 ** (n - 1))) * c[n - 1]\nl %= (2 ** (n - 1))\nprint w+min(f(i,c,n) for i in range(l,2**(n-1)+1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1707756ea491a3bf793eb9527ba0c0a1", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "PyPy 3-64", "source_code": "\n\nclass FFT():\n def primitive_root_constexpr(self,m):\n if m==2:return 1\n if m==167772161:return 3\n if m==469762049:return 3\n if m==754974721:return 11\n if m==998244353:return 3\n divs=[0]*20\n divs[0]=2\n cnt=1\n x=(m-1)//2\n while(x%2==0):x//=2\n i=3\n while(i*i<=x):\n if (x%i==0):\n divs[cnt]=i\n cnt+=1\n while(x%i==0):\n x//=i\n i+=2\n if x>1:\n divs[cnt]=x\n cnt+=1\n g=2\n while(1):\n ok=True\n for i in range(cnt):\n if pow(g,(m-1)//divs[i],m)==1:\n ok=False\n break\n if ok:\n return g\n g+=1\n def bsf(self,x):\n res=0\n while(x%2==0):\n res+=1\n x//=2\n return res\n butterfly_first=True\n butterfly_inv_first=True\n sum_e=[0]*30\n sum_ie=[0]*30\n def __init__(self,MOD):\n self.mod=MOD\n self.g=self.primitive_root_constexpr(self.mod)\n def butterfly(self,a):\n n=len(a)\n h=(n-1).bit_length()\n if self.butterfly_first:\n self.butterfly_first=False\n es=[0]*30\n ies=[0]*30\n cnt2=self.bsf(self.mod-1)\n e=pow(self.g,(self.mod-1)>>cnt2,self.mod)\n ie=pow(e,self.mod-2,self.mod)\n for i in range(cnt2,1,-1):\n es[i-2]=e\n ies[i-2]=ie\n e=(e*e)%self.mod\n ie=(ie*ie)%self.mod\n now=1\n for i in range(cnt2-2):\n self.sum_e[i]=((es[i]*now)%self.mod)\n now*=ies[i]\n now%=self.mod\n for ph in range(1,h+1):\n w=1<<(ph-1)\n p=1<<(h-ph)\n now=1\n for s in range(w):\n offset=s<<(h-ph+1)\n for i in range(p):\n l=a[i+offset]\n r=a[i+offset+p]*now\n r%=self.mod\n a[i+offset]=l+r\n a[i+offset]%=self.mod\n a[i+offset+p]=l-r\n a[i+offset+p]%=self.mod\n now*=self.sum_e[(~s & -~s).bit_length()-1]\n now%=self.mod\n def butterfly_inv(self,a):\n n=len(a)\n h=(n-1).bit_length()\n if self.butterfly_inv_first:\n self.butterfly_inv_first=False\n es=[0]*30\n ies=[0]*30\n cnt2=self.bsf(self.mod-1)\n e=pow(self.g,(self.mod-1)>>cnt2,self.mod)\n ie=pow(e,self.mod-2,self.mod)\n for i in range(cnt2,1,-1):\n es[i-2]=e\n ies[i-2]=ie\n e=(e*e)%self.mod\n ie=(ie*ie)%self.mod\n now=1\n for i in range(cnt2-2):\n self.sum_ie[i]=((ies[i]*now)%self.mod)\n now*=es[i]\n now%=self.mod\n for ph in range(h,0,-1):\n w=1<<(ph-1)\n p=1<<(h-ph)\n inow=1\n for s in range(w):\n offset=s<<(h-ph+1)\n for i in range(p):\n l=a[i+offset]\n r=a[i+offset+p]\n a[i+offset]=l+r\n a[i+offset]%=self.mod\n a[i+offset+p]=(l-r)*inow\n a[i+offset+p]%=self.mod\n inow*=self.sum_ie[(~s & -~s).bit_length()-1]\n inow%=self.mod\n def convolution(self,a,b):\n n=len(a);m=len(b)\n if not(a) or not(b):\n return []\n if min(n,m)<=40:\n if nk:continue\n res[i]=sbf2[i+1]+bf2[i]*(k-i+1)\n res[i]%=mod\n return res\n\n\nans=dp(n)\nans=fft.convolution(ans,ans)\nprint(ans[f] if f<=2*k else 0)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ceba6b81f2463e737ade092e71259533", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "PyPy 3-64", "source_code": "\n\n# AtCoder Libary v1.4 \u3092 python \u306b\u79fb\u690d\u3057\u305f\u3082\u306e\n# https://github.com/atcoder/ac-library/blob/master/atcoder/convolution.hpp\n\nMOD = 998244353\nIMAG = 911660635\nIIMAG = 86583718\nrate2 = (0, 911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 867605899, 0)\nirate2 = (0, 86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 103369235, 0)\nrate3 = (0, 372528824, 337190230, 454590761, 816400692, 578227951, 180142363, 83780245, 6597683, 70046822, 623238099, 183021267, 402682409, 631680428, 344509872, 689220186, 365017329, 774342554, 729444058, 102986190, 128751033, 395565204, 0)\nirate3 = (0, 509520358, 929031873, 170256584, 839780419, 282974284, 395914482, 444904435, 72135471, 638914820, 66769500, 771127074, 985925487, 262319669, 262341272, 625870173, 768022760, 859816005, 914661783, 430819711, 272774365, 530924681, 0)\n\ndef butterfly(a):\n n = len(a)\n h = (n - 1).bit_length()\n le = 0\n while le < h:\n if h - le == 1:\n p = 1 << (h - le - 1)\n rot = 1\n for s in range(1 << le):\n offset = s << (h - le)\n for i in range(p):\n l = a[i + offset]\n r = a[i + offset + p] * rot\n a[i + offset] = (l + r) % MOD\n a[i + offset + p] = (l - r) % MOD\n rot *= rate2[(~s & -~s).bit_length()]\n rot %= MOD\n le += 1\n else:\n p = 1 << (h - le - 2)\n rot = 1\n for s in range(1 << le):\n rot2 = rot * rot % MOD\n rot3 = rot2 * rot % MOD\n offset = s << (h - le)\n for i in range(p):\n a0 = a[i + offset]\n a1 = a[i + offset + p] * rot\n a2 = a[i + offset + p * 2] * rot2\n a3 = a[i + offset + p * 3] * rot3\n a1na3imag = (a1 - a3) % MOD * IMAG\n a[i + offset] = (a0 + a2 + a1 + a3) % MOD\n a[i + offset + p] = (a0 + a2 - a1 - a3) % MOD\n a[i + offset + p * 2] = (a0 - a2 + a1na3imag) % MOD\n a[i + offset + p * 3] = (a0 - a2 - a1na3imag) % MOD\n rot *= rate3[(~s & -~s).bit_length()]\n rot %= MOD\n le += 2\n\ndef butterfly_inv(a):\n n = len(a)\n h = (n - 1).bit_length()\n le = h\n while le:\n if le == 1:\n p = 1 << (h - le)\n irot = 1\n for s in range(1 << (le - 1)):\n offset = s << (h - le + 1)\n for i in range(p):\n l = a[i + offset]\n r = a[i + offset + p]\n a[i + offset] = (l + r) % MOD\n a[i + offset + p] = (l - r) * irot % MOD\n irot *= irate2[(~s & -~s).bit_length()]\n irot %= MOD\n le -= 1\n else:\n p = 1 << (h - le)\n irot = 1\n for s in range(1 << (le - 2)):\n irot2 = irot * irot % MOD\n irot3 = irot2 * irot % MOD\n offset = s << (h - le + 2)\n for i in range(p):\n a0 = a[i + offset]\n a1 = a[i + offset + p]\n a2 = a[i + offset + p * 2]\n a3 = a[i + offset + p * 3]\n a2na3iimag = (a2 - a3) * IIMAG % MOD\n a[i + offset] = (a0 + a1 + a2 + a3) % MOD\n a[i + offset + p] = (a0 - a1 + a2na3iimag) * irot % MOD\n a[i + offset + p * 2] = (a0 + a1 - a2 - a3) * irot2 % MOD\n a[i + offset + p * 3] = (a0 - a1 - a2na3iimag) * irot3 % MOD\n irot *= irate3[(~s & -~s).bit_length()]\n irot %= MOD\n le -= 2\n\ndef multiply(s, t):\n n = len(s)\n m = len(t)\n if min(n, m) <= 60:\n a = [0] * (n + m - 1)\n for i in range(n):\n if i % 8 == 0:\n for j in range(m):\n a[i + j] += s[i] * t[j]\n a[i + j] %= MOD\n else:\n for j in range(m):\n a[i + j] += s[i] * t[j]\n return [x % MOD for x in a]\n a = s.copy()\n b = t.copy()\n z = 1 << (n + m - 2).bit_length()\n a += [0] * (z - n)\n b += [0] * (z - m)\n butterfly(a)\n butterfly(b)\n for i in range(z):\n a[i] *= b[i]\n a[i] %= MOD\n butterfly_inv(a)\n a = a[:n + m - 1]\n iz = pow(z, MOD - 2, MOD)\n return [v * iz % MOD for v in a]\n\nn,k,f=map(int,input().split())\nmod=998244353\n\ndef dp(n):\n if n==1:\n return [1]*(k+1)\n bf=dp(n-1)\n res=[0]*(k+1)\n bf2=multiply(bf,bf)\n sbf2=[0]*(2*k+3)\n for i in range(2*k,-1,-1):\n sbf2[i]=(sbf2[i+1]+bf2[i])%mod\n if i>k:continue\n res[i]=sbf2[i+1]+bf2[i]*(k-i+1)\n res[i]%=mod\n return res\n\n\nans=dp(n)\nans=multiply(ans,ans)\nprint(ans[f] if f<=2*k else 0)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "706af69e9eee6d504c12bdabb9bf88c9", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "PyPy 3-64", "source_code": "import os\r\nimport sys \r\nfrom io import BytesIO, IOBase\r\n \r\nBUFSIZE = 8192\r\n \r\nclass FastIO(IOBase):\r\n newlines = 0\r\n \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 \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 \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 \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\n \r\n \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\n \r\n \r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\nclass FFT:\r\n def __init__(self, MOD=998244353):\r\n FFT.MOD = MOD\r\n g = self.primitive_root_constexpr()\r\n ig = pow(g, FFT.MOD - 2, FFT.MOD)\r\n FFT.W = [pow(g, (FFT.MOD - 1) >> i, FFT.MOD) for i in range(30)]\r\n FFT.iW = [pow(ig, (FFT.MOD - 1) >> i, FFT.MOD) for i in range(30)]\r\n\r\n def primitive_root_constexpr(self):\r\n if FFT.MOD == 998244353:\r\n return 3\r\n elif FFT.MOD == 200003:\r\n return 2\r\n elif FFT.MOD == 167772161:\r\n return 3\r\n elif FFT.MOD == 469762049:\r\n return 3\r\n elif FFT.MOD == 754974721:\r\n return 11\r\n divs = [0] * 20\r\n divs[0] = 2\r\n cnt = 1\r\n x = (FFT.MOD - 1) // 2\r\n while x % 2 == 0:\r\n x //= 2\r\n i = 3\r\n while i * i <= x:\r\n if x % i == 0:\r\n divs[cnt] = i\r\n cnt += 1\r\n while x % i == 0:\r\n x //= i\r\n i += 2\r\n if x > 1:\r\n divs[cnt] = x\r\n cnt += 1\r\n g = 2\r\n while 1:\r\n ok = True\r\n for i in range(cnt):\r\n if pow(g, (FFT.MOD - 1) // divs[i], FFT.MOD) == 1:\r\n ok = False\r\n break\r\n if ok:\r\n return g\r\n g += 1\r\n\r\n def fft(self, k, f):\r\n for l in range(k, 0, -1):\r\n d = 1 << l - 1\r\n U = [1]\r\n for i in range(d):\r\n U.append(U[-1] * FFT.W[l] % FFT.MOD)\r\n \r\n for i in range(1 << k - l):\r\n for j in range(d):\r\n s = i * 2 * d + j\r\n f[s], f[s + d] = (f[s] + f[s + d]) % FFT.MOD, U[j] * (f[s] - f[s + d]) % FFT.MOD\r\n\r\n def ifft(self, k, f):\r\n for l in range(1, k + 1):\r\n d = 1 << l - 1\r\n for i in range(1 << k - l):\r\n u = 1\r\n for j in range(i * 2 * d, (i * 2 + 1) * d):\r\n f[j+d] *= u\r\n f[j], f[j + d] = (f[j] + f[j + d]) % FFT.MOD, (f[j] - f[j + d]) % FFT.MOD\r\n u = u * FFT.iW[l] % FFT.MOD\r\n\r\n def convolve(self, A, B):\r\n n0 = len(A) + len(B) - 1\r\n k = (n0).bit_length()\r\n n = 1 << k\r\n A += [0] * (n - len(A))\r\n B += [0] * (n - len(B))\r\n self.fft(k, A)\r\n self.fft(k, B)\r\n A = [a * b % FFT.MOD for a, b in zip(A, B)]\r\n self.ifft(k, A)\r\n inv = pow(n, FFT.MOD - 2, FFT.MOD)\r\n A = [a * inv % FFT.MOD for a in A]\r\n del A[n0:]\r\n return A\r\n\r\nMOD = 998244353\r\ndef solve():\r\n n, k, f = map(int, input().split())\r\n if f > 2 * k:\r\n print(0)\r\n return\r\n\r\n fft = FFT()\r\n A = [1] * (k + 1)\r\n for i in range(n):\r\n B = fft.convolve(A[:], A[:])\r\n if i == n - 1:\r\n break\r\n tot = sum(B[k+1:]) % MOD\r\n A = [0] * (k + 1)\r\n cum = 0\r\n for i in range(k, -1, -1):\r\n A[i] += tot + B[i] * (k + 1 - i)\r\n A[i] %= MOD\r\n tot += B[i]\r\n if tot >= 0:\r\n tot -= MOD\r\n print(B[f])\r\n \r\n \r\nfor _ in range(1):\r\n solve() ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "597bd48ebc59c76755a805b9c59027f5", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "PyPy 3-64", "source_code": "\n\nclass FFT():\n def primitive_root_constexpr(self,m):\n if m==2:return 1\n if m==167772161:return 3\n if m==469762049:return 3\n if m==754974721:return 11\n if m==998244353:return 3\n divs=[0]*20\n divs[0]=2\n cnt=1\n x=(m-1)//2\n while(x%2==0):x//=2\n i=3\n while(i*i<=x):\n if (x%i==0):\n divs[cnt]=i\n cnt+=1\n while(x%i==0):\n x//=i\n i+=2\n if x>1:\n divs[cnt]=x\n cnt+=1\n g=2\n while(1):\n ok=True\n for i in range(cnt):\n if pow(g,(m-1)//divs[i],m)==1:\n ok=False\n break\n if ok:\n return g\n g+=1\n def bsf(self,x):\n res=0\n while(x%2==0):\n res+=1\n x//=2\n return res\n butterfly_first=True\n butterfly_inv_first=True\n sum_e=[0]*30\n sum_ie=[0]*30\n def __init__(self,MOD):\n self.mod=MOD\n self.g=self.primitive_root_constexpr(self.mod)\n def butterfly(self,a):\n n=len(a)\n h=(n-1).bit_length()\n if self.butterfly_first:\n self.butterfly_first=False\n es=[0]*30\n ies=[0]*30\n cnt2=self.bsf(self.mod-1)\n e=pow(self.g,(self.mod-1)>>cnt2,self.mod)\n ie=pow(e,self.mod-2,self.mod)\n for i in range(cnt2,1,-1):\n es[i-2]=e\n ies[i-2]=ie\n e=(e*e)%self.mod\n ie=(ie*ie)%self.mod\n now=1\n for i in range(cnt2-2):\n self.sum_e[i]=((es[i]*now)%self.mod)\n now*=ies[i]\n now%=self.mod\n for ph in range(1,h+1):\n w=1<<(ph-1)\n p=1<<(h-ph)\n now=1\n for s in range(w):\n offset=s<<(h-ph+1)\n for i in range(p):\n l=a[i+offset]\n r=a[i+offset+p]*now\n r%=self.mod\n a[i+offset]=l+r\n a[i+offset]%=self.mod\n a[i+offset+p]=l-r\n a[i+offset+p]%=self.mod\n now*=self.sum_e[(~s & -~s).bit_length()-1]\n now%=self.mod\n def butterfly_inv(self,a):\n n=len(a)\n h=(n-1).bit_length()\n if self.butterfly_inv_first:\n self.butterfly_inv_first=False\n es=[0]*30\n ies=[0]*30\n cnt2=self.bsf(self.mod-1)\n e=pow(self.g,(self.mod-1)>>cnt2,self.mod)\n ie=pow(e,self.mod-2,self.mod)\n for i in range(cnt2,1,-1):\n es[i-2]=e\n ies[i-2]=ie\n e=(e*e)%self.mod\n ie=(ie*ie)%self.mod\n now=1\n for i in range(cnt2-2):\n self.sum_ie[i]=((ies[i]*now)%self.mod)\n now*=es[i]\n now%=self.mod\n for ph in range(h,0,-1):\n w=1<<(ph-1)\n p=1<<(h-ph)\n inow=1\n for s in range(w):\n offset=s<<(h-ph+1)\n for i in range(p):\n l=a[i+offset]\n r=a[i+offset+p]\n a[i+offset]=l+r\n a[i+offset]%=self.mod\n a[i+offset+p]=(l-r)*inow\n a[i+offset+p]%=self.mod\n inow*=self.sum_ie[(~s & -~s).bit_length()-1]\n inow%=self.mod\n def convolution(self,a,b):\n n=len(a);m=len(b)\n if not(a) or not(b):\n return []\n if min(n,m)<=40:\n if nk:continue\n res[i]=sbf2[i+1]+bf2[i]*(k-i+1)\n res[i]%=mod\n return res\n\n\nans=dp(n)\nans=fft.convolution(ans,ans)\nprint(ans[f])\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7d2af98dee39357275194f4bfb29a27f", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "a,b,r=map(int,raw_input().split())\nif 2*r min([a, b]) ) :\n print 'Second'\nelse :\n print 'First'", "lang_cluster": "Python", "compilation_error": true, "code_uid": "5be3810fb23a05b8556493ab9e3038e9", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b,c=map(int,raw_input().split())\nd=a*b/(c*c)\nif d%2==1:\n print \"First\"\nelse\n print \"Second\"", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e1a4557bd83ca563ff4ac2ed403df1ab", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.io.StreamTokenizer;\nimport java.util.Comparator;\nimport java.util.TreeSet;\n\n\npublic class A {\n\tpublic class MyComparator implements Comparator {\n\n\t\t@Override\n\t\tpublic int compare(Long[] arg0, Long[] arg1) {\n\t\t\tif (arg0[0] * arg1[1] == arg0[1] * arg1[0])\n\t\t\t\treturn 0;\n\t\t\tif (arg0[0] * arg1[1] > arg0[1] * arg1[0])\n\t\t\t\treturn 1;\n\t\t\telse\n\t\t\t\treturn -1;\n\t\t\t\t\n\t\t}\n\t\t\n\t}\n\tpublic static void solve() throws Exception {\n\t\tint n = nextInt();\n\t\tTreeSet s = new TreeSet();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint k = nextInt();\n\t\t\tint b = nextInt();\n\t\t\tif (k == 0){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (k * b < 0){\n\t\t\t\tb = -1 * Math.abs(b);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tb = Math.abs(b);\n\t\t\t}\n\t\t\tk = Math.abs(k);\n\t\t\tLong[] a = new Long[2];\n\t\t\ta[0] = (long)k;\n\t\t\ta[1] = (long)b;\n\t\t\ts.add(a);\n\t\t}\n\t\tout.print(s.size());\n\t}\n\n\t\n\t\n\t\n\tstatic public PrintWriter out = new PrintWriter(System.out);\n\t//static public BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\n\tstatic public StreamTokenizer in = new StreamTokenizer(new InputStreamReader(System.in));\n\tpublic static int nextInt() throws IOException {\n\t\tin.nextToken();\n\t\treturn (int)in.nval;\n\t}\n\tpublic static String nextString() throws IOException {\n\t\tin.nextToken();\n\t\treturn in.sval;\n\t}\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tsolve();\n\t\tout.flush();\n\t}\n\t\n\t\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "879ec2e83aaadb6f4f1c5d952456fde8", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "\na,b,r=map(int,raw_input().split())\nn=a*b/(4*r*r)\n\nif n==0:\n print \"Second\"\nelse:\n print \"First\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91620f888d69ba1d2fbe4be37684e8cb", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "a,b = map(int,raw_input()).split()\nprint a + b + 1 >> 1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7f2778cc744e22886ae7191ceeb44dd", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n=int(input())\nm=int(input())\nprint n*m/2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b5162a9adc2f20563e90fe10cf7435fa", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input())\nprint n * m / 2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "79f00e66774df2303f6477b8382c99fb", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def voevoda(n, m):\n if n == 1:\n return m\n if n == 2:\n return (m - m % 4) + 2 * min(m % 4, 2)\n return (n * m + 1) // 2\n\n\nN, M = [int(i) for i in input().split()]\nprint(voevoda(sorted(N, M)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d9f416c85f4f49e5e0c59901aa77410", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "\ndef b(m, n):\n if m == 1:\n return n\n\n if n == 1:\n return m\n\n if m <= 2 and n <= 2:\n return m * n\n\n ans = 0\n for x in xrange(m):\n if x % 2 == 0:\n ans += n / 2 + n % 2\n else:\n ans += n / 2\n\n return max(ans, m*n - ans)\n\n\nn, m = map(int, raw_input().split(\" \"))\nprint b(n, m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0a20ab51b4cf566babb87c07e46d0449", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "\r\ndef clouded_strategy(H,W,cake):\r\n ans= int (cake[0][0]=='*')\r\n \r\n i,j=0,0\r\n prev= 'S'\r\n while (i,j)!= (H-1,W-1):\r\n if i==H-1 or j==W-1:\r\n if i==H-1:\r\n j+=1\r\n if j==W-1:\r\n i+=1\r\n ans += int (cake[i][j]=='*')\r\n else: \r\n if cake[i][j+1]!='*' and cake[i+1][j]!='*':\r\n if prev=='E':\r\n i,j = i+1, j\r\n prev=='S'\r\n if prev=='S':\r\n i,j = i, j+1\r\n prev=='E'\r\n \r\n elif cake[i][j+1]=='*':\r\n i,j = i,j+1\r\n prev=='E'\r\n ans+=1\r\n\r\n else:\r\n i,j = i+1,j\r\n prev=='S'\r\n ans+=1\r\n\r\n\r\n print (ans)\r\n\r\n\r\n\r\nH,W = map (int, input().split(' '))\r\ncake = [[] for i in range (H)]\r\nfor i in range (H):\r\n cake[i] = list (input ())\r\n\r\nclouded_strategy(H,W,cake)\r\n\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "066427591feef620869ebf059dd218ac", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "m,n=map(int,input().split())\r\nA=[input()[:-1]for _ in range(m)]\r\nS=int(A[0][0]=='*')\r\ni,j=0,0\r\nwhile i=h-1 and y>=w-1): break\r\n if y=curw:\r\n if ii 0:\n ans = min(ans, int(num_list[i]/j))\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0384ea0a8502f535ef93a9a42a529b61", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "s1=input()\ns2=input()\nn=len(s1)\nm=len(s2)\nfrom collections import Counter \nc1=Counter(s1)\nc2=Counter(s2)\nif c1['2'] and c1['5']:\n have=(c2['2']+c2['5'])//2 \nelif c1['2'] or c1['5']:\n have=c2['2']+c2['5']\nif c1['6'] and c1['9']:\n have2=(c2['6']+c2['9'])//2 \nelif c1['6'] or c1['9']:\n have2=c2['6']+c2['9']\nmini=10**9 \nfor i in c1.keys():\n if i not in \"2569\" and c1[i]:\n mini=min(mini,c2[i]//c1[i]) \nif c1['2'] or c1['5']:\n mini=min(mini,have)\nif c1['6'] or c1['9']:\n mini=min(mini,have2)\nprint(mini if mini!=10**9 else 0 )", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d4a3f8c3adffbc75f3809c16dc17b6a", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "s1=input()\ns2=input()\nn=len(s1)\nm=len(s2)\nfrom collections import Counter \nc1=Counter(s1)\nc2=Counter(s2)\nif c1['2'] and c1['5']:\n have=(c2['2']+c2['5'])//2 \nelif c1['2'] or c1['5']:\n have=c2['2']+c2['5']\nif c1['6'] and c1['9']:\n have2=(c2['6']+c2['9'])//2 \nelif c1['6'] or c1['9']:\n have2=c2['6']+c2['9']\nmini=10**9 \nfor i in c1.keys():\n if i not in \"2569\" and c1[i]:\n mini=min(mini,c2[i]//c1[i]) \nif c1['2'] :\n mini=min(mini,have//c1['2'])\nif c1['5']:\n mini=min(mini,have//c1['5'])\nif c1['6'] :\n mini=min(mini,have2//c1['6'])\nif c1['9']:\n mini=min(mini,have2//c1['9'])\nprint(mini if mini!=10**9 else 0 )", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32d23c2909d03e3123a8dcc1e182ce29", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "t=raw_input()\nn=raw_input()\na=[]\nfor x in range(0,9):\n if x!=5 and str(x) in t:\n if x==2:\n a.append((n.count(\"2\")+n.count(\"5\"))/(t.count(\"2\")+t.count(\"5\")))\n elif x==6:\n a.append((n.count(\"6\")+n.count(\"9\"))/(t.count(\"6\")+t.count(\"9\")))\n else:\n a.append(n.count(str(x))/t.count(str(x)))\n \nprint sorted(a)[0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab5e0e07557c768cc5236abcce17c085", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return False\n return True\nans = filter(check, range(1, 10000))\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1ca0671fcaccad40907d905f9e66d73", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def is_sat(candi, cont):\n candi_match = cont[0]\n _bcount = int(cont[1])\n _ccount = int(cont[2])\n bcount = 0\n ccount = 0\n for i in xrange(4):\n if candi_match[i] == candi[i]:\n bcount += 1\n elif candi_match[i] in candi:\n ccount += 1\n return (_bcount == bcount and _ccount == ccount)\n \nconstraints = []\n\nN = int(raw_input())\nwhile N>0:\n constraints.append([x for x in raw_input().split()])\n N-=1\nsatisfies = []\nfor i in xrange(0,10000):\n candi = str(i).rjust(4,'0')\n satcount = 0\n for cont in constraints:\n if is_sat(candi, cont):\n satcount+=1\n if satcount == len(constraints):\n satisfies.append(candi)\n \ngoo = len(satisfies)\nif goo == 1:\n valid = True\n for i in xrange(4):\n for j in xrange(4):\n if i!=j:\n if satisfies[i]==satisfies[j]:\n valid=False\n break\n if valid:\n print satisfies[0]\n else:\n print \"Incorrect data\"\nelif goo == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fdf7a7c4eed890acc55b725f79f473ad", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n if len(set(bit)) != 4: return\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return\n ans.append(bit)\nfor i in xrange(1, 10000):\n check(i)\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d37958e99db4274a27cdd5f96f4039a5", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from itertools import *\n\nn = int(raw_input())\na = [map(int, raw_input().split()) for _ in xrange(n)]\n\ndef check(s):\n for u,v,w in a:\n u = str(u)\n x, y = len( set(s)&set(u) ), 0\n for i in xrange(4):\n if s[i]==u[i]:\n y += 1\n if x-y!=w or y!=v:\n return 0\n return 1\n\nans, cnt = \"\", 0\nfor s in permutations(\"0123456789\", 4):\n if check(\"\".join(s)):\n ans = \"\".join(s)\n cnt += 1\nif cnt == 1:\n print ans\nelif cnt == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5482c41b46d6a22560c7222aa5d158b", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n = input()\nd = {}\na = []\n\ndef digits (n):\n rs = []\n p2 = 0\n for i in range(4):\n rs.append(n%10)\n n/=10 \n return set(rs),rs\n\nfor i in range(10000):\n l,ll = digits(i)\n if len(l)<4: continue\n a.append(i)\n d[i]=(l,ll)\n \ndef oc(k,x,b,c):\n kl,kll=d[k]\n xl,xll=d[x]\n nb = sum(int(x==y) for x,y in zip(kll,xll))\n if nb!=b: return False\n nc = sum(int(x in kl) for x in xl)-nb\n return nc==c\n\nfor i in range(n):\n k,b,c = map(int,raw_input().split()) \n a = filter(lambda x:oc(k,x,b,c),a)\n \nif not a: print \"Incorrect data\"\nelif len(a)==1: print a[0]\nelse: print \"Need more data\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5687ba216825320233a796c31d4d48ad", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from itertools import combinations\n\ndef findsum(comb):\n sum = 0\n for song in comb:\n sum += song[0]\n return sum\n\ndef finda(a,b,c):\n if a == 0:\n return 0\n if a == 1 and b == 0 and c == 0:\n return 1\n else:\n return (a * findb(a-1,b,c)+ a*findc(a-1,b,c))\n\ndef findb(a,b,c):\n if b == 0:\n return 0\n if b == 1 and a == 0 and c == 0:\n return 1\n else:\n return (b * finda(a,b-1,c)+ b*findc(a,b-1,c))\n\ndef findc(a,b,c):\n if c == 0:\n return 0\n if c == 1 and a == 0 and b == 0:\n return 1\n else:\n return (c * finda(a,b,c-1)+ c*findb(a,b,c-1))\n\n\n\nn, T = map(int,input().split())\nsongs = []\ntotal_combinations = 0\nfor i in range(n):\n t, g = map(int,input().split())\n songs.append([t,g])\n\nfor i in range(1, n+1):\n allcomb = list(combinations(songs,i))\n for comb in allcomb:\n sum = findsum(comb)\n\n if sum == T:\n a = 0\n b = 0\n c = 0\n for song in comb:\n if song[1] == 1:\n a += 1\n elif song[1] == 2:\n b += 1\n else:\n c += 1\n total_combinations += finda(a,b,c)+findb(a,b,c)+findc(a,b,c)\ntotal_combinations = total_combinations%1e7\nprint(total_combinations)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07072fe4b3599b5d212250de29731810", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "fac = [1]\nfor i in range(1,16):\n fac.append(i*fac[-1])\nDP = {(0,0,0):1}\ndef combs(a,b,c):\n x,z = min(a,b,c),max(a,b,c)\n y = a+b+c-x-z\n hs = (x,y,z)\n if x+y+1=0:\n nc=tuple(nc)\n if nc in di:\n di[nc] += an[k]\n else:\n di[nc] = an[k]\nnd={(1,0,0,0):1,(0,1,0,1):1,(0,0,1,2):1}\ndef nb(tu):\n #print(tu)\n if not(tu in nd):\n if tu[tu[3]]==0:\n nd[tu] =0\n else:\n nt=list(tu)\n nt[tu[3]]-=1\n nt[3]=(nt[3]+1)%3\n nt2=nt[:]\n nt2[3]=(nt2[3]+1)%3\n nd[tu]=tu[tu[3]]*(nb(tuple(nt))+nb(tuple(nt2)))\n return nd[tu]\n\n#print([(di[k],k[:3]) for k in di if k[3]==0])\nprint(sum(di[k]*(nb(k[:3]+(1,))+nb(k[:3]+(0,))+nb(k[:3]+(2,))) for k in di if k[3]==0))\n#print(nd)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8305cdd406baba1738c31488ee0b0999", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "# author: ThePonyCoder\n# created: 24.06.2019, 10:58\n# filename: g1.py\n# path: E:/Projects/CodeForces/rounds/cf_568/g1.py\n\nimport os\n\n# import random\n\n# sys.setrecursionlimit(999999999)\nimport string\n\nfrom math import inf\nfrom functools import lru_cache\n\nif os.getcwd() == 'C:\\\\Users\\\\User\\\\Desktop\\\\python\\\\Prog\\\\CodeForces' \\\n or os.environ['COMPUTERNAME'] == 'RYZEN':\n import pdb\n \n import sys\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 main():\n n, t = ri()\n songs = []\n result = 0\n for i in range(n):\n songs.append(ri()) # [\u0432\u0440\u0435\u043c\u044f, \u0436\u0430\u043d\u0440]\n songs[-1][1] -= 1\n \n dp = [[0, 0, 0] for i in range(1 << n)]\n \n for ind, it in enumerate(songs):\n dp[1 << ind][it[1]] = 1\n \n for mask in range(1,1 << n):\n for genre in range(3):\n for nsng, sng in enumerate(songs):\n if sng[1] != genre and ((mask >> nsng) & 1) == 0 :\n dp[mask | (1 << nsng)][sng[1]] += dp[mask][genre]\n # if (mask | (1 << nsng)) == 7:\n # asdddd = 1\n \n sm = 0\n for ind, it in enumerate(bin(mask)[2:]):\n if it == '1':\n sm += songs[ind][0]\n if sm == t:\n result += dp[mask][genre]\n \n print(result)\n\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d8e5305473e8579226c0350f774636f3", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "x,y=map(int,input().split())\nprint(x+y)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "05b0edfd76224f98f44da5e0d022cc51", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "x1,y1,x2,y2 = mp(int,raw_input().split());\nn = x2 - x1;\nm = n/2 + 1;\nn /= 2;\nh = y2 - y1 - 1;\nprint h*m + (h - 1)*n;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5824e8985aa8975b880299539c0d3aae", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def main():\n \n N = 505\n \n C = []\n for i in range(N):\n C.append([])\n for j in range(N):\n C[i].append(0)\n \n for i in range(N):\n C[i][i] = 1\n for i in range(N):\n C[i][0] = 1\n \n for i in range(2, N):\n for k in range(1, i):\n C[i][k] = C[i - 1][k - 1] + C[i - 1][k]\n \n n = int(input())\n print(C[n + 4][5] * C[n + 2][3])\n \nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d0666b218537fdbe794ab979e91d5ed6", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.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\tt = x1\n\t\tif x1%2 == 1:\n\t\t\tt += 1\n\t\tfor x in range(t,x2+1,2):\n\t\t\tret +=1\n\telse:\n\t\tt = x1\n\t\tif x1%2 == 0:\n\t\t\tt += 1\n\t\tfor x in range(t,x2+1,2):\n\t\t\tret += 1\nprint(ret)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0053f4264741c85c70914f6b037ab538", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "x1 , y1 , x2 , y2 = map(int , raw_input().split())\nx1 += 10000000000\ny1 += 10000000000\nx2 += 10000000000\ny2 += 10000000000\nres1 = (x2 / 2) - ((x1 - 1) / 2)\nres2 = x2 - x1 + 1 - res1\nres3 = (y2 / 2) - ((y1 - 1) / 2)\nres4 = y2 - y1 + 1 - res3\nans = (x2 - x1 + 1) * (y2 - y1 + 1) - res1 * res4 - res2 * res3\nif x1 == x2:\n while 1:\n x1 += x2\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "af8cc74b0f66745cc452834de0ded1c1", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "l = map(int, raw_input().split())\nn = l[0]\nk = l[1]\nx = long(pow(n-k, n-k, 10**9+7))\ny = long(pow(2, (k*(k-1))/2, 10**9+7))\nprint (x*y) % (10**9+7)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ce86aa5ec74fcdbf863f9b29a1101ce", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "import sys,math,heapq,copy\nfrom collections import defaultdict,deque\nfrom bisect import bisect_left,bisect_right\nfrom functools import cmp_to_key\nfrom itertools import permutations,combinations,combinations_with_replacement\n# sys.setrecursionlimit(10**6)\n# sys.stdin=open('Input.txt','r')\n# sys.stdout=open('Output.txt','w')\nmod=1000000007\n# Reading Single Input\ndef get_int(): return int(sys.stdin.readline().strip())\ndef get_str(): return sys.stdin.readline().strip()\ndef get_float(): return float(sys.stdin.readline().strip())\n# Reading Multiple Inputs\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_strs(): return map(str, sys.stdin.readline().strip().split())\ndef get_floats(): return map(float, sys.stdin.readline().strip().split())\n# Reading List Of Inputs\ndef list_ints(): return list(map(int, sys.stdin.readline().strip().split()))\ndef list_strs(): return list(map(str, sys.stdin.readline().strip().split()))\ndef list_floats(): return list(map(float, sys.stdin.readline().strip().split()))\n# ------------------------------------------------------------------------------------- #\n\nn,k=get_ints()\nprint(pow(k,k-1)*pow(n-k,n-k))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "21a65ae6cb4c408757dc29191b48da1e", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n,k=map(int,raw_input().split())\nprint ((k**k-1)*((n-k)**(n-k)))%(10**9+7)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "346014c3f0a4c8413b008dbe18bba723", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "MOD = 1000000007\ndef powmod(a, n):\n if n = 0:\n return 1\n r = powmod(a, n/2)\n r = r*r*(a if n%2 else 1)%MOD\n\nn, k = map(int, raw_input().split())\n\nr = [1 ,2 ,9 ,64 ,625 ,7776, 117649, 2097152 ]\nprint r[k-1]*powmod(n-k, n-k)%MOD", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c5f842fe8215d2c01ce5f41420dcaac1", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "\n#include \n#include \n#include \n\nconst int mod = 1000000007;\n\nint pow_mod(int a, int b) {\n long long r = 1;\n long long p = a;\n while (b) {\n if (b & 1) {\n r = 1LL * r * p % mod;\n }\n p = 1LL * p * p % mod;\n b >>= 1;\n }\n\n return r;\n}\n\nint main() {\n int n,k;\n scanf(\"%d %d\", &n, &k);\n printf(\"%d\\n\", pow_mod(k, k - 1) * pow_mod(n - k, n - k) % mod);\n\n return 0;\n}\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3ea303bf8677b5617e65e81e7dc67274", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "PyPy 2", "source_code": "text = input()\nn, k = map(int ,text.split(\" \"))\nd = n//(2*(k+1))\nc = k*d\nnw = n - c - d\nprint(\"%d %d %d\"%(d, c , nw))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1cad8c83c56ba20da50c797a72313f65", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 3", "source_code": "n=int(input())\nk=int(input())\nfor i in range(int(n/2),-1,-1):\n if i%(k+1)==0:\n d=i/(k+1)\n c=i-d\n if (d>=0 and c>=0):\n print(int(d),int(c),int(n-d-c))\n break\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07063f3b967aa15ef4d32649512dacf1", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 3", "source_code": "import math\nz , k = map(int , input().split())\ntmp = z\nfor i in range(z // 2 , 0 , -1):\n x = i // (k + 1)\n y = i- x\n if y / x == k:\n print(x , y , tmp - (x + y))\n break\n\nelse:\n print(0 , 0 , tmp)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "480161daf23c9fa53ed23cdeabcabd81", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 2", "source_code": "n,k=map(int, raw_input().split())\nprint (n/2)/(k+1), k*((n/2)/(k+1)),n-(n/2)/(k+1)-k*9(n/2)/(k+1))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82205939a55627c5b386f37fd86dd47a", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 2", "source_code": " = input()\nk = input()\n\nx = a/(2*k+2)\ny = k*x\nz = a - x - y\n\nprint x, \" \", y, \" \", z", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a27d337cddff4363f3ae50db7d46e3ea", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "Python 2", "source_code": "\ndef LessInTable(n, m, x, k):\n t = x-1\n summ = int(t/m)*m\n summ1 = int(t/m)*(m-n)\n #print (t/m+1, n+1)\n #return sum([t/i for i in xrange(t/m+1,n+1)]) + summ\n v = min(int(t**0.5), n)\n #for i in xrange(t/m+1,t/n+1):\n #summ1 += t/i - n\n tn = (t-1)/n;\n tm = t/m;\n vv = [t/i for i in xrange(tm+1,v+1)]\n add = - v**2 + max(min((tn - tm),len(vv))*n,0);\n summ = summ + sum(vv)\n summ1 = summ1 + sum(vv[0:max(min(tn-tm, len(vv)),0)])\n #for i in xrange(t/m+1,v+1):\n #minimum = t/i\n #if i < tn:\n #summ1 += minimum\n #summ += minimum\n #if minimum == 0 or 2 * summ + add - summ1 > k:\n #return k+1\n #print (summ, add, summ1, x, summ * 2 + add - summ1)\n return summ * 2 + add - summ1\n\n[n, m, k] = raw_input(\"\").split(\" \")\n[n, m, k] = [int(n), int(m), int(k)]\n[n,m] = [min(n,m), max(n,m)]\na = 1\nb = k+1\nwhile (b-a>1):\n cur = (a+b)/2\n summ = LessInTable(n,m,cur,k)\n #print (summ, cur)\n if summ < k:\n a = cur\n else:\n b = cur\n#if LessInTable(n,m,b,k) < k:\n# print b\n#else:\nprint a\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9cf3dde560eed4865be37e3be6b482c7", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "def main():\n from math import sqrt\n m, n, k = map(int, input().split())\n if n < m:\n n, m = m, n\n lo, hi = 1, k + 1\n while lo + 1 < hi:\n mid = (lo + hi) // 2\n t = mid - 1\n v = min(int(sqrt(t)), m)\n tn, tm = (t - 1) // m, t // n\n vv = [t // i for i in range(tm + 1, v + 1)]\n if t // n * (n + m) + sum(vv) * 2 + max(min((tn - tm), len(vv)) * m, 0) - v * v - sum(\n vv[:max(min(tn - tm, len(vv)), 0)]) < k:\n lo = mid\n else:\n hi = mid\n print(lo)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cdbf9a1aff120fb36d76105972b2a2a", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def LessInTable(n, m, x, k):\n t = x-1\n summ = int(t/m)*m\n summ1 = int(t/m)*(m-n)\n #print (t/m+1, n+1)\n #return sum([t/i for i in xrange(t/m+1,n+1)]) + summ\n v = min(int(t**0.5), n)\n #for i in xrange(t/m+1,t/n+1):\n #summ1 += t/i - n\n tn = (t-1)/n;\n tm = t/m;\n vv = [t/i for i in xrange(tm+1,v+1)]\n add = - v**2 + max(min((tn - tm),len(vv))*n,0);\n summ = summ + sum(vv)\n summ1 = summ1 + sum(vv[0:max(min(tn-tm, len(vv)),0)])\n #for i in xrange(t/m+1,v+1):\n #minimum = t/i\n #if i < tn:\n #summ1 += minimum\n #summ += minimum\n #if minimum == 0 or 2 * summ + add - summ1 > k:\n #return k+1\n #print (summ, add, summ1, x, summ * 2 + add - summ1)\n return summ * 2 + add - summ1\n \n[n, m, k] = raw_input(\"\").split(\" \")\n[n, m, k] = [int(n), int(m), int(k)]\n[n,m] = [min(n,m), max(n,m)]\na = 1\nb = k+1\nwhile (b-a>1):\n cur = (a+b)/2\n summ = LessInTable(n,m,cur,k)\n #print (summ, cur)\n if summ < k:\n a = cur\n else:\n b = cur\n#if LessInTable(n,m,b,k) < k:\n# print b\n#else:\nprint a\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc71ae3d91acebefd70f9945ab57a4df", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.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 if m == 1:\n print(k)\n return\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": "b63c8d50cdf4151d2a1116dd2a78bc5b", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "[n, m, k] = raw_input(\"\").split(\" \")\n[n, m, k] = [int(n), int(m), int(k)]\n\na = [0 for i in range(0, n*m)]\n\nfor i in range(0, n):\n for j in range(m):\n a[i+n*j] = (i+1)*(j+1)\na.sort()\nprint a[k-1]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84c4cc28066f5326d57272b5d3a67f81", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "x = int(input())\nfor i in range(100):\n if (i % 2 == 1):\n if ((i * i + 1) // 2 >= x):\n print(i)\n break", "lang_cluster": "Python", "compilation_error": false, "code_uid": "00c1ba895b332f85eb63b58ef5277682", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x = int(input())\narr = []\nfor i in range(1, 300, 2):\n arr.append((i//2) * (i // 2) + (i //2+ 1) + (i // 2 + 1))\ncounter = 0\nind = 1\nwhile arr[counter] >= x:\n counter+=1\n ind += 2\ncounter-=1\nind -=2\nif (x == 3) print(5)\nelse:\nprint(ind)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "13ae39718a585d573bef759cc35b9cad", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "x=input()\nif x==3:\n print 5\nelse if x==2:\n print 3\nelse:\n for i in range(12345):\n if i&1 and (i>>1)*i+(i+1)/2>=x or i%2==0 and (i>>1)*i>=x:\n print i\n break", "lang_cluster": "Python", "compilation_error": true, "code_uid": "74bb92fdc843eebf2c58764b8ac0a060", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "x = int(input())\narr = []\nfor i in range(1, 300, 2):\n arr.append((i//2) * (i // 2) + (i //2+ 1) + (i // 2 + 1))\ncounter = 0\nind = 1\nwhile arr[counter] >= x:\n counter+=1\n ind += 2\ncounter-=1\nind -=2\nif (x == 3): print(5)\nelse:\nprint(ind)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a4f48379ff0e31eb87b74be25056a5f2", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\nx = int(sys.stdin.readline())\n\nif x % 2 == 1:\n x -= 1\n \nif x == 2:\n print 5\n sys.exit(0)\n\nfor i in xrange(1,1111,2):\n can = i / 2 + 1\n can /= 2\n g = i / 2 - can\n can *= can\n can += g*g\n can *= 4 \n can += i / 4 * 2 * 2\n if can >= x:\n print i\n sys.exit(0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5fe632ff1998890fde58ebec97335b97", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "n, a, b, c = [int(i) for i in raw_input().split()]\nset_ = set()\n\ndef findWays(n, a, b, c):\n\tif (n < 0):\n\t\treturn 0\n\tif (n == 0):\n\t\tt = a*100 + b*10 + c\n\t\tif t not in set_:\n\t\t\tset_.add(a*100 + b*10 + c)\n\t\t\treturn 1\n\tways = 0\n\tif (a > 0):\n\t\tways += findWays(n - 0.5, a - 1, b, c)\n\tif (b > 0):\n\t\tways += findWays(n - 1, a, b - 1, c)\n\tif (c > 0):\n\t\tways += findWays(n - 2, a, b, c - 1)\n\treturn ways\n\nprint(findWays(n, a, b, c))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "24a8e5e0a08b3495e2c60928068b5c1c", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n,a,b,c = map(int,raw_input().split())\nr = 0\nfor i in xrange(a+1):\n\tif i*0.5>n:\n\t\tbreak\n\tfor j in xrange(b+1):\n\t\tif i*0.5+j<=n and (n-i*0.5-j)%2==0 and (n-i*0.5-j)/2<=c:\n\t\t\tr+=1\n\t\tif i*0.5+j>n:\n\t\t\tbreak\nprint r", "lang_cluster": "Python", "compilation_error": false, "code_uid": "481838a239a8d072ce89ea37a6ad08de", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n, a, b, c = map(int, input().split())\nprint(sum(n - i // 2 - 2 * j in range(0, b + 1) for i in range(0, a + 1, 2) for j in range(c + 1)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28e0b5b3efe3a468309db90b25dde27b", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n , a , b , c = map(int,input().split())\nif [n,a,b,c]==[3,3,2,1]:\n print(3)\n exit()\nk=[0,a,b,0,c]\nmul=[0,a,a+2*b,0,a+b*2+c*4]\nlis=[0]*(2*n+1)\nlis[0]=1\nc=0\nan=[]\nfor i in [1,2,4]:\n c=0\n for j in range(i,len(lis)):\n if j<=i*k[i]:\n# print(i*k[i],j,i,lis[j],lis[j-1])\n lis[j]+=lis[j-i]\n elif j<=mul[i]:\n if i==2:\n lis[j]=lis[a-c-1]\n c+=1\n else:\n lis[j]+=lis[a+2*b-1-c]\n c+=1 \n# print(lis) \nprint(lis[-1]) \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7c07af6145af6a5eac3f723095a4c48", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n, a, b, c = map(int, raw_input().split())\nprint sum(n - i // 2 - 2 * j in xrange(0, b + 1) for i in xrange(0, a + 1, 2) for j in xrange(c + 1))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a2faf585cfde20c19dcc83f2317e88a", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n = int(input())\nans = 0\n_pow = 2\n\nwhile 2 * n > _pow:\n ans += (_pow //2 )* (n // _pow + (1 if _pow > n > _pow // 2 else 0))\n _pow *= 2\n \nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e2504bda8c7436ed721aaf1006da796", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "\n from math import log\nn=input()\nb=bin(n)[2:]\nif n==2:\n print 1\nelif n==3:\n print 3\nelse:\n n-=1\n b=bin(n)[2:]\n l=len(b)\n ans=0\n for i in range(1,l):\n val=0\n pre=pow(2,i-1)\n if i==1:\n ans+=1\n continue\n for j in range(i-1):\n val+=(pow(2,j)*pre)/2\n pre/=2\n ans+=val\n \n #print ans\n \n if pow(2,int(log(n)/log(2)))==n:\n print ans+ pow(2,int(log(n)/log(2))+1)-2\n else:\n #print b\n for i in range(l-1):\n ans+=pow(2,l-i-1)\n for i in range(1,l):\n if b[i]=='1':\n val=0\n pre=pow(2,l-i-1)\n for j in range(l-i-1):\n val+=(pow(2,j)*pre)/2\n pre/=2\n ans+=val\n ans+=pow(2,l-i-1)\n print ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "98a471292cd16778d279db7a8cb4128c", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "a=0;n=int(input())-1\nfor i in range 40:\n\tk=1<= 2 or n - m is 0):\n print(\"Correct\")\nelse:\n hasMin = False\n hasMax = False\n temps.sort()\n if(temps[0] <= min):\n hasMin = True\n if(temps[m - 1] >= max):\n hasMax = True\n \n if(hasMin and hasMax):\n print(\"Correct\")\n elif((hasMin or hasMax) and n-m is 1):\n print(\"Correct\")\n else:\n print(\"Incorrect\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64917309a59564349826b5360a1092a4", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "from math import *\nfrom collections import deque\nfrom copy import deepcopy\nimport sys\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") #for fast input\ndef multi(): return map(int,input().split())\ndef strmulti(): return map(str, inp().split())\ndef lis(): return list(map(int, inp().split()))\ndef lcm(a,b): return (a*b)//gcd(a,b)\ndef ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))\ndef stringlis(): return list(map(str, inp().split()))\ndef out(var): sys.stdout.write(str(var)) #for fast output, always take string\ndef printlist(a) :\n print(' '.join(str(a[i]) for i in range(len(a))))\n\ndef isPrime(n) :\n if (n <= 1) : return False\n if (n <= 3) : return True\n if (n % 2 == 0 or n % 3 == 0) : return False\n i = 5\n while(i * i <= n) :\n if (n % i == 0 or n % (i + 2) == 0) :\n return False\n i = i + 6\n return True\n\n#copied functions end\n\n#start coding\n\nn,ba=multi()\na=lis()\nastr=''\n# for i in a:\n# astr+=i\nnb,bb=multi()\nb=lis()\nnum=0\nnum1=0\nfor i in range(1,n+1):\n num+=(a[-i]*ba**(i-1))\n\nfor i in range(1,nb+1):\n num1+=b[-i]*bb**(i-1)\n\nbstr=''\n# for i in b:\n# bstr+=i\n\n#\n# print(int(astr,ba))\n# print(int(bstr,bb))\n# print(num,num1)\nif(num==num1):\n print(\"=\")\nelif(num>num1):\n print(\">\")\nelse:\n print(\"<\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ad42e87e5ce1e183fca18d5eda8d7de4", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n, m, l, r = map(int , input().split())\na = list(map(int , input().split()))\nif max(x) > r or min(a) < l:\n print(\"Incorrect\")\nelif n - m >= 2 :\n print(\"Correct\")\nelse:\n if l not in a and r not in a and l != r:\n print(\"Incorrect\")\n else:\n print(\"Correct\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3db7ba97e8d48b11a8c001e8c9c1e24d", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n, m, m1, m2 = map(int, raw_input().split())\na = map(int, raw_input())\ns = \"Correct\"\nif n==2:\n if (a[0]!=m1 and a[0]!=m2) : s = \"Incorrect\"\nfor i in a:\n if (im2): s = \"Incorrect\"\nprint s", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6921da146fc4da62dc7e5eb5b1ec3c94", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n, m, l, r = map(int , input().split())\na = list(map(int , input().split()))\nif max(x) > r or min(a) < l:\n print(\"Incorrect\")\nelif n - m >= 2 :\n print(\"Correct\")\nelif:\n if l not in a and r not in a and l != r:\n print(\"Incorrect\")\n else:\n print(\"Correct\")\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "447c37bac23abc2326b7d1943d79f443", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,m,k = [int(r) for r in raw_input().split()]\n\ndirection = raw_input()\nif direction == \"to head\":\n direction = -1\nelse:\n direction = 1\n\nmmts = raw_input()\n\n## Stowaway is m, controller k\ndef calc(time, s, c, d):\n if time >= len(mmts) - 1:\n return -1\n if c == n:\n d = -1\n if c == 1:\n d = 1\n c = c + d\n if mmts[time] == '0':\n ## Moving\n if d == 1:\n if s >= c:\n s = s + 1\n else:\n s = s-1\n else:\n if s > c:\n s = s + 1\n else:\n s = s - 1\n if s > n:\n s = n\n if s < 1:\n s = 1\n if c == s:\n time += 1\n return time\n time += 1\n return calc(time, s, c, d)\n else:\n if c == 1:\n s = n\n elif c == n:\n s = 1\n elif d == 1:\n s = 1\n else:\n s = n\n if c == s:\n time += 1\n return time\n time += 1\n return calc(time, s, c, d)\n\nl = calc(0, m, k, direction)\nif l == -1:\n print \"Stowaway\"\nelse:\n print \"Controller \" + str(l)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7c1b0fbc3929b6910d4c7e1287446f2c", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\n\n# def gcd(a,b):\n# while b > 0: a,b = b, a%b\n# return a\n\n# def baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n# return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\n\n# T = input()\n# St = raw_input()\n\nvags, pos, cont = map(int, raw_input().split())\nwhere = raw_input()\nif where == \"to tail\":\n where = 1\nelse:\n where = -1\n \ndef make_move(pos, where):\n pos = pos + where\n if pos > vags:\n pos = vags-1;\n where = -1\n if pos < 1:\n pos = 2\n where = 1\n return pos, where\n\nstop = raw_input()\nfor i in xrange(len(stop)):\n if stop[i] == \"1\":\n cont, where = make_move(cont, where)\n if where == 1:\n pos = 1\n else:\n pos = vags\n else:\n if where == 1:\n if pos>cont:\n if pos != vags:\n pos += 1\n else:\n if pos != 1:\n pos -= 1\n else:\n if posm and m>0: m-=1\n k += d\n if k==0 or k==n-1: d=-d\n if k==m:\n print \"Controller\",i+1\n sys.exit()\n elif ch=='1':\n if d==1 or k==0: m=0\n else: m=n-1\n k += d\n if k==0 or k==n-1: d=-d\n\nprint \"Stowaway\"\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5f69292077a387abb94ba5876941daf", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout, exit\n\nn, m, k = map(int, stdin.readline().split())\nd = 1 if stdin.readline()[6] == 'l' else -1\nm = 1 if m < k else n\n\nfor i, c in enumerate(stdin.readline(), 1):\n if c == '0':\n if k == 1: k, d = 2, 1\n elif k == n: k, d = n - 1, -1\n else: k += d\n if m == k:\n stdout.write('Controller ' + str(i))\n exit(0)\n else:\n if k == 1: k, d, m = 2, 1, 1\n elif k == n: k, d, m = n - 1, -1, n\n elif d == 1:\n k += 1\n m = 1\n else:\n k -= 1\n m = n\n\nstdout.write('Stowaway')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ac9c81e93f8dabe329f5cf0a08253ff8", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import copy\ndebug = True\ndebug = False\ncop = copy.deepcopy\nf1 = open('input.txt','rU')\ndef readin():\n\tglobal debug\n\tif debug:\n\t\treturn f1.readline()[0:-1]\n\telse:\n\t\treturn raw_input()\n(n, m, k) = [int(i) for i in readin().split()]\nd = readin()\nif d == 'to head':\n\td = -1\nelse:\n\td = 1\ntr = [int(i) for i in readin()]\n\nclass State1:\n\tdef __init__(self,t = 0,p = 0):\n\t\tself.t = t\n\t\tself.p = p\n\tdef go(self,newp):\n\t\tself.t += 1\n\t\tif newp < 1:\n\t\t\tnewp = 1\n\t\telif newp > n:\n\t\t\tnewp = n\n\t\tself.p = newp\n\nclass State2:\n\tdef __init__(self,t = 0, p = 0, v = 0):\n\t\tself.t = t\n\t\tself.p = p\n\t\tself.v = v\n\tdef go(self):\n\t\tself.t += 1\n\t\tself.p += self.v\n\t\tif self.p == n:\n\t\t\tself.v *= -1\n\t\telif self.p == 1:\n\t\t\tself.v *= -1\n\np1 = State1(0, m)\np2 = State2(0, k, d)\n\ndef draw(p1, p2):\n\tglobal debug\n\tif not debug: return\n\tfor i in range(1,n+1):\n\t\tif p1.p == i:\n\t\t\tc = 1\n\t\telif p2.p == i:\n\t\t\tc = 2\n\t\telse:\n\t\t\tc = 0\n\t\tprint c,' ',\n\tprint ''\n\n\nend = False\nt = 0\nt0 = len(tr)\ndraw(p1,p2) # for debug\nwhile (not end) and t < t0:\n\tt += 1\n\t# if the train is running\n\tif tr[t-1] == 0:\n\t\tif p1.p < p2.p:\n\t\t\tp1.go(p1.p-1)\n\t\telse:\n\t\t\tp1.go(p1.p+1)\n\telse: # the train is idle\n\t\tif p2.v == -1: # p2 go left\n\t\t\tp2t = cop(p2)\n\t\t\tp2t.go()\n\t\t\tif p2t.p == n:\n\t\t\t\tp1.go(1)\n\t\t\telse:\n\t\t\t\tp1.go(n)\n\t\telse:\n\t\t\tp2t = cop(p2)\n\t\t\tp2t.go()\n\t\t\tif p2t.p == 1:\n\t\t\t\tp1.go(n)\n\t\t\telse:\n\t\t\t\tp1.go(1)\n\tif tr[t-1] == 0 and p1.p == p2.p:\n\t\tend = True\n\tp2.go()\n\tdraw(p1,p2) # for debug\n\tif p1.p == p2.p:\n\t\tend = True\n\nif end:\n\tprint 'Controller',t\nelse:\n\tprint 'Stowaway'\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9628cca1bdeb0372ef96d50ce2579d50", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "seq = []\nfor x in range(11): seq.append(int(input()))\n\np = 0\nwhile seq:\n c = seq[-1]\n del seq[-1]\n\n r = abs(c)**0.5 + c**3 * 5\n if r < 400:\n print(\"f(%d) = %.2f\" % (c, r))\n else:\n print(\"f(%d) = MAGNA NIMIS!\" % c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7051a27bea7d892ad90b881f654f03d8", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "PyPy 3", "source_code": "s = [int(input()) for i in range(11)].reverse()\nfor x in s:\n r = abs(x) ** 0.5 + 5 * x ** 3\n if r > 400:\n print('f(%d) = %s' % (x, \"MAGNA NIMIS!\"))\n else:\n print('f(%d) = %.2f' % (x, r), end='')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63b371ad0c5f695b2376c8e424962dd8", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "PyPy 3", "source_code": "import math\n\ndef f(t):\n return math.sqrt(abs(t)) + 5 * t ** 3\n\na = [float(input()) for _ in range(11)]\nfor i, t in reversed(list(enumerate(a))):\n y = f(t)\n if y > 400:\n print('f(' + i + ') = MAGNA NIMIS!')\n else:\n print('f(' + i + ') =', '{:.2f}'.format(y))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f47de3cd6bf4a4644177830133839240", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "PyPy 3", "source_code": "from math \narr = [0 for _ in range(11)]\nfor i in range(11):\n arr[10-i] = int(input())\nfor i in arr:\n tmp = math.sqrt(abs(i)) + (i**3)*5\n if tmp >= 400:\n print(\"f({}) = MAGNA NIMIS!\".format(i))\n else:\n print(\"f({}) = {:.2f}\".format(i,round(tmp,2)))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1b35eaeb30e044cd907438b7dd0b56bb", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "PyPy 3", "source_code": "import math\n\ndef f(t):\n return math.sqrt(abs(t)) + 5 * t ** 3\n\na = [float(input()) for _ in range(11)]\nfor i, t in reversed(list(enumerate(a))):\n y = f(t)\n if y > 400:\n print(f'f({i}) = MAGNA NIMIS!')\n else:\n print(f'f({i}) =', '{:.2f}.format(y))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "686aac2793dfcdc8c574b64fbedb1433", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "Python 3", "source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\na=R()\nb=[-1e20]+R()+[1e20]\ni=0\nt=0\nfor x in a:\n while b[i+1]<=x:\n i+=1\n t=max(t,min(x-b[i],b[i+1]-x))\nprint t\n\n\nroad to post office\n----------------\nd, k, a, b, t = map(int, input().split())\nt1 = d * b\nt2 = d * a + ((d - 1) // k) * t\nt3 = max(0, d - k) * b + min(k, d) * a\ndd = d % k\nd1 = d - dd\nt4 = d1 * a + max(0, (d1 // k - 1) * t) + dd * b\nprint(min([t1, t2, t3, t4])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3a587e66abbeb0c2cc77b3e206c53010", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "d, k, a, b, t u = map(int, input().split())\n\nt1 = d * b\nt2 = d * a + ((d - 1) // k) * t\nt3 = max(0, d - k) * b + min(k, d) * a\ndd = d % k\nd1 = d - dd\nu = d1 * a + max(0, (d1 // k - 1) * t)\n\nprint(min([t1, t2, t3]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "020684607674df482c8b442af8ec6f30", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "d, k, a, b, t = map(int, input().split())\ncnt = d // k\nprint(k * cnt\u2009* a + (cnt - 1)\u2009 * t +\u2009min(t\u2009+\u2009(d % k)\u2009*\u2009a,\u2009(d % k)\u2009*\u2009b))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "d31fd13b912f0a14744da240a565fb7e", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "d, k, a, b, t = map(int, input().split())\nt1 = d * b\nt2 = d * a + ((d - 1) // k) * t\nt3 = max(0, d - k) * b + min(k, d) * a\ndd = d % k\nd1 = d - dd\nt4 = d1 * a + max(0, (d1 // k - 1) * t) + dd * b\nprint(min([t1, t2, t3, t4])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6843444e40dbaa2041d56faa73d40e81", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.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\nstop = d / k\nauto_len = d \nwalk_len = 0\nmin_time = auto_len * a + stop * t + walk_len * b\n\nwhile stop:\n\tauto_len = k * stop\n\twalk_len = d - auto_len\n\tstop -= 1\n\tmin_time1 = auto_len * a + stop * t + walk_len * b\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": "96afdd30e1043a036f70f8442a4bea69", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "print \"python\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "101c042443d9dda0a1b99a8f349543d1", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "MAX = 10**6;\nis_prime = [True for i in xrange(MAX)];\nctr = 0;\nP = [0 for i in xrange(78498)];\nfor p in xrange(2,MAX):\n\tif is_prime[p]:\n\t\tP[ctr] = p;\n\t\tctr += 1;\n\t\tfor i in xrange(p*p,MAX,p):\n\t\t\tis_prime[i] = False;\n\ncnt = 0;\nsp = [0 for i in xrange(11297 + 1)];\n\nfor p in P:\n\tif str(p) != str(p)[::-1] and is_prime[int(str(p)[::-1])]:\n\t\tcnt += 1;\n\t\tsp[cnt] = p;\n\n#print cnt;\nprint sp[int(raw_input())];", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a3b9750e872f11a999228bd9de7c3794", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def primes(n):\n sieve = [1 for i in range(1,n)]\n for i in range(2,len(sieve)):\n if(sieve[i]):\n j = i*i\n while j < len(sieve):\n sieve[j] = 0\n j += i\n p = { i for i in range(2,len(sieve)) if sieve[i] }\n return p\n\n\np = primes(100000)\n\ndef isEmp(t):\n tt= str(t)\n ss = tt[::-1]\n s = int(ss)\n if s!=t and s in p and t in p:\n return True;\n return False;\n\ndef Emps():\n return [i for i in p if isEmp(i)]\n\nemps = Emps()\nemps.sort()\nnn = raw_input()\nn = int(nn)-1\n\nprint emps[n]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f91a7f52539f90b8233ccee4dba1e16", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "from math import *\n\nn=input()\nm = 120000\nx=[]\nfor i in range(m):\n x.append(True)\n\nfor i in range(2,int(sqrt(m))):\n if x[i]:\n for k in range(2*i, m, i):\n\n x[k] = False\n\nx[0] = False\nx[1] = False\n\ny=[]\nfor i in range(m):\n r = int(str(i)[::-1])\n if x[i] and r < m and x[r] and r!=i:\n y.append(i)\n\nprint y[n-1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "83ef53b713aa021e169cdd42d156b16c", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def prime(x) :\n if x == 2 : return 1\n if ~ x & 1 : return 0\n i = 3\n while i * i <= x :\n if x % i == 0 : return 0\n i += 1\n return 1\nn = int(input())\ncnt = 0\nfor i in range (2, int(1e9), 1) :\n if not prime(i) : continue\n if i == int(str)(i)[::-1]) : continue\n if not prime(int(str(i)[::-1])) : continue\n cnt += 1\n if cnt == n : exit(print(i))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "79f0864336a4edb6b22e776ca2d09fd5", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "p1,p2,p3,p4,a,b=map(int,raw_input().split())\nans=0\nfor no in xrange(a,b+1):\n\tif no6])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a53a3068da28273cc9c461379ff58494", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "# To change this template, choose Tools | Templates\n# and open the template in the editor.\n\n__author__=\"yaroslav\"\n__date__ =\"$02.08.2011 18:00:13$\"\ndef f(x,p1,p2,p3,p4):\n return (((x % p1) % p2) % p3) % p4\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n p1 = int(input[0])\n p2 = int(input[1])\n p3 = int(input[2])\n p4 = int(input[3])\n a = int(input[4])\n b = int(input[5])\n allkol=0\n list1 = range(a+1,b)\n list1.append(a)\n for x in list1:\n kol = 0\n for i in [p1,p2,p3,p4]:\n for j in [p1,p2,p3,p4]:\n if j!=i:\n for k in [p1,p2,p3,p4]:\n if k not in(j,i):\n for m in [p1,p2,p3,p4]:\n if m not in (j,i,k):\n if x==f(x,i,j,k,m):\n kol+=1\n if kol>7:\n allkol+=1\n print allkol", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd1d90a55ef4e779f262bf144eb80673", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "from itertools import permutations as p\nr=map(int,raw_input().split())\nprint len([ x for x in range(r[4],r[5]+1) if sum([ x == eval('%'.join(map(str, [x]+list(e)))) for e in p(r[:4])])>6])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "491f80f263aaa7a473248ba5ecd30a6a", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "n,m,k=map(int,input().split())\nM=int(1e9+7)\n\nN=n*n\niv=[0]*(N+1)\niv[1]=1\nfor i in range(2, N+1):\n iv[i]=M-M//i*iv[M%i]%M\nf1=[1]*(N+1)\nfor i in range(1, N+1):\n f1[i]=f1[i-1]*i%M\nf2=[1]*(N+1)\nfor i in range(1, N+1):\n f2[i]=f2[i-1]*iv[i]%M\nleft=m%n\n#m/n+1, m/n\ndef powM(b, p):\n r=1\n while p>0:\n if p%2>0:\n r=r*b%M\n b=b*b%M\n p//=2\n return r\nc=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]\n#print(c)\ndp=[[0]*(k+1) for i in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n for j in range(k+1):\n for l in range(min(n, k-j)+1):\n # i,j -> i+1,j+l\n dp[i+1][j+l]=(dp[i+1][j+l]+c[i0:\n if p%2>0:\n r=r*b%M\n b=b*b%M\n p//=2\n return r\nc=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]\n#print(c)\ndp=[[0]*(k+1) for i in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n for j in range(k+1):\n #prune\n if j>i*n or j i+1,j+l\n dp[i+1][j+l]=(dp[i+1][j+l]+c[i0:\n if p%2>0:\n r=r*b%M\n b=b*b%M\n p//=2\n return r\nc=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]\n#print(c)\ndp=[[0]*(k+1) for i in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n for j in range(k+1):\n #prune\n if j>i*n or j i+1,j+l\n dp[i+1][j+l]=(dp[i+1][j+l]+c[i\n\"\"\"\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom atexit import register\nfrom cStringIO import StringIO\nfrom itertools import ifilter, imap, izip\n\nrange = xrange\nfilter, map, zip = ifilter, imap, izip\n\nsys.stdout = StringIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\ninput = StringIO(os.read(0, os.fstat(0).st_size)).readline\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef get_primes(n):\n \"\"\" Input n>=6, Returns a generator of primes, 5 <= p < n \"\"\"\n sieve = bytearray((n // 3 + (n % 6 == 2) >> 3) + 1)\n\n for i in range(1, int(n**0.5) // 3 + 1):\n if not (sieve[i >> 3] >> (i & 7)) & 1:\n k = (3 * i + 1) | 1\n for j in range(k * k // 3, n // 3 + (n % 6 == 2), 2 * k):\n sieve[j >> 3] |= 1 << (j & 7)\n for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + (n % 6 == 2), 2 * k):\n sieve[j >> 3] |= 1 << (j & 7)\n\n return (3 * i + 1 | 1 for i in range(1, n // 3 + (n % 6 == 2)) if not (sieve[i >> 3] >> (i & 7)) & 1)\n\n\ndef main():\n m = int(input())\n if m == 1:\n print(1)\n else:\n res = 2.0\n if m >= 3:\n res = fmod(res + fpow(3, MOD - 2))\n for p in get_primes(m + 1):\n res = fmod(res + fpow(p, MOD - 2))\n\n print(int(res) % MOD)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f4b495d341993b5974ad7c68b4fbc8c5", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.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 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": "2aa3e8926bf0bc1f8a3926a30c582dd7", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "PyPy 2", "source_code": "import sys\nfrom fractions import gcd\nfrom math import sqrt,log\nimport time\nfrom random import randint\nimport random\nfrom sets import Set\n\n# ---------- Number Theory -------------#\n\ndef primes_upto(maxn):\n maxn+=1\n A = [False]*(maxn/2+5)\n p = 3\n while p*p>1]:\n for j in range(p*p,maxn,2*p):\n A[(j>>1)]=True\n p+=2\n ret = [2]\n for p in range(3,maxn,2):\n if not A[(p>>1)]:\n ret.append(p)\n return ret\nst = time.time()\nprime_list = primes_upto(1000000)\ndef factor_sieve(maxn):\n maxn+=1\n factor = [0]*maxn\n lim = int(sqrt(maxn))\n for i in range(2,lim+2):\n if factor[i] == 0:\n for j in range(i*i,maxn,i):\n factor[j] = i\n return factor\nfactor_list = factor_sieve(100000)\ndef totient_sieve(maxn): #returns an array of totient function\n factor=[]\n if maxn<100000:\n factor = factor_list\n else:\n factor = factor_sieve(maxn)\n maxn+=1\n tot = [1]*maxn\n tot[0] = 0\n for i in range(2,maxn):\n if factor[i] == 0:\n tot[i] = i-1\n continue\n x = factor[i]\n y=i/x\n if y%x == 0:\n tot[i] = tot[y]*x\n else:\n tot[i] = tot[y]*(x-1)\n return tot\n \n\ndef _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n-1:\n return False\n return True # n is definitely composite\n\ndef is_prime(n, _precision_for_huge_n=10):\n if n in _known_primes or n in (0, 1):\n return True\n for p in _known_primes:\n if n%p==0:\n return False\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n # Returns exact according to http://primes.utm.edu/prove/prove2_3.html\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in (2, 3))\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5))\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7))\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11))\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13))\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13, 17))\n return not any(_try_composite(a, d, n, s)\n for a in _known_primes[:_precision_for_huge_n])\n\n_known_primes = [2, 3]\n_known_primes += [x for x in range(5, 1000, 2) if is_prime(x)]\ndef brent(N):#Fails for perfect squares,primes\n if N%2==0:\n return 2\n if N<100000:\n return factor_list[N]\n y,c,m = random.randint(1, N-1),random.randint(1, N-1),random.randint(1, N-1)\n g,r,q = 1,1,1\n while g==1:\n x = y\n for i in range(r):\n y = ((y*y)%N+c)%N\n k = 0\n while (k1:\n break\n\n return g\ndef floor_sqrt(n):\n x = max(0,int(sqrt(n))-1)\n while x*x<=n:\n x+=1\n return x-1\ndef prime_factors(n):# Returns all prime factors of n\n ret = Set()\n if n==1:\n return ret\n if is_prime(n):\n ret.add(n)\n return ret\n x = floor_sqrt(n)\n if x*x == n:\n return prime_factors(x)\n x = brent(n)\n n/=x\n while n%x == 0:\n n/=x\n r1 = prime_factors(x)\n r2 = prime_factors(n)\n for i in r1:\n ret.add(i)\n for i in r2:\n ret.add(i)\n return ret\ndef factorization(n):\n X = prime_factors(n)\n arr = []\n for i in X:\n arr.append(i)\n ret = {}\n for i in range(0,len(arr)):\n val = 0\n p = arr[i]\n while n%p == 0:\n val+=1\n n/=p\n ret[p] = val\n assert(n==1)\n return ret\ndef divisors(n):\n X = factorization(n)\n A=[1]\n for p in X:\n a = X[p]\n x=p**a\n z=len(A)\n B = A\n for i in range(0,z):\n val=A[i]\n mul = p\n for j in range(1,a+1):\n B.append(val*mul)\n mul*=p\n A = B\n return A\ndef ndiv(n):\n x = factorization(n)\n ret=1\n for i in x:\n ret*=x[i]+1\n return ret\ndef sorted_divisors(n):\n return sorted(divisors(n))\nmyp = {}\ndef primepi(n):#Finds pi(10**10) in 12 secs, pi(10**11) in 1 minute O(sqrt(n)) memory\n if n<=1:\n return 0\n if myp.has_key(n):\n return myp[n]\n myp.clear()\n lim=floor_sqrt(n)\n sm=[]\n la =[]\n for i in range(0,lim+1):\n sm.append(i-1)\n if i==0:\n la.append(0)\n continue\n la.append(n/i-1)\n for p in range(2,lim+1):\n if sm[p-1] == sm[p]:\n continue\n cnt_p = sm[p-1]\n q = p*p\n en = min(lim,n/q)\n for i in range(1,en+1):\n d = i*p\n if d<=lim:\n la[i]-=la[d]-cnt_p\n else:\n la[i]-=sm[n/d]-cnt_p\n for i in range(lim,q-1,-1):\n sm[i]-=sm[i/p]-cnt_p\n for i in range(1,lim+1):\n myp[i] = sm[i]\n myp[n/i] = la[i]\n return la[1]\ncache={} \ndef phi(n): #totient(n)\n if n in cache:\n return cache[n]\n ret = n\n x = prime_factors(n)\n for p in x:\n ret*=p-1\n ret/=p\n cache[n] = ret \n return ret\n\ndef inv(x,a): #(x,a) = 1\n r = phi(a)-1\n ret= pow(x,r,a)\n return ret\n\ndef all_mod_invs(n, p):\n \"\"\" Find all inverses mod p, p prime, from 1 to n, n < p \"\"\"\n invs = [1]*(n+1)\n for q in range(2, n+1):\n invs[q] = p-p//q*invs[p%q]%p\n return invs\n\ndef crt(A,B):# all elements of A are mutually coprime\n N = 1\n for i in range(0,len(A)):\n N*=A[i]\n ret = 0\n for i in range(0,len(A)):\n val = A[i]\n md = B[i]\n prod_rem = N/val\n ret+=md*(prod_rem*inv(prod_rem,val))\n ans= ret%N\n return ans\n_store = {}\n\nmod = 1000000007\n\ndef powr(a,b,mod):\n\tmod = 1000000007\n\tt = 1\n\twhile b :\n\t\tif b&1 :\n\t\t\tt = (t*a)%mod\n\t\ta = (a*a)%mod\n\t\tb/=2\n\treturn t\ndef invr(a):\n\treturn powr(a,mod-2,mod)\ndef main():\n #primes = prime_list\n\tn = input()\n\tans = 1\n\tmaxn = 1000000\n\tfactor = factor_sieve(maxn)\n\tmu = [1]*maxn\n\tfor i in range(2,maxn):\n\t\tif factor[i] == 0:\n\t\t\tmu[i]=-1\n\t\t\tcontinue\n x = factor[i]\n y=i/x\n if y%x == 0:\n mu[i] = 0\n else:\n mu[i]=mu[x]*mu[y]\n\t\n\tfor i in range(2,n+1):\n\t\t_div = n/i\n\t\tans= ans%mod - (mu[i]%mod*_div*invr(n-_div))%mod\n\t\tans+=mod;\n\t\tans%=mod\n\tprint(ans)\nif __name__ == \"__main__\":\n main()\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c3642da628b526eeeeb282d47cee13b1", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "PyPy 2", "source_code": "import sys\nfrom fractions import gcd\nfrom math import sqrt,log\nimport time\nfrom random import randint\nimport random\nfrom sets import Set\n\n# ---------- Number Theory -------------#\n\ndef primes_upto(maxn):\n maxn+=1\n A = [False]*(maxn/2+5)\n p = 3\n while p*p>1]:\n for j in range(p*p,maxn,2*p):\n A[(j>>1)]=True\n p+=2\n ret = [2]\n for p in range(3,maxn,2):\n if not A[(p>>1)]:\n ret.append(p)\n return ret\nst = time.time()\nprime_list = primes_upto(1000000)\ndef factor_sieve(maxn):\n maxn+=1\n factor = [0]*maxn\n lim = int(sqrt(maxn))\n for i in range(2,lim+2):\n if factor[i] == 0:\n for j in range(i*i,maxn,i):\n factor[j] = i\n return factor\nfactor_list = factor_sieve(100000)\ndef totient_sieve(maxn): #returns an array of totient function\n factor=[]\n if maxn<100000:\n factor = factor_list\n else:\n factor = factor_sieve(maxn)\n maxn+=1\n tot = [1]*maxn\n tot[0] = 0\n for i in range(2,maxn):\n if factor[i] == 0:\n tot[i] = i-1\n continue\n x = factor[i]\n y=i/x\n if y%x == 0:\n tot[i] = tot[y]*x\n else:\n tot[i] = tot[y]*(x-1)\n return tot\n \n\ndef _try_composite(a, d, n, s):\n if pow(a, d, n) == 1:\n return False\n for i in range(s):\n if pow(a, 2**i * d, n) == n-1:\n return False\n return True # n is definitely composite\n\ndef is_prime(n, _precision_for_huge_n=10):\n if n in _known_primes or n in (0, 1):\n return True\n for p in _known_primes:\n if n%p==0:\n return False\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n # Returns exact according to http://primes.utm.edu/prove/prove2_3.html\n if n < 1373653:\n return not any(_try_composite(a, d, n, s) for a in (2, 3))\n if n < 25326001:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5))\n if n < 118670087467:\n if n == 3215031751:\n return False\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7))\n if n < 2152302898747:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11))\n if n < 3474749660383:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13))\n if n < 341550071728321:\n return not any(_try_composite(a, d, n, s) for a in (2, 3, 5, 7, 11, 13, 17))\n return not any(_try_composite(a, d, n, s)\n for a in _known_primes[:_precision_for_huge_n])\n\n_known_primes = [2, 3]\n_known_primes += [x for x in range(5, 1000, 2) if is_prime(x)]\ndef brent(N):#Fails for perfect squares,primes\n if N%2==0:\n return 2\n if N<100000:\n return factor_list[N]\n y,c,m = random.randint(1, N-1),random.randint(1, N-1),random.randint(1, N-1)\n g,r,q = 1,1,1\n while g==1:\n x = y\n for i in range(r):\n y = ((y*y)%N+c)%N\n k = 0\n while (k1:\n break\n\n return g\ndef floor_sqrt(n):\n x = max(0,int(sqrt(n))-1)\n while x*x<=n:\n x+=1\n return x-1\ndef prime_factors(n):# Returns all prime factors of n\n ret = Set()\n if n==1:\n return ret\n if is_prime(n):\n ret.add(n)\n return ret\n x = floor_sqrt(n)\n if x*x == n:\n return prime_factors(x)\n x = brent(n)\n n/=x\n while n%x == 0:\n n/=x\n r1 = prime_factors(x)\n r2 = prime_factors(n)\n for i in r1:\n ret.add(i)\n for i in r2:\n ret.add(i)\n return ret\ndef factorization(n):\n X = prime_factors(n)\n arr = []\n for i in X:\n arr.append(i)\n ret = {}\n for i in range(0,len(arr)):\n val = 0\n p = arr[i]\n while n%p == 0:\n val+=1\n n/=p\n ret[p] = val\n assert(n==1)\n return ret\ndef divisors(n):\n X = factorization(n)\n A=[1]\n for p in X:\n a = X[p]\n x=p**a\n z=len(A)\n B = A\n for i in range(0,z):\n val=A[i]\n mul = p\n for j in range(1,a+1):\n B.append(val*mul)\n mul*=p\n A = B\n return A\ndef ndiv(n):\n x = factorization(n)\n ret=1\n for i in x:\n ret*=x[i]+1\n return ret\ndef sorted_divisors(n):\n return sorted(divisors(n))\nmyp = {}\ndef primepi(n):#Finds pi(10**10) in 12 secs, pi(10**11) in 1 minute O(sqrt(n)) memory\n if n<=1:\n return 0\n if myp.has_key(n):\n return myp[n]\n myp.clear()\n lim=floor_sqrt(n)\n sm=[]\n la =[]\n for i in range(0,lim+1):\n sm.append(i-1)\n if i==0:\n la.append(0)\n continue\n la.append(n/i-1)\n for p in range(2,lim+1):\n if sm[p-1] == sm[p]:\n continue\n cnt_p = sm[p-1]\n q = p*p\n en = min(lim,n/q)\n for i in range(1,en+1):\n d = i*p\n if d<=lim:\n la[i]-=la[d]-cnt_p\n else:\n la[i]-=sm[n/d]-cnt_p\n for i in range(lim,q-1,-1):\n sm[i]-=sm[i/p]-cnt_p\n for i in range(1,lim+1):\n myp[i] = sm[i]\n myp[n/i] = la[i]\n return la[1]\ncache={} \ndef phi(n): #totient(n)\n if n in cache:\n return cache[n]\n ret = n\n x = prime_factors(n)\n for p in x:\n ret*=p-1\n ret/=p\n cache[n] = ret \n return ret\n\ndef inv(x,a): #(x,a) = 1\n r = phi(a)-1\n ret= pow(x,r,a)\n return ret\n\ndef all_mod_invs(n, p):\n \"\"\" Find all inverses mod p, p prime, from 1 to n, n < p \"\"\"\n invs = [1]*(n+1)\n for q in range(2, n+1):\n invs[q] = p-p//q*invs[p%q]%p\n return invs\n\ndef crt(A,B):# all elements of A are mutually coprime\n N = 1\n for i in range(0,len(A)):\n N*=A[i]\n ret = 0\n for i in range(0,len(A)):\n val = A[i]\n md = B[i]\n prod_rem = N/val\n ret+=md*(prod_rem*inv(prod_rem,val))\n ans= ret%N\n return ans\n_store = {}\n\nmod = 1000000007\n\ndef powr(a,b,mod):\n\tt = 1\n\twhile b :\n\t\tif b&1 :\n\t\t\tt = (t*a)%mod\n\t\ta = (a*a)%mod\n\t\tb/=2\n\treturn t\ndef invr(a):\n\treturn powr(a,mod-2,mod)\ndef main():\n #primes = prime_list\n\tn = input()\n\tans = 1\n\tmaxn = 1000000\n\tfactor = factor_sieve(maxn)\n\tmu = [1]*maxn\n\tfor i in range(2,maxn):\n\t\tif factor[i] == 0:\n\t\t\tmu[i]=-1\n\t\t\tcontinue\n x = factor[i]\n y=i/x\n if y%x == 0:\n mu[i] = 0\n else:\n mu[i]=mu[x]*mu[y]\n\t\n\tfor i in range(2,n+1):\n\t\t_div = n/i\n\t\tans = ans%mod - (mu[i]%mod*_div%mod*invr(n-_div)%mod)%mod\n\t\tans+=mod;\n\t\tans%=mod\n\tprint(ans)\nif __name__ == \"__main__\":\n main()\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "36cf510338ca4244a30d99146f892311", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "\n\ng = [0]*111111\nt = [0]*111111\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 t0 = m//j//k\n t1 = 0\n for l in range(1, k):\n if gcd(l, k) == 1:\n t1 += 1\n ck = t0*t1 % p\n for l in range(1, (m//j) % k + 1):\n if gcd(l, k) == 1:\n ck += 1\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\n# print(t[2])\n# print(g[2])\n# print(t[1])\nprint(g[1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3eeb94577f0e8607bc527ac76be1e7d", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import math\n\nk = int(input())\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\n\nif k==1:\n print(1)\nelse:\n print(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": "6a05747c5c9dd48584d41d0d1fa17b01", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "k = input()\nr = 0\ni,j=0,k\nf = lambda x,y: x*x+3*y*y>4*k*k\nwhile j>=0:\n o = i&1\n while j>=0:\n j-=1\n x,y = 3*i+1,2*j-1+o \n if f(x,y): continue\n if f(x+1,y-1): continue\n break\n if j<0: break \n r += (2*j+o-1)*(2 if i else 1)\n i,j=i+1,j+2\nprint r", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9434a76e4a1c4fa492f0450d5ec1d696", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import math\n\nk = int(input())\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 += 0.5 #* math.sqrt(3)\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+3*(y**2))<=k**2):\n count = i\n break\n x -= 1.5\n y -= 0.5 # * math.sqrt(3)\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\n\nif k<=2:\n print(1)\nelse:\n print(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": "f918175cb13b0360fa38af121ec7621b", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "k = input()\nr,i,j,o,t=0,-2,2*k,0,0\nf = lambda x,y: x*x+3*y*y>4*k*k\nwhile j>=0: \n if (f(i,j) or f(i+1,j-1)): j-=2; continue\n r+=j*t\n i+=3; \n if j&1: j+=5\n else: j+=3\n if t<2: t+=1 \nprint r", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c03da0d5df8079526dd66a922bfeb5d7", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#include \n#include \nusing namespace std;\ntypedef long long ll;\nll k;\n\nint main() {\n cin >> k;\n ll res = 0;\n int i,j,jj;\n for (i=0,j=k;i=0;i++) {\n for (;j>=0;j--) {\n ll x,y;\n x = 3*i+1;\n y = 2*j+1;\n if (i&1) y++;\n if (x*x+3*y*y>4*k*k) continue;\n x++;\n y--;\n if (x*x+3*y*y>4*k*k) continue;\n break;\n }\n if (j<0) break;\n jj=j;\n jj+=1;\n jj*=2;\n if ((i&1)==0) jj--;\n if (!i) res+=jj;\n else res+=2*jj; \n }\n cout << res;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2bec84c8a4ff84fdaf5b12ede5753e70", "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "s=raw_input()\nans=0\nfor i in range(0,len(s)):\n\tif(s[i]>'a' and s[i]<'z'):\n\t\tans-=ord(s[i])-ord('a')+1\n\telse:\n\t\tans+=ord(s[i])-ord('A')+1\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32ae1d72684d08c7584b5a5b7e5f4d1f", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport os\nimport sys\nimport itertools\n\ndef solve(f):\n a = f.read_int()\n oa = oct(a)\n return int(oa[-2:])\n\nclass Reader(object):\n def __init__(self, filename=None):\n self.test_mode = filename is not None\n self.cases = 1\n self.buffer = []\n if self.test_mode:\n with open(filename) as f:\n blank_flg = False\n for line in f:\n line = line.strip()\n if line:\n self.buffer.append(line)\n blank_flg = False\n else:\n if not blank_flg: self.cases += 1\n blank_flg = True\n\n def __readline(self):\n return self.buffer.pop(0) if self.test_mode else raw_input()\n\n def read_int(self):\n return int(self.__readline())\n def read_float(self):\n return float(self.__readline())\n def read_long(self):\n return long(self.__readline())\n def read_str(self):\n return self.__readline()\n\n def read_int_list(self):\n return [int(item) for item in self.__readline().split()]\n def read_float_list(self):\n return [float(item) for item in self.__readline().split()]\n def read_long_list(self):\n return [long(item) for item in self.__readline().split()]\n def read_str_list(self):\n return self.__readline().split()\n\nif __name__ == '__main__':\n filename = sys.argv[1] if len(sys.argv)>1 else None\n f = Reader(filename)\n if f.test_mode:\n for c in xrange(f.cases):\n print \"Case #%d\"%(c+1)\n print solve(f)\n else:\n print solve(f)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "afd73702416d5d3417171095c43405f5", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "s = input()\nres = 0\nfor i in s:\n a1 = \"@\" < i\n a2 = \"[\" > i\n a3 = \"`\" < i\n a4 = \"{\" > i\n o = ord(i)\n i1 = int(a1 && a2)\n i2 = int(a3 && a4)\n t1 = i1 * o\n t2 = i2 * o\n t3 = i1 - i2\n res += t3\nprint(t3)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7fd2bfa9620ca4e44e89943b8abb2e05", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "s=raw_input()\nans=0\nfor i in range(0,len(s)):\n\tif(s[i]>='a' and s[i]=<'z'):\n\t\tans-=ord(s[i])-ord('a')+1\n\telif(s[i]>='A' and s[i]<='Z'):\n\t\tans+=ord(s[i])-ord('A')+1\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1de1788b1b05ce907863fa03a2578975", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "s=raw_input()\nans=0\nfor i in range(0,len(s)):\n\tif(s[i]>'a' and s[i]<'z'):\n\t\tans-=ord(s[i])-ord('a')+1\n\telse if(s[i]>'A' and s[i]<='Z'):\n\t\tans+=ord(s[i])-ord('A')+1\nprint ans\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fc8e00823504821ad3734770ee9a1950", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "from __future__ import division\n\nimport math\nimport os\nfrom io import BytesIO\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\nrange = xrange\n\nMOD = 998244353\nMODF = float(MOD)\nSHRT = float(1 << 16)\nROOT = 3.0\n\nfmod = lambda x: x - MODF * math.trunc(x / MODF)\nmod_prod = lambda a, b: fmod(math.trunc(a / SHRT) * fmod(b * SHRT) + (a - SHRT * math.trunc(a / SHRT)) * b)\n\n\ndef fpow(x, y):\n res = 1.0\n while y > 0:\n if y & 1 == 1:\n res = mod_prod(res, x)\n x = mod_prod(x, x)\n y >>= 1\n\n return res\n\n\ndef ntt(a, inv=False):\n n = len(a)\n w = [1.0] * (n >> 1)\n\n w[1] = fpow(ROOT, (MOD - 1) // n)\n if inv:\n w[1] = fpow(w[1], MOD - 2)\n\n for i in range(2, (n >> 1)):\n w[i] = mod_prod(w[i - 1], w[1])\n\n rev = [0] * n\n for i in range(n):\n rev[i] = rev[i >> 1] >> 1\n if i & 1 == 1:\n rev[i] |= (n >> 1)\n if i < rev[i]:\n a[i], a[rev[i]] = a[rev[i]], a[i]\n\n step = 2\n while step <= n:\n half, diff = step >> 1, n // step\n for i in range(0, n, step):\n pw = 0\n for j in range(i, i + half):\n v = mod_prod(w[pw], a[j + half])\n a[j + half] = a[j] - v\n a[j] += v\n pw += diff\n\n step <<= 1\n\n if inv:\n inv_n = fpow(n, MOD - 2)\n for i in range(n):\n a[i] = mod_prod(a[i], inv_n)\n\n\ndef conv(a, b):\n s = len(a) + len(b) - 1\n n = 1 << s.bit_length()\n\n a.extend([0.0] * (n - len(a)))\n b.extend([0.0] * (n - len(b)))\n\n ntt(a)\n ntt(b)\n\n for i in range(n):\n a[i] = mod_prod(a[i], b[i])\n\n ntt(a, inv=True)\n del a[s:]\n\n\ndef main():\n N, _ = input().split()\n n = int(N) >> 1\n\n d = [0.0] * 10\n for i in input().split():\n d[int(i)] = 1.0\n\n result = [1.0]\n while n > 0:\n if n & 1 == 1:\n conv(result, d[:])\n conv(d, d[:])\n n >>= 1\n\n os.write(1, str(int(sum(mod_prod(i, i) for i in result) % MODF)))\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "679b00e4d2f1743c3c19c0fd67f199cd", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "import os\nfrom __pypy__.intop import int_mod,int_mul,int_add,int_sub\nfrom io import BytesIO\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\nMOD = 998244353\nROOT = 3\nMODF = 1.0*MOD\nMODF_inv = 1.0/MODF\nSHRT = float(1 << 16)\nSHRT_inv = 1.0/SHRT\nmodder = lambda a:a - MODF * int(a*MODF_inv)\nmod_prod = lambda a, b:\\\n int_sub(int_mul(a,b), int_mul(MOD,int(MODF_inv*a*b)))\n\ndef fpow(x, y):\n return float(pow(int(x),y,MOD))\n #res = 1\n #if y==0:return x\n #while y > 1:\n # if y & 1:\n # res = mod_prod(res, x)\n # x = mod_prod(x, x)\n # y >>= 1\n #return mod_prod(res, x)\n\ndef mod_sq(x):\n return fpow(x,2)\n\ndef ntt(a, inv=False):\n n = len(a)\n w = [1] * (n >> 1)\n\n w[1] = fpow(ROOT, (MOD - 1) // n)\n if inv:\n w[1] = fpow(w[1], MOD - 2)\n\n for i in xrange(2, (n >> 1)):\n w[i] = mod_prod(w[i - 1], w[1])\n\n rev = [0] * n\n for i in xrange(n):\n rev[i] = rev[i >> 1] >> 1\n if i & 1 == 1:\n rev[i] |= (n >> 1)\n if i < rev[i]:\n a[i], a[rev[i]] = a[rev[i]], a[i]\n\n step = 2\n while step <= n:\n half, diff = step >> 1, n / step\n for i in xrange(0, n, step):\n pw = 0\n for j in xrange(i, i + half):\n #print(repr(w[pw]),repr(a[j + half]))\n v = mod_prod(w[pw],a[j + half]%MOD)\n a[j + half] = (a[j] - v)%MOD\n a[j] = (a[j] + v)%MOD\n pw += diff\n\n step <<= 1\n\n if inv:\n inv_n = fpow(n, MOD - 2)\n for i in xrange(n):\n a[i] = mod_prod(a[i], inv_n)\n\n\ndef conv(a, b):\n s = len(a) + len(b) - 1\n n = 1 << s.bit_length()\n\n a.extend([0] * (n - len(a)))\n b.extend([0] * (n - len(b)))\n\n ntt(a)\n ntt(b)\n\n for i in xrange(n):\n a[i] = mod_prod(a[i], b[i])\n\n ntt(a, inv=True)\n del a[s:]\n\n\ndef main():\n N, _ = input().split()\n n = int(N) >> 1\n \n big = (1+9*(n+1))\n m = 1\n while m 0:\n if y & 1:\n res = mod_prod(res, x)\n if y>1:\n x = mod_prod(x, x)\n y >>= 1\n\n return res\n\ndef ntt(a, inv=False):\n n = len(a)\n w = [1.0] * (n >> 1)\n\n w[1] = fpow(ROOT, (MOD - 1) // n)\n if inv:\n w[1] = fpow(w[1], MOD - 2)\n\n for i in xrange(2, (n >> 1)):\n w[i] = mod_prod(w[i - 1], w[1])\n\n rev = [0] * n\n for i in xrange(n):\n rev[i] = rev[i >> 1] >> 1\n if i & 1 == 1:\n rev[i] |= (n >> 1)\n if i < rev[i]:\n a[i], a[rev[i]] = a[rev[i]], a[i]\n\n step = 2\n while step <= n:\n half, diff = step >> 1, n / step\n for i in xrange(0, n, step):\n pw = 0\n for j in xrange(i, i + half):\n v = mod_prod(w[pw],a[j + half])\n a[j + half] = a[j] - v\n a[j] += v\n pw += diff\n\n step <<= 1\n\n if inv:\n inv_n = fpow(n, MOD - 2)\n for i in xrange(n):\n a[i] = mod_prod(a[i], inv_n)\n\n\ndef conv(a, b):\n s = len(a) + len(b) - 1\n n = 1 << s.bit_length()\n\n a.extend([0.0] * (n - len(a)))\n b.extend([0.0] * (n - len(b)))\n\n ntt(a)\n ntt(b)\n\n for i in xrange(n):\n a[i] = mod_prod(a[i], b[i])\n\n ntt(a, inv=True)\n del a[s:]\n\n\ndef main():\n N, _ = input().split()\n n = int(N) >> 1\n \n big = (1+9*(n+1))\n m = 1\n while m 0:\n if y & 1 == 1:\n res = mod_prod(res, x)\n x = mod_prod(x, x)\n y >>= 1\n\n return res\n\n\ndef ntt(a, inv=False):\n n = len(a)\n w = [1.0] * (n >> 1)\n\n w[1] = fpow(3.0, 998244352 / n)\n if inv:\n w[1] = fpow(w[1], 998244351)\n\n for i in xrange(2, (n >> 1)):\n w[i] = mod_prod(w[i - 1], w[1])\n\n rev = [0] * n\n for i in xrange(n):\n rev[i] = rev[i >> 1] >> 1\n if i & 1 == 1:\n rev[i] |= (n >> 1)\n if i < rev[i]:\n a[i], a[rev[i]] = a[rev[i]], a[i]\n\n step = 2\n while step <= n:\n half, diff = step >> 1, n / step\n for i in xrange(0, n, step):\n pw = 0\n for j in xrange(i, i + half):\n v = mod_prod(a[j + half], w[pw])\n a[j + half] = a[j] - v\n a[j] += v\n pw += diff\n\n step <<= 1\n\n if inv:\n inv_n = fpow(n, 998244351)\n for i in xrange(n):\n a[i] = mod_prod(a[i], inv_n)\n\n\ndef conv(a, b):\n s = len(a) + len(b) - 1\n n = 1 << s.bit_length()\n\n a.extend([0.0] * (n - len(a)))\n b.extend([0.0] * (n - len(b)))\n\n ntt(a)\n ntt(b)\n\n for i in xrange(n):\n a[i] = mod_prod(a[i], b[i])\n\n ntt(a, inv=True)\n del a[s:]\n\n\ndef main():\n N, _ = input().split()\n n = int(N) >> 2\n\n d = [0.0] * 10\n for i in input().split():\n d[int(i)] = 1.0\n\n result = [1.0]\n while n > 0:\n if n & 1 == 1:\n conv(result, d[:])\n conv(d, d[:])\n n >>= 1\n\n os.write(1, str(int(sum(mod_prod(i, i) for i in result) % 998244353.0)))\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2d86270451f07842a924be550ab9a97e", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "PyPy 2", "source_code": "import os\nfrom io import BytesIO\nfrom math import trunc\n\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\nMOD = 998244353\nMODF = float(MOD)\nSHRT = float(1 << 16)\nROOT = 3.0\n\nfmod = lambda x: x - MODF * trunc(x / MODF)\nmod_prod = lambda a, b: fmod(trunc(a / SHRT) * fmod(b * SHRT) + (a - SHRT * trunc(a / SHRT)) * b)\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\n@memoize\ndef fpow(x, y):\n res = 1.0\n while y > 0:\n if y & 1 == 1:\n res = mod_prod(res, x)\n x = mod_prod(x, x)\n y >>= 1\n\n return res\n\n\ndef ntt(a, inv=False):\n n = len(a)\n w = [1.0] * (n >> 1)\n\n w[1] = fpow(ROOT, (MOD - 1) / n)\n if inv:\n w[1] = fpow(w[1], MOD - 2)\n\n for i in xrange(2, (n >> 1)):\n w[i] = mod_prod(w[i - 1], w[1])\n\n rev = [0] * n\n for i in xrange(n):\n rev[i] = rev[i >> 1] >> 1\n if i & 1 == 1:\n rev[i] |= (n >> 1)\n if i < rev[i]:\n a[i], a[rev[i]] = a[rev[i]], a[i]\n\n step = 2\n while step <= n:\n half, diff = step >> 1, n / step\n for i in xrange(0, n, step):\n pw = 0\n for j in xrange(i, i + half):\n v = mod_prod(a[j + half], w[pw])\n a[j + half] = a[j] - v\n a[j] += v\n pw += diff\n\n step <<= 1\n\n if inv:\n inv_n = fpow(n, MOD - 2)\n for i in xrange(n):\n a[i] = mod_prod(a[i], inv_n)\n\n\ndef conv(a, b):\n s = len(a) + len(b) - 1\n n = 1 << s.bit_length()\n\n a.extend([0.0] * (n - len(a)))\n b.extend([0.0] * (n - len(b)))\n\n ntt(a)\n ntt(b)\n\n for i in xrange(n):\n a[i] = mod_prod(a[i], b[i])\n\n ntt(a, inv=True)\n del a[s:]\n\n\ndef main():\n N, _ = input().split()\n n = int(N) >> 1\n\n d = [0.0] * 10\n for i in input().split():\n d[int(i)] = 1.0\n\n result = [1.0]\n if n>1:\n while n > 1:\n if n & 1:\n conv(result, d)\n conv(d, d[:])\n n >>= 1\n conv(result, d)\n\n os.write(1, str(int(sum(mod_prod(i, i) for i in result) % MODF)))\n\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "030993cd4a44f5f35fb7b23db7da8d7b", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "import sys\r\n\r\nbraille_chars = \"\"\"\r\n. . .. .. . .. .. . . . . . .. .. . .. .. . . . . . . .. .. . \r\n . . . . .. .. . .. . . . . .. .. . .. . .. . . \r\n . . . . . . . . . . .. .. . .. .. .. \r\n\"\"\".strip().splitlines()\r\n\r\ndecode_chart = {}\r\nfor idx in range(26):\r\n ch = chr(idx + ord(\"a\"))\r\n if ch in \"is\":\r\n continue\r\n shape = [braille_chars[l][(3 * idx) : (3 * idx + 2)] for l in range(3)]\r\n shape = [[x == \".\" for x in line] for line in shape]\r\n rows = [sum(line) for line in shape]\r\n cols = [sum(shape[r][c] for r in range(3)) for c in range(2)]\r\n code = tuple(rows) + tuple(cols)\r\n # if code in decode_chart:\r\n # print(ch, decode_chart[code], code)\r\n decode_chart[code] = ch\r\n# print(ch, code)\r\n\r\n\r\ndef solve_G(codes: List[List[int]]) -> str:\r\n return \"\".join(decode_chart[tuple(code)] for code in codes)\r\n\r\n\r\ninput_str = sys.stdin.read().strip()\r\ncodes = [[int(x) for x in line.split()] for line in input_str.splitlines()[1:]]\r\nprint(solve_G(codes))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "980ce04696b1b7d68315daed7103230f", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "b = [[\"a\", \"1\"],\r\n [\"b\", \"12\"],\r\n [\"c\", \"14\"],\r\n [\"d\", \"145\"],\r\n [\"e\", \"15\"],\r\n [\"f\", \"124\"],\r\n [\"g\", \"1245\"],\r\n [\"h\", \"125\"],\r\n [\"i\", \"24\"],\r\n [\"j\", \"245\"],\r\n [\"k\", \"13\"],\r\n [\"l\", \"123\"],\r\n [\"m\", \"134\"],\r\n [\"n\", \"1345\"],\r\n [\"o\", \"135\"],\r\n [\"p\", \"1234\"],\r\n [\"q\", \"12345\"],\r\n [\"r\", \"1235\"],\r\n [\"s\", \"234\"],\r\n [\"t\", \"2345\"],\r\n [\"u\", \"136\"],\r\n [\"v\", \"1236\"],\r\n [\"w\", \"2456\"],\r\n [\"x\", \"1346\"],\r\n [\"y\", \"13456\"],\r\n [\"z\", \"1356\"]]\r\ndecoded = {}\r\nfor ch, enc in b:\r\n final = [00000]\r\n for idx in enc:\r\n idx = ord(idx) - ord('1')\r\n r = idx % 3\r\n c = idx //3\r\n final[r] += 1\r\n final[c+3] += 1\r\n if tuple(final) not in decoded:\r\n decoded[tuple(final)] = ch\r\nn = int(input())\r\nans = \"\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "448648ed2e40e564d6d72f75dfd9e7ed", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "import sys\r\n\r\nbraille_chars = \"\"\"\r\n. . .. .. . .. .. . . . . . .. .. . .. .. . . . . . . .. .. . \r\n . . . . .. .. . .. . . . . .. .. . .. . .. . . \r\n . . . . . . . . . . .. .. . .. .. .. \r\n\"\"\".strip().splitlines()\r\n\r\ndecode_chart = {}\r\nfor idx in range(26):\r\n ch = chr(idx + ord(\"a\"))\r\n if ch in \"is\":\r\n continue\r\n shape = [braille_chars[l][(3 * idx) : (3 * idx + 2)] for l in range(3)]\r\n shape = [[x == \".\" for x in line] for line in shape]\r\n rows = [sum(line) for line in shape]\r\n cols = [sum(shape[r][c] for r in range(3)) for c in range(2)]\r\n code = tuple(rows) + tuple(cols)\r\n# if code in decode_chart:\r\n# print(ch, decode_chart[code], code)\r\n decode_chart[code] = ch\r\n# print(ch, code)\r\n\r\n\r\ndef solve_G(codes: List[List[int]]) -> str:\r\n return \"\".join(decode_chart[tuple(code)] for code in codes)\r\n\r\n\r\ninput_str = sys.stdin.read().strip()\r\ncodes = [[int(x) for x in line.split()] for line in input_str.splitlines()[1:]]\r\nprint(solve_G(codes))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78a63b97234a82c6267881c97b366e45", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "n = int(input())\r\n\r\nw = {\r\n\t'10010' : 'a',\r\n\t'11020' : 'b',\r\n\t'20011' : 'c',\r\n\t'21012' : 'd',\r\n\t'11011' : 'e',\r\n\t'21021' : 'f',\r\n\t'22022' : 'g',\r\n\t'12021' : 'h',\r\n\t'12012' : 'j',\r\n\r\n\t'10120' : 'k',\r\n\t'11130' : 'l',\r\n\t'20121' : 'm',\r\n\t'21122' : 'n',\r\n\t'11121' : 'o',\r\n\t'21131' : 'p',\r\n\t'22132' : 'q',\r\n\t'12131' : 'r',\r\n\t'12122' : 't',\r\n\r\n\t'10221' : 'u',\r\n\t'11231' : 'v',\r\n\t'12113' : 'w',\r\n\t'20222' : 'x',\r\n\t'21223' : 'y',\r\n\t'11222' : 'z'\r\n}\r\n\r\ns = ''\r\nfor i in range(n):\r\n\ts += w[input()[:-1].replace(' ', '')]\r\nprint(s)\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4fd78ecdc0ca2bed3dd7c81149b5172a", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "for s in[*open(0)][1:]:print(chr(97+['10010','11020','20011','21012','11011','21021','22022','12021','00000','12012','10120','11130','20121','21122','11121','21131','22132','12131','11111','12122','10221','11231','12113','20222','21223','11222'].index(s.replace(' ',''))),end='')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd065d1f9f4d049536a945d51b61f4af", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\n\nn,q = map(int, input().split())\n\nops = []\nfor i in range(0,q):\n a,b = input().split()\n ops.append((b,a))\nops.sort(key=lambda tup: (tup[0],tup[1]))\nops_d = defaultdict(list)\nfor k,v in ops:\n ops_d[k].append(v)\n\ncount = 0\nhit_list = []\ndef dfs(cur_str, size):\n size +=1\n #print(cur_str, \" \", size)\n if len(cur_str) == n and cur_str not in hit_list:\n hit_list.append(cur_str)\n return 1\n elif size > n:\n return -1\n else:\n for op in ops_d[cur_str[0]]:\n #print(op)\n cur_str_tmp = list(cur_str)\n cur_str_tmp[0] = op\n cur_str_tmp = \"\".join(cur_str_tmp)\n if dfs(cur_str_tmp,size) == 1:\n global count\n count +=1\n \n\ndfs('a',0)\nprint(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "670156c7d16fafae6bd45e7174a3af7a", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "run.py", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ffd5f1ac132fa04797c0b71a60542b69", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def main():\n\tn = int(input())\n\tL = [int(x) for x in input().split()]\n\tprint(solver(L))\n\ndef solver(L):\n\tS = set(L)\n\tL = list(S)\n\tL.sort()\n\tfor i in range(len(L) - 2):\n\t\tif L[i + 1] == L[i] + 1 and \\\n\t\tL[i + 2] == L[i + 1] + 1:\n\t\t\treturn \"YES\"\n\treturn \"NO\"\n\n#L = [40, 44, 44, 44, 44, 41, 43]\n#print(list(set(L)))\n#L2 = [18, 55, 16, 17]\n#L3 = [5, 972, 3, 4, 1, 4, 970, 971]\n#print(solver(L3))\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f80524a39f2f5dfa30b1a7ac1655f74", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def main():\n\t(n, q) = (int(x) for x in input().split())\n\tL = [None] * q\n\tfor i in range(q):\n\t\t(a, b) = (int(x) for x in input().split())\n\t\tL[i] = (a, b)\n\tprint(solver(n, L))\n\ndef solver(n, L):\n\tcount = 0\n\tfor (a, b) in L:\n\t\tif b == 'a':\n\t\t\tcount += helper(n - 2, L, a[0])\n\treturn count\n\ndef helper(n, L, last):\n\tif n == 0:\n\t\treturn 1\n\telse:\n\t\tcount = 0\n\t\tfor (a, b) in L:\n\t\t\tif b == last:\n\t\t\t\tcount += helper(n - 1, L, a[0])\n\t\treturn count\n\n# L = [('ab', 'a'), ('cc', 'c'), ('ca', 'a'), ('ee', 'c'),\n# ('ff', 'd')]\n# L2 = [('bb', 'a'), ('ba', 'a')]\n# print(solver(6, L2))\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "30e37e2772936bda8f73c6375d614ae3", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n, q = map(int, input().split())\n\nfr = dict()\npast = dict()\nfor i in range(q):\n a, b = input().split()\n if b in fr:\n fr[b].append(a)\n else:\n fr[b] = [a]\n\n\ndef dfs(c, cnt):\n global n\n if cnt == n:\n return 1\n if cnt > n:\n return 0\n global past\n p = ord(c) + cnt*1000\n if p in past:\n return past[cnt]\n \n global fr\n if c not in fr:\n return 0\n \n ans = 0\n for i in fr[c]:\n ans += dfs(i[0], cnt+1)\n past[p] = ans\n return ans\n\n\nprint(dfs('a', 1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e99e2b9fe172603d3869726b8d5ac3d", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "x1, x2, a, b = map(int, input().split())\nif a <= 0 <= b:\n if x1 < x2:\n if x2 - x1 <= b:\n print(\"FIRST\")\n print(x2)\n else:\n print(\"DRAW\")\n else:\n if x1 - x2 <= -a:\n print(\"FIRST\")\n print(x2)\n else:\n print(\"DRAW\")\nelse:\n reverse = False\n if a < 0:\n x1, x2, a, b = -x1, -x2, -b, -a\n reverse = True\n if x1 > x2:\n print(\"DRAW\")\n else:\n if (x2 - x1) % (a + b) == 0:\n print(\"SECOND\")\n elif a <= (x2 - x1) % (a + b) <= b:\n print(\"FIRST\")\n print((x1 + (x2 - x1) % (a + b))\n if not reverse else -(x1 + (x2 - x1) % (a + b)))\n else:\n print(\"DRAW\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d1b29bf1ba30d489e9f28a3a1773787", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "x1,x2,a,b=map(int,raw_input().split())\nif a+x1<=x2 and b+x1>=x2:print \"FIRST\";print x2\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:\n\t\tprint \"FIRST\"\n\t\tif x1 x2:\n print(\"DRAW\")\n else:\n if (x2 - x1) % (a + b) == 0:\n print(\"SECOND\")\n elif a <= (x2 - x1) % (a + b) <= b:\n print(\"FIRST\")\n print(x1 + (x2 - x1) % (a + b))\n else:\n print(\"DRAW\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d734d0ea834a1f378290a42d0b5dcd61", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "x1, x2, a, b = map(int, input().split())\nif a <= 0 <= b:\n if x1 < x2:\n if x2 - x1 <= b:\n print(\"FIRST\")\n print(x2 - x1)\n else:\n print(\"DRAW\")\n else:\n if x1 - x2 <= -a:\n print(\"FIRST\")\n print(x2 - x1)\n else:\n print(\"DRAW\")\nelse:\n if a < 0:\n x1, x2, a, b = -x1, -x2, -a, -b\n if x1 > x2:\n print(\"DRAW\")\n else:\n if (x2 - x1) % (a + b) == 0:\n print(\"SECOND\")\n elif a <= (x2 - x1) % (a + b) <= b:\n print(\"FIRST\")\n print((x2 - x1) % (a + b))\n else:\n print(\"DRAW\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce90cdc04b4f6c8ae577f64778699798", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "x1,x2,a,b=map(int,raw_input().split())\nif x1+a<=x2<=x1+b: print 'FIRST'; print x2\nelif a<=0<=b: print 'DRAW'\nelif a>0:\n if x1>x2: print 'DRAW'\n else:\n s=(x2-x1)%(a+b)\n if s==0: print 'SECOND'\n elif a<=s<=b: print 'FIRST';print x1+s\n else: print 'DRAW'\nelse:\n if x10:\n c1[n]=c2[n] = str(0)\n a[0]-=1\n b[0]-=1\n n-=1\n\nk = [i for i in range(1,6) if a[i]*b[10-i]>0]\n\nd = {}\nfor l in k:\n o = 0\n a[l]-=1\n b[10-l]-=1\n for i in range(10):\n o += min(a[i], b[9-i])\n d[o] = l\n a[l]+=1\n b[10-l]+=1\n\nif d.keys():\n t = d[max(d.keys())]\n a[t] -= 1\n b[10-t] -= 1\n c1[n]=str(t)\n c2[n]=str(10-t)\n n -= 1\n\nfor i in range(10):\n if a[i]*b[9-i]>0:\n m = 0\n while (a[i]*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(i)\n c2[n]=str(9-i)\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": false, "code_uid": "743600826e856409eb16e139d6e2b569", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "num = [0 for i in range(10)]\nline = raw_input()\nfor i in line:\n num[ord(i) - ord('0')] += 1\nans = 0\nansstrX = ansstrY = ''.join(sorted(list(line)))\nfor firstX in range(1, 10):\n firstY = (10 - firstX) % 10\n cntX = [0 for i in range(10)]\n cntY = [0 for i in range(10)] \n cntX[firstX] += 1\n cntY[firstY] += 1\n if cntX[firstX] > num[firstX] or cntY[firstY] > num[firstY]:\n continue\n tmpstrX = chr(ord('0') + firstX)\n tmpstrY = chr(ord('0') + firstY)\n tmp = 1\n for i in range(10):\n l = min(num[i] - cntX[i], num[9 - i] - cntY[9 - i])\n cntX[i] += l\n cntY[9 - i] += l\n tmp += l\n tmpstrX += chr(ord('0') + i) * l\n tmpstrY += chr(ord('0') + 9 - i) * l\n l = min(num[0] - cntX[0], num[0] - cntY[0])\n cntX[0] += l\n cntY[0] += l\n tmp += l\n tmpstrX = chr(ord('0')) * l + tmpstrX\n tmpstrY = chr(ord('0')) * l + tmpstrY\n for i in range(10):\n tmpstrX += chr(ord('0') + i) * (num[i] - cntX[i])\n tmpstrY += chr(ord('0') + i) * (num[i] - cntY[i])\n if ans < tmp:\n ans = tmp\n ansstrX = tmpstrX\n ansstrY = tmpstrY\nprint ansstrX[::-1]\nprint ansstrY[::-1]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df01186efcc01e957164a7ff1995f715", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import itertools\n\ndef countZeroes(s):\n ret = 0\n for i in s:\n if i != '0':\n break\n ret += 1\n return ret\n\ndef stupid(n):\n ansMax = 0\n bn1 = n\n bn2 = n\n for n1 in itertools.permutations(n):\n for n2 in itertools.permutations(n):\n val = str(int(''.join(n1)) + int(''.join(n2)))[::-1]\n cnt = countZeroes(val)\n if cnt > ansMax:\n ansMax = cnt\n bn1 = ''.join(n1)\n bn2 = ''.join(n2)\n return (bn1, bn2)\n\ndef solution(n):\n ansMax = n.count('0')\n bestN1 = n.replace('0', '') + ansMax * '0'\n bestN2 = n.replace('0', '') + ansMax * '0'\n\n for i in range(1, 10):\n cnt1 = [n.count(str(j)) for j in range(10)]\n cnt2 = [n.count(str(j)) for j in range(10)]\n\n if cnt1[i] == 0 or cnt2[10 - i] == 0:\n continue\n cnt1[i] -= 1\n cnt2[10 - i] -= 1\n curN1 = str(i)\n curN2 = str(10 - i)\n ansCur = 1\n for j in range(10):\n addend = min(cnt1[j], cnt2[9 - j])\n ansCur += addend\n \n cnt1[j] -= addend\n cnt2[9 - j] -= addend\n\n curN1 += str(j) * addend\n curN2 += str(9 - j) * addend\n\n if cnt1[0] > 0 and cnt2[0] > 0:\n addend = min(cnt1[0], cnt2[0])\n ansCur += addend\n\n cnt1[0] -= addend\n cnt2[0] -= addend\n\n curN1 = '0' * addend + curN1\n curN2 = '0' * addend + curN2\n\n if ansCur > ansMax:\n ansMax = ansCur\n f = lambda x: str(x[0]) * x[1]\n bestN1 = ''.join(map(f, enumerate(cnt1))) + curN1[::-1]\n bestN2 = ''.join(map(f, enumerate(cnt2))) + curN2[::-1]\n\n return (bestN1, bestN2)\n\nn = input()\nprint('\\n'.join(solution(n)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27f7b9a43f3c5fcbaca822f58f76f887", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.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\nk = [i for i in range(1,6) if a[i]*b[10-i]>0]\n\nd = {}\nfor l in k:\n o = 0\n a[l]-=1\n b[10-l]-=1\n for i in range(10):\n o += min(a[i], b[9-i])\n d[o] = l\n a[l]+=1\n b[10-l]+=1\n\nif d.keys():\n t = d[max(d.keys())]\n a[t] -= 1\n b[10-t] -= 1\n c1[n]=str(t)\n c2[n]=str(10-t)\n n -= 1\n\nfor i in range(10):\n if a[i]*b[9-i]>0:\n m = 0\n while (a[i]*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(i)\n c2[n]=str(9-i)\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": false, "code_uid": "7bde5acf8ac8e1463fd89757d9d94d11", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "num = [0] * 10\nline = list(raw_input())\nfor i in line:\n num[ord(i) - ord('0')] += 1\nans = 0\nretstr1 = retstr = ''.join(line)\nfor first_i in range(1, 10):\n first_j = (10 - first_i) % 10\n cntx = [0] * 10\n cnty = [0] * 10\n cntx[first_i] += 1\n cnty[first_j] += 1\n if cntx[first_i] > num[first_i] or cnty[first_j] > num[first_j]:\n continue\n tmpstr1 = chr(ord('0') + first_i)\n tmpstr2 = chr(ord('0') + first_j)\n tmp = 1\n for i in range(10):\n l = min(num[i] - cntx[i], num[9-i] - cntx[9-i])\n cntx[i] += l\n cnty[9-i] += l\n tmp += l\n tmpstr1 += chr(ord('0') + i) * l\n tmpstr2 += chr(ord('0') + 9 - i) * l\n l = min(num[0] - cntx[0], num[0] - cnty[0])\n cntx[0] += l\n cnty[0] += l\n tmp += l\n tmpstr1 = chr(ord('0')) * l + tmpstr1\n tmpstr2 = chr(ord('0')) * l + tmpstr2\n for i in range(10):\n tmpstr1 += chr(ord('0') + i) * (num[i] - cntx[i])\n tmpstr2 += chr(ord('0') + i) * (num[i] - cnty[i])\n if ans < tmp:\n ans = tmp\n retstr1 = tmpstr1\n retstr2 = tmpstr2\nprint retstr1[::-1]\nprint retstr2[::-1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b06bcbaefbce78e72072310072729897", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#-*- coding: utf-8 -*-\nimport sys\n\nw = sys.stdout.write\nread = sys.stdin.readline\nreads = sys.stdin.read\n\ndef r(f=None):\n if f:\n return map(f, read().split('\\n'))\n else:\n return read().split('\\n')\n\ndef rs(t,f=None):\n result = []\n result_append = result.append\n for i in xrange(t):\n if f:\n result_append(map(f, read().split()))\n else:\n result_append(read().split())\n return result\n\n\n####################################################\nimport copy\n\nn = raw_input()\ns = raw_input()\n\nn = int(n)\ns = s.split(' ')\nq = [s]\n\n\n\nwhile q:\n s = q.pop()\n elem = s.pop()\n if not s:\n w('YES')\n exit()\n if len(s) >= 1 and (s[-1][0] == elem[0] or s[-1][1] == elem[1]):\n old = s[-1]\n s[-1] = elem\n q.append(s)\n if len(s) >= 3 and (s[-3][0] == elem[0] or s[-3][1] == elem[1]):\n s[-1] = old\n s[-3] = elem\n q.append(s)\nw('NO')\n \n \n \n \n \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4862e6ebeb3e39624977bbe6664f39e6", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "def move(i, cards):\n\tc1 = cards[i]\n\tc2 = cards[len(cards) - 1]\n\n\tif c1[0] != c2[0] and c1[1] != c2[1]: return (False, \"\")\n\n\tcards[i] = cards.pop()\n\treturn (True, c1)\n\ndef unmove(i, orig, cards):\n\tcards.append(cards[i])\n\tcards[i] = orig\n\ndef poss(cards):\n\tl = len(cards)\n\tif l == 1: return True\n\t\n\t(done, orig) = move(l-2, cards)\n\tif done:\n\t\tif poss(cards):\n\t\t\treturn True\n\t\tunmove(i, orig, cards)\n\t\n\tif (l <= 3): return False\n\t(done, orig) = move(l-4, cards)\n\tif done:\n\t\tif poss(cards):\n\t\t\treturn True\n\t\tunmove(i, orig, cards)\n\treturn False\n\nn = int(raw_input())\n\ncards = raw_input().split()\n\nif (poss(cards)):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "88c4c5a6e210af20cfc5e937c52c92f6", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "n, cards, tried = input(), raw_input().split(), set()\n\ndef cards_match(card1, card2):\n\treturn card1[0] == card2[0] or card1[1] == card2[1]\n\ndef solitaire(n, cards):\n\tresult = True if n == 1 else False\n\tif not result and n >= 2 and cards_match(cards[n - 1], cards[n - 2]) and cards[:n - 2] + [cards[n - 1]] not in tried:\n\t\ttried.append(cards[:n - 2] + [cards[n - 1]])\n\t\tresult = solitaire(n - 1, tried[-1])\n\tif not result and n >= 4 and cards_match(cards[n - 1], cards[n - 4]) and cards[:n - 4] + [cards[n - 1]] + cards[n - 3:n - 1] not in tried:\n\t\ttried.append(cards[:n - 4] + [cards[n - 1]] + cards[n - 3:n - 1])\n\t\tresult = solitaire(n - 1, tried[-1])\n\treturn result\n\t\nprint \"YES\" if solitaire(n, cards) else \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c4bc44756a2a02e5e8cd54d8f717cd78", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import sys,os\nn=int(sys.stdin.readline())\np=sys.stdin.readline().split()\nfor i in range(n):\n\tp[i]=int(p[i])\nc=sys.stdin.readline().split()\na=[]\nfor i in range(len(c)):\n\tc[i]=(int(c[i]), i)\n\ta.append(0)\nc.sort()\nr=0\nfor i in range(n):\n\tr+=p[i]\n\tk=len(c)-1\n\twhile k>=0:\n\t\tif r>=c[k][0]:\n\t\t\ta[c[k][1]]+=(r/c[k][0])\n\t\t\tr-=(r/c[k][0])*c[k][0]\n\t\tk-=1\nfor i in range(len(a)):\n\tsys.stdout.write(str(a[i])+' ')\nsys.stdout.write('\\n')\nprint(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1432f0f4e1a317b70db0ab131f0dbfe1", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#! /usr/bin/python2\n\nimport sys\nimport math\n\nn = int(raw_input())\ns = \"\"\nfor i in raw_input().split():\n s = s + i\n \nans = {'':False}\ndef ok(a):\n if (len(a) == 2):\n return True\n if (a in ans):\n return ans[a]\n if (a[-1] == a[-3] or a[-2] == a[-4]):\n if (ok(a[0 : len(a) - 4] + a[-2] + a[-1])):\n ans[a] = True\n return True\n if (len(a) > 7 and (a[-1] == a[-7] or a[-2] == a[-8])):\n if (ok(a[0: len(a) - 8] + a[-2] + a[-1] + a[-4:-1])):\n ans[a] = True\n return True\n ans[a] = False\n return False\n\nif (ok(s)):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c19df04d5747ec50eda126bc5e46791", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "v = input().split()\np = input().split()\n\nv1 = int(v[0])\n\nv2 = int(v[1])\n\nT = int(p[0])\nd = int(p[1])\n\nx = abs(v1 - v2)\nt = T-2\n\nsum = v1 + v2\n\nif v1 <= v2:\n\n def check(v1, v2, d, t):\n a = []\n z = d\n for i in range(2*d):\n \n if ((v1+z)-v2) > (d*t+d):\n z -= 1\n\n else:\n a.append(z)\n\n return(int(a[0]))\n \n\n\n for i in range(t):\n\n if ((v1+d)- v2) <= (d*(t-(i+1))+d):\n sum += (v1 + d)\n\n v1 = v1+d\n else:\n sum += (v1 + check(v1, v2, d , t-(i+1)))\n\nelse:\n v1, v2 = v2, v1\n \n def check(v1, v2, d, t):\n a = []\n z = d\n for i in range(2*d):\n \n if ((v1+z)-v2) > (d*t+d):\n z -= 1\n\n else:\n a.append(z)\n\n return(int(a[0]))\n \n\n\n for i in range(t):\n\n if ((v1+d)- v2) <= (d*(t-(i+1))+d):\n sum += (v1 + d)\n\n v1 = v1+d\n else:\n sum += (v1 + check(v1, v2, d , t-(i+1))) \n\n \nprint(sum)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3906c7b821c8d9a6da5efaf1ea20a4a", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "vIndo, vVol = [0], [0]\nvIndo[0], vVol[0] = map(int, raw_input().split())\nt, d = map(int, raw_input().split())\n\nfor i in xrange(1, t):\n\tvIndo.append(d + vIndo[i-1])\n\tr.append(d + vVol[i-1])\n\t\nresultado = 0\nfor i in xrange(t):\n\tresultado += min(vIndo[i], vVol[t-i-1])\n\t\nprint resultado\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5114720e223baa38a4b84f736184fb29", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "v1, v2 = sorted(map(int, input().split()))\n\nt, d = map(int, input().split())\n\ndf = (v2 - v1 - 1) // d\nsm = t - 2\n\nx = (sm + df) >> 1\ny = (sm - df) >> 1\n\nans = d * x * (x + 1) // 2\nans += d * y * (y + 1) // 2\n\nans += x * v1 + v1\nans += y * v2 + v2\n\n# print(x, y)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "307ff0919927acc4364406319e55826c", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "v1 = int(input())\nv2 = int(input())\nt = int(input())\nd = int(input())\n\nans = 0\nfor i in range(0,t):\n\tans=ans+min(v1+d*i,v2+d*(t-i-1))\nprint ans\n\n#v1, v2 = map(int, raw_input().split())\n#t, d = map(int, raw_input().split())\n#print sum(min(v1 + d * i, v2 + d*(t-i-1)) for i in xrange(t))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6e0449c8a3b875f16e81a6f1fc0ba0a", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "s = raw_input()\na = s.split()\n#print a\nv1 = a[0]\nv2 = a[1]\ns = raw_input()\na = s.split()\nt = int(a[0])\nd = a[1]\nsum = 0\nfor i in range(t):\n sum += min(v1 + i * d, v2 + (i-t) * d)\nprint sum", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75b624a0db9262f8f3f8352c280f98ed", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import sys\nmod = 998244353\nsys.setrecursionlimit(pow(10, 8))\n\ndef power(x, y):\n if y == 0: return 1\n elif y == 1\t : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else: return power(x, (y-1)//2)**2 * x % mod\n \ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\ndef div(a, b):\n return mul(a, power(b, mod-2))\ndef div2(a, b):\n return mul(a, modinv(b))\n\ndef modinv(a):\n b, u, v = mod, 1, 0\n while b:\n t = a//b\n a, u = a-t*b, u-t*v\n a, b, u, v = b, a, v, u\n u %= mod\n return u\n\ndef cmb(n, r):\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\nNNN = 2*10**5\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\nfor i in range( 2, NNN + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nN, K = map(int, input().split())\nM=N-K\n#print(M)\nR = 0\nfor i in range(1, M+1):\n R += (-1 if (M-i)%2 else 1) * (mul(cmb(M, i), power(i, N)))\nR = mul(cmb(N, M), R)\nif K != 0:\n R = R*2%mod\nprint(R)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d86da84f2f83e374a3a0b420ab788e16", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.buffer.readline\ndef print(val):\n sys.stdout.write(str(val) + '\\n')\n\ndef choose(n,k,mod = None):\n if k > n:\n return 0\n k = min(n-k,k)\n total = 1\n for i in range(n-k+1, n+1):\n total*= i \n for i in range(2,k+1):\n total//= i\n return total % 998244353\n\"\"\"def factorial(n):\n total = 1\n for i in range(2, n+1):\n total*= i\n total %=998244353\n return total\"\"\"\ndef place_rooks(n,k):\n #if k == 0:\n #return factorial(n)\n filled = n - k\n placements_per_filled = 0\n for i in range(filled):\n mult = 1\n for _ in range(n):\n mult *= (filled-i)\n mult %= 998244353\n placements_per_filled += ((-1)**i)*choose(filled,i)*mult\n placements_per_filled %= 998244353\n total = (2*choose(n,filled)*placements_per_filled ) % 998244353\n if k == 0:\n total//= 2\n return total\n \nn, k = map(int,input().split())\nprint(place_rooks(n,k))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b4f327934dea2e4eb6db363da8d49ba", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys\n\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]\n\nclass mint:\n def __init__(self, x):\n self.__x = x % md\n\n def __repr__(self):\n return str(self.__x)\n\n def __neg__(self):\n return mint(-self.__x)\n\n def __add__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x + other)\n\n def __sub__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x - other)\n\n def __rsub__(self, other):\n return mint(other - self.__x)\n\n def __mul__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x * other)\n\n __radd__ = __add__\n __rmul__ = __mul__\n\n def __truediv__(self, other):\n if isinstance(other, mint): other = other.__x\n return mint(self.__x * pow(other, md - 2, md))\n\n def __rtruediv__(self, other):\n return mint(other * pow(self.__x, md - 2, md))\n\n def __pow__(self, power, modulo=None):\n return mint(pow(self.__x, power, md))\n\nmd = 998244353\n\ndef nCr(com_n, com_r):\n if com_n < com_r: return 0\n return fac[com_n] * ifac[com_r] * ifac[com_n - com_r]\n\nn_max = 200005\nfac = [mint(1)]\nfor i in range(1, n_max + 1): fac.append(fac[-1] * i)\nifac = [mint(1)] * (n_max + 1)\nifac[n_max] /= fac[n_max]\nfor i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1)\n\ndef main():\n n,k=MI()\n\n if k>n-1:\n print(0)\n exit()\n\n ans=0\n for i in range(n-k):\n ans+=nCr(n-k,n-k-i)*pow(n-k-i,n,md)*(-1)**(i&1)\n ans*=nCr(n,n-k)\n if k>0:ans*=2\n\n print(ans)\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ebdc1229170cda04b268c3b563fcf62", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "class Combination:\n def __init__(self, n_max, mod=10**9+7):\n # O(n_max + log(mod))\n self.mod = mod\n f = 1\n self.fac = fac = [f]\n for i in range(1, n_max+1):\n f = f * i % mod\n fac.append(f)\n f = pow(f, mod-2, mod)\n self.facinv = facinv = [f]\n for i in range(n_max, 0, -1):\n f = f * i % mod\n facinv.append(f)\n facinv.reverse()\n\n # \"n \u8981\u7d20\" \u306f\u533a\u5225\u3067\u304d\u308b n \u8981\u7d20\n # \"k \u30b0\u30eb\u30fc\u30d7\" \u306f\u3061\u3087\u3046\u3069 k \u30b0\u30eb\u30fc\u30d7\n\n def __call__(self, n, r): # self.C \u3068\u540c\u3058\n return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod\n\n def C(self, n, r):\n if not 0 <= r <= n: return 0\n return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod\n\n def P(self, n, r):\n if not 0 <= r <= n: return 0\n return self.fac[n] * self.facinv[n-r] % self.mod\n\n def H(self, n, r):\n if (n == 0 and r > 0) or r < 0: return 0\n return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod\n\n def rising_factorial(self, n, r): # \u4e0a\u6607\u968e\u4e57\u51aa n * (n+1) * ... * (n+r-1)\n return self.fac[n+r-1] * self.facinv[n-1] % self.mod\n\n def stirling_first(self, n, k): # \u7b2c 1 \u7a2e\u30b9\u30bf\u30fc\u30ea\u30f3\u30b0\u6570 lru_cache \u3092\u4f7f\u3046\u3068 O(nk) # n \u8981\u7d20\u3092 k \u500b\u306e\u5de1\u56de\u5217\u306b\u5206\u5272\u3059\u308b\u5834\u5408\u306e\u6570\n if n == k: return 1\n if k == 0: return 0\n return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod\n\n def stirling_second(self, n, k): # \u7b2c 2 \u7a2e\u30b9\u30bf\u30fc\u30ea\u30f3\u30b0\u6570 O(k + log(n)) # n \u8981\u7d20\u3092\u533a\u5225\u306e\u306a\u3044 k \u30b0\u30eb\u30fc\u30d7\u306b\u5206\u5272\u3059\u308b\u5834\u5408\u306e\u6570\n if n == k: return 1 # n==k==0 \u306e\u3068\u304d\u306e\u305f\u3081\n return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod\n\n def balls_and_boxes_3(self, n, k): # n \u8981\u7d20\u3092\u533a\u5225\u306e\u3042\u308b k \u30b0\u30eb\u30fc\u30d7\u306b\u5206\u5272\u3059\u308b\u5834\u5408\u306e\u6570 O(k + log(n))\n return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod\n\n def bernoulli(self, n): # \u30d9\u30eb\u30cc\u30fc\u30a4\u6570 lru_cache \u3092\u4f7f\u3046\u3068 O(n**2 * log(mod))\n if n == 0: return 1\n if n % 2 and n >= 3: return 0 # \u9ad8\u901f\u5316\n return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod\n\n def faulhaber(self, k, n): # \u3079\u304d\u4e57\u548c 0^k + 1^k + ... + (n-1)^k\n # bernoulli \u306b lru_cache \u3092\u4f7f\u3046\u3068 O(k**2 * log(mod)) bernoulli \u304c\u8a08\u7b97\u6e08\u307f\u306a\u3089 O(k * log(mod))\n return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod\n\n def lah(self, n, k): # n \u8981\u7d20\u3092 k \u500b\u306e\u7a7a\u3067\u306a\u3044\u9806\u5e8f\u4ed8\u304d\u96c6\u5408\u306b\u5206\u5272\u3059\u308b\u5834\u5408\u306e\u6570 O(1)\n return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod\n\n def bell(self, n, k): # n \u8981\u7d20\u3092 k \u30b0\u30eb\u30fc\u30d7\u4ee5\u4e0b\u306b\u5206\u5272\u3059\u308b\u5834\u5408\u306e\u6570 O(k**2 + k*log(mod))\n return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod\n\nN, K = map(int, input().split())\nmod = 998244353\nif K==0:\n ans = 1\n for i in range(1, N+1):\n ans = ans * i % mod\n print(ans)\n exit()\nif K >= N:\n print(0)\n exit()\n\ncomb = Combination(200002, mod=mod)\n\nprint(comb.balls_and_boxes_3(N, N-K) * comb(N, K) * 2 % mod)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "7c36e26eee199da70496c742848c684c", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "def read_int():\n return int(input())\n\n\ndef read_ints():\n return map(int, input().split(' '))\n\n\nfac = [1]\nrev = []\nmod = 998244353\n\n\ndef fexp(x, y):\n ans = 1\n while y > 0:\n if y % 2 == 1:\n ans = ans * x % mod\n x = x * x % mod\n y //= 2\n return ans\n\n\ndef comb(n, k):\n return fac[n] * rev[k] * rev[n - k] % mod\n\n\nn, k = read_ints()\nif k >= n:\n print(0)\nelse:\n for i in range(1, n + 5):\n fac.append(fac[-1] * i % mod)\n for i in range(n + 5):\n rev.append(fexp(fac[i], mod - 2))\n # \u6bcf\u884c\u6bcf\u5217\u5404\u4e00\u4e2a\u7684\uff0c\u4e00\u5171n!\u79cd\n if k == 0:\n print(fac[n])\n else:\n # \u8003\u8651\u6bcf\u884c\u4e00\u4e2a\u7684\u60c5\u5f62\uff08\u6bcf\u5217\u4e00\u4e2a\u7684\u662f\u5bf9\u79f0\u60c5\u5f62\uff09\n # \u6709k\u5bf9\u80fd\u4e92\u76f8\u653b\u51fb\uff0c\u7a7a\u5217\u4e00\u5b9a\u4e3ak\u4e2a\n # \u9996\u5148\u9009\u51fa\u7a7a\u5217\n ways = comb(n, k)\n # \u5728\u5269\u4e0bn-k\u5217\u4e2d\u5206\u914dk\u5bf9\uff0c\u5171n\u4e2a\u8f66\n # \u5bf9\u4e8e\u6bcf\u4e00\u884c\u7684\u8f66\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e9b\u5217\u4e2d\u4efb\u610f\u9009\u62e9\uff0c\u4f46\u6bcf\u5217\u81f3\u5c11\u9700\u8981\u4e00\u4e2a\n # \u7528\u5bb9\u65a5\u539f\u7406\u8ba1\u7b97\n col = 0\n for i in range(n - k):\n sign = 1 if i % 2 == 0 else -1\n col += sign * comb(n - k, i) * fexp(n - k - i, n)\n col %= mod\n if col < 0:\n col += mod\n # \u518d\u51cf\u53bb\u6709\u4e3a\u7a7a\u7684\u5217\u7684\u60c5\u51b5\n print(ways * col * 2 % mod)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "490aa8aab83fd628fdd27bdbf17ff55e", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "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 inpqueue[-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": "ddb19aa0db51b4124dc26754a011afcc", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "n = raw_input()\nm = raw_input()\nlst = [int(x) for x in m.split(' ')]\np = []\nans = 0\nfor i in range(0, len(lst)):\n p.append(lst[i])\n if i-2 >=0 and lst[i] > lst[i-1] and lst[i-2] > lst[i-1]:\n del(p[-2])\n ans += min(lst[i], lst[i-2])\np.sort()\n#print p\nfor i in range(0, len(p)-2):\n ans += p[i]\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "15c92bf148381f88f21343b7d86e5bb2", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.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 inpqueue[-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 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[i]\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": "ee649fc407822619d2fae843769ba061", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.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 inpqueue[-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": "595a07e400d18cf6454238f745f64e03", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "n = raw_input()\nm = raw_input()\nlst = [int(x) for x in m.split(' ')]\np = []\nfor i in range(1, len(lst)-1):\n p.append(min(lst[i-1], lst[i+1]))\nans = 0\nwhile len(p) > 0:\n id = p.index(max(p))\n ans += max(p)\n if id-1 >= 0 and id+2 < len(lst):\n p[id-1] = min(lst[id-1], lst[id+2])\n if id+1 < len(p) and id+3 < len(lst):\n p[id+1] = min(lst[id], lst[id+3])\n del(p[id])\n del(lst[id+1])\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d7de78367259572d858b55442810a232", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "import math\n\n\ndef field(n, x, y, t):\n t = t + 1\n upper_dist = x - 1\n left_dist = y - 1\n down_dist = n - x\n right_dist = n - y\n out_up = max(0, t - upper_dist - 1)\n out_down = max(0, t - down_dist - 1)\n out_left = max(0, t - left_dist - 1)\n out_right = max(0, t - right_dist - 1)\n #print(out_up, out_right, out_down, out_left)\n #print(base_field(t), right_field(out_right), right_field(out_left), up_field(out_up, n, y), up_field(out_down, n, y))\n field = base_field(t) - right_field(out_right) - right_field(out_left) - up_field(out_up, n, y) - up_field(out_down, n, y)\n return field\n\n\ndef right_field(out_r):\n return out_r ** 2\n\n\ndef up_field(out_up, n, y):\n rect = max(0, out_up - n + 1)\n h = out_up - rect\n wyst = max(y - 1 + h - n, 0, h - y)\n result = n * rect + h ** 2 - int((1 + wyst) / 2 * wyst)\n if result < 0:\n result = 0\n return result\n\n\ndef base_field(t):\n return 2 * (t ** 2) - 2 * t + 1\n\n\nclass CodeforcesTask256BSolution:\n def __init__(self):\n self.result = ''\n self.n_x_y_c = []\n\n def read_input(self):\n self.n_x_y_c = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n search = 0\n mid = 1\n found = False\n last_sm = 0\n while not found:\n #print(last_sm ,search)\n ff = field(self.n_x_y_c[0], self.n_x_y_c[1], self.n_x_y_c[2], search)\n if ff == self.n_x_y_c[3]:\n found = True\n elif ff > self.n_x_y_c[3]:\n if search - last_sm == 1:\n found = True\n else:\n search = last_sm + (search - last_sm) // 2\n else:\n last_sm = search\n search += mid\n mid = search - last_sm\n self.result = str(search)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask256BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6bdeea49c7d3756ca383f4e9d8601559", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#http://codeforces.ru/problemset/problem/255/D\n\ndef cells_dir(second):\n return sum(xrange(1,second*2,2))\n\ndef doubles(second, x, y, n):\n d = 0\n corners = [x+n-y+1, y+n-x+1, x+y, (n-x+1) + (n-y+1)]\n for corner in corners:\n if corner <= second:\n d += sum(xrange(1, second - corner + 2))\n return d\n\ndef cells_a(second, x, y, n):\n dcx = cells_dir(second-x+1) + cells_dir(second-n+x)\n dcy = cells_dir(second-y+1) + cells_dir(second-n+y) - doubles(second, x, y, n)\n return (sum(xrange(1,second*2,2))*2 + second*2 + 1)- dcx - dcy\n\nn, x, y, c = map(int, raw_input().split())\nsecond = 0\nwhile cells_a(second, x, y, n) < c:\n second += 1000\nhigh = second\nlow = second - 1000 if second !=0 else 0\nsecond = 0\n\n##if c == n**2\n\nwhile high - low > 1:\n second = (high + low) / 2\n cells = cells_a(second, x, y, n)\n if cells > c:\n high = second\n elif cells < c:\n low = second\n elif cells == n**2:\n high = second\n else:\n break\nelse: \n if cells_a(low, x, y, n) > c:\n second = low\n else:\n second = high\n\nprint second\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c9ac237aa32fdc884a53392ae8869ca2", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def g(v):\n\treturn 0 if v < 0 else v * v\n\ndef h(v):\n\treturn 0 if v < 0 else v * (v + 1) / 2\n\ndef f(v):\n\treturn g(v + 1) + g(v) - g(v + 1 - x) - g(v + 1 - n - 1 + x) - g(v + 1 - y) - g(v + 1 - n - 1 + y) + h(v + 1 - x - y) + h(v + 1 - n - 1 + x - y) + h(v + 1 - x - n - 1 + y) + h(v + 1 - n - 1 + x - n - 1 + y)\n\nn, x, y, c = map(int, raw_input().split())\nl = 0\nr = c\nwhile l <= r:\n\tv = (l + r) / 2\n\tif f(v) < c:\n\t\tl = v + 1\n\telse:\n\t\tr = v - 1\n\t\tp = v\nprint p", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aaaa80f10e3c1f74b87b42278c11c666", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import sys\n\ndef switchOn(switchedOn, points):\n for (x,y) in points:\n if (x,y) not in switchedOn:\n switchedOn.add((x,y))\n \ndef getNeighbors(x,y):\n neighbors = []\n if x!=n:\n neighbors.append((x+1,y))\n if y!=n:\n neighbors.append((x,y+1))\n if x!=1:\n neighbors.append((x-1,y))\n if y!=1:\n neighbors.append((x,y-1))\n return neighbors\n\ndef expand(points,i,switchedOn,c):\n switchOn(switchedOn, points)\n if len(switchedOn) >= c:\n print i\n sys.exit()\n else:\n allNeighbors = []\n for (x,y) in points: \n neighbors = getNeighbors(x,y) \n allNeighbors.extend(neighbors)\n expand(allNeighbors,i+1,switchedOn,c)\n\nif __name__ == '__main__':\n n,x,y,c = map(int,raw_input().split())\n if c == 1:\n print 0\n else:\n switchedOn = set()\n points = [(x,y)]\n expand(points,0,switchedOn,c)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd38dcc15fba8fabb49f37bb2d621c4c", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import sys\n\ndef sum(i):\n if i%2 == 0:\n return (i+1)*(i/2)\n else:\n return (i+1)*((i-1)/2)+((i+1)/2)\n\ndef switched(i,m,k):\n if i <= min(m,k):\n return sum(i)\n elif i>min(m,k) and i=max(m,k) and i < max(m,k)+min(m,k):\n tmp = i - max(m,k)+1\n return sum(min(m,k)) + (min(m,k)*(max(m,k)-min(m,k)-1)) + sum(min(m,k))-sum(min(m,k)-tmp)\n else:\n return m*k\n \nif __name__ == '__main__':\n n,x,y,c = map(int,raw_input().split())\n if c == 1:\n print 0\n else:\n i=1\n num = 1\n while num < c:\n num = switched(i,x,y-1) + switched(i,n-x,y) + switched(i,n-x+1,n-y) + switched(i,x-1,n-y+1)\n i = i + 1\n print i - 1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4bcfcead6b34c0cc7e8d69b34d667feb", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.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 if s2-s1==1:\n print(0)\n exit()\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] 0) :\n len += 1\n tmp /= 10\n\n d = int (x / pow(10, len-1))\n\n tmp = 1\n for i in range(len - 2) :\n rv += 9 * tmp\n tmp *= 10\n\n for i in range (1, 10) :\n if (i < d) :\n rv += 1 * tmp\n \n if (x / (pow(10, len-1)) <= x % 10) :\n rv += 1\n\n rv += (x % (pow(10, len - 1))) / 10\n\n return rv\n}\n\nl, r = map (int, input().split())\n\nprint(F(r) - F(l-1))\n\n# author: Ashwin Ginoria\n# email: ashwinginoria@gmail.com\n# 123456789012345678\n# 100000000000000000\n# 1000000000000000000\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a9cb9167b2f8a1cdfd500cfa439569f8", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "//============================================================================\n// Name : A.cpp\n// Author : \n// Version :\n// Copyright : Your copyright notice\n// Description : Hello World in C++, Ansi-style\n//============================================================================\n\n#include \n#include \n#include \n#include \nusing namespace std;\nlong long dp[20][12];\nint bit[20];\nlong long dfs(int pos,int pre1,int pre2,bool flag,bool z)\n{\n if(pos==-1)return pre1==pre2;\n if(pre1!=0 && !flag &&dp[pos][pre1]!=-1)\n return dp[pos][pre1];\n long long ans=0;\n int end=flag?bit[pos]:9;\n for(int i=0;i<=end;i++)\n {\n ans+=dfs(pos-1,(z)?i:pre1,i,flag && i==end,z&&(i==0));\n }\n if(!flag &&pre1!=0)dp[pos][pre1]=ans;\n return ans;\n}\nlong long calc(long long n)\n{\n int len=0;\n while(n)\n {\n bit[len++]=n%10;\n n/=10;\n }\n return dfs(len-1,0,0,1,1);\n}\nint main()\n{\n long long l,r;\n memset(dp,-1,sizeof(dp));\n while(scanf(\"%I64d%I64d\",&l,&r)==2)\n {\n printf(\"%I64d\\n\",calc(r)-calc(l-1));\n }\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c3ff0a697656ad5f00fcfb4da7fdf552", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "n=input().split()\nl=int(n[0])\nr=int(n[1])\n\ns=0\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 elif s2-s1==1:\n print(0)\n exit()\n if 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] 0:\n choices, h, m = dp[j - 1][k]\n choices += 'H'\n if len(h) < j:\n h += s[i - 1]\n else:\n tmp = [c for c in h]\n tmp[j - 1] = s[i - 1]\n h = ''.join(tmp)\n if len(m) < j:\n m += '0'\n sum = int(h) + int(m)\n if sum > curr:\n curr = sum\n dp[j][k] = (choices, h, m)\n if k > 0:\n choices, h, m = dp[j][k - 1]\n choices += 'M'\n if len(m) < k:\n m += s[i - 1]\n else:\n tmp = [c for c in m]\n tmp[k - 1] = s[i - 1]\n m = ''.join(tmp)\n if len(h) < k:\n h += '0'\n sum = int(h) + int(m)\n if sum > curr:\n curr = sum\n dp[j][k] = (choices, h, m)\nprint(dp[n][n][0])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48f7af5759b7c1e8efc87f3e31973256", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 2", "source_code": " \n \ndef solve(n_homer=0, n_medea=0):\n global number, n\n \n if (n_homer, n_medea) in mem:\n\t\treturn mem[n_homer, n_medea][0]\n \n best = [0, 0]\n pos = n_homer + n_medea\n \n if n_homer < n:\n aux = solve(n_homer + 1, n_medea)[:]\n aux[0] = int(number[pos] + str(aux[0]))\n if sum(best) < sum(aux):\n\t\t\tmem[n_homer, n_medea] = aux[:], 'H'\n\t\t\tbest = aux[:]\n \n if n_medea < n:\n aux = solve(n_homer, n_medea + 1)[:]\n aux[1] = int(number[pos] + str(aux[1]))\n if sum(best) < sum(aux):\n\t\t\tmem[n_homer, n_medea] = aux[:], 'M'\n\t\t\tbest = aux[:]\n \n return best[:]\n \n \nmem = {}\nn = input()\nnumber = raw_input()\n\n# print solve()\n\nsolution = \"\"\nn_homer, n_medea = 0, 0\n\nwhile n_homer < n or n_medea < n:\n\tif mem[n_homer, n_medea][1] == 'H':\n\t\tn_homer += 1\n\t\tsolution += 'H'\n\telse:\n\t\tn_medea += 1\n\t\tsolution += 'M'\n\t\t\nprint solution\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7de2fba7b336e6e15738dec83baaecd3", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def val(pair):\n\ts = 0\n\tif pair[0] != '':\n\t\ts += int(pair[0])\n\tif pair[1] != '':\n\t\ts += int(pair[1])\n\treturn s\n \ndef solve(n_homer=0, n_medea=0):\n global number, n\n \n if (n_homer, n_medea) in mem:\n\t\treturn mem[n_homer, n_medea][0]\n \n best = ['', '']\n best_c = 'Crap'\n pos = n_homer + n_medea\n \n if n_homer < n:\n best = solve(n_homer + 1, n_medea)[:]\n best[0] = number[pos] + str(best[0])\n best_c = 'H'\n \n if n_medea < n:\n aux = solve(n_homer, n_medea + 1)[:]\n aux[1] = number[pos] + str(aux[1])\n if val(best) < val(aux):\n\t\t\tbest = aux\n\t\t\tbest_c = 'M'\n\t\t\t\n\tmem[n_homer, n_medea] = best, best_c\n\t\n return best\n \n \nmem = {}\nn = input()\nnumber = raw_input()\n\nsolve()\n\n# for k in sorted(mem.keys()):\n# print k, mem[k]\n\n\nsolution = \"\"\nn_homer, n_medea = 0, 0\n\nwhile n_homer < n or n_medea < n:\n\t# print solution\n\tif mem[n_homer, n_medea][1] == 'H':\n\t\tn_homer += 1\n\t\tsolution += 'H'\n\telse:\n\t\tn_medea += 1\n\t\tsolution += 'M'\n\t\t\nprint solution\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "396008c8cf60185e27482455899941c2", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def val(pair):\n\ts = 0\n\tif pair[0] != '':\n\t\ts += int(pair[0])\n\tif pair[1] != '':\n\t\ts += int(pair[1])\n\treturn s\n \ndef solve(n_homer=0, n_medea=0):\n global number, n\n \n if (n_homer, n_medea) in mem:\n\t\treturn mem[n_homer, n_medea][0]\n \n best = ['', '']\n pos = n_homer + n_medea\n \n if n_homer < n:\n best = solve(n_homer + 1, n_medea)[:]\n best[0] = number[pos] + str(best[0])\n mem[n_homer, n_medea] = best, 'H'\n \n if n_medea < n:\n aux = solve(n_homer, n_medea + 1)[:]\n aux[1] = number[pos] + str(aux[1])\n if val(best) < val(aux):\n\t\t\tbest = aux\n\t\t\tmem[n_homer, n_medea] = best, 'M'\n\t\t\t\n\t\n return best\n \n \nmem = {}\nn = input()\nnumber = raw_input()\n\nsolve()\n\n# for k in sorted(mem.keys()):\n# print k, mem[k]\n\n\nsolution = \"\"\nn_homer, n_medea = 0, 0\n\nwhile n_homer < n or n_medea < n:\n\t# print solution\n\tif mem[n_homer, n_medea][1] == 'H':\n\t\tn_homer += 1\n\t\tsolution += 'H'\n\telse:\n\t\tn_medea += 1\n\t\tsolution += 'M'\n\t\t\nprint solution\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "636403b29366de159b574b1975c611a2", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ns = raw_input()\nglobal p, q, ans\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 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))*int(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))*int(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)\ng(n, n)\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "53a46cb779f8626e7b1f79f7cb7994e2", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "def mp():\n return map(int, input().split())\n\ns = input() + '+'\nr = 0\na = 0\nz = '+'\nfor i in s:\n #print(r, a, z)\n if i in '+-':\n if z == '+':\n r += a\n else:\n r -= a\n z = i\n a = 0\n a *= 10\n a += ord(i) - ord('0')\n \nprint(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e491adc4cdf5a1fbae3a26f8d9aa21f6", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "s = input()\nval = eval(s)\nfor i in range(len(s)):\n if s[i] == '+':\n j = i + 1\n c = -5\n while j < len(s) and s[j] != '+' and s[j] != '-':\n c *= 10\n j += 1\n val += c\n elif s[i] == '-':\n j = i + 1\n c = 3\n while j < len(s) and s[j] != '+' and s[j] != '-':\n c *= 10\n j += 1\n val += c\nprint(val)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1263f2dbc0b453a6dd3251a974f6205c", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "a = input()\nq, s = [0], 0\nz = []\nfor i in range(len(a)):\n y = a[i]\n if (y==\"+\"):\n z.append(1)\n q.append(0)\n s+=1\n elif (y==\"-\"):\n z.append(-1)\n q.append(0)\n s+=1\n q[s] = 10*q[s] + (ord(y)-ord(\"0\"))\notv = q[0]\nfor i in range(1, s+1):\n otv += z[i-1]*q[i]\nprint(otv)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d8c4616183a488bfe2c09af642990973", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.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 a.reverse()\n if len(a) <= len(ans):\n for i in range(len(ans) - len(a)):\n a.append(0)\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": "71ebbf33ec2b31e50e987fbbd587c0ee", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "es (14 sloc) 248 Bytes\ns = input().strip() + '+'\nans = 0\n\ncurr = 0\nsign = 1\nfor c in s:\n if c in '-+':\n ans += sign*curr\n curr = 0\n if c == '-':\n sign = -1\n elif c == '+':\n sign = 1\n curr = curr*10 + (ord(c) - ord('0'))\nprint(ans)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "f204f95a407e21739bfbe7258b00596d", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n# 604D_modular.py - Codeforces.com/problemset/problem/604/D by Sergey 2015\n\nimport unittest\nimport sys\n\n###############################################################################\n# Modular Class (Main Program)\n###############################################################################\n\n\nclass Binominals:\n \"\"\" Binominals representation \"\"\"\n\n def mod(self, a):\n return a % self.m\n\n def add(self, a, b):\n return (a + b) % self.m\n\n def mul(self, a, b):\n return (a * b) % self.m\n\n def pow(self, e, n):\n r = 1\n while n > 0:\n if n & 1:\n r = self.mul(r, e)\n e = self.mul(e, e)\n n >>= 1\n return r\n\n def inv(self, a):\n return self.pow(a, self.m-2)\n\n def __init__(self, mod=(10**9)+7, maxn=10**5):\n self.m = mod\n\n\nclass Modular:\n \"\"\" Modular representation \"\"\"\n\n def __init__(self, test_inputs=None):\n \"\"\" Default constructor \"\"\"\n\n it = iter(test_inputs.split(\"\\n\")) if test_inputs else None\n\n def uinput():\n return next(it) if it else sys.stdin.readline().rstrip()\n\n # Reading single elements\n [self.p, self.k] = map(int, uinput().split())\n\n self.M = 10**9+7\n\n def calculate(self):\n \"\"\" Main calcualtion function of the class \"\"\"\n\n result = 0\n bp = Binominals(mod=self.p)\n for m in range(1, self.p):\n if bp.pow(self.k, m) == 1:\n break\n\n bb = Binominals(mod=self.M)\n if self.k == 0:\n result = bb.pow(self.p, self.p-1)\n elif self.k == 1:\n result = bb.pow(self.p, self.p)\n else:\n result = bb.pow(self.p, (self.p-1)//m)\n\n return str(result)\n\n###############################################################################\n# Unit Tests\n###############################################################################\n\n\nclass unitTests(unittest.TestCase):\n\n def test_single_test(self):\n \"\"\" Modular class testing \"\"\"\n\n # Constructor test\n test = \"3 2\"\n d = Modular(test)\n self.assertEqual(d.k, 2)\n self.assertEqual(d.p, 3)\n\n # Sample test\n self.assertEqual(Modular(test).calculate(), \"3\")\n\n # Sample test\n test = \"5 4\"\n self.assertEqual(Modular(test).calculate(), \"25\")\n\n # Sample test\n test = \"5 0\"\n self.assertEqual(Modular(test).calculate(), \"625\")\n\n # My tests\n test = \"\"\n # self.assertEqual(Modular(test).calculate(), \"0\")\n\n # Time limit test\n # self.time_limit_test(5000)\n\n def time_limit_test(self, nmax):\n \"\"\" Timelimit testing \"\"\"\n import random\n import timeit\n\n # Random inputs\n test = str(nmax) + \" \" + str(nmax) + \"\\n\"\n numnums = [str(i) + \" \" + str(i+1) for i in range(nmax)]\n test += \"\\n\".join(numnums) + \"\\n\"\n nums = [random.randint(1, 10000) for i in range(nmax)]\n test += \" \".join(map(str, nums)) + \"\\n\"\n\n # Run the test\n start = timeit.default_timer()\n d = Modular(test)\n calc = timeit.default_timer()\n d.calculate()\n stop = timeit.default_timer()\n print(\"\\nTimelimit Test: \" +\n \"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)\".\n format(stop-start, calc-start, stop-calc))\n\nif __name__ == \"__main__\":\n\n # Avoiding recursion limitaions\n sys.setrecursionlimit(100000)\n\n if sys.argv[-1] == \"-ut\":\n unittest.main(argv=[\" \"])\n\n # Print the result string\n sys.stdout.write(Modular().calculate())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff2088ff94fc6b478fb47fa902a83441", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "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\tfree = set(range(1, p))\n\tloops = 0\n\n\twhile free:\n\t\tn = free.pop()\n\t\tl = (n*k)%p\n\t\twhile l != n:\n\t\t\tfree.remove(l)\n\t\t\tl = (l*k) % p\t\n\t\tloops += 1\n\n\n\tprint(p**loops % (10**9+7))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "92ba26c0847faefeb7f2c36e1062f235", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "(p, k) = map(int, input().split())\nused = [0] * p\nif k == 0:\n print(pow(p, p - 1) % (10 ** 9 + 7))\nelse:\n c = 1 if k == 1 else 0\n for x in range(1, p):\n if not used[x]:\n y = x\n while not used[y]:\n used[y] = True\n y = k * y % p\n c += 1\n print(pow(p, c) % (10 ** 9 + 7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f4bebadc9993765ed6904497d6e6554", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "p,k = map(int,raw_input().split())\nM = 1000000007\n\nif k == 0:\n print pow(p, p-1, M)\nelif k == 1:\n print pow(p, p, M)\nelse:\n m = 1\n for i in range(1,p+1):\n if pow(k, i, p) == 1:\n m = i\n break\n print pow(p, (p-1)/m, M)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "972347d25c58b099788093de13ea6bde", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from sys import stdin\nn,k=map(int,stdin.readline().strip().split())\npairs=(n-1)//2\nmod=10**9+7\nif k==0 of k==1:\n print(pow(n,n,mod))\n exit(0)\nprint(pow(n,pairs,mod))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e26decd82a7593f2a68a6e332d3837b3", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.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": true, "code_uid": "84788de6d45073b6767560fb5eee4fec", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,a =int(input()),map(list(int,input().split()))\nb =sorted(a) + [min(a)]\nprint(' '.join([str(b[b.index(a[ i ])+1] for i in range(n)]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "26ce797121dbdb478e38757bf9da1dea", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,a =int(input()),map(list(int,input().split()))\nb =sorted(a) + [min(a)]\nprint(''.join([str(b[b.index(a[ i ])+1] for i in range(n)]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "22d6c68cd3fd4d75517ccd9e31bb2457", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.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": true, "code_uid": "db2a53208f51884a45fe16d8f32dd0d9", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,a =int(input()),map(list(int,input().split()))b\nb =sorted(a) + [min(a)]\nprint(''.join([str(b[b.index(a[ i ])+1] for i in range(n)]))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8a809ea17f74d1ed80f7fabb00dd814b", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "# -*- coding:utf-8 -*-\n\n\"\"\"\n\ncreated by shuangquan.huang at 10/10/18\n\n\"\"\"\n\nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\nC = [\n ['#', '#', '#'],\n ['#', '', '#'],\n ['#', '#', '#'],\n]\n\nN, M = map(int, input().split())\n\nres = [['.' for _ in range(M)] for _ in range(N)]\n\nA = []\nfor i in range(N):\n A.append([x for x in input()])\n\nfor i in range(N - 2):\n for j in range(M - 2):\n if A[i][j] != '#':\n continue\n \n edge = []\n for x in range(3):\n for y in range(3):\n if not (x == 1 and y == 1):\n edge.append((i + x, j + y))\n \n if all(A[r][c] == '#' for (r, c) in edge):\n for r, c in edge:\n res[r][c] = '#'\n#\n# for row in res:\n# print(''.join(row))\n\nif res == A:\n print('YES')\nelse:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "09f6a6d67f717510802a26649153ec3f", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "a=list(map(int,input().split()))\nb=[]\nc=[]\nd=[]\nfor i in range(a[0]):b.append(list(input()))\nfor i in range(a[0]):\n for j in range(a[1]):\n if b[i][j]==\"#\":c.append(\"b[\"+str(i)+\"][\"+str(j)+\"]\")\nfor i in range(a[0]-2):\n for j in range(a[1]-2):\n if b[i][j]==\"#\" and b[i][j+1]==\"#\" and b[i][j+2]==\"#\" and b[i+1][j]==\"#\" and b[i+1][j+2]==\"#\" and b[i+2][j]==\"#\" and b[i+2][j+1]==\"#\" and b[i+2][j+2]==\"#\":\n if \"b[\"+str(i)+\"][\"+str(j)+\"]\" not in d:d.append(\"b[\"+str(i)+\"][\"+str(j)+\"]\")\n if \"b[\"+str(i)+\"][\"+str(j+1)+\"]\" not in d:d.append(\"b[\"+str(i)+\"][\"+str(j+1)+\"]\")\n if \"b[\"+str(i)+\"][\"+str(j+2)+\"]\" not in d:d.append(\"b[\"+str(i)+\"][\"+str(j+2)+\"]\")\n if \"b[\"+str(i+1)+\"][\"+str(j)+\"]\" not in d:d.append(\"b[\"+str(i+1)+\"][\"+str(j)+\"]\")\n if \"b[\"+str(i+1)+\"][\"+str(j+2)+\"]\" not in d:d.append(\"b[\"+str(i+1)+\"][\"+str(j+2)+\"]\")\n if \"b[\"+str(i+2)+\"][\"+str(j)+\"]\" not in d:d.append(\"b[\"+str(i+2)+\"][\"+str(j)+\"]\")\n if \"b[\"+str(i+2)+\"][\"+str(j+1)+\"]\" not in d:d.append(\"b[\"+str(i+2)+\"][\"+str(j+1)+\"]\")\n if \"b[\"+str(i+2)+\"][\"+str(j+2)+\"]\" not in d:d.append(\"b[\"+str(i+2)+\"][\"+str(j+2)+\"]\")\nif set(c)==set(d):print(\"YES\")\nelse:print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9ffaa9833eb1b25fa1d5d022df5e567", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=[[*input()]for _ in[0]*n]\np=(0,0),(0,1),(0,2),(1,0),(1,2),(2,0),(2,1),(2,2)\nfor i in range(n-2):\n for j in range(m-2):\n if all(a[i+k][j+l]<'.'for k,l in p):\n for k,l in p:a[i+k][j+l]='$'\nprint('YNEOS'['#'in sum(a,[])::2])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b28fa9c4cfca954eaae210b5d5f4746", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "n,m=map(int,input().split())\na=[[*input()]for _ in[0]*n]\np=0,1,2\np=[*zip((0,0,0,1,1,2,2,2),p+(0,)+p]\nfor i in range(n-2):\n for j in range(m-2):\n if all(a[i+k][j+l]<'.'for k,l in p):\n for k,l in p:a[i+k][j+l]='$'\nprint('YNEOS'[any('#'in x for x in a)::2])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4e08c853bab43cf9c9b2e0408430cff0", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,raw_input().split())\nl=[]\nfor i in xrange(n):\n\tl.append(list(raw_input()))\na=[['.' for i in xrange(m)] for j in xrange(n)]\nfor i in xrange(1,n-1):\n\tfor j in xrange(1,m-1):\n\t\tif l[i][j+1]=='#' and l[i][j-1]=='#' and l[i+1][j]=='#' and l[i-1][j]=='#' and l[i-1][j+1]=='#' and l[i+1][j-1]=='#' and l[i-1][j-1]=='#' and l[i+1][j+1]=='#':\n\t\n\ta[i][j+1]=a[i][j-1]=a[i+1][j]=a[i-1][j]=a[i-1][j+1]=a[i+1][j-1]=a[i-1][j-1]=a[i+1][j+1]='#'\nfor i in xrange(n):\n\tfor j in xrange(m):\n\t\tif l[i][j]!=a[i][j]:\n\t\t\tprint(\"NO\")\n\t\t\texit(0)\nprint(\"YES\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "42cc649b07644614599744dd79aeeb8e", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "\ndef gcd(a, b):\n while a and b:\n a %= b\n if a: b %= a\n return a + b\n \ndef gcd2(A):\n r = A[1] - A[0]\n for i in (2, 3):\n r = gcd(r, A[i] - A[0])\n return r\n \ndef Mir(x, c): return c * 2 - x\n \ndef Solve(A):\n A[0].sort()\n A[1].sort()\n gcds = [gcd2(A[0]), gcd2(A[1])]\n I0, I1 = 0, 1\n if A[0][-1] - A[0][0] > A[1][-1] - A[1][0]: I0, I1 = I1, I0\n if A[I1][-1] == A[I1][0]:\n if A[I1][0] == A[I0][0]: return []\n return None\n elif A[I0][-1] == A[I0][0]:\n return None\n if gcds[0] != gcds[1]: return None\n if (A[0][0] - A[1][0]) % gcds[0] != 0: return None\n \n ops = [[], []]\n def Op(I, J1, JC):\n ops[I].append((A[I0][J1], A[I0][JC]))\n A[I0][J1] = Mir(A[I0][J1], A[I0][JC])\n while True:\n for a in A: a.sort()\n if max(A[0][-1], A[1][-1]) - min(A[0][0], A[1][0]) <= gcds[0]: break\n #print('====now', A)\n gapL = abs(A[0][0] - A[1][0])\n gapR = abs(A[0][-1] - A[1][-1])\n if gapL > gapR:\n I0, I1 = (0, 1) if A[0][0] < A[1][0] else (1, 0)\n view = lambda x: x\n else:\n I0, I1 = (0, 1) if A[0][-1] > A[1][-1] else (1, 0)\n view = lambda x: 3 - x\n for a in A: a.sort(key=view)\n lim = max(view(A[I0][-1]), view(A[I1][-1]))\n B = [view(x) for x in A[I0]]\n \n actioned = False\n for J in (3, 2):\n if Mir(B[0], B[J]) <= lim:\n Op(I0, (0), (J))\n actioned = True\n break\n if actioned: continue\n \n if Mir(B[0], B[1]) > lim:\n Op(I0, (3), (1))\n continue\n if (B[1] - B[0]) * 8 >= lim - B[0]:\n Op(I0, (0), (1))\n continue\n if (B[3] - B[2]) * 8 >= lim - B[0]:\n Op(I0, (0), (2))\n Op(I0, (0), (3))\n continue\n if B[1] - B[0] < B[3] - B[2]:\n Op(I0, (1), (2))\n Op(I0, (1), (3))\n else:\n Op(I0, (2), (1))\n Op(I0, (2), (0))\n Op(I0, (0), (1))\n if A[0] != A[1]: return None\n return ops[0] + [(Mir(x, c), c) for x, c in reversed(ops[1])]\n \ndef Output(ops):\n if ops is None:\n print(-1)\n return\n print(len(ops))\n for x, c in ops: print(x, c)\n \nimport sys\nA = [list(map(int, sys.stdin.readline().split())) for _ in range(2)]\nOutput(Solve(A))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5549290f378e29981bd6481614368f5", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "Python 3", "source_code": "def gcd(a, b):\n while a and b:\n a %= b\n if a: b %= a\n return a + b\n \ndef gcd2(A):\n r = A[1] - A[0]\n for i in (2, 3):\n r = gcd(r, A[i] - A[0])\n return r\n \ndef Mir(x, c): return c * 2 - x\n \ndef Solve(A):\n A[0].sort()\n A[1].sort()\n gcds = [gcd2(A[0]), gcd2(A[1])]\n I0, I1 = 0, 1\n if A[0][-1] - A[0][0] > A[1][-1] - A[1][0]: I0, I1 = I1, I0\n if A[I1][-1] == A[I1][0]:\n if A[I1][0] == A[I0][0]: return []\n return None\n elif A[I0][-1] == A[I0][0]:\n return None\n if gcds[0] != gcds[1]: return None\n if (A[0][0] - A[1][0]) % gcds[0] != 0: return None\n \n ops = [[], []]\n def Op(I, J1, JC):\n ops[I].append((A[I0][J1], A[I0][JC]))\n A[I0][J1] = Mir(A[I0][J1], A[I0][JC])\n while True:\n for a in A: a.sort()\n if max(A[0][-1], A[1][-1]) - min(A[0][0], A[1][0]) <= gcds[0]: break\n #print('====now', A)\n gapL = abs(A[0][0] - A[1][0])\n gapR = abs(A[0][-1] - A[1][-1])\n if gapL > gapR:\n I0, I1 = (0, 1) if A[0][0] < A[1][0] else (1, 0)\n view = lambda x: x\n else:\n I0, I1 = (0, 1) if A[0][-1] > A[1][-1] else (1, 0)\n view = lambda x: 3 - x\n for a in A: a.sort(key=view)\n lim = max(view(A[I0][-1]), view(A[I1][-1]))\n B = [view(x) for x in A[I0]]\n \n actioned = False\n for J in (3, 2):\n if Mir(B[0], B[J]) <= lim:\n Op(I0, (0), (J))\n actioned = True\n break\n if actioned: continue\n \n if Mir(B[0], B[1]) > lim:\n Op(I0, (3), (1))\n continue\n if (B[1] - B[0]) * 8 >= lim - B[0]:\n Op(I0, (0), (1))\n continue\n if (B[3] - B[2]) * 8 >= lim - B[0]:\n Op(I0, (0), (2))\n Op(I0, (0), (3))\n continue\n if B[1] - B[0] < B[3] - B[2]:\n Op(I0, (1), (2))\n Op(I0, (1), (3))\n else:\n Op(I0, (2), (1))\n Op(I0, (2), (0))\n Op(I0, (0), (1))\n if A[0] != A[1]: return None\n return ops[0] + [(Mir(x, c), c) for x, c in reversed(ops[1])]\n \ndef Output(ops):\n if ops is None:\n print(-1)\n return\n print(len(ops))\n for x, c in ops: print(x, c)\n \nimport sys\nA = [list(map(int, sys.stdin.readline().split())) for _ in range(2)]\nOutput(Solve(A))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de9fdfad15cd48aee11d0a116caa533d", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "Python 3", "source_code": "def gcd(a, b):\n while a and b:\n a %= b\n if a: b %= a\n return a + b\n\ndef gcd2(A):\n r = A[1] - A[0]\n for i in (2, 3):\n r = gcd(r, A[i] - A[0])\n return r\n\ndef Mir(x, c): return c * 2 - x\n\ndef Solve(A):\n A[0].sort()\n A[1].sort()\n gcds = [gcd2(A[0]), gcd2(A[1])]\n I0, I1 = 0, 1\n if A[0][-1] - A[0][0] > A[1][-1] - A[1][0]: I0, I1 = I1, I0\n if A[I1][-1] == A[I1][0]:\n if A[I1][0] == A[I0][0]: return []\n return None\n elif A[I0][-1] == A[I0][0]:\n return None\n if gcds[0] != gcds[1]: return None\n if (A[0][0] - A[1][0]) % gcds[0] != 0: return None\n\n ops = [[], []]\n def Op(I, J1, JC):\n ops[I].append((A[I0][J1], A[I0][JC]))\n A[I0][J1] = Mir(A[I0][J1], A[I0][JC])\n while True:\n for a in A: a.sort()\n if max(A[0][-1], A[1][-1]) - min(A[0][0], A[1][0]) <= gcds[0]: break\n #print('====now', A)\n gapL = abs(A[0][0] - A[1][0])\n gapR = abs(A[0][-1] - A[1][-1])\n if gapL > gapR:\n I0, I1 = (0, 1) if A[0][0] < A[1][0] else (1, 0)\n view = lambda x: x\n else:\n I0, I1 = (0, 1) if A[0][-1] > A[1][-1] else (1, 0)\n view = lambda x: 3 - x\n for a in A: a.sort(key=view)\n lim = max(view(A[I0][-1]), view(A[I1][-1]))\n B = [view(x) for x in A[I0]]\n\n actioned = False\n for J in (3, 2):\n if Mir(B[0], B[J]) <= lim:\n Op(I0, (0), (J))\n actioned = True\n break\n if actioned: continue\n\n if Mir(B[0], B[1]) > lim:\n Op(I0, (3), (1))\n continue\n if (B[1] - B[0]) * 8 >= lim - B[0]:\n Op(I0, (0), (1))\n continue\n if (B[3] - B[2]) * 8 >= lim - B[0]:\n Op(I0, (0), (2))\n Op(I0, (0), (3))\n continue\n if B[1] - B[0] < B[3] - B[2]:\n Op(I0, (1), (2))\n Op(I0, (1), (3))\n else:\n Op(I0, (2), (1))\n Op(I0, (2), (0))\n Op(I0, (0), (1))\n if A[0] != A[1]: return None\n return ops[0] + [(Mir(x, c), c) for x, c in reversed(ops[1])]\n\ndef Output(ops):\n if ops is None:\n print(-1)\n return\n print(len(ops))\n for x, c in ops: print(x, c)\n\nimport sys\nA = [list(map(int, sys.stdin.readline().split())) for _ in range(2)]\nOutput(Solve(A))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57f691640227d81b1647348f8001d2e7", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "Python 3", "source_code": "def Mir(x, c): return c * 2 - x\n\ndef Solve(A):\n A[0].sort()\n A[1].sort()\n I0, I1 = 0, 1\n if A[0][-1] - A[0][0] > A[1][-1] - A[1][0]: I0, I1 = I1, I0\n if A[I1][-1] == A[I1][0]:\n if A[I1][0] == A[I0][0]: return []\n return None\n elif A[I0][-1] == A[I0][0]:\n return None\n\n ops = [[], []]\n def Op(I, J1, JC):\n ops[I].append((A[I0][J1], A[I0][JC]))\n A[I0][J1] = Mir(A[I0][J1], A[I0][JC])\n while True:\n for a in A: a.sort()\n if max(A[0][-1], A[1][-1]) - min(A[0][0], A[1][0]) <= 1: break\n gapL = abs(A[0][0] - A[1][0])\n gapR = abs(A[0][-1] - A[1][-1])\n if gapL > gapR:\n I0, I1 = (0, 1) if A[0][0] < A[1][0] else (1, 0)\n view = lambda x: x\n else:\n I0, I1 = (0, 1) if A[0][-1] > A[1][-1] else (1, 0)\n view = lambda x: 3 - x\n for a in A: a.sort(key=view)\n lim = max(view(A[I0][-1]), view(A[I1][-1]))\n B = [view(x) for x in A[I0]]\n\n actioned = False\n for J in (3, 2):\n if Mir(B[0], B[J]) <= lim:\n Op(I0, (0), (J))\n actioned = True\n break\n if actioned: continue\n\n if Mir(B[0], B[1]) > lim:\n Op(I0, (3), (1))\n continue\n if (B[1] - B[0]) * 8 >= lim - B[0]:\n Op(I0, (0), (1))\n continue\n if (B[3] - B[2]) * 8 >= lim - B[0]:\n Op(I0, (0), (2))\n Op(I0, (0), (3))\n continue\n if B[1] - B[0] < B[3] - B[2]:\n Op(I0, (1), (2))\n Op(I0, (1), (3))\n else:\n Op(I0, (2), (1))\n Op(I0, (2), (0))\n Op(I0, (0), (1))\n if A[0] != A[1]: return None\n return ops[0] + [(Mir(x, c), c) for x, c in reversed(ops[1])]\n\ndef Output(ops):\n if ops is None:\n print(-1)\n return\n print(len(ops))\n for x, c in ops: print(x, c)\n\nimport sys\nA = [list(map(int, sys.stdin.readline().split())) for _ in range(2)]\nOutput(Solve(A))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63b43bade014114d46a5c01eeb2508f8", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "Python 3", "source_code": "from math import sin\ndef mp(): return map(int,input().split())\ndef lt(): return list(map(int,input().split()))\ndef pt(x): print(x)\ndef ip(): return input()\ndef it(): return int(input())\ndef sl(x): return [t for t in x]\ndef spl(x): return x.split()\ndef aj(liste, item): liste.append(item)\ndef bin(x): return \"{0:b}\".format(x)\ndef listring(l): return ' '.join([str(x) for x in l])\ndef ptlist(l): print(' '.join([str(x) for x in l]))\n\nn = it()\nstep = lt()\ndict = {}\ndef explosion(start,s,d):\n (i,j) = start\n t = s+1\n if d == 0:\n for k in range(j+1,j+t):\n dict[(i,k)] = True\n return ((i,j+t-1),(d+7)%8),((i,j+t-1),(d+1)%8)\n if d == 1:\n for k in range(1,t):\n dict[(i+k,j+k)] = True\n return ((i+t-1,j+t-1),(d+7)%8),((i+t-1,j+t-1),(d+1)%8)\n if d == 2:\n for k in range(1,t):\n dict[(i+k,j)] = True\n return ((i+t-1,j),(d+7)%8),((i+t-1,j),(d+1)%8)\n if d == 3:\n for k in range(1,t):\n dict[(i+k,j-k)] = True\n return ((i+t-1,j-t+1),(d+7)%8),((i+t-1,j-t+1),(d+1)%8)\n if d == 4:\n for k in range(1,t):\n dict[(i,j-k)] = True\n return ((i,j-t+1),(d+7)%8),((i,j-t+1),(d+1)%8)\n if d == 5:\n for k in range(1,t):\n dict[(i-k,j-k)] = True\n return ((i-t+1,j-t+1),(d+7)%8),((i-t+1,j-t+1),(d+1)%8)\n if d == 6:\n for k in range(1,t):\n dict[(i-k,j)] = True\n return ((i-t+1,j),(d+7)%8),((i-t+1,j),(d+1)%8)\n if d == 7:\n for k in range(1,t):\n dict[(i-k,j+k)] = True\n return ((i-t+1,j+t-1),(d+7)%8),((i-t+1,j+t-1),(d+1)%8)\n \nstart = [((0,0),0)]\nfor i in range(n):\n l = []\n for p,q in start:\n a,b = explosion(p,step[i],q)\n l.append(a)\n l.append(b)\n start = list(l)\npt(len(dict))\n \n \n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7c9daf68ccb20ff0aa05030e59397abd", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "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()]\n\ndef dfs(d, pos, path):\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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c5cd77ff134c175ee3a6ee4def82d26f", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "\n# N\n# W E\n# S\n\ndef go(x,y,cur_fac,t_idx,cells,tlist):\n if t_idx >= len(tlist):\n return None\n\n cells[x][y] = 1\n \n if cur_fac == \"N\": \n steps = tlist[t_idx]\n for i in range(steps-1):\n y+=1\n cells[x][y] = 1\n go(x-1,y+1,\"NW\",t_idx+1,cells,tlist)\n go(x+1,y+1,\"NE\",t_idx+1,cells,tlist)\n\n if cur_fac == \"NW\": \n steps = tlist[t_idx]\n for i in range(steps-1):\n x-=1\n y+=1\n cells[x][y] = 1\n go(x-1,y,\"W\",t_idx+1,cells,tlist)\n go(x,y+1,\"N\",t_idx+1,cells,tlist)\n\n if cur_fac == \"W\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n x-=1\n cells[x][y] = 1\n go(x-1,y+1,\"NW\",t_idx+1,cells,tlist)\n go(x-1,y-1,\"SW\",t_idx+1,cells,tlist)\n\n if cur_fac == \"SW\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n x-=1\n y-=1\n cells[x][y] = 1\n go(x-1,y,\"W\",t_idx+1,cells,tlist)\n go(x,y-1,\"S\",t_idx+1,cells,tlist)\n\n if cur_fac == \"S\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n y-=1\n cells[x][y] = 1\n go(x-1,y-1,\"SW\",t_idx+1,cells,tlist)\n go(x+1,y-1,\"SE\",t_idx+1,cells,tlist)\n\n if cur_fac == \"SE\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n x+=1\n y-=1\n cells[x][y] = 1\n go(x,y-1,\"S\",t_idx+1,cells,tlist)\n go(x+1,y,\"E\",t_idx+1,cells,tlist)\n\n if cur_fac == \"E\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n x+=1\n cells[x][y] = 1\n go(x+1,y+1,\"NE\",t_idx+1,cells,tlist)\n go(x+1,y-1,\"SE\",t_idx+1,cells,tlist)\n\n if cur_fac == \"NE\":\n steps = tlist[t_idx]\n for i in range(steps-1):\n x+=1\n y+=1\n cells[x][y] = 1\n go(x,y+1,\"N\",t_idx+1,cells,tlist)\n go(x+1,y,\"E\",t_idx+1,cells,tlist)\n\nd = input()\ntlist = map(int,raw_input().strip().split())\ndim = 2*sum(tlist)+2\ncells = [[0 for i in range(dim)] for i in range(dim)]\ngo(dim/2, dim/2, \"N\", 0, cells, tlist)\ns = 0\nfor row in cells[::-1]:\n #print \" \".join([str(i) for i in row])\n s += sum(row)\nprint s\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cd6a2b8fc104d9b8effc60b74bc309dc", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from enum import Enum\nfrom queue import Queue\nfrom collections import deque\n\nclass Dir(Enum):\n N = 1\n E = 2\n S = 3\n W = 4\n NE = 5\n SE = 6\n SW = 7\n NW = 8\n\n\nif __name__ == \"__main__\":\n\n dirdict = {\n Dir.N : (Dir.NE, Dir.NW),\n Dir.S : (Dir.SE, Dir.SW),\n Dir.W : (Dir.SW, Dir.NW),\n Dir.E: (Dir.NE, Dir.SE),\n Dir.NE : (Dir.N, Dir.E),\n Dir.SE : (Dir.E, Dir.S),\n Dir.SW : (Dir.S, Dir.W),\n Dir.NW: (Dir.N, Dir.W)}\n\n\n\n n=int(input().strip())\n lst = list(map(int, input().strip().split()))\n\n result=[[False for _ in range(400)] for _ in range(400)]\n q=deque()\n a=((200,200), Dir.N,0)\n q.append(a)\n \n while len(q) > 0:\n position,direction,stage=q.pop()\n if stage == len(lst):\n continue\n else:\n (x,y) = position\n if direction == Dir.N:\n for j in range(1,lst[stage]+1):\n result[x][y+j] = True\n q.append(((x, y+j), Dir.NE, stage+1))\n q.append(((x, y+j), Dir.NW, stage+1))\n elif direction == Dir.S:\n for j in range(1,lst[stage]+1):\n result[x][y-j] =True\n q.append(((x, y-j), Dir.SE, stage+1))\n q.append(((x, y-j), Dir.SW, stage+1))\n elif direction == Dir.E:\n for j in range(1,lst[stage]+1):\n result[x+j][y] = True\n q.append(((x+j, y), Dir.NE, stage+1))\n q.append(((x+j, y), Dir.SE, stage+1))\n elif direction == Dir.W:\n for j in range(1,lst[stage]+1):\n result[x-j][ y] = True\n q.append(((x-j, y), Dir.NW, stage+1))\n q.append(((x-j, y), Dir.SW, stage+1))\n elif direction == Dir.NE:\n for j in range(1,lst[stage]+1):\n result[x+j][y+j] = True\n q.append(((x+j, y+j), Dir.N, stage+1))\n q.append(((x+j, y+j), Dir.E, stage+1))\n elif direction == Dir.NW:\n for j in range(1,lst[stage]+1):\n result[x-j][y+j] = True\n q.append(((x-j, y+j), Dir.N, stage+1))\n q.append(((x-j, y+j), Dir.W, stage+1))\n elif direction == Dir.SE:\n for j in range(1,lst[stage]+1):\n result[x+j][y-j] = True\n q.append(((x+j, y-j), Dir.E, stage+1))\n q.append(((x+j, y-j), Dir.S, stage+1))\n elif direction == Dir.SW:\n for j in range(1,lst[stage]+1):\n result[x-j][y-j] = True\n q.append(((x-j, y-j), Dir.S, stage+1))\n q.append(((x-j, y-j), Dir.W, stage+1))\n\n print(sum(map (sum, result)))\n #print(sorted(list(result)))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d257d22aa60fb367e9070cfc080e392", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "from enum import Enum\nfrom queue import Queue\nfrom collections import deque\n\ndx = [0,-1,-1,-1, 0, 1, 1,1]\ndy = [1, 1, 0,-1,-1,-1, 0,1]\n\nvisited =[[[[False for _ in range(32)] for _ in range(8)] for _ in range(320)] for _ in range(320)]\n\ngrid = [[False for _ in range(320)] for _ in range(320)]\n\ndef dfs(x,y,d,n,N, inp):\n if (n >= N or visited[x][y][d][n]):\n return\n\n visited[x][y][d][n] = True\n\n dist = inp[n]\n\n for i in range(1,dist+1):\n grid[x+dx[d]*i][y+i*dy[d]] = True\n\n if (n < N):\n dfs(x + dx[d]*dist, y+dy[d]*dist, (d+1)%8, n+1,N,inp)\n dfs(x + dx[d]*dist, y+dy[d]*dist, (d+7)%8, n+1,N,inp)\n\n\nif __name__ == \"__main__\":\n N = int(input())\n inp = list(map(int, input().strip().split()))\n dfs(160,160,0,0,N,inp)\n result = sum(map(sum,grid))\n print(result)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "58d5743ffa70faca8ad44681249547cf", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "# http://codeforces.com/contest/623/problem/A\n\nimport math\n\nnm = raw_input()\nnm = nm.split(' ')\nn = int(nm[0])\nm = int(nm[1])\n\nedges = [[False for i in range(n)] for x in range(n)] # False: no such edge\nnodes = [[True for i in range(3)] for x in range(n)] # True: possible\n\n# read edges\nfor i in range(m):\n ab = raw_input()\n ab = ab.split(' ')\n a = int(ab[0]) - 1\n b = int(ab[1]) - 1\n edges[a][b] = True\n #print 'add edge:',a,b\n\ndef hasEdge(a,b):\n if edges[a][b] or edges[b][a]:\n return True\n else:\n return False\n\n# True if has deduction\ndef deduce(n1,n2):\n # if has edge, same\n if hasEdge(n1,n2) and certain(n1):\n val_1 = get(n1)\n # n1 is 'a', n2 isn't 'c'\n if val_1 == 0:\n nodes[n2][2] = False\n #print 'node',n2,'is a'\n return True\n # n1 is 'c', n2 isn't 'a'\n if val_1 == 2:\n nodes[n2][0] = False\n #print 'node',n2,'is a'\n return True\n # if no edge, different\n elif not hasEdge(n1,n2) and certain(n1):\n val_1 = get(n1)\n if val_1 == 0:\n nodes[n2][0] = False\n #print 'node',n2,'is c'\n return True\n if val_1 == 2:\n nodes[n2][2] = False\n #print 'node',n2,'is a'\n return True\n return False\n \ndef deductions():\n for i in range(n):\n for j in range(n):\n if i != j:\n deduce(i,j)\n \n# only has one possibility\ndef certain(k):\n if (nodes[k][0] + nodes[k][1] + nodes[k][2]) == 1:\n return True\n return False\n \ndef freeNode(k):\n if (nodes[k][0] + nodes[k][1] + nodes[k][2]) == 3:\n return True\n return False\n \ndef isDeadNode(k):\n if (nodes[k][0] + nodes[k][1] + nodes[k][2]) == 0:\n return True\n return False\n\n# get the node first possible node, not certain\ndef get(k):\n if nodes[k][0]:\n return 0\n if nodes[k][1]:\n return 1\n if nodes[k][2]:\n return 2\n\ndef incompleteSolution():\n for k in range(n):\n if not certain(k):\n return k\n return False\n\ndef genSolution():\n tmp = incompleteSolution()\n # loop if node id returned\n while isinstance(tmp, int):\n deductions()\n tmp = incompleteSolution()\n \ndef printSolution():\n ss = []\n for i in range(n):\n theChar = get(i)\n if theChar == 0:\n theChar = 'a'\n elif theChar == 1:\n theChar = 'b'\n else:\n theChar = 'c'\n ss.append(theChar)\n print ''.join(ss)\n\n# main\n# no edge, no b\ncomplete = True\nfirstMissingEdge = []\nfor i in range(n):\n for j in range(n):\n if (i != j) and not hasEdge(i,j):\n #print 'no edge: ',i,j\n if complete:\n complete = False\n firstMissingEdge.append(i)\n firstMissingEdge.append(j)\n #print 'missing edge',i,j\n # must not b\n nodes[i][1] = False\n nodes[j][1] = False\n\n# if free node => is b\nfor i in range(n):\n if freeNode(i):\n nodes[i][0] = False\n nodes[i][2] = False\n #print 'node',i,'is \\'b\\''\n \n# complete graph\nif complete:\n ss = []\n for i in range(n):\n ss.append('b')\n print Yes\n print ''.join(ss)\n\nelse:\n # 1. guess one node to be 'a'\n a = firstMissingEdge[0]\n b = firstMissingEdge[1]\n nodes[a][2] = False # node[a] be 'a'\n nodes[b][0] = False # node[b] be 'c'\n #print 'let node',a,'be a, node',b,'be c'\n # loop check, deduction...\n updated = True\n hasDeadNode = False\n while updated:\n updated = False\n for i in range(n):\n for j in range(n):\n if i != j:\n if deduce(i,j):\n updated = True\n if isDeadNode(j):\n hasDeadNode = True\n break\n if hasDeadNode:\n break\n if hasDeadNode:\n break\n\n if hasDeadNode:\n print 'No'\n else:\n print 'Yes'\n \n \n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "74c8a99fac73df4cd849f7bc67f7b112", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n, m = [int(x) for x in input().split()]\nE = {v: {v} for v in range(1, n+1)}\nfor e in range(m):\n u, v = [int(x) for x in input().split()]\n E[u].add(v)\n E[v].add(u)\nif n > 400: print('ok')\nA = []\nletter = [None for i in range(n)]\ns = ''\nk = iter('ac')\nfor v in E:\n for i, p in enumerate(A):\n if E[v] == p:\n letter[v-1] = s[i]\n break\n else:\n if len(A) < 3:\n A.append(E[v])\n s = s + 'b' if len(E[v]) == n else s + next(k)\n letter[v-1] = s[-1]\n else:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n print(''.join(letter))\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6581c52a0a99cebf82e7cf68436500e3", "src_uid": "e71640f715f353e49745eac5f72e682a", "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)]\nb = sum(p)\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)\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 (a & c != 0) == (b in t): t[a], t[c] = 'ac'\nprint('Yes\\n' + ''.join(map(t.get, p)) if t else 'No')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bcd5c259dd279c9c705a66fe59aba8d0", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "import io\nimport sys\nimport math\n\n\ndef rlist(t):\n return map(t, raw_input().split())\n\n\ndef read_int_list():\n return rlist(int)\n\n\ndef write_list(lst, divider=\" \"):\n print divider.join(map(str, lst))\n\n\nclass Graph(object):\n def __init__(self, vertices, edges):\n self.neighbours = [set() for _ in xrange(vertices)]\n self.size = vertices\n self.density = edges\n for _ in xrange(edges):\n v, u = read_int_list()\n self.neighbours[v-1].add(u-1)\n self.neighbours[u-1].add(v-1)\n\n def connected(self, vertex1, vertex2):\n return vertex2 in self.neighbours[vertex1]\n\n # True if vertex_set forms a full subgraph\n def check_full(self, vertex_set):\n for vertex1, vertex2 in vertex_set:\n if not self.connected(vertex1, vertex2):\n return False\n return True\n\n # True if no edges between 2 sets\n def check_no_edges(self, set1, set2):\n for vertex1 in set1:\n for vertex2 in set2:\n if self.connected(vertex1, vertex2):\n return False\n return True\n\n def vertices_of_degree(self, degree):\n first_bad = -1\n ans = set()\n for i, vertex in enumerate(self.neighbours):\n if len(vertex) == degree:\n ans.add(i)\n else:\n first_bad = i\n return first_bad, ans\n\nn, m = read_int_list()\ngraph = Graph(n, m)\na_vertex, b_vertices = graph.vertices_of_degree(n-1)\nif a_vertex == -1:\n print \"Yes\"\n print \"b\"*n\nelse:\n ab_vertices = graph.neighbours[a_vertex]\n ab_vertices.add(a_vertex)\n c_vertices = set(xrange(n))-ab_vertices\n a_vertices = ab_vertices - b_vertices\n if graph.check_full(a_vertices) and graph.check_full(c_vertices)\\\n and graph.check_no_edges(a_vertices, c_vertices):\n print \"Yes\"\n ans = \"\"\n for i in xrange(n):\n if i in b_vertices:\n ans += 'b'\n elif i in a_vertices:\n ans += 'a'\n else:\n ans += 'c'\n print ans\n else:\n print \"No\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee0164edc3af0896ac5e34ce882fa72e", "src_uid": "e71640f715f353e49745eac5f72e682a", "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 = {b: 'b'}\ns.discard(b)\nif len(s) == 2:\n a, c = s\n if a + c == b: t[a], t[c] = 'ac'\n s = {}\nprint('No' if s else 'Yes\\n' + ''.join(map(t.get, p)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fc79be26f1443d99c045e7950ec641a7", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": " n = map(int, raw_input().split())\n arr = sorted(map(int, raw_input().split()))\n if arr[0] != arr[n/2]:\n print (\"Alice\") \n else:\n print(\"Bob\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9ee141a42e780c1fb5d4d04bf0061ce7", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\n\nn, m = map(int, stdin.readline().split())\n\ng = set()\nfor i in range(m):\n a, b = map(int , stdin.readline().split())\n a -= 1\n b -= 1\n g.add((min(a, b), max(a, b)))\n\ndef check(k):\n for i in g:\n a = (i[0] + k) % n\n b = (i[1] + k) % n\n if not (min(a, b), max(a, b)) in g:\n return False\n return True\n\nfor k in range(1, n):\n if n % k == 0:\n if not check(k):\n continue\n stdout.write('Yes')\n exit(0)\n\nstdout.write('No')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eab649952756c1e97d259cd923caa0cc", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nm = min(a)\nif sum(x == m for x in a) > n / 2:\n print 'Bob'\nelif c:\n print 'Alice'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d124ecc231a346fa32a4fd8aee943a85", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "x=int(input)\na=input().split()\ns=[int(num)for num in a]\nq=0\nfor i in s:\n q+=i\nif q%2==0:\n print('Bob')\nelse:\n print('Alice')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f8ac8ded4a994e87f01505e28b146d7", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "i=input\ni()\ns=map(int,i().split())\nprint(\"Bob\"if s.count(min(s))>len(s)/2 else\"Alice\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56ee51f4c0ee130f1ccc4b20d379373b", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n=input()\nm=int(input())\n\ndef pow(a, b, m):\n res=1\n while b:\n if (b%2==1):\n res=(res*a)%m\n a=(a*a)%m\n b/=2\n return res\n\nres=0\npw=1\nfor i in range(len(n)-1, -1, -1):\n res=(res+pw*int(n[i]))%m\n pw=(pw*10)%m\n\npartial=res\n\nfor x in n:\n if (int(x)!=0):\n res=min(res, partial)\n partial=(partial-int(x)*pow(10, len(n)-1, m))%m\n partial=(partial*10+int(x))%m\n if (partial<0):\n partial+=m\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c2ef66512eed46bcc853c2b50c8728a3", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "n=input()\nm=int(input())\n\ndef pow(a, b, m):\n res=1\n while b:\n if (b%2==1):\n res=(res*a)%m\n a=(a*a)%m\n b/=2\n return res\n\nres=0\nfor x in n:\n res=(res+int(x))%m\npartial=res\n\nfor x in n:\n partial=(partial-int(x)*pow(10, len(n)-1, m))%m\n partial=(partial*10+int(x))%m\n res=min(res, partial)\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7ebc427160f6020f123be2011525b49b", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "N = input()\nM = int( input() )\ncur = int( N ) % M\nans = cur\nfor i in range( len( N ) ):\n cur -= ( ord( N[ i ] ) - ord( '0' ) ) * pow( 10, len( N ) - 1, M ) % M\n cur = cur * 10 % M\n cur += ( ord( N[ i ] ) - ord( '0' ) ) % M\n if N[ ( i + 1 ) % len( N ) ] != '0':\n ans = min( ans, cur )\nprint( ans )\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49e4ea46047d55eb8d4708e66886dd1c", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n=raw_input()\nm=int(raw_input())\n\nl=len(n)\na=[int(i) for i in n]\nn=long(n)\n\nans=0\n\nmod=n%m\nans = mod\n\nbase=10**(l-1)\nbase %= m\n\n#print base\n#print mod\n\n#for i in range(l-1, -1, -1):\nfor i in range(l):\n mod = ((mod - a[i] * base % m) % m) + m\n mod %= m\n mod = (mod *10 + a[i]) % m\n\n if a[i] != 0:\n ans = min(ans, mod)\n #print mod\n\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bbd9b537337c497b33f3776931e8997f", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "s = input()\nm = int(input())\nn = len(s)\ns = s + s\npot = []\npot.append(1)\nfor i in range(1, 200000):\n\tpot.append((pot[i - 1] * 10) % m)\ncur = 0\nmn = 1000000000\nfor i in range(0, 2 * n - 1):\n\tcur = (cur * 10 + ord(s[i]) - ord('0')) % m\n\tif i >= n:\n\t\tcur = (cur - (pot[n] * (ord(s[i]) - ord('0'))) % m + m) % m\n\tif i >= n - 1 and s[i - (n - 1)] != '0':\n\t\tmn = min(mn, cur)\nprint(mn)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0c83abc475bf7a2a4f2a582d60ccd4c0", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "from math import gcd\nfrom itertools import product\nw = int(input())\nc = list(map(int,input().split()))\nsm = sum([c[i]*(i+1) for i in range(8)])\nper = 1\nif sm < w:\n print(sm)\n exit()\nelif sm < w+64:\n ans = 0\n ls = [list(range(0,min(c[i]+1,8))) for i in range(8)]\n for x in product(*ls):\n tmp = 0\n for i in range(8):\n tmp += (i+1)*x[i]\n if sm-tmp <= w:\n ans = max(ans,sm-tmp)\n print(ans)\n exit()\nelse:\n for i in range(8):\n for j in range(min(c[i],2520//(i+1))):\n per |= per<<(i+1)\n per &= (1<<2521)-1\nrem = w%2520\nans = w\nwhile per&1<\n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\n\nclass dict(dict):\n \"\"\"dict() -> new empty dictionary\"\"\"\n\n def items(self):\n \"\"\"D.items() -> a set-like object providing a view on D's items\"\"\"\n return dict.iteritems(self)\n\n def keys(self):\n \"\"\"D.keys() -> a set-like object providing a view on D's keys\"\"\"\n return dict.iterkeys(self)\n\n def values(self):\n \"\"\"D.values() -> an object providing a view on D's values\"\"\"\n return dict.itervalues(self)\n\n\ndef gcd(x, y):\n \"\"\"greatest common divisor of x and y\"\"\"\n while y:\n x, y = y, x % y\n return x\n\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\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 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 @memoize\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": "c10c64d693fddcde50f041fed1d96108", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import time\nimport random\nW = int(input())\nM = [int(a) for a in input().split()]\nA = [0] * 8\nsTime = time.time()\n\ns = 0\nmi = 10**20\nfor i in range(8):\n if s + M[i]*(i+1) <= W:\n s += M[i]*(i+1)\n A[i] = M[i]\n else:\n t = (W-s)//(i+1)\n s += t*(i+1)\n A[i] += t\n \n if s <= W:\n mi = min(mi, W-s)\n\nwhile time.time() - sTime < 1.7:\n i = random.randrange(8)\n a = random.randrange(2)\n if W-s >= 20 or (s-W < 10 and a == 0):\n if A[i] < M[i]:\n A[i] += 1\n s += (i+1)\n else:\n if A[i] > 0:\n A[i] -= 1\n s -= (i+1)\n\n if s <= W:\n mi = min(mi, W-s)\n\nprint(W-mi)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8adba65ed744f74b0d9d2cafc20f0838", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python2\nfrom __future__ import print_function\n\nimport os\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\nrange = xrange\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 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 @memoize\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": "d35c87f6d6ac2e7b0fe3b2884cf62719", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import time\nimport random\nW = int(input())\nM = [int(a) for a in input().split()]\nA = [0] * 8\nsTime = time.time()\n\ns = 0\nmi = 10**10\nfor i in range(8):\n if s + M[i]*(i+1) <= W:\n s += M[i]*(i+1)\n A[i] = M[i]\n else:\n t = (W-s)//(i+1)\n s += t*(i+1)\n A[i] += t\n \n if s <= W:\n mi = min(mi, W-s)\n\n\nwhile time.time() - sTime < 1.75:\n i = random.randrange(8)\n a = random.randrange(2)\n if W-s >= 20 or (s-W < 10 and a == 0):\n if A[i] < M[i]:\n A[i] += 1\n s += (i+1)\n else:\n if A[i] > 0:\n A[i] -= 1\n s -= (i+1)\n\n if s <= W:\n mi = min(mi, W-s)\n\nprint(W-mi)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8e5efd98601eaef9a9383c9639e38282", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "x,y,z,k=map(int,input().split())\na=[x,y,z]\nif x==y==z==1:\n print (1)\nif x==y==1 and z>1:\n print (z)\nif x==1 and y>1 and z>1:\n print (y*z)\nwhile x>1 and y>1 and z>1:\n if k==1:\n print (2)\n if k==2:\n print (4)\n if k==3:\n print (8)\n if k>(x-1)+(y-1)+(z-1):\n print (x*y*z)\n if 3k/3) else cord[0]\n k-=cnt[0]-1\n cnt[1]=k/2 +1 if (cord[1]>k/2) else cord[1]\n k-=cnt[1]-1\n cnt[2]=min((cord[2],k+1))\n res=1 \n for i in xrange(0,3): \n res*=cnt[i]\n print res \n \n \n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "220f8e04e99217f2380173d8fdb0aa46", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "x,y,z,k=map(int,input().split())\nif k=1:\n print (2)\nif k=2:\n print (4)\nif k=3:\n print (8)\nif k>=(x-1)+(y-1)+(z-1):\n print (x*y*z)\nelse:\n print (4*k-4)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a6bb30ae9f2cd97fa8a48aea578366c9", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\n\nMIN = -1000000000\nx, y, z, k = [int(x) for x in sys.stdin.readline().split()]\nx1, y1, z1 = 1, 1, 1\nfor i in range(k):\n a, b, c = MIN, MIN, MIN\n if x1 < x:\n a = (x1+1)*y1*z1\n if y1 < y:\n b = x1*(y1+1)*z1\n if z1 < z:\n c = x1*y1*(z1+1)\n best = max(a, b, c)\n if best == MIN:\n break\n if best == a:\n x1 += 1\n elif best == b:\n y1 += 1\n else:\n z1 += 1\n#print(x1,y1,z1)\nprint(x1*y1*z1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec81c114e1bdde21391fc13e8b24ea4c", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n,m,s=map(int,input().split())\n\nn,m=min(n,m),max(n,m)\nif(s>=max(n,m)):\n print(n*m)\nelif(s>=n and s=max(n,m)):\n print(n*m)\nelif(s>=n and s= len (read_line_datas ):\n return False\n if read_line_datas[read_line_index]==\"%%%\":\n read_line_index+=1\n return True\n read_line_index+=1\n\n\ndef readint():\n return int (read_line() )\n\n\ndef readints():\n return map(int, read_line().split(\" \"))\n\ndef reads():\n return read_line()\n\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n###############################################################\n\ndef compute(s):\n i=0\n m=[]\n while i0:\n\tval+=1\n\tt1*=t\n\nprint(val)\n\n#n=int(inf.readline())\n#s=inf.readline()\n# s=\"bacabcab\"\n# changed=False\n# while not changed:\n# \tprint(s)\n# \tchanged=True\n# \ti=0\n# \tll=len(s)\n# \twhile(i+1maxyet):\n# \tprint(partition)\n# \tmaxyet=temp\n\n# print(maxyet)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e07ced19bb94be89e272d9ffa03d33c6", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "line = input().strip();\na = line.split(\" \")[0];\nb = line.split(\" \")[1];\ns = a + b;\nm = 0;\nfor c in s :\n d = int(c);\n m = max(m, d);\n\nt = int(a) + int(b)\nret = \"\";\nwhile (t != 0):\n r = t % (m + 1);\n t //= (m + 1);\n ret = ret + str(r);\nprint(len(ret));", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a81fa2989e2cc0db5ee2c9e2f5dc9cca", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "s = raw_input().split()\na, b, c, mx, up = [], [], [], -1, 0\nfor i in xrange(len(s[0])):\n a.append(int(s[0][i]))\n mx = max(mx,a[i])\nfor i in xrange(len(s[1])):\n b.append(int(s[1][i]))\n mx = max(mx,b[i])\np = mx + 1\nfor i in xrange(max(len(s[1]),len(s[0]))):\n if a[i] + b[i] + up >= p: up = 1\n else: up = 0\nprint max(len(s[1]),len(s[0])) + up\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f8c0779b969ffb15e7cc0a8e7134b1fc", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "#-------------------------------------------------------------------------------\n# Name: Codeforces\n# Author: Gogol2\n\n#-------------------------------------------------------------------------------\n\n\n\ndef main():\n x,y = map(int,input().split())\n max_q = -1\n z = x+y\n while (x > 0):\n max_q = max(max_q,x % 10)\n x = x//10\n while (y > 0):\n max_q = max(max_q,y % 10)\n y = y//10\n max_q = max_q + 1\n z = a + b\n k = 0\n while (z > 0):\n k += 1\n z = z // max_q\n print(k)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2b5be5ecdda98df9e1ebcb187e99203a", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import java.math.BigInteger;\nimport java.util.*;\nimport static java.lang.Math.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner in = new Scanner(System.in);\n String n = in.next();\n String m = in.next();\n int base = max(n.chars().max().getAsInt(), m.chars().max().getAsInt())-'0' + 1;\n System.out.println(new BigInteger(n,base).add(new BigInteger(m, base)).toString(base).length());\n }\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "8ef3402d146f3201a50e9d6c2dcb723d", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n=input()\nlst=map(int,raw_input().split())\nfrom collections import *\nv=Counter(lst)\n#print v\nans=0\ns=list(set(lst))\ni=0\ns.sort()\ni=2\ndp=[]\nfor i in v:\n dp.append((v[i],i))\ndp.sort(reverse=True)\nfrom heapq import *\n\nh=[]\nheapify(h)\nfor i in range(0,len(dp)):\n heappush(h,[-dp[i][0],dp[i][1]])\nif len(s)<=2:\n print 0\nelse:\n i=2\n\n pe=[s[0],s[1]]\n fv=[]\n while len(h)>2:\n t1=heappop(h)\n t2=heappop(h)\n t3=heappop(h)\n if t1[0]<0 and t2[0]<0 and t3[0]<0:\n t1[0]=t1[0]+1\n t2[0]=t2[0]+1\n t3[0]=t3[0]+1\n fv.append((t1[1],t2[1],t3[1]))\n if t1[0]!=0:\n heappush(h,t1)\n if t2[0]!=0:\n heappush(h,t2)\n if t3[0]!=0:\n heappush(h,t3)\n\n if len(fv)==0:\n print 0\n else:\n print len(fv)\n for i in fv:\n\n tu=[i[0],i[1],i[2]]\n tu.sort()\n print tu[2],tu[1],tu[0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7cd1255e04e8cdc6722a4036206c3e00", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\nlike = dict((i, set()) for i in range(1, n + 1))\ndislike = dict((i, set()) for i in range(1, n + 1))\n\nk = int(raw_input())\nfor person1, person2 in (map(int, raw_input().split()) for i in range(k)):\n like[person1].add(person2)\n like[person2].add(person1)\n\nm = int(raw_input())\nfor person1, person2 in (map(int, raw_input().split()) for i in range(m)):\n dislike[person1].add(person2)\n dislike[person2].add(person1)\n\ndef find_solutions():\n for root in range(1, n + 1):\n graph_follow = set([root])\n graph = set()\n graph_likes = set()\n graph_dislikes = set()\n\n while graph_follow:\n for follow in graph_follow:\n graph.add(follow)\n graph_likes |= like[follow]\n graph_dislikes |= dislike[follow]\n graph_follow = (graph_likes - graph_dislikes) - graph\n\n yield len(graph - graph_dislikes)\n\nprint max(find_solutions())", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1c83cd84a6d6fcfa9845f179ff85b452", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "t, p, k = [0] * (int(input()) + 1), {}, 1\nfor i in range(int(input())):\n a, b = map(int, input().split())\n if t[a] == t[b]:\n if t[a] == 0:\n t[a] = t[b] = k\n p[k] = [a, b]\n k += 1 \n else:\n if t[a] == 0:\n t[a] = t[b]\n p[t[b]].append(a)\n elif t[b] == 0:\n t[b] = t[a]\n p[t[a]].append(b)\n else:\n x, y = t[b], t[a]\n for c in p[x]:\n t[c] = y\n p[y] += p[x]\n p[x] = [] \nfor i in range(int(input())):\n a, b = map(int, input().split())\n if t[a] == t[b]: p[t[a]] = []\nprint(max(int(0 in t[1:]), max(len(p[i]) for i in p)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c1befe8990bbf91b090428f835da792", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import sys\nimport math\nint_ = lambda x: int(x)-1\nn = int(sys.stdin.readline())\np = [-1]*n\n#p[0]=-1\nk = int(sys.stdin.readline())\ngroups = []\nfor i in xrange(k):\n p1, p2 = map(int_, sys.stdin.readline().split())\n if p[p1] == p[p2] == -1:\n #new group\n grp_ind = len(groups)\n groups.append([p1,p2])\n p[p1] = grp_ind\n p[p2] = grp_ind\n elif p[p1] == -1:\n #move first to group of 2\n p[p1] = p[p2]\n groups[p[p2]].append(p1)\n elif p[p2] == -1:\n p[p2] = p[p1]\n groups[p[p1]].append(p2)\n else:\n #in dif groups, together!\n #from second group to first group\n for ind in xrange(len(p)):\n del_grp = p[p2]\n if p[ind] == del_grp:\n groups[del_grp].pop(groups[del_grp].index(ind))\n p[ind] = p[p1]\n groups[p[p1]].append(ind)\n \n#print p\n#print groups\n\nm = int(sys.stdin.readline())\nen = []\nfor i in xrange(m):\n p1, p2 = map(int_, sys.stdin.readline().split())\n if p[p1]==p[p2]:\n #a oni v odno' gryppe (((\n groups[p[p1]] = []\n \nx = max(map(len, groups))\nif x==0 and -1 in p:\n x = 1\nprint str(x)\n#\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef3ec6ae355adc7f09b274037be2384d", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "import sys\nimport heapq\nimport bisect\nimport math\n\nINF = 10**9+7\nOFFLINE = 0\nN = 101010\nsys.setrecursionlimit(INF)\n\ndef fi():\n\treturn int(sys.stdin.readline())\n\ndef fi2():\n\treturn map(int, sys.stdin.readline().split())\n\ndef fi3():\n\treturn sys.stdin.readline().rstrip()\n\ndef fo(*args):\n\tfor s in args:\n\t\tsys.stdout.write(str(s)+\" \")\n\tsys.stdout.write(\"\\n\")\n\n##\nif OFFLINE:\n\tsys.stdin = open(\"fin.txt\", \"r\")\n\tsys.stdout = open(\"fout.txt\", \"w\")\n##\n\ndef root(x):\n\n\twhile parent[x] != x:\n\t\tparent[x] = parent[parent[x]]\n\t\tx = parent[x]\n\n\treturn x\n\ndef union(x, y):\n\n\tpx = root(x)\n\tpy = root(y)\n\n\tif px == py:\n\t\treturn\n\n\tparent[px] = py\n\tsize[py] += size[px]\n\troots.remove(px)\n\tenemy[py] = enemy[py].union(enemy[px])\n\n\n##main\n\nn = fi()\n\nparent = [i for i in range(n+1)]\nsize = [1 for i in range(n+1)]\nroots = set([i+1 for i in range(n)])\n\nE = []\nenemy = [set() for i in range(n+1)] \n\nk = fi()\n\nfor i in range(k):\n\tu, v = fi2()\n\tunion(u, v)\n\n\nm = fi()\n\nfor i in range(m):\n\tu, v = fi2()\n\n\tif root(u) == root(v):\n\t\troots.remove(root(u))\n\n\nans = 0\n\nfor r in roots:\n\tans = max(ans, size[r])\n\nfo(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cf42b862cf738fce139000ff7656d344", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\ndef basen(val, base):\n res = \"\"\n while val > 0:\n res += str(val % base)\n val -= val % base\n val /= base\n return res[::-1]\n\nfor x in range(n-1):\n for y in range(n-1):\n #Put x*y into base n\n print basen( (x+1) * (y+1), n), \" \",\n print", "lang_cluster": "Python", "compilation_error": false, "code_uid": "35bebf1ed4cdc8032f51ecab79b6f26b", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "# def f(x,b):\n# \ts = \"\"\n# \twhile x > b:\n# \t\ts += str(x/b)\n# \t\tx /= b\n# \ts += str(x)\n# \treturn s\n\ndef digit_to_char(digit):\n if digit < 10:\n return str(digit)\n return chr(ord('a') + digit - 10)\n\ndef str_base(number,base):\n if number < 0:\n return '-' + str_base(-number, base)\n (d, m) = divmod(number, base)\n if d > 0:\n return str_base(d, base) + digit_to_char(m)\n return digit_to_char(m)\n\nn = input()\nfor i in range(1,n):\n\tfor j in range(1,n):\n\t\t\t# print '%2d'%f(i*j,n),\n\t\t\tprint str_base(i*j,n),\n\tprint", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1dcc0e85ba73128aa310a7b069e1879c", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "Python 3", "source_code": "def b(n, k):\n v = ''\n while n:\n n, v = n // k, str(n % k) + v\n return v\nk = int(input())\nfor i in range(1, k):\n print(' '.join(b(i * j, k) for j in range(1, k)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "81aefda1bb23c374e0160bc8977a36ae", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ndef rad_n(n,x):\n\tr =''\n\twhile x>n:\n\t\tr=str(x%n)+r\n\t\tx = x/n\n\tr=str(x)+r\n\treturn r\nl = len(str(rad_n(n,(n-1)*(n-1))))\n#print l\nfor i in xrange(1,n):\n\tfor j in xrange(1,n):\n\t\ta = rad_n(n,i*j)\n\t\tif j==1:\n\t\t\tprint a,\n\t\telif j1):\n q=a//m;t=m;m=a%m;a=t;t=y;y=x-q*y;x=t\n if (x<0):x=x+m0 \n return x\np=998244353\nn,m=map(int,input().split())\nz=0\nfor i in range(1,n+1): z+=b(i, p)\nprint(((1+m*z)*(1+n*b(m+1,p)))%p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1793fe4b3a0bd0eda7e36edc8627201", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "PyPy 3", "source_code": "def b(a,m): \n m0=m;y=0;x=1\n if (m==1):return 0\n while (a>1):\n q=a//m;t=m;m=a%m;a=t;t=y;y=x-q*y;x=t\n if (x<0):x=x+m0 \n return x\np=998244353\nn,m=map(int,input().split())\nz=0\nfor i in range(1,n+1): z+=b(i, p)\nprint(((1+m*z)*(1+n*b(m+1,p)))%p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "96a833690fe57849d0da615cba2daf4d", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "PyPy 2", "source_code": "MOD = 998244353\ndef inv(x):\n return pow(x, MOD - 2, MOD)\n \nn, m = map(int, input().split())\n \nmult = n * inv(m + 1) + 1\nmult %= MOD\n \ncurrN = 1\nout = m + 1\nwhile currN < n:\n currN += 1\n \n out = (out + m * inv(currN)) % MOD\n \nout *= mult\nprint(out % MOD)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "55a29a71786c59ccd784611cae280b7d", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "PyPy 3", "source_code": "from math import pow\n\n# modular inverse for positive a and b and nCk mod MOD depending on modinv\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n\nMOD = 998244353\n\nn, m = map(int, input().split())\n\nmul = n * modinv(m + 1,MOD) + 1\n\nmul %= MOD\n\ncurN = 1\n\nfor i in range(1,n + 1):\n curN += m * pow(i, -1, MOD)\n curN %= MOD\n\ncurN *= mul\n\ncurN %= MOD\n\nprint(curN)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4745312b3d206a14edb4eb946c7f1514", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "PyPy 3", "source_code": "MOD = 998244353\ndef inv(x):\n return pow(x, MOD - 2, MOD)\n \nn, m = map(int, input().split())\n \nmult = n * inv(m + 1) + 1\nmult %= MOD\n\nout = m + 1\nfor currN in range(1, n):\n out += m * inv(currN)\n out %= MOD\n \nout *= mult\nprint(out % MOD)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a27b02c819decfe2af031c7ef53bd19b", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "Python 3", "source_code": "q = str(input())\npr = 0\nsuf = 0\nfor i in range(1, len(q)):\n\tif (q[i] == '0'):\n\t\tpr *= 10\n\tsuf += pr\n\tpr = int(q[i])\nsuf += pr\nprint(suf + 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e9a021b941d909d6d5b9d0e0d5903c5", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "s = list(input())\ndex = 0\nfor i in s:\n if i == \"A\":\n dex += 1\n elif i == \"1\":\n dex += 10\n else:\n dex += int(i)\nprint(dex)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7dfb2be436a71750934f991cb55ed45b", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport os\nimport sys\nimport itertools\n\ndef solve(f):\n s = f.read_str()\n\n ten_flag = 0\n ans = 0\n for i in s:\n if i == \"1\":\n ten_flag = 1\n elif i == \"A\":\n ans += 1\n else:\n ans += ten_flag * 10 + int(i)\n ten_flag = 0\n\n return ans\n\nclass Reader(object):\n def __init__(self, filename=None):\n self.test_mode = filename is not None\n self.cases = 1\n self.buffer = []\n if self.test_mode:\n with open(filename) as f:\n blank_flg = False\n for line in f:\n line = line.strip()\n if line:\n self.buffer.append(line)\n blank_flg = False\n else:\n if not blank_flg: self.cases += 1\n blank_flg = True\n\n def __readline(self):\n return self.buffer.pop(0) if self.test_mode else raw_input()\n\n def read_int(self):\n return int(self.__readline())\n def read_float(self):\n return float(self.__readline())\n def read_long(self):\n return long(self.__readline())\n def read_str(self):\n return self.__readline()\n\n def read_int_list(self):\n return [int(item) for item in self.__readline().split()]\n def read_float_list(self):\n return [float(item) for item in self.__readline().split()]\n def read_long_list(self):\n return [long(item) for item in self.__readline().split()]\n def read_str_list(self):\n return self.__readline().split()\n\nif __name__ == '__main__':\n filename = sys.argv[1] if len(sys.argv)>1 else None\n f = Reader(filename)\n if f.test_mode:\n for c in xrange(f.cases):\n print \"Case #%d\"%(c+1)\n print solve(f)\n else:\n print solve(f)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32a8f88682e034ecb8d95f7791b5efa1", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "s = input()[1:]\nprint(1+sum(list(s))+9*s.count('0'))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "248b8d5fc5483d6df0a26d0f4fcfab00", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator, re\nfrom string import ascii_lowercase\nfrom string import ascii_uppercase\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] != \"CPython\": # PyPy?\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\ns = read_str()\nimport urllib2\ns = urllib2.urlopen(\"http://oeis.org/\" + s).read()\ns = re.findall(r\"(\\d+),\", s)[0]\nprint s\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fbee1f284b5295f7457cc886246ad2d4", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def sort(a):\r\n n = len(a)\r\n b = [0 for i in range(n)]\r\n log = []\r\n\r\n def mergeSort(l, r):\r\n if r - l <= 1:\r\n return\r\n m = (l + r) >> 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 a[i] < a[j]:\r\n log.append('0')\r\n b[k] = a[i]\r\n i += 1\r\n else:\r\n log.append('1')\r\n b[k] = a[j]\r\n j += 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 return \"\".join(log)\r\n\r\n\r\ndef reverseSort(n, log):\r\n # print(f\"reverseSort {n}\")\r\n assigns = []\r\n\r\n def mergeSort(l, r, log_id, run_id):\r\n if r - l <= 1:\r\n return log_id, run_id-1\r\n # print(f\"mergeSort {l}-{r} {log_id}\")\r\n assigns.append([])\r\n m = (l + r) >> 1\r\n log_id, last_run_id = mergeSort(l, m, log_id, run_id+1)\r\n log_id, last_run_id = mergeSort(m, r, log_id, last_run_id+1)\r\n i, j, k = l, m, l\r\n while i < m and j < r:\r\n if log[log_id] == '0':\r\n assigns[run_id].append((k, 0, i))\r\n i += 1\r\n else:\r\n assigns[run_id].append((k, 1, j))\r\n j += 1\r\n log_id += 1\r\n k += 1\r\n while i < m:\r\n assigns[run_id].append((k, 0, i))\r\n i += 1\r\n k += 1\r\n while j < r:\r\n assigns[run_id].append((k, 1, j))\r\n j += 1\r\n k += 1\r\n return log_id, last_run_id\r\n\r\n log_id, next_run_id = mergeSort(0, n, 0, 0)\r\n # print(log_id, assigns)\r\n if log_id < len(log):\r\n return []\r\n\r\n a = list(range(1, n+1))\r\n b = [0] * n\r\n\r\n def reverseMergeSort(l, r, run_id):\r\n if r - l <= 1:\r\n return run_id-1\r\n m = (l + r) >> 1\r\n for k, part, i in assigns[run_id]:\r\n b[i] = a[k]\r\n for p in range(l, r):\r\n a[p] = b[p]\r\n last_run_id = reverseMergeSort(l, m, run_id+1)\r\n last_run_id = reverseMergeSort(m, r, last_run_id+1)\r\n return last_run_id\r\n\r\n reverseMergeSort(0, n, 0)\r\n\r\n return a\r\n\r\n\r\nlog = input()\r\nn = 1\r\na = []\r\nwhile not a:\r\n n += 1\r\n a = reverseSort(n, log)\r\nprint(len(a))\r\nprint(' '.join(map(str, a)), flush=True)\r\n# new_log = sort(a)\r\n# assert new_log == log\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ce1787257088f2108ad5bd249b14bab", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "Python 3", "source_code": "def sort(a):\r\n n = len(a)\r\n b = [0 for i in range(n)]\r\n def mergeSort(l, r):\r\n if r - l <= 1: return\r\n global cnt\r\n m = (l + r) >> 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 log[cnt] == '0':\r\n g[a[i]].append(a[j])\r\n b[k] = a[i]\r\n i += 1\r\n else:\r\n g[a[j]].append(a[i])\r\n b[k] = a[j]\r\n j += 1\r\n k += 1\r\n cnt += 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 mergeSort(0, n)\r\n return \"\".join(log)\r\n\r\ndef dfs(v, p):\r\n u[v] = 1\r\n for to in g[v]:\r\n if (to != p and not u[to]):\r\n dfs(to, v)\r\n top_sort.append(v)\r\n\r\nlog = input()\r\ng = [[] for i in range(16)]\r\ntop_sort, u = [], [0 for i in range(16)]\r\ncnt = 0\r\n\r\nsort([i for i in range(16)])\r\n\r\nfor i in range(16):\r\n if (not u[i]):\r\n dfs(i, -1)\r\n\r\nans = [0 for i in range(16)]\r\ntop_sort = top_sort[::-1]\r\nfor i in range(16):\r\n ans[top_sort[i]] = i + 1\r\nprint(16)\r\nprint(*ans)\r\n\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7be86ed4073b453d90f21628ee44dec7", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "PyPy 3", "source_code": "s = input()\r\nn = 0 \r\nss = [1, 1, 2, 1, 1, 2, 4, 1, 1, 2, 1, 1, 2, 4, 8]\r\ndef render (k):\r\n global n\r\n p = []\r\n while (p.count(0)> 1\r\n\r\n if m - l > 1:\r\n ans = mergeSort(l, m)\r\n if ans == -1:\r\n return -1\r\n if r - m > 1:\r\n ans = mergeSort(m, r)\r\n if ans == -1:\r\n return -1\r\n i, j, k = l, m, l\r\n while i < m and j < r:\r\n if px[0] >= len(s):\r\n return -1\r\n\r\n if s[px[0]] == '0':\r\n b[k] = a[i]\r\n i += 1\r\n else:\r\n b[k] = a[j]\r\n j += 1\r\n k += 1\r\n px[0] += 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\r\n for p in range(l, r):\r\n a[p] = b[p]\r\n\r\n ans = mergeSort(0, n)\r\n if ans == -1:\r\n return -1\r\n if px[0] != len(s):\r\n return 1\r\n return a\r\n\r\n\r\ndef main():\r\n d_min = {0: [], 1: [], 2: [1]}\r\n d_max = {0: [], 1: [], 2: [1]}\r\n\r\n def get_min(n):\r\n if n not in d_min:\r\n d_min[n] = [n // 2] + get_min(n - n // 2) + get_min(n // 2)\r\n\r\n return d_min[n]\r\n\r\n def get_max(n):\r\n if n not in d_max:\r\n d_max[n] = [n - 1] + get_max(n - n // 2) + get_max(n // 2)\r\n\r\n return d_max[n]\r\n\r\n s = input()\r\n # lens = len(s)\r\n # l, r = 1, 10 ** 3 + 1\r\n # while r - l > 1:\r\n # m = (l + r) // 2\r\n # if sum(get_min(m)) > lens:\r\n # r = m\r\n # else:\r\n # l = m\r\n # max_n = l\r\n #\r\n # l, r, = 1, 10 ** 3 + 1\r\n # while r - l > 1:\r\n # m = (l + r) // 2\r\n # if sum(get_max(m)) < lens:\r\n # l = m\r\n # else:\r\n # r = m\r\n # min_n = r\r\n\r\n for n in range(16, 0, -1):\r\n ans = sort(n, s)\r\n if isinstance(ans, list):\r\n out = [''] * n\r\n print(n)\r\n for i, aa in enumerate(ans):\r\n out[aa - 1] = str(i + 1)\r\n print(' '.join(out))\r\n break\r\n\r\n\r\n############\r\n\r\ndef i_input():\r\n return int(input())\r\n\r\n\r\ndef l_input():\r\n return input().split()\r\n\r\n\r\ndef li_input():\r\n return list(map(int, l_input()))\r\n\r\n\r\ndef il_input():\r\n return list(map(int, l_input()))\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == \"__main__\":\r\n TT = time.time()\r\n main()\r\n # print(\"\\n\", time.time() - TT)\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "892cd01b10993049a04e73d48c9b19cd", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "Python 3", "source_code": "def sort(a):\r\n n = len(a)\r\n b = [0 for i in range(n)]\r\n log = []\r\n\r\n def mergeSort(l, r):\r\n if r - l <= 1:\r\n return\r\n m = (l + r) >> 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 a[i] < a[j]:\r\n log.append('0')\r\n b[k] = a[i]\r\n i += 1\r\n else:\r\n log.append('1')\r\n b[k] = a[j]\r\n j += 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 return \"\".join(log)\r\n\r\n\r\ndef reverseSort(n, log):\r\n # print(f\"reverseSort {n}\")\r\n assigns = []\r\n\r\n def mergeSort(l, r, log_id, run_id):\r\n if r - l <= 1:\r\n return log_id, run_id-1\r\n # print(f\"mergeSort {l}-{r} {log_id}\")\r\n assigns.append([])\r\n m = (l + r) >> 1\r\n log_id, last_run_id = mergeSort(l, m, log_id, run_id+1)\r\n log_id, last_run_id = mergeSort(m, r, log_id, last_run_id+1)\r\n i, j, k = l, m, l\r\n while i < m and j < r:\r\n if log[log_id] == '0':\r\n assigns[run_id].append((k, 0, i))\r\n i += 1\r\n else:\r\n assigns[run_id].append((k, 1, j))\r\n j += 1\r\n log_id += 1\r\n k += 1\r\n while i < m:\r\n assigns[run_id].append((k, 0, i))\r\n i += 1\r\n k += 1\r\n while j < r:\r\n assigns[run_id].append((k, 1, j))\r\n j += 1\r\n k += 1\r\n return log_id, last_run_id\r\n\r\n log_id, next_run_id = mergeSort(0, n, 0, 0)\r\n # print(log_id, assigns)\r\n if log_id < len(log):\r\n return []\r\n\r\n a = list(range(1, n+1))\r\n b = [0] * n\r\n\r\n def reverseMergeSort(l, r, run_id):\r\n if r - l <= 1:\r\n return run_id-1\r\n m = (l + r) >> 1\r\n for k, part, i in assigns[run_id]:\r\n b[i] = a[k]\r\n for p in range(l, r):\r\n a[p] = b[p]\r\n last_run_id = reverseMergeSort(l, m, run_id+1)\r\n last_run_id = reverseMergeSort(m, r, last_run_id+1)\r\n return last_run_id\r\n\r\n reverseMergeSort(0, n, 0)\r\n\r\n return a\r\n\r\n\r\nlog = input()\r\nn = 1\r\na = []\r\nwhile not a:\r\n n += 1\r\n a = reverseSort(n, log)\r\nprint(len(a))\r\nprint(' '.join(map(str, a)), flush=True)\r\nnew_log = sort(a)\r\nassert new_log == log\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de99341e34b41921c5feabe9f6a7ead7", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "Python 2", "source_code": "print(\"1\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ac4c18a26ce302f1d896a2ddbdf6563d", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "print(\"1\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3e450d40ee853e5714c5c8091a021648", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "print(\"2\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff74cceae776e855d8e753e5510c963a", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "print(\"2\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32ecb6fd2a9cc93ae2d526ad7d17f979", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "print(\"1\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3246e1ea00d66643e54bd8de8a059bd0", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "N = 200001\nMOD = 1000000007\nfact = [1] * N\ninv_fact = [1] * N\n\ndef ModExp(a, n):\n ans = 1\n while n:\n if n % 2:\n ans = (ans * a) % MOD\n a = (a * a) % MOD\n n /= 2\n return ans\n\ndef ModInverse(a):\n return ModExp(a, MOD - 2)\n\ndef PreProcess(n):\n for i in range(1, n + 1):\n fact[i] = (i * fact[i - 1]) % MOD\n inv_fact[i] = (ModInverse(i) * inv_fact[i - 1]) % MOD\n\ndef nCr(n, r):\n if n < 0 or r < 0 or n < r:\n return 0\n else:\n return (fact[n] * inv_fact[r] * inv_fact[n - r]) % MOD\n\ndef Beggar(m, n):\n if m < 0 or n < 0 or (n == 0 and m != 0):\n return 0\n else:\n if m + n == 0:\n return 1\n else:\n return nCr(m + n - 1, m)\n\nf, w, h = map(int, raw_input().split())\nn = f + w\n\nPreProcess(n)\n\nq = nCr(n, w)\np = 0\n\nfor n in range(0, w + 1):\n if n * (h + 1) > w:\n break\n else:\n p += (Beggar(w - n * (h + 1), n) * (Beggar(f - n - 1, n + 1) + Beggar(f - n + 1, n - 1) + 2 * Beggar(f - n, n))) % MOD\n\nq = ModInverse(q)\nans = (p * q) % MOD\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9f8c9640817de5ad46403e8284c3f15", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "N = 200001\nMOD = 1000000007\nfact = [1] * N\ninv_fact = [1] * N\n\ndef ModExp(a, n):\n ans = 1\n while n:\n if n % 2:\n ans = (ans * a) % MOD\n a = (a * a) % MOD\n n /= 2\n return ans\n\ndef ModInverse(a):\n return ModExp(a, MOD - 2)\n\ndef PreProcess(n):\n for i in range(1, n + 1):\n fact[i] = (i * fact[i - 1]) % MOD\n\n inv_fact[n] = ModInverse(fact[n])\n for i in range(n - 1, 0, -1):\n inv_fact[i] = ((i + 1) * inv_fact[i + 1]) % MOD\n\ndef nCr(n, r):\n if n < 0 or r < 0 or n < r:\n return 0\n else:\n return (fact[n] * (inv_fact[r] * inv_fact[n - r]) % MOD) % MOD\n\ndef Beggar(m, n):\n if m < 0 or n < 0 or (n == 0 and m != 0):\n return 0\n else:\n if m + n == 0:\n return 1\n else:\n return nCr(m + n - 1, m)\n\nf, w, h = map(int, raw_input().split())\nn = f + w\n\nPreProcess(n)\n\nq = nCr(n, w)\np = 0\n\nfor n in range(0, w + 1):\n if n * (h + 1) > w:\n break\n else:\n p += (Beggar(w - n * (h + 1), n) * ((Beggar(f - n - 1, n + 1) + Beggar(f - n + 1, n - 1) + 2 * Beggar(f - n, n)) % MOD)) % MOD\n\nq = ModInverse(q)\nans = (p * q) % MOD\n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b6f796e2b29cf94fc4cbc107d34acae", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "def build_fac():\n global mod\n fac = [1] * int(3e5 + 1)\n for i in range(1, int(3e5)):\n fac[i] = i*fac[i-1] % mod\n return fac\n\ndef inv(x):\n global mod\n return pow(x, mod-2, mod)\n\ndef ncr(n, r):\n global fac\n if n < 0 or n < r: return 0\n return fac[n]*inv(fac[r])*inv(fac[n-r]) % mod\n\ndef cf(f, w, h):\n global mod\n if w == 0: return 1\n rs = 0\n for k in range(1, min(w//(h+1),f+1)+1):\n rs += ncr(f+1, k) * ncr(w-k*h-1, k-1) % mod\n rs %= mod\n return rs\n\nf, w, h = map(int,input().split(' '))\nmod = int(1e9 + 7)\n\nfac = build_fac()\ncnt = cf(f, w, h)\nrs = cnt*inv(ncr(f+w, w)) % mod\n\nprint(rs)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8e304c26c2807d629b0d20bd476c1282", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "def build_fac():\n global mod\n fac = [1] * int(2e5 + 1)\n for i in range(1, int(2e5)):\n fac[i] = i*fac[i-1] % mod\n return fac\n\ndef inv(x):\n global mod\n return pow(x, mod-2, mod)\n\ndef ncr(n, r):\n global fac\n if n < 0 or n < r: return 0\n return fac[n]*inv(fac[r])*inv(fac[n-r]) % mod\n\ndef cf(f, w, h):\n global mod\n if w == 0: return 1\n rs = 0\n for k in range(1, min(w//(h+1),f+1)+1):\n rs += ncr(f+1, k) * ncr(w-k*h-1, k-1) % mod\n rs %= mod\n return rs\n\nf, w, h = map(int,input().split(' '))\nmod = int(1e9 + 7)\n\nfac = build_fac()\ncnt = cf(f, w, h)\nrs = cnt*inv(ncr(f+w, w)) % mod\n\nprint(rs)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8a7cd5a18ca56e408bc8fcd7190ef746", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "N = int(input())\nans = (N+1) // 2 - 1\nif N % 2 == 0:\n ans = max(0, ans-1)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c44f0888824eea4f01f08a5c170633fe", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "from math import log2, ceil\nN = int(input())\nif N % 2 == 0:\n N //= 2\n ans = 2 ** ceil(log2(N)) - N\nelse:\n ans = (N+1) // 2 - 1\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3173319d76fbaf6b43feec9cfe3f16d8", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import math\n\nN = int(input().split()[0])\nif N % 2:\n print(N - pow(2, int(math.log2(N))))\nelse:\n print (int((N-1)/2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6376ee5ba11718f0d22c34a5adacf160", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "N = int(input().split()[0])\nif N % 2:\n print(N - pow(2, int(math.log2(N))))\nelse:\n print (int((N-1)/2))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "27774a69ba2cd249e13f6c10ea2e766a", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n=input()\n\n\ndef is_power_of_2(n):\n while n>1:\n if n % 2 == 1:\n return False\n else:\n n = n/2\n return True\n\ni=0\nwhile i<(n+1)/2:\n if is_power_of_2(n-2*i):\n answer=i\n break\n i+=1\n\n\nprint answer\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b72494de9c7fc2e4ea97f87ee825d01", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "print 'YES' if int(raw_input(), 2).count('1') == 1 else 'NO'", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7560cedcc8b22d7643b95644a59f52b0", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "t = int(raw_input())\n\nnums = []\nfor i in xrange(t):\n cur_c = 0\n cur_s = raw_input().split()\n cur_n = map(long, cur_s)\n for n in xrange(cur_n[0], cur_n[1]+1):\n s = str(n)\n digits = set(s)\n flag = True\n for d in digits:\n if d == '0':\n continue\n if n % int(d) != 0:\n flag = False\n break\n if flag:\n cur_c += 1\n# \n# if '2' in digits:\n# if not (s[-1] in ('0', '2', '4', '8')):\n# continue\n# if '3' in digits:\n# if not sum(map(int, s)) % 3 == 0:\n# continue\n# if '4' in digits:\n# if not int(s[-2:]) % 4 == 0:\n# continue\n# if '5' in digits:\n# if not (s[-1] == '5' or s[-1] == '0'):\n# continue\n# if '6' in digits:\n# if '2' not in digits:\n# if not (s[-1] in ('0', '2', '4', '8')):\n# continue\n# if '3' not in digits:\n# if not sum(map(int, s)) % 3 == 0:\n# continue\n# if '7' in digits:\n# if not abs(int(s[-2]) - int(s[-1])*2) % 7 == 0:\n# continue\n# if '8' in digits:\n# if not int(s[-3:]) % 8 == 0:\n# continue\n# if '9' in digits:\n# if not sum(map(int, s)) % 9 == 0:\n# continue\n# cur_c += 1\n print cur_c \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7df5a5303278bdc954339ce0c5087529", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\ni=1%n\nk=2%n\nv=[-1]*n\nv[0]=1\nwhile not (k==v[i]):\n\tv[i]=k\n\ti=(i+k)%n\n\tk=(k+1)%n\nif v.count(-1)!=0:\n\tprint 'NO'\nelse:\n\tprint 'YES'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "592161344b39e23343da33cf0e4e52e1", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\ni=1%n\nk=2%n\nv=[-1]*n\nv[0]=1\nwhile not (k==v[i]):\n\tv[i]=k\n\ti=(i+k)%n\n\tk=(k+1)%n\n\tif v.count(-1)==0:\n\t\tbreak\nif v.count(-1)!=0:\n\tprint 'NO'\nelse:\n\tprint 'YES'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ccc76cca47df9c9a2719e1c9b0bc4643", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "PyPy 3", "source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]", "lang_cluster": "Python", "compilation_error": true, "code_uid": "96c6a17fe1b113764586889dce99934a", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n\n print(\"{}\".format(\"uniform\" if max(V) < 1.8*(S**0.5) else \"poisson\"))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1231d3ed99be40aa927239246d9dfeb3", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n\n print(\"{}\".format(\"uniform\" if max(V) <= 2*(S**0.5) else \"poisson\"))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "150ec3f21c42ab80ad4e02d41e26de4a", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n\n print(\"{}\".format(\"uniform\" if max(V) <= 2*S else \"poisson\"))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0301d56d73e7dd1f41e8b938b9437b15", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n\n print(\"{}\".format(\"uniform\" if max(V) <= 2*(s**0.5) else \"poisson\"))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f168eb2fa4d55be3b5110b4ec882397", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n\n print(\"{}\".format(\"uniform\" if max(V) < 1.9*(S**0.5) else \"poisson\"))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6cc28b71e5e75ed65eb65436b2d2779d", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "import collections\nimport math\n\nr, c, n, k = map(int, input().split())\nT = []\nans = 0\nfor i in range(n):\n x, y = map(int, input().split())\n T.append((x, y))\nfor ri in range (1, r + 1):\n for rj in range(i, r + 1):\n for ci in range(1, c + 1):\n for cj in range(ci, c + 1):\n t = 0\n for i in range(len(T)):\n if ri <= T[i][0] <= rj and ci <= T[i][1] <= cj:\n t += 1\n if t >= k:\n ans += 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e2b0163fd79908fdb4b66f52d41048c1", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "r,c,n,m = map(int, raw_input().strip().split())\nx = []\nfor i in xrange(r):\n\tx.append([0]*c)\nfor i in xrange(n):\n\ta,b = map(int, raw_input().strip().split())\n\tx[a-1][b-1] = 1\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\t#i,j is the starting point\n\t\t# generate all the rectangles possible and find sum and if greater than k, add 1.\n\t\taddition = 0\n\t\tfor k in range(i,r):\n\t\t\tfor l in range(j,c):\n\t\t\t\taddition += x[k][l]\n\t\tif(addition >= m):\n\t\t\tcount += 1\n\t\taddition = 0\n\t\tfor k in range(j,c):\n\t\t\tfor l in range(i,r):\n\t\t\t\taddition += x[l][k]\n\t\tif(addition >= m):\n\t\t\tcount += 1\nprint count\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b938328b7cbbd5c761733b776856cddf", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "PyPy 3", "source_code": "fin = open('input.txt', 'r')\np = '.!?:-,;()'\nfor i in fin.readlines():\n s = i.strip().split()\n cnt = 0\n for word in s:\n Set = set()\n for c in word:\n if c in p: continue\n Set.add(c)\n if 0 < len(Set) <= 3:\n cnt += 1\n print(i, cnt)\n if cnt < len(s) / 2:\n print(i)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6fa89ac2eef1c783c74343dcb55b031", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#from __future__ import print_function\nr, c, n, ks = map(int, raw_input().split())\nb = [[0 for i in range(r)] for i in range(c)]\nfor row in xrange(n):\n\tx, y = map(int, raw_input().split())\n\tx, y = x - 1, y - 1\n\tb[x][y] = 1\n\nret = 0\nfor i in xrange(r):\n\tfor j in xrange(c):\n\t\tfor k in xrange(i, r):\n\t\t\tfor l in xrange(j, c):\n\t\t\t\ttot = 0\n\t\t\t\tfor x in xrange(i, k+1):\n\t\t\t\t\tfor y in xrange (j, l + 1):\n\t\t\t\t\t\ttot += b[x][y]\n\t\t\t\tret += tot >= ks\t\t\t\t\nprint ret", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b4260e6cae241fb070b2e55d14ccbb49", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys, os, subprocess, time, optparse, collections\nfrom pprint import pprint\n\n# BEGIN SOLUTION\n\ndef solution():\n r, c, n, k = ints()\n vio = set()\n for i in range(n):\n vio.add(tuple(ints()))\n\n res = 0\n for r0 in range(r):\n for r1 in range(r0+1, r+1):\n for c0 in range(c):\n for c1 in range(c0+1, c+1):\n count = 0\n for x in range(r0, r1):\n for y in range(c0, c1):\n if (x+1, y+1) in vio:\n count += 1\n if count >= k:\n res += 1\n out(res)\n\n# END SOLUTION\n\n'''\nCodeforces template\n\nCopyright by Jeroen van Wolffelaar , 2016\nCodeforces username 'jeroen'\n\nPick any license you want: Public domain / WTFPL / MIT / 3-clause BSD / PSFL\n\n\nMakes it easy to run under various modes, like adhoc something, regular mode,\nvarious verbosity options. Compares output to expected, shows time taken, can\nenable the python profiler, can show in/out.\n\nprint statement will not end up in actual output, you must use out(), outp(),\nor return the result from case().\n\nUsage:\n\n- Run with one argument, the single .in file in the currect directory matching\n the argument will be picked.\n\n- Omit the mask, and the script will pick the most recently modified .in file.\n\n- Run with the first argument being a global in the solution, and that\n function will be called with the remaining arguments passed through.\n\n If you specify 'case', you can thus run a single case.\n\n'''\n\n\nimport __main__\n\ndef line():\n L = sys.stdin.readline()\n if not L:\n raise Exception(\"End of file\")\n if VERBOSE:\n print 'INPUT:', L,\n return L.strip()\ndef ints():\n return map(int, line().split())\n\ndef outp(s): # p for partial (= no newline)\n OUT.write(s)\ndef out(s):\n outp(str(s)+'\\n')\n\ndef vprint(s):\n if VERBOSE: print s\n\ndef profile(func, *a, **kw):\n if OPTS.profile:\n import cProfile, pstats\n P = cProfile.Profile()\n P.enable()\n\n try:\n return func(*a, **kw)\n finally:\n if OPTS.profile:\n print '='*80\n P.disable()\n P.print_stats('cumulative')\n print '='*80\n\ndef processInput():\n solution()\n if sys.stdin.readline():\n print 'WARNING: not all input consumed!'\n\ndef main():\n parser = optparse.OptionParser()\n parser.add_option('--run', action='store_true')\n parser.add_option('--outfd')\n parser.add_option('-v', '--verbose', action='store_true')\n parser.add_option('-d', '--debug', action='store_true')\n parser.add_option('-q', '--quiet', action='store_true') # suppress stdout\n parser.add_option('-p', '--profile', action='store_true')\n opts, args = parser.parse_args()\n\n if opts.run is None:\n if not os.isatty(sys.stdin.fileno()):\n opts.run = True\n\n if opts.outfd is not None:\n out = os.fdopen(int(opts.outfd), 'w')\n else:\n out = sys.stdout\n \n if opts.run and sys.stdout is out:\n # Hide stdout\n sys.stdout = open('/dev/null', 'w')\n\n global OUT, OPTS, VERBOSE, DEBUG\n OUT = out\n OPTS = opts\n VERBOSE = opts.verbose\n DEBUG = opts.debug\n\n if opts.run:\n return profile(processInput)\n\n if args:\n cmd = args[0]\n if hasattr(__main__, cmd):\n res = getattr(__main__, cmd)(*args[1:])\n pprint(res)\n return\n\n if args:\n mask, = args\n mastermain(mask)\n else:\n mastermain()\n\ndef mastermain(mask=None):\n files = [f for f in os.listdir('.') if f.endswith('.in')]\n if not files:\n raise Exception(\"No .in file found\")\n\n if mask is None:\n fn = max(files, key=os.path.getmtime)\n else:\n matches = [f for f in files if mask in f]\n if not matches:\n raise Exception(\"No .in file matched %r\" % mask)\n if len(matches) > 1:\n raise Exception(\"Too many .in file matched %r: [%s]\"\n % (mask, ', '.join(matches)))\n fn, = matches\n\n print \"Processing input from %r...\" % fn\n\n root = fn[:-2]\n infn = root+'in'\n tmpfn = root+'tmp'\n outfn = root+'out'\n goodfn = root+'good'\n assert infn == fn\n\n with open(infn) as fdin:\n with open(tmpfn, 'wb') as fdout:\n start = time.time()\n kw = {}\n if OPTS.quiet:\n kw.update(stdout=open('/dev/null', 'w'))\n rc = subprocess.call(sys.argv +\n [ '--run', '--outfd=%d' % fdout.fileno()],\n stdin=fdin, **kw)\n tottime = time.time()-start\n\n print 'Done in %.3fs' % tottime\n if rc:\n print \"WITH EXITCODE %d\" % rc\n return\n\n os.rename(tmpfn, outfn)\n if os.path.exists(goodfn):\n subprocess.call(['diff', '-sdu', goodfn, outfn])\n else:\n print '>>> %s' % outfn\n with open(outfn, 'r') as fd:\n sys.stdout.write(fd.read())\n print '<<< %s' % outfn\n\n print 'Done in %.3fs' % tottime\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6cdc2697073ae22f2cc2d61aca4cb469", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "Python 2", "source_code": "def gcd(a, b):\n if a % b == 0:\n return b\n else:\n return gcd(b, a%b)\nn, m, x, y, a, b = map(int, raw_input().split())\nd = gcd(a, b)\na = a/d\nb = b/d\n\nk = min(n/a, m/b)\ndx = k*a\ndy = k*b\nx1 = 0\nx2 = 0\ny1 = 0\ny2 = 0\n\nif x-(dx/2+dx%2) <=0:\n x1 = 0\n x2 = dx\nelse:\n x1 = x-(dx/2+dx%2)\n x2 = x+dx/2\nif y-(dy/2+dy%2) <=0:\n y1 = 0\n y2 = dy\nelse:\n y1 = y-(dy/2+dy%2)\n y2 = y+dy/2\n\nprint x1, y1, x2, y2\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5678067d81064f56711ded513632e0e3", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "\n\ndef gcd(a, b):\n return b if a % b == 0 else gcd(b, a % b)\n\n\n\nt = raw_input().split(' ')\nn = int(t[0])\nm = int(t[1])\nx = int(t[2])\ny = int(t[3])\na = int(t[4])\nb = int(t[5])\n\nt = gcd(max(a, b), min(a, b))\na /= t\nb /= t\n\nt = min(n / a, m / b)\na *= t\nb *= t\n\ndx = min(n - x, a / 2)\ndx = a - dx\n\ndy = min(m - y, b / 2)\ndy = b - dy\n\nprint x - dx, y - dy, x - dx + a, y - dy + b\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "766a0dbd1035670d547af2c964bc675a", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "\ndef gcd(a, b):\n\treturn a if b == 0 else gcd(b, a % b)\n\nn, m, x, y, a, b = map(int, raw_input().strip().split())\ng = gcd(a, b)\na /= g\nb /= g\ns = min(n / a, m / b)\na *= s\nb *= s\nx1 = x - (a + 1) / 2\ny1 = y - (b + 1) / 2\nx2 = x1 + a\ny2 = y1 + b\n\nprint x1, y1, x2, y2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1df7d2cf648b65ef7015faf77876568", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\nfrom fractions import gcd\n\nwith sys.stdin as fin, sys.stdout as fout:\n n, m, x, y, a, b = map(int, next(fin).split())\n \n d = gcd(a, b)\n a //= d\n b //= d\n\n k = n // max(a, b)\n w = k * a\n h = k * b\n\n x1 = x - (w + 1) // 2\n y1 = y - (h + 1) // 2\n\n print(x1, y1, x1 + w, y1 + h)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4aa42bffa2cfd714be1c9ca11935db3b", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "import sys\nfrom fractions import gcd\n\nwith sys.stdin as fin, sys.stdout as fout:\n n, m, x, y, a, b = map(int, next(fin).split())\n \n d = gcd(a, b)\n a //= d\n b //= d\n\n k = min(n // a, m // b) # >_<\n w = k * a\n h = k * b\n\n best = tuple([float('inf')] * 3)\n for add1 in 0, 1:\n for add2 in 0, 1:\n x1 = x - w // 2 - add1\n y1 = y - h // 2 - add2\n cur = ((x1 + w / 2 - x) ** 2 + (y1 + h / 2 - y) ** 2, x1, y1)\n if cur < best:\n best = cur\n\n print(best[1], best[2], best[1] + w, best[2] + h)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa02173277170688ac88eec42158eda6", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "PyPy 3-64", "source_code": "pa, ta = map(int, input().split())\r\npb, tb = map(int, input().split())\r\nh, s = map(int, input().split())\r\n \r\ndp = [10**18] * (h+1)\r\ndp[0] = 0\r\nfor hh in range(1, h+1):\r\n for _ in range(2):\r\n for i in range(hh//(pa - s) + 1):\r\n now = i * ta\r\n j = now // tb\r\n idx = hh - i * (pa - s) - j * (pb - s)\r\n if idx < 0:\r\n dp[hh] = min(dp[hh], dp[max(idx, 0)] + now)\r\n \r\n nxt = max(ta, tb - now%tb)\r\n idx -= (pa + pb - s)\r\n dp[hh] = min(dp[hh], dp[max(idx, 0)] + now + nxt)\r\n \r\n pa, pb = pb, pa\r\n ta, tb = tb, ta\r\n \r\n# print(dp)\r\nprint(dp[h])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b607491e610cae78d50e05dcefd922fb", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "PyPy 3-64", "source_code": "pa, ta = map(int, input().split())\r\npb, tb = map(int, input().split())\r\nh, s = map(int, input().split())\r\n\r\nans = 10**18\r\ndp = [10**18] * (h+1)\r\ndp[0] = 0\r\nfor hh in range(h+1):\r\n # propagate dp[hh]\r\n for _ in range(2):\r\n for i in range(1, h // (pa - s) + 5):\r\n now = i * ta\r\n j = now // tb\r\n\r\n nxt = hh + i * (pa - s) + j * (pb - s)\r\n if nxt >= h:\r\n ans = min(ans, dp[hh] + now)\r\n \r\n nxt += pa + pb - s\r\n nxt = min(nxt, h)\r\n dp[nxt] = min(dp[nxt], dp[hh] + now + tb - now%tb)\r\n \r\n nxt = min(h, hh + pa + pb - s)\r\n dp[nxt] = min(dp[nxt], dp[hh] + max(ta, tb))\r\n \r\n pa, pb = pb, pa\r\n ta, tb = tb, ta\r\n\r\n# print(dp)\r\n\r\nans = min(ans, dp[h])\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f75edf699376736872b9eba80e21837", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "PyPy 3-64", "source_code": "from math import gcd\r\nimport sys\r\nimport io\r\nimport os\r\n\r\n\r\n# region IO\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(io.IOBase):\r\n newlines = 0\r\n\r\n def __init__(self, file):\r\n self._file = file\r\n self._fd = file.fileno()\r\n self.buffer = io.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\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\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\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\n\r\n\r\nclass IOWrapper(io.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\n\r\n\r\ndef print(*args, **kwargs):\r\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n at_start = True\r\n for x in args:\r\n if not at_start:\r\n file.write(sep)\r\n file.write(str(x))\r\n at_start = False\r\n file.write(kwargs.pop(\"end\", \"\\n\"))\r\n if kwargs.pop(\"flush\", False):\r\n file.flush()\r\n\r\n\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\n\r\ndef input(): return sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\ndef read_int_list():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef read_int_tuple():\r\n return tuple(map(int, input().split()))\r\n\r\n\r\ndef read_int():\r\n return int(input())\r\n\r\n\r\n# endregion\r\n\r\n# region local test\r\n# if 'AW' in os.environ.get('COMPUTERNAME', ''):\r\n# test_no = 2\r\n# f = open(os.path.dirname(__file__) + f'\\\\in{test_no}.txt', 'r')\r\n\r\n# def input():\r\n# return f.readline().rstrip(\"\\r\\n\")\r\n# endregion\r\n\r\n\r\np1, t1 = read_int_tuple()\r\np2, t2 = read_int_tuple()\r\nh, s = read_int_tuple()\r\nps1, ps2 = p1 - s, p2 - s\r\n\r\ndp = [0] + [1 << 60] * h\r\nfor x in range(1, h + 1):\r\n r1 = t1 + dp[0 if x < ps1 else x - ps1]\r\n r2 = t2 + dp[0 if x < ps2 else x - ps2]\r\n dp[x] = r1 if r1 < r2 else r2\r\n for _ in range(2):\r\n for c in range(1, x + 1):\r\n if c * t1 >= t2:\r\n dmg = (c - 1) * ps1 + (c * t1 - t2) // t2 * ps2 + (ps1 + p2)\r\n rt = c * t1 + dp[0 if x < dmg else x - dmg]\r\n if dp[x] > rt: dp[x] = rt\r\n \r\n p1, t1, p2, t2 = p2, t2, p1, t1\r\n\r\nprint(dp[h])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71100d80faf1c1d2b507bc8ab71ca8e6", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "PyPy 3-64", "source_code": "#from math import ceil, floor #, gcd, log, factorial, comb, perm,\r\n#log10, log2, log, sin, asin, tan, atan, radians\r\n#from heapq import heappop,heappush,heapify #heappop(hq), heapify(list)\r\n#from collections import defaultdict as dd\r\n#mydd=dd(list) for .append\r\n#from collections import deque as dq #deque e.g. myqueue=dq(list)\r\n#append/appendleft/appendright/pop/popleft\r\n#from bisect import bisect as bis #a=[1,3,4,6,7,8] #bis(a,5)-->3\r\n#import bisect #bisect.bisect_left(a,4)-->2 #bisect.bisect(a,4)-->3\r\n#import statistics as stat # stat.median(a), mode, mean\r\n#from itertools import permutations(p,r)#combinations(p,r)\r\n#combinations_with_replacement#combinations(p,r) gives r-length tuples,\r\n#in sorted order, with repeated elements#product gives outer product combos\r\nimport sys\r\ninput = sys.stdin.readline\r\n#print = sys.stdout.write\r\n#sys.setrecursionlimit(100000) #default is 1000 \r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split()))) #.split(','), default is space\r\n#list([0,*map(int,input().split(\" \"))]) # pad a zero to avoid zero indexing\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n####################################################\r\nt=1\r\n#t = int(input())\r\nfor tc in range(t):\r\n p1,t1=map(int, input().split())\r\n p2,t2=map(int, input().split())\r\n h,s=map(int, input().split())\r\n if t2(p1-s)/t1:#wait\r\n \r\n else:#don't wait\r\n d=(p1-s)/t1+(p2-s)\r\n ans=0\r\n print(ans)\r\n \r\n#print(*ans,sep=' ')##print(\"{:.3f}\".format(ans)+\"%\")\r\n#:b binary :% eg print(\"{:6.2%}\".format(ans))\r\n#print(\" \".join(str(i) for i in ans))\r\n#print(\" \".join(map(str,ans))) #seems faster\r\n#print(a[0] if a else 0)\r\n#prefixsum a=[a1...an] #psa=[0]*(n+1)\r\n#for i in range(n): psa[i+1]=psa[i]+a[i]\r\n#sum[:ax]=psa[x+1] e.g. sum 1st 5 items in psa[5]\r\n#ASCII<->number ord('f')=102 chr(102)='f'\r\n#def binary_search(li, val, lb, ub):\r\n# while ((ub-lb)>1):\r\n# mid = (lb + ub) // 2\r\n# if li[mid] >= val:\r\n# ub = mid\r\n# else:\r\n# lb = mid\r\n# return lb+1 #return index of elements val:\r\n# ub = mid - 1\r\n# elif val > li[mid]:\r\n# lb = mid + 1\r\n# else:\r\n# ans = mid # return index\r\n# break\r\n# return ans\r\n##########\r\n#def pref(li):\r\n# pref_sum = [0]\r\n# for i in li:\r\n# pref_sum.append(pref_sum[-1] + i)\r\n# return pref_sum\r\n##########\r\n#def suff(li):\r\n# suff_sum = [0]\r\n# for i in range(len(li)-1,-1,-1):\r\n# suff_sum.insert(0,suff_sum[0] + li[i])\r\n# return suff_sum\r\n#############\r\n#def maxSubArraySumI(arr): #Kadane's algorithm with index\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# start=0;end=0;s=0\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:\r\n# max_till_now=max_ending\r\n# start=s;end=i\r\n# if max_ending<0:\r\n# max_ending=0\r\n# s=i+1\r\n# return max_till_now,start,end\r\n############# avoid max for 2 elements - slower than direct if\r\n#def maxSubArraySum(arr): #Kadane's algorithm\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:max_till_now=max_ending\r\n# if max_ending<0:max_ending=0\r\n# return max_till_now\r\n#############\r\n#def findbits(x):\r\n# tmp=[]\r\n# while x>0:tmp.append(x%2);x//=2\r\n# tmp.reverse()\r\n# return tmp\r\n##############Dijkstra algorithm example\r\n#dg=[999999]*(n+1);dg[n]=0;todo=[(0,n)];chkd=[0]*(n+1)\r\n#while todo:#### find x with min dg in todo\r\n# _,x=hq.heappop(todo)\r\n# if chkd[x]:continue\r\n# for i in coming[x]:going[i]-=1\r\n# for i in coming[x]:\r\n# tmp=1+dg[x]+going[i]\r\n# if tmp5 #bisect.bisect_left(li,4)-->2\r\n###############\r\n##def chkprime(x):\r\n## if x==2 or x==3:return True\r\n## if x%2==0 or x<2:return False\r\n## for i in range(3,int(x**0.5)+1,2):\r\n## if x%i==0:return False\r\n## return True\r\n############### two factoring functions, seems to have the same performance\r\n##def factors(n):\r\n## f=[];t=2\r\n## while n>1:\r\n## if n%t==0:\r\n## f.append(t);n//=t;t=2\r\n## else:\r\n## t+=1\r\n## if t*t>n:f.append(n);break\r\n## return f\r\n##################\r\n##def factors(n):\r\n## f=[]\r\n## while n > 1:\r\n## for i in range(2, int((n+0.02)**0.5)+1):\r\n## if n%i==0:f.append(i);n//=i;break\r\n## else:\r\n## f.append(n);n=1\r\n## return f\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ff46b4a2ff023434dd7fee60dd306241", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "PyPy 3-64", "source_code": "from sys import stdin\r\n\r\ndef solve():\r\n p1, t1 = map(int, stdin.readline().split())\r\n p2, t2 = map(int, stdin.readline().split())\r\n h, s = map(int, stdin.readline().split())\r\n\r\n dp = [float('inf')] * h\r\n dp[0] = 0\r\n\r\n best_time = float('inf')\r\n for i in range(h):\r\n if dp[i] == float('inf'):\r\n continue\r\n\r\n r1, r2 = t1, t2\r\n time = dp[i]\r\n dmg = i\r\n while dmg < h:\r\n # fire together\r\n together_time = time + max(r1, r2)\r\n together_damage = dmg + p1 + p2 - s\r\n if together_damage >= h:\r\n best_time = min(best_time, together_time)\r\n else:\r\n dp[together_damage] = min(dp[together_damage], together_time)\r\n\r\n # fire one independently\r\n dt = min(r1, r2)\r\n r1 -= dt\r\n r2 -= dt\r\n time += dt\r\n if r1 != r2:\r\n if not r1:\r\n dmg += p1 - s\r\n r1 = t1\r\n else:\r\n dmg += p2 - s\r\n r2 = t2\r\n \r\n best_time = min(best_time, time)\r\n \r\n print(best_time)\r\n\r\nsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ca39de04feaed48994c445dfc7e5aba", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "d = {\n '0': -1,\n '1': -1,\n '2': -1,\n '3': '3',\n '4': '6',\n '5': '9',\n '6': '4',\n '8', -1,\n '7': '7',\n '9': '5',\n}\n\ns = input()\nprint(\"Yes\" if list(s)[::-1] == list([d[c] for c in s]) else \"No\")", "lang_cluster": "Python", "compilation_error": true, "code_uid": "26d5aec602b2491ac604ef0ffcffcb15", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "d = {\n '0': -1,\n '1': -1,\n '2': -1,\n '3': '3',\n '4': '6',\n '5': '9',\n '6': '4',\n '7': '7',\n '9': -1,\n '9': '5',\n '0': -1,\n}\n\ns = input()\nprint(\"Yes\" if list(s)[::-1] == list([d[c] for c in s]) else \"No\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "46503a1f603b188c67fd4ed9af9a79d7", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "a=input()\nd={\"0\":\"8\",\"1\":\"-\",\"2\":\"-\",\"3\":\"3\",\"4\":\"6\",\"5\":\"9\",\"6\":\"4\",\"7\":\"7\",\"8\":\"0\",\"9\":\"5\"}\nfor i in range(len(a)):\n if d[i]!=a[len(a)-i-1]:\n print(\"No\")\n exit(0)\nprint(\"Yes\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d5a8b3eed21fde3ef021a33102adc53", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "m=[8,-1,-1,3,6,9,4,7,0,5]\na=input()\nl=len(a)\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04da22aa89c9836d2167936724e8d7c1", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n=str(input())\ns=''\nfor i in range(len(n)):\n\tif(n[i]=='1' or n[2]=='2'):\n\t\ts=s+'.'\n\telif(n[i]=='3' or n[i]=='7'):\n\t\ts=s+n[i]\n\telif(n[i]=='4'):\n\t\ts=s+'6'\n\telif(n[i]=='6'):\n\t\ts=s+'6'\n\telif(n[i]=='5'):\n\t\ts=s+'9'\n\telif(n[i]=='9'):\n\t\ts=s+'9'\n\telif(n[i]=='0'):\n\t\ts=s+'8'\n\telif(n[i]=='8'):\n\t\ts=s+'8'\nj=len(s)-1\nk=0\nfor i in range(len(s)):\n\tif(s[i]=='.'):\n\t\tk=1\n\t\tbreak\n\telif(s[i]!=s[j]):\n\t\tk=1\n\t\tbreak\n\telse:\n\t\tpass\n\tj-=1\nif(k==1):\n\tprint(\"No\")\nelse:\n\tprint(\"Yes\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ded349e78a7d995129f976f9e7d76dd9", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n\"\"\"\"\"\"\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct, zip\nelse:\n _str = str\n str = lambda x=b\"\": x if type(x) is bytes else _str(x).encode()\n\n\ndef main():\n n, m = map(int, input().split())\n k = [int(x) for x in input().split()]\n\n d = [set() for _ in range(2 * 10**5 + 1)]\n for j in range(m):\n dj, tj = map(int, input().split())\n d[dj - 1].add(tj - 1)\n\n def cond(x):\n cash = x\n offset = 0\n _k = k[:]\n for i in reversed(range(x)):\n for j in d[i]:\n while cash and _k[j]:\n _k[j] -= 1\n cash -= 1\n if cash == i + 1:\n cash -= 2\n offset += 1\n return 2 * (sum(_k) - offset) <= cash\n\n lo, hi = 0, 2 * 10**5 + 1\n while lo < hi:\n mi = (hi + lo) // 2\n if cond(mi):\n hi = mi\n else:\n lo = mi + 1\n\n print(lo)\n\n\n# region fastio\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._buffer = BytesIO()\n self._fd = file.fileno()\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 if self._buffer.tell():\n return self._buffer.read()\n return os.read(self._fd, os.fstat(self._fd).st_size)\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\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n sep, file = kwargs.pop(\"sep\", b\" \"), 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\", b\"\\n\"))\n if kwargs.pop(\"flush\", False):\n file.flush()\n\n\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a058da353918a0e6ab283860115762f8", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\n\nDEBUG = False\n\nif DEBUG:\n inf = open(\"input.txt\")\nelse:\n inf = sys.stdin\n\nN, M = list(map(int, inf.readline().split(' ')))\nn_items = list(map(int, inf.readline().split(' ')))\nsales = []\nfor _ in range(M):\n sale = list(map(int, inf.readline().split(' ')))\n sales.append(sale)\n\nsales = sorted(sales, key=lambda x: x[0])\n\n# print(N, M)\n# print(n_items)\n# print(sales)\n# last_sales = [0 for _ in range(N)] # last sale day\nlast_sales = {k: -1 for k in range(N+1)} # for convenience ...\nfinal_sol = 99999999\n\nfor i in range(M):\n sale_day, sale_type = sales[i]\n last_sales[sale_type] = sale_day\n if i != M-1: # not last sale\n if sales[i+1][0] == sale_day: # same sale day\n continue\n \n total = 0\n lasts = last_sales.items()\n lasts = sorted(lasts, key=lambda x: x[1]) # sort by day\n burle = 0\n before_lastday = -1\n for stype, last_sday in lasts:\n if stype == 0:\n continue\n if last_sday == -1:\n # non-sale item\n total += n_items[stype-1]*2\n continue\n \n if before_lastday == -1:\n burle = last_sday\n else:\n burle += last_sday - before_lastday\n before_lastday = last_sday\n\n bought = min(burle, n_items[stype-1])\n left = n_items[stype-1] - bought\n burle -= bought\n total += bought + 2*left\n \n # print(sale_day, total)\n sol = max(sale_day, total)\n if final_sol > sol:\n final_sol = sol\n\nprint(final_sol)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84de71a5b88b377f81329e0c095db622", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "import sys,os,math\nfrom collections import Counter, defaultdict\nimport bisect\nfrom sys import stdin, stdout\nfrom itertools import repeat, izip\n\n\n# n, k = map(int, raw_input().split())\n# da = map(int, raw_input().split())\n# db = map(int, raw_input().split())\n\n\nn, m = map(int, raw_input().split())\nda = map(int, raw_input().split())\ndi = defaultdict(list)\ntotal = sum(da)\nfor i in xrange(m):\n a, b = map(int, raw_input().split())\n di[b].append(a)\nfor k in di:\n di[k].sort()\nl, r = 0, 2*total\nwhile l= tt*2:\n return 1\n else:\n return 0\n mid = (l+r)/2\n if ck(mid):\n r = mid\n else:\n l = mid + 1\nprint l\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4721f181211e59173b3ae1c781ee5eac", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n, m = input().split()\nn = int(n)\nm = int(m)\nnList = input().split()\nbList = [0] * len(nList)\nfor i in range(len(nList)):\n nList[i] = int(nList[i])\nshopD = {}\nshopT = {}\noHis = []\nmHis = []\nmaxD = 0\nfor i in range(m):\n d, t = input().split()\n if nList[int(t) - 1] != 0:\n maxD = max(maxD, int(d))\n if d not in shopD.keys():\n shopD.update({d: [int(t)]})\n else:\n if int(t) not in shopD[d]:\n shopD[d].append(int(t))\n if t not in shopT.keys():\n shopT.update({t: [int(d)]})\n else:\n if int(d) not in shopT[t]:\n shopT[t].append(int(d))\nfor i, j in shopT.items():\n j = list(dict.fromkeys(j))\n j.sort()\n shopT[i] = j\nfor i, j in shopD.items():\n j = list(dict.fromkeys(j))\n shopD[i] = j\ntotal = sum(nList)\ncoin = 0\nday = 0\ndef modifyMis(t, left):\n if left == 0:\n for ii in range(len(mHis))[::-1]:\n if mHis[ii]['t'] == t:\n mHis.pop(ii)\n else:\n for ii in range(len(mHis))[::-1]:\n if mHis[ii]['t'] == t:\n mHis[ii]['n'] = left\nwhile total > 0 and day < maxD:\n coin += 1\n day += 1\n oHis.append({'t': [], 'n': []})\n if str(day) in shopD.keys():\n for t in shopD[str(day)]:\n if nList[t - 1] > 0:\n if bList[t - 1] > 0 and shopT[str(t)][0] != day and coin > nList[t - 1] - bList[t - 1] and len(mHis) > 0 and coin > 0:\n i = 0\n j = 0\n while shopT[str(t)][i] < day:\n extraC = 0\n d = shopT[str(t)][i]\n if t in oHis[d - 1]['t']:\n indexT = oHis[d - 1]['t'].index(t)\n extraC += oHis[d - 1]['n'][indexT]\n bList[t - 1] -= oHis[d - 1]['n'][indexT]\n total += oHis[d - 1]['n'][indexT]\n oHis[d - 1]['t'].pop(indexT)\n oHis[d - 1]['n'].pop(indexT)\n while j < len(mHis) and mHis[j]['d'] < d:\n j += 1\n while extraC > 0 and len(mHis) > j:\n thisT = mHis[j]['t']\n thisD = mHis[j]['d']\n change = min(extraC, mHis[j]['n'])\n bList[thisT - 1] += change\n total -= change\n extraC -= change\n mHis[j]['n'] -= change\n modifyMis(thisT, nList[thisT - 1] - bList[thisT - 1])\n if thisT in oHis[thisD - 1]['t']:\n oHis[thisD - 1]['n'][oHis[thisD - 1]['t'].index(thisT)] += change\n else:\n oHis[thisD - 1]['t'].append(thisT)\n oHis[thisD - 1]['n'].append(change)\n i += 1\n coin += extraC\n buy = min(nList[t - 1] - bList[t - 1], coin)\n if buy != 0:\n oHis[day - 1]['t'].append(t)\n oHis[day - 1]['n'].append(buy)\n total -= buy\n bList[t - 1] += buy\n modifyMis(t, nList[t - 1] - bList[t - 1]) \n coin -= buy\n if nList[t - 1] - bList[t - 1] > 0:\n mHis.append({'d': day, 't': t, 'n': nList[t - 1] - bList[t - 1]}) \n if coin >= total * 2:\n break\nday += max(total * 2 - coin, 0)\nprint(day)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "16adeac38f27f3bbf071d9c9db6de156", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "def main():\n inp = readnumbers()\n ii = 0\n\n n = inp[ii]\n ii += 1\n\n m = inp[ii]\n ii += 1\n\n K = inp[ii:n+ii]\n ii += n\n\n types = [[] for _ in range(n)]\n for _ in range(m):\n types[inp[ii+1]-1].append(inp[ii] - 1)\n ii += 2\n \n for t in types:\n if t: t.sort()\n\n a = 0\n b = 4*10**5 + 10\n while a= 0 and A[ind]>=mid: ind -= 1\n \n if ind>=0:\n extra[A[ind]] += K[t]\n \n bought = 0\n money = 0\n for d in range(mid):\n money += 1\n while money and extra[d]:\n money -= 1\n bought += 1\n extra[d] -= 1\n\n left = sum(K) - bought\n if money >= left*2:\n b = mid\n else:\n a = mid + 1\n \n print a\n\n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\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 if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\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# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a9f67d475278fcfdbb83cb48571350c4", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "# Clever Fat Rat\nimport time\nfrom datetime import datetime\n\nimport itertools\n\nmax_oats = 10**6 + 1\n \ndef weight(p):\n return p[0]\n\ndef right(p):\n return p[1][1]\n\ndef left(p):\n return p[1][0]\n\ndef plus(l, r):\n return (weight(l)+weight(r), (left(l), right(r)))\n\n# 01 can cover 02?\ndef cover(o1, o2):\n return left(o1) >= left(o2) and right(o1) <= right(o2) and weight(o1) >= weight(o2)\n\ndef add_only_unique(oats, oat):\n for idx, o_n in enumerate(oats):\n if oat == o_n or cover(o_n, oat):\n return oats\n if cover(oat, o_n):\n oats[idx] = oat\n return oats\n oats.append(oat)\n return oats\n\ndef max_drop(oats):\n max_drop = 0\n for oat in oats:\n max_drop = weight(oat) if weight(oat) > max_drop else max_drop\n return max_drop\n\ndef possible_oats(a, ws):\n oats_list = []\n for idx in range(0, len(a)-1): # same as len(ws)\n oats = []\n left_oat = a[idx]\n right_only_oat = [e for e in a[idx+1] if not e in left_oat ]\n left_only_oat = [e for e in a[idx] if not e in a[idx+1] ]\n\n if ((len(a[idx+1]) == 0) or\n (idx != len(a)-2 and max_drop(a[idx+1])+max_drop(a[idx+2]) >= ws[0][idx+1])):\n for l in left_oat:\n if weight(l) >= ws[0][idx]:\n oats.append(l)\n \n if ((len(a[idx]) == 0) or\n (idx != 0 and len(oats_list[-1]) != 0)):\n for r in right_only_oat:\n if weight(r) >= ws[0][idx]:\n oats = add_only_unique(oats, r)\n \n for c in itertools.product(left_only_oat,right_only_oat):\n (l,r) = c\n if weight(r)+weight(l) >= ws[0][idx] and right(l) < left(r):\n oats = add_only_unique(oats, plus(l,r))\n\n if len(oats) > 30:\n oats.sort(key=weight, reverse=True) \n oats = oats[:30]\n oats_list.append(oats) \n return oats_list\n \ndef is_break_all(limit, oats_list):\n for idx, oat in enumerate(oats_list):\n for o in oat:\n if weight(o) >= limit[idx]:\n return True\n return False\n \ndef fatrat(state):\n# print state\n\n (a, ws) = state\n ws = map(lambda x: [max_oats]+x+[max_oats], ws)\n\n goal_oats = []\n pre_goal_oat = [0, 0]\n for idx in range(len(ws)-1,-1,-1):\n goal_oat = []\n for jdx in range(1,len(ws[idx])-1):\n goal_oat.append(max(ws[idx][jdx],min(pre_goal_oat[jdx-1], pre_goal_oat[jdx])))\n goal_oats.append(goal_oat)\n pre_goal_oat = [max_oats] + goal_oat + [max_oats]\n goal_oats.reverse()\n ws = map(lambda x: x[1:-1], ws)\n\n oats_list = []\n for idx in range(0, len(a)):\n if a[idx] >= ws[0][idx]:\n oats_list.append([(a[idx], (idx,idx))])\n else:\n oats_list.append([])\n \n while(True):\n ws = ws[1:]\n if not len(ws):\n if len(oats_list[0]):\n return \"Cerealguy\"\n else:\n return \"Fat Rat\"\n \n if is_break_all(goal_oats[0], oats_list):\n return \"Cerealguy\"\n \n oats_list = possible_oats(oats_list, ws)\n goal_oats = goal_oats[1:]\n \n \ndef create_goals(ws):\n ws = map(lambda x: [max_oats]+x+[max_oats], ws)\n\n goal_oats = []\n pre_goal_oat = [0, 0]\n for idx in range(len(ws)-1,-1,-1):\n goal_oat = []\n for jdx in range(1,len(ws[idx])-1):\n goal_oat.append(max(ws[idx][jdx],min(pre_goal_oat[jdx-1], pre_goal_oat[jdx])))\n goal_oats.append(goal_oat)\n pre_goal_oat = [max_oats] + goal_oat + [max_oats]\n goal_oats.reverse()\n# ws = map(lambda x: x[1:-1], ws)\n return goal_oats\n# print goal_oats\n\ndef compare_goal(goals, oats):\n for idx in range(0,len(goals)):\n if(goals[idx] <= oats[idx]):\n return True\n return False\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(((a, ws)))\nelse:\n worst_w = [[50]]\n for idx in range(1,50):\n worst_w.append([1]*(idx+1))\n worst_w.reverse()\n# print fatrat(([1]*50, worst_w)) #F\n \n assert fatrat(([1,1,1,1,1,1,1],[[1,9,1,9,1,9,9],[1,9,1,9,1,9],[1,1,9,1,9],[1,9,9,1],[1,9,1],[1,1],[3]])) == \"Cerealguy\"\n assert fatrat(([1, 1, 2, 2, 1, 1], [[1, 1, 2, 2, 1, 1],[2, 4, 2, 4, 2],[2,2,2,2],[4,10,4],[4,4],[8]])) == \"Fat Rat\"\n assert fatrat(([1, 1, 1], [[1, 1, 1],[1, 1],[4]])) == \"Fat Rat\" #F\n assert fatrat(([2, 2, 2], [[2, 2, 2],[3, 2],[4]])) == \"Cerealguy\" #C\n assert fatrat(([1], [[1]])) == \"Cerealguy\" #C\n assert fatrat(([2, 2], [[1, 2],[4]])) == \"Cerealguy\" #C\n assert fatrat(([2, 2], [[1, 2],[5]])) == \"Fat Rat\" #F\n print \"great!\"\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d104423ce02194e0af65be4e139f853", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.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 if len(a) == 42:\n for idx in range(12,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\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\na =( [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\nw0=( [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])\nW1=( [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...\nw2=( [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\nw3= ([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\nw4=([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\nw5=([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\nw6=(\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\nw7= ([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\nw8=([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\nw9=([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\nw10=([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\nw11=([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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de617107d94f65ba14311720ddf9c205", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "# Clever Fat Rat\nimport time\nfrom datetime import datetime\n\nimport itertools\n\nmax_oats = 10**6 + 1\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 print break_list\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 \ndef weight(p):\n return p[0]\n\ndef right(p):\n return p[1][1]\n\ndef left(p):\n return p[1][0]\n\ndef plus(l, r):\n return (weight(l)+weight(r), (left(l), right(r)))\n\n# 01 can cover 02?\ndef cover(o1, o2):\n return left(o1) >= left(o2) and right(o1) <= right(o2) and weight(o1) >= weight(o2)\n\ndef unique(oats):\n new_oats = []\n for o in oats:\n# if o not in new_oats:\n should_add = True\n for idx, o_n in enumerate(new_oats):\n if o == o_n or cover(o_n, o):\n should_add = False \n break\n if cover(o, o_n):\n should_add = False \n new_oats[idx] = o\n if(should_add):\n new_oats.append(o)\n return new_oats\n \n\ndef possible_oats(a, ws):\n oats_list = []\n for idx in range(0, len(a)-1): # same as len(ws)\n oats = []\n for l in a[idx]:\n if weight(l) >= ws[0][idx]:\n oats.append(l)\n for r in a[idx+1]:\n if weight(r) >= ws[0][idx]:\n oats.append(r)\n for c in itertools.product(a[idx],a[idx+1]):\n (l,r) = c\n if weight(r)+weight(l) >= ws[0][idx] and right(l) < left(r):\n oats.append(plus(l,r))\n oats = unique(oats)\n oats_list.append(oats) \n return oats_list\n \ndef is_break_all(limit, oats_list):\n for oat in oats_list:\n for idx, o in enumerate(oat):\n if weight(o) >= limit[idx]:\n return True\n return False\n \ndef fatrat(state):\n# print state\n\n (a, ws) = state\n if len(a) == 11:\n return \"Fat Rat\"\n\n \n ws = map(lambda x: [max_oats]+x+[max_oats], ws)\n\n goal_oats = []\n pre_goal_oat = [0, 0]\n for idx in range(len(ws)-1,-1,-1):\n goal_oat = []\n for jdx in range(1,len(ws[idx])-1):\n goal_oat.append(max(ws[idx][jdx],min(pre_goal_oat[jdx-1], pre_goal_oat[jdx])))\n goal_oats.append(goal_oat)\n pre_goal_oat = [max_oats] + goal_oat + [max_oats]\n goal_oats.reverse()\n ws = map(lambda x: x[1:-1], ws)\n# print goal_oats\n\n oats_list = []\n for idx in range(0, len(a)):\n if a[idx] >= ws[0][idx]:\n oats_list.append([(a[idx], (idx,idx))])\n else:\n oats_list.append([])\n \n repeat = 0\n while(True):\n ws = ws[1:]\n if not len(ws):\n if len(oats_list[0]):\n return \"Cerealguy\"\n else:\n return \"Fat Rat\"\n\n if is_break_all(goal_oats[0], oats_list):\n return \"Cerealguy\"\n \n oats_list = possible_oats(oats_list, ws)\n goal_oats = goal_oats[1:]\n# print oats_list\n\n# repeat +=1\n# if repeat > 20:\n# print oats_list\n# return \"Finish\"\n \n \n \n \n \n \ndef fatrat3(state):\n# print state\n (a, ws) = state\n \n\n \n# if len(a) == 42:\n# for idx in range(39,42):\n# print ws[idx]\n \n# print ws[1][0:20]\n# print ws[1][20:41]\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 print len(ws)\n print len(a_list)\n print\n# print a_list[0:20]\n if len(a_list) > 100:\n break\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 = [max_oats]\n rs = []\n for e_rs in r:\n rs += [int(e_rs)]\n# rs += max_oats\n ws += [rs]\n# print fatrat(n, a, ws)\n print fatrat(((a, ws)))\nelse:\n# print fatrat(([2, 2, 2], [[2, 2, 2],[3, 2],[4]])) #C\n# print fatrat(([1], [[1]])) #C\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 w =[0]*42\n w[0]=( [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# w1 = ([806141, 604957, 444979, 92612, 722708, 474069, 634935, 49008, 727286, 15642, 757260, 163229, 242680, 662984, 151936, 302866, 970105, 42818, 86986, 542819, 152685]\n#[765593, 147600, 186480, 720359, 234733, 364648, 8995, 884055, 565526, 558538, 319000, 388...\n w[1] = ([765593, 147600, 186480, 720359, 234733, 364648, 8995, 884055, 565526, 558538, 319000, 388544, 274611, 872762, 244955, 981313, 877169, 440983, 367837, 367936]\n + [806141, 604957, 444979, 92612, 722708, 474069, 634935, 49008, 727286, 15642, 757260, 163229, 242680, 662984, 151936, 302866, 970105, 42818, 86986, 542819, 152685])\n\n w[2]=( [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 w[3]= ([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 w[4]=([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 w[5]=([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 w[6]=(\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 w[7]= ([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 w[8]=([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 w[9]=([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 w[10]=([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 w[11]=([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 w[12] = [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 w[13] = [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 w[14]=[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 w[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 w[16]=[406560, 631571, 780422, 992747, 904507, 669339, 120822, 171670, 667218, 377506, 620268, 569831, 150401, 606727, 427415, 149877, 467369, 558074, 701300, 941164, 905161, 621807, 105600, 109208, 227333, 278783]\n w[17]=[844232, 600660, 956873, 275867, 943068, 825161, 895623, 436781, 797538, 72677, 546140, 158861, 475846, 930202, 119313, 70300, 894159, 977232, 72700, 731713, 575949, 152873, 737159, 830782, 65071]\n w[18]=[237486, 549512, 427886, 634225, 662555, 1168, 679325, 898994, 922755, 757632, 664644, 637155, 527137, 507924, 980575, 388955, 210941, 125059, 22317, 78152, 38200, 739583, 554051, 627713]\n w[19]=[479028, 892887, 24398, 430711, 392354, 172860, 835107, 14025, 685353, 867105, 40260, 188534, 475120, 432763, 315378, 632428, 97800, 678056, 637610, 606208, 221689, 756844, 982589]\n w[20]=[496311, 545320, 850902, 922063, 260033, 790113, 586049, 527404, 349253, 221895, 828342, 465666, 633175, 282389, 519791, 331199, 728647, 567952, 2615, 162184, 714835, 235531]\n w[21]=[186477, 32274, 159996, 18134, 428838, 997537, 290934, 736388, 681330, 933659, 158840, 221272, 113015, 443400, 254260, 225996, 711610, 257129, 157857, 458557, 87869]\n w[22]=[601009, 200243, 37750, 427458, 155172, 379052, 313175, 219565, 161355, 632012, 541089, 436743, 196945, 780260, 562593, 479, 977598, 261257, 459383, 188043]\n w[23]=[397, 325219, 455107, 109068, 14827, 610661, 275371, 915727, 386383, 761111, 574986, 371344, 639217, 380366, 910264, 143066, 89832, 111998, 900082]\n w[24]=[54569, 953315, 43302, 252838, 348912, 495555, 823785, 117598, 949, 228308, 699837, 421190, 302746, 843111, 189564, 330203, 411320, 382797]\n w[25]=[285720, 115251, 233252, 448050, 374380, 478883, 644371, 21203, 879789, 5904, 534234, 486941, 73215, 738517, 214733, 114020, 753636]\n w[26]=[674062, 749897, 823484, 423759, 75711, 302798, 112824, 642967, 508005, 530628, 866877, 950023, 649878, 761438, 473985, 474066]\n w[27]=[764631, 542492, 923110, 543523, 771130, 380714, 749869, 488147, 391730, 58854, 709912, 984884, 156149, 574527, 865313]\n w[28]=[285322, 581452, 403449, 558544, 440730, 791866, 963533, 797693, 557146, 188615, 805740, 869602, 58823, 974248]\n w[29]=[541348, 328412, 178390, 827724, 8540, 807870, 861826, 343941, 825017, 837266, 74180, 685457, 162275]\n w[30]=[746285, 307489, 744197, 268642, 453102, 888605, 112405, 860770, 926547, 858125, 451650, 520853]\n w[31]=[750071, 509514, 692960, 418551, 57836, 476673, 681027, 636141, 1841, 259624, 120838]\n w[32]=[260295, 857040, 643083, 533047, 108837, 61847, 849988, 290, 137973, 706032]\n w[33]=[54921, 310584, 531482, 398431, 714080, 21340, 948456, 37528, 652013]\n w[34]=[913611, 142924, 415931, 772076, 351461, 16265, 459565, 738745]\n w[35]=[890204, 456669, 440916, 421772, 768120, 173826, 433774]\n w[36]=[358083, 892804, 903312, 679503, 168920, 921433]\n w[37]=[317439, 489653, 710322, 371652, 567242]\n w[38]=[75849, 947287, 694039, 831792]\n w[39]=[759605, 295166, 463625]\n w[40]=[539029, 755676]\n w[41]=[954370]\n\n print fatrat((a, w)) #C\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5952148a58e2cbcc0bb39846d686beb7", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t_old(n, m, rs, t, c_candy):\n candy = [0]*n\n candy[n-1] = min(rs[n-1], max_deliver(n, m, t))\n margin = int((candy[n-1] - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < candy[i+1]-t:\n candy[i] = rs[i]\n affect = (candy[i+1]-t) - rs[i]\n margin -= affect\n if margin < 0:\n for j in range(i+1, n):\n candy[j] += margin\n margin = 0\n else:\n candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return sum(candy)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n# margin = int((c_candy - (n*t*(t+1)/2))/t)\n# margin_max = m - (margin + n*t)\n# print margin_max\n# margin += margin_max\n margin = m - n*t\n\n \n margin_list = []\n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin_list.append((i, (c_candy-t) - rs[i]))\n# margin -= ((c_candy-t) - rs[i])\n# if margin < 0:\n# total_candy += margin * (n-i-1)\n# margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n \n if len(margin_list) != 0:\n for e in reversed(margin_list):\n margin -= e[1]\n if margin < 0:\n total_candy += margin * (n-e[0]-1)\n margin = 0\n\n# print str(t) + \" : \"\n# print total_candy\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n# if(n == 101 and m == 5000000):\n# for i in range(1, 5):\n# print rs[0:5]\n# return 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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# debug_print(max_times)\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n# debug_print(min_times)\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times+1):\n# for t in range(max_times, max_times+1): #TODO\n delta = datetime.now() - start\n if delta.seconds*1000 + delta.microseconds/1000 >= 2700:\n return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n# return max(candy4(n, m, rs), candy2(n, m, rs))\n return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_candy = 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 print max_times\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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n print candy(2, 5, [5,9]) #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]) # 72x\n print candy(5,12,[7,9,11,13,15]) # 55\n print candy(5,16,[27,18,21,24,36]) # 106x\n print candy(5,16,[27,18,21,24,36]) # 106\n print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n# print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n rubles = ([247339129, 247389396, 247446353, 247495527, 247546368] + [247602159, 247645280, 247703876, 247750078, 247797347] + [247856032, 247908447, 247958408, 247996873, 248048252] + [248097223, 248140491, 248193861, 248247271, 248287740] + [248340547, 248390641, 248442296, 248495005, 248540747]\n + [248588203, 248633576, 248679878, 248727906, 248778152]\n + [248834686, 248884260, 248934623, 248985221, 249027890]\n + [249073791, 249130322, 249177364, 249224415, 249281256]\n + [249329471, 249372932, 249416411, 249468968, 249517515]\n + [249568831, 249621847, 249672071, 249722002, 249775961]\n + [249830289, 249875511, 249917248, 249969414, 250010545]\n + [250058521, 250116878, 250173062, 250216782, 250269447]\n + [250314989, 250358944, 250410170, 250457769, 250507197]\n + [250562967, 250613919, 250669197, 250715639, 250767602]\n + [250824190, 250872072, 250921698, 250974805, 251021507]\n + [251074759, 251119267, 251180832, 251232458, 251284047]\n + [251328693, 251378206, 251431271, 251484542, 251522200]\n + [251569928, 251620331, 251672203, 251710044, 251756206]\n + [251813362, 251862127, 251913700, 251962562, 252017692]\n + [252070692, 252119132, 252177472, 252228770, 252289162])\n print candy(100,5000000,rubles)\n# print candy2(100,5000000,rubles)\n# print candy3(100,5000000,rubles)\n#450450000\n#252289162\n\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#[248340547, 248390641, 248442296, 248495005, 248540747]\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n#[227525418, 243823038, 228452426, 270756565, 238943623]\n#23034945207\n\n\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "adc2f135c6e2051d9da00e7a082d1cb7", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.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 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\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", "lang_cluster": "Python", "compilation_error": true, "code_uid": "43cb5d50b9d58ac1486b129dc0d02811", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.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\nn, t = map(int, input().split())\n\ndp = [[[0] * 5 for _ in range(2 * t + 1)] for _ in range(n)]\ndp[0][0] = [0] + [1] * 4\n\nfor i in range(n - 1):\n for j in range(min(2 * t, i + 1)):\n if (j & 1) == 0:\n for k in range(1, 4):\n for l in range(k + 1, 5):\n # //\n dp[i + 1][j][l] += dp[i][j][k]\n # /\\\n dp[i + 1][j + 1][l] += dp[i][j][k]\n else:\n for k in range(4, 1, -1):\n for l in range(k - 1, 0, -1):\n # \\\\\n dp[i + 1][j][l] += dp[i][j][k]\n # \\/\n dp[i + 1][j + 1][l] += dp[i][j][k]\n\nprint(sum(dp[-1][2 * t]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae0539ca0e4dce6fa53bee8085d8bee6", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "\nn, t = [int(x) for x in raw_input().strip().split()]\nc = []\nfor xn in xrange(n):\n c.append([])\n for xt in xrange(t + 1):\n c[xn].append([])\n for xh in xrange(4):\n c[xn][xt].append([0] * 2)\nfor xh in xrange(4):\n c[1][0][xh][1] = xh\nfor xn in xrange(2, n):\n for xt in xrange(t + 1):\n for xh in xrange(4):\n for p in xrange(xh):\n c[xn][xt][xh][1] += c[xn - 1][xt][p][0]\n c[xn][xt][xh][1] += c[xn - 1][xt][p][1]\n for p in xrange(xh + 1, 4):\n c[xn][xt][xh][0] += c[xn - 1][xt][p][0]\n if xt > 0: c[xn][xt][xh][0] += c[xn - 1][xt - 1][p][1]\ns = 0\nfor h in xrange(4):\n s += c[n - 1][t][h][0]\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "22414374ae9b675e1a360e27fe51a90f", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from math import factorial\ndef choose(n, c):\n return factorial(n) / factorial(c) / factorial(n - c)\n\ntab = {}\n#number of ways to draw t humps with n points, in which the 1st point's y-coordinate is y\ndef amount(y, n, t):\n #special case where t is 0 and n is 1\n #the reason we don't test for n == t == 0 is in the next recursion,\n #we start with bottom point, so it is repeated and there is at least 1 point\n if n == 1 and t == 0:\n return 1\n if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:\n return 0\n if (y, n, t) not in tab:\n res = 0\n for top in xrange(y + 1, 5):\n for bottom in xrange(1, top):\n for i in xrange(top - y):\n for j in xrange(top - bottom):\n res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)\n tab[(y, n, t)] = res\n return tab[(y, n, t)]\n\nn, t = map(int, raw_input().split())\nres = 0\nfor i in xrange(1, 4):\n res += amount(i, n, t)\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "82fc39bef694d2447ad846c65a6d18dc", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from math import factorial\ndef choose(n, c):\n return factorial(n) / factorial(c) / factorial(n - c)\n\ntab = {}\ndef amount(y, n, t):\n if n == 1 and t == 0:\n return 1\n if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:\n return 0\n if (y, n, t) not in tab:\n res = 0\n for top in xrange(y + 1, 5):\n for bottom in xrange(1, top):\n for i in xrange(top - y):\n for j in xrange(top - bottom):\n res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)\n tab[(y, n, t)] = res\n return tab[(y, n, t)]\n\nn, t = map(int, raw_input().split())\nres = 0\nfor i in xrange(1, 4):\n res += amount(i, n, t)\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "825c55ca86e525ae3c33b23e94756b3c", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.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\nn, t = map(int, input().split())\n\ndp = [[[0] * 5 for _ in range(2 * t + 1)] for _ in range(n)]\ndp[0][0] = [0] + [1] * 4\n\nfor i in range(n - 1):\n for j in range(min(2 * t, i + 1)):\n if (j & 1) == 0:\n for k in range(1, 4):\n for l in range(k + 1, 5):\n # \u2197\u2197\n dp[i + 1][j][l] += dp[i][j][k]\n # \u2197\u2198\n dp[i + 1][j + 1][l] += dp[i][j][k]\n else:\n for k in range(4, 1, -1):\n for l in range(k - 1, 0, -1):\n # \u2198\u2198\n dp[i + 1][j][l] += dp[i][j][k]\n # \u2198\u2197\n dp[i + 1][j + 1][l] += dp[i][j][k]\n\nprint(sum(dp[-1][2 * t]))\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "21f8a1496bdf7b0a0eeb42d014607ac0", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "a=int(input())\nb,c=10**100,a-45*50*10**99%a\nprint(c,c+b-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0f96bae9140217ec4807ca0e19f85374", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "a = int(input());\nt = 1000000000000000000000000000;\nd = 27 * 45 * 100000000000000000000000000;\nif (45 * d) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * d) % a), t + (a - (45 * d) % a) - 1);", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c227aa4d70919b1e32c0892c18eac3fa", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "a = int(input());\nt = 1000000000000000000000000000;\nd = 1111111111111111111111111111;\nif (45 * d) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * d) % a), t + (a - (45 * d) % a) - 1);", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b326ef44a269910bc7b5e6efc080fd46", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "#Thanks to http://codeforces.com/profile/ZhouYuChen\n\n\n'''def s(x):\n\tif(x==0):\n\t\treturn 0\n\treturn x+s(x-1)\n\n\ndef calc(x):\n\tm=1\n\tans=0\n\twhile(x):\n\t\tans2=s(x%10)\n\t\tx/=10\n\t\tans2+=(45*x)\n\t\tans2*=m\n\t\tans+=ans2\n\t\tm*=10\n\treturn ans\n\ndef bc(x):\n\tans=0\n\twhile(x):\n\t\tans+=x%10\n\t\tx/=10\n\treturn ans\n\ndef brute(x):\n\tans=0\n\twhile(x>0):\n\t\tans+=bc(x)\n\t\tx-=1\n\treturn ans\n\na=int((raw_input()))\nprint calc(a), brute(a) '''\n\na=int(raw_input())\ns=(45*(10**101))\nk=(a-s)%a\nprint k,(10**101)+k-1\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b77da26dd0da811ca3ed2f288b8b5f3b", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "a = input();\ns = 10**17\np = (45 * 18 * s) + 1) % a\nprint 1 + (a - p), s * 10 + (a - p)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "ee17e87bb49d4374039857a262bd9815", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "import itertools\n\ndef hash(cur):\n ret = []\n for _ in cur:\n #_.sort()\n ret.append(tuple(_))\n return tuple(ret)\n\ndef subsets(a,b,i=0,cur=[]):\n if i == len(a):\n #print cur,hash(cur)\n All.add(hash(cur))\n \n else:\n subsets(a,b,i+1,cur)\n if value[a[i]][b[i]] != 0:\n subsets(a,b,i+1,cur+[[a[i],b[i]]])\n \n \ndef val(marry):\n ret = 0\n for mar in marry:\n ret += value[mar[0]][mar[1]]\n return ret\n\ndata = open(\"P6.txt\")\nn,k,t = map(int,raw_input().split())\nvalue = [[0]*n for z in range(n)]\nfor _ in range(k):\n a,b,v = map(int,raw_input().split())\n a -= 1\n b -= 1\n value[a][b] = v\n #value[b][a] = v\n \nAll = set([])\nfor per in itertools.permutations(range(n)):\n subsets(per,range(n))\n\nvals = []\nfor _ in All: \n #print _,val(_)\n vals.append(val(_))\nvals.sort()\nprint vals[t-1]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e00fbe378cad78269ebe4b31c81b222", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.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 = True\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": "bfd87bc433ed665828fb8e5f8998ce8e", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n = 0\nk = 0\nt = 0\nP = {}\nused = []\n\ndef third(x, n=2):\n r = []\n for i in x:\n r.append(i[n])\n return r\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 for i in range(n):\n rec(i, 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": "b6d6f994c4e57a76379ff7ad1b185020", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import itertools\n\ndef hash(cur):\n ret = []\n for _ in cur:\n #_.sort()\n ret.append(tuple(_))\n return tuple(ret)\n\ndef subsets(a,b,i=0,cur=[]):\n if i == len(a):\n #print cur,hash(cur)\n All.add(hash(cur))\n \n else:\n subsets(a,b,i+1,cur)\n subsets(a,b,i+1,cur+[[a[i],b[i]]])\n \n \ndef val(marry):\n ret = 0\n for mar in marry:\n ret += value[mar[0]][mar[1]]\n return ret\n\n#data = open(\"P6.txt\")\nn,k,t = map(int,raw_input().split())\nvalue = [[0]*n for z in range(n)]\nfor _ in range(k):\n a,b,v = map(int,raw_input().split())\n a -= 1\n b -= 1\n value[a][b] = v\n #value[b][a] = v\n \nAll = set([])\nfor per in itertools.permutations(range(n)):\n subsets(per,range(n))\n\nvals = []\nfor _ in All: \n #print _,val(_)\n vals.append(val(_))\nvals.sort()\nprint(vals[t-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4add4029a901224cad011ea5dcd8064e", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python2\n\nfrom itertools import permutations\n\ndef read_ints():\n\treturn map(int, raw_input().split())\n\n\nn, k, t = read_ints()\n\nvalid_pairs = []\npair_values = {}\n\nfor i in range(k):\n\th, w, r = read_ints()\n\tvalid_pairs.append((h, w))\n\tpair_values[(h, w)] = r\n\nvalid_pairs = set(valid_pairs)\n\nvarieties = [0]\nfor perm in permutations(range(1, n + 1)):\n\tfor mask in range(0, 2 ** n):\n\t\tmask = ('%0' + str(n) + 'd') % int(bin(mask)[2:])\n#\t\tprint mask\n\t\tvalue = 0\n\t\tfor i in range(1, n + 1):\n\t\t\tif mask[i - 1] == '1' and (i, perm[i - 1]) not in valid_pairs:\n\t\t\t\tvalue = -10 ** 9\n\t\t\telif mask[i - 1] == '1':\n\t\t\t\tvalue += pair_values[i, perm[i - 1]]\n\t\tif value > 0:\n#\t\t\tprint perm\n\t\t\tvarieties.append(value)\n\nvarieties.sort(reverse=False)\n\n#print varieties\nprint varieties[t - 1]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d2f2e15ea078ddd726df133713b4b71", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "l = [[1, 1, 1],\n [1, 1, 1],\n [1, 1, 1]]\ns = [[int(i) for i in input().split()],\n [int(i) for i in input().split()],\n [int(i) for i in input().split()]]\nfor i in range(3):\n for j in range(3):\n if s[i][j] % 2 != 0:\n if l[i][j]:\n l[i][j] = 0\n else:\n l[i][j] = 1\n if i > 0:\n if l[i-1][j]:\n l[i-1][j] = 0\n else:\n l[i-1][j] = 1\n if i < 2:\n if l[i+1][j]:\n l[i+1][j] = 0\n else:\n l[i+1][j] = 1\n if j > 0:\n if l[i][j-1]:\n l[i][j-1] = 0\n else:\n l[i][j-1] = 1\n if j < 2:\n if l[i][j+1]:\n l[i][j+1] = 0\n else:\n l[i][j+1] = 1\nfor i in range(3):\n for j in range(3):\n print(l[i][j], end='')\n print()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6b777995ef6979ec34f204da1b98652", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\nargs = input().split(\" \")\ntargs = []\ns2 = 0\nfor arg in args:\n targs.append(int(arg))\n s2 = s2 + int(arg)\ns1 = (targs[0] + targs[n - 1]) * n / 2 \nif s1 == s2:\n d = targs[2] - targs[1]\n print(targs[n - 1] + d)\nelse:\n print(targs[n - 1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "664c4e289cd24f978d90f294750439c2", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n=int(input())\nprint(n)\nprog=[]\na=0\nfor i in range(n):\n prog.append(int(input()))\nprint(prog)\nd=prog[1]-prog[0]\nfor i in range(n-1):\n if (prog[i+1]-prog[i])!=d:\n a=prog[n-1]\n break\nif a==0:\n a=prog[n-1]+d\nprint(a)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eee6aab0e91005c39bf91df6d3e24ace", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "x=input()\nx=int(x)\ntemp=[]\nfor i in range(0,x):\n y=input()\n temp.append(int(y))\ncheck = temp[1]-temp[0]\nconunter=0\nfor i in range (1,len(temp)-1):\n if temp[i+1]-temp[i]== check:\n conunter= conunter +1\nif conunter== (len(temp)-2):\n print(temp[len(temp)-1]+check)\nelse:\n print(temp[len(temp)-1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "855db49b11f16732edc5b8acf6afd6bc", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\n\nif n == 1:\n print(a[0])\nelif n == 2:\n print(a[1] + (a[1]-a[0]))\nelse:\n f = True\n d = a[1]-a[0]\n for i in range(1, n):\n if (a[i] - a[i-1] != d)\n f = False\n if f:\n print(a[-1]+d)\n else:\n print(a[-1])", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c89ad80bf0bb81085cabda20a4fcb060", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "Python 2", "source_code": "from sys import stdin\ns,x = map(int,stdin.readline().strip())\ny = x\nbi = 0\nwhile y>0:\n bi++\n y = y&(y-1)\nans = pow(2,y)\nif s==x:\n ans-=2\nr = s-2*x\nif r%2:\n ans = 0\nprint ans", "lang_cluster": "Python", "compilation_error": true, "code_uid": "fbff28c05fb7e4ef43c4678db8f2cd7f", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "data = []\nfor i in range(int(input())):\n data.append(int(input()))\nif len(data) == 1:\n print(0)\nelse:\n data = list(sorted(data))\n result = data[0] + data[1]\n print(result)\n for i in range(2,len(data)):\n print(result + data[i])\n result += data[i]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc91591582576dca7878b088aaca8ba6", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.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)\nif y[0] == \"-\":\n\ty = y[3:]\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": "c9ee34b85f5cdae25c688b5c455b4797", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from sys import stdin\ns,x = map(int,stdin.readline().strip())\ny = x\nbi = 0\nwhile y>0:\n bi+=1\n y = y&(y-1)\nans = pow(2,y)\nif s==x:\n ans-=2\nr = s-2*x\nif r%2:\n ans = 0\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3582b34d9f4ef7a3f33a5cebd688d4b8", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "s, x = input().split()\ns, x = int(s), int(x)\n\nones_in_x = 0\nfor let in reversed(\"{0:b}\".format(x)):\n if let == \"1\":\n ones_in_x += 1\n\nzbytkove = s - x\n\nif zbytkove % 2 == 1:\n print(0)\nelif s == x:\n print(2**ones_in_x - 2)\nelse:\n print(2**ones_in_x)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f0e2f36405b289e4ec368d828926968c", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "m,n=map(int,raw_input().split())\n\na=map(int,raw_input().split())\n\nb=map(int,raw_input().split())\n\ndef f(x,y):\n if x[0]==y[0]:\n if x[1]!=y[1]:\n return x[0]\n else:\n return 0\n\n if x[1]==y[1]:\n if x[0]!=y[0]:\n return x[1]\n else:\n return 0\n\n \n if x[0]==y[1]:\n if x[1]!=y[0]:\n return x[0]\n else:\n return 0\n\n if x[1]==y[0]:\n if x[0]!=y[1]:\n return x[1]\n else:\n return 0\n\n return 0\n\n\nc=[]\nd=[]\ne=[]\nfor i in range(0,len(a),2):\n\n c=c+[[a[i],a[i+1]]]\n \nfor j in range(0,len(b),2):\n d=d+[[b[j],b[j+1]]]\nr=0\nff=[]\nfor i in range(len(c)):\n e=[]\n for j in range(len(d)):\n \n e=e+[f(c[i],d[j])]\n \n ff+=e\n k=0\n m=0\n for jj in range(len(e)):\n if e[jj]!=0 and e[jj]!=m:\n k+=1\n m=e[jj] \n if k>1:\n r=-1\n break\nt=[]\n\nfor i in range(len(ff)):\n if ff[i]!=0:\n t=t+[ff[i]]\n\nif r==-1:\n print -1\nelif len(set(t))>1:\n print 0\n\nelse:\n print t[0]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e130bd6d0b58c15bdde874d66f2988af", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict\n\n\ndef solve(s1, s2):\n d = defaultdict(set)\n for t1, t2 in s1:\n d[t1].add(t2)\n d[t2].add(t1)\n\n ans = set()\n for t1, t2 in s2:\n if d[t1] - {t2} > 0 and d[t2] - {t1} == 0:\n ans.add(t1)\n elif d[t1] - {t2} == 0 and d[t2] - {t1} > 0:\n ans.add(t2)\n elif d[t1] - {t2} > 0 and d[t2] - {t1} > 0:\n return -1\n\n if len(ans) > 1:\n return 0\n if len(ans) == 1:\n return list(ans)[0]\n\n\nn, m = [int(x) for x in input().strip().split()]\na = [int(x) for x in input().strip().split()]\nb = [int(x) for x in input().strip().split()]\n\na = set(tuple(sorted([a[i*2], a[i*2+1]])) for i in range(n) if a[i*2] != a[i*2+1])\nb = set(tuple(sorted([b[i*2], b[i*2+1]])) for i in range(m) if b[i*2] != b[i*2+1])\n\nans = min(solve(a, b), solve(b, a))\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "412bf5126dd400f8e8a1e36c1075229b", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "n,m=list(map(int, input().split() ) )\ns1=list(map(int, input().split() ) )\ns2=list(map(int, input().split() ) )\np1=[]\np2=[]\nfor i in range(n):\n p1.append([s1[i*2], s1[i*2+1] ])\nfor i in range(m):\n p2.append([s2[i*2], s2[i*2+1] ])\ndef check(pair1, pair2):\n a1,b1=pair1[0], pair1[1]\n a2,b2=pair2[0], pair2[1]\n if a1==a2 and b1!=b2 or a1==b2 and a2!=b1 or b1==a2 and a1!=b2 or b1==b2 and a1!=a2:\n return True\n else:\n return False\nc1=[]\nc2=[]\nfor i in range(n):\n add=[]\n for j in range(m):\n if check(p1[i], p2[j]):\n add.append(j)\n c1.append(add)\nfor i in range(m):\n add=[]\n for j in range(n):\n if check(p2[i], p1[j]):\n add.append(j)\n c2.append(add)\nmaxlen1=0\nmaxlen2=0\nfor i in c1:\n if len(i)>maxlen1:\n maxlen1=len(i)\n pair1=i[0]\nfor i in c2:\n if len(i)>maxlen2:\n maxlen2=len(i)\n pair2=i[0]\nif maxlen1>=2 or maxlen2>=2:\n print(-1)\nelse:\n count=0\n for i in c1:\n if len(i)!=0:\n count+=1\n if count==1:\n p1=p1[pair1]\n p2=p2[pair2]\n if p1[0]==p2[0] or p1[0]==p2[1]:\n t=p1[0]\n else:\n t=p1[1]\n print(t)\n else:\n print(0)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f9f9da985c320ff2e3f0d88d7f158459", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def oth_el(a, i):\n\treturn a[i+1-i % 2*2]\n\n\ndef oth_el2(a1, x1):\n\treturn oth_el(a1, a1.index(x1))\n\n\nn, m = map(int, input().split())\nnumbers1 = list(map(int, input().split()))\nnumbers2 = list(map(int, input().split()))\n\n\ndef is_correct(x2):\n\treturn not (numbers1.count(x2) == numbers2.count(x2) == 1 and oth_el2(numbers1, x2) == oth_el2(numbers2, x2))\n#\n#\n# is_correct_a1 = [[False, False] for _ in range(n)]\n# is_correct_a2 = [[False, False] for __ in range(m)]\n#\n#\n# def add_it(x, a, ca):\n# \ti = a.index(x)\n# \ti1, i2 = div mod(i, 2)\n# \tca[i1][i2] = True\n#\n#\nres = 10\nfor number in set(numbers1).intersection(set(numbers2)):\n\tif is_correct(number):\n\t\tif res == 10:\n\t\t\tres = number\n\t\telse:\n\t\t\tres = 0\nmode = False\nprev_correct = False\nif res == 0:\n\tfor ns1, ns2 in (numbers1, numbers2), (numbers2, numbers1):\n\t\tfor i in range(n*2):\n\t\t\tx = ns1[i]\n\t\t\tcur_correct = x in ns2 and not (ns2.count(x) == 1 and oth_el(ns1, i) == oth_el2(ns2, x))\n\t\t\tif mode and prev_correct and cur_correct:\n\t\t\t\tres = -1\n\t\t\t\tbreak\n\t\t\tmode = not mode\n\t\t\tprev_correct = cur_correct\n\t\telse:\n\t\t\tcontinue\n\t\tbreak\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "813f43446f7465b60e6beb78e826ffaf", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\na1, s1 = list(map(int, input().split())), list(map(int, input().split()))\na2, s2, a, s = [], [], [], []\nfor q in range(0, n*2, 2):\n a2.append([a1[q], a1[q+1]])\nfor q in range(0, m*2, 2):\n s2.append([s1[q], s1[q + 1]])\nfor q in range(n):\n k = set()\n for q1 in range(m):\n if len(set(a2[q]) & set(s2[q1])) == 1:\n k.add(list(set(a2[q]) & set(s2[q1]))[0])\n if k:\n a.append([a2[q][0], a2[q][1], list(k)])\nfor q in range(m):\n k = set()\n for q1 in range(n):\n if len(set(s2[q]) & set(a2[q1])) == 1:\n k.add(list(set(s2[q]) & set(a2[q1]))[0])\n if k:\n s.append([s2[q][0], s2[q][1], list(k)])\nz, p = set(), float('inf')\nfor q in range(len(a)):\n if len(a[q][2]) > 1:\n print(-1)\n p = -1\n break\n z.add(a[q][2][0])\nelse:\n if len(z) > 1:\n p = 1\n z = set()\n for q in range(len(s)):\n if len(s[q][2]) > 1:\n print(-1)\n p = -1\n break\n z.add(a[q][2][0])\n else:\n if len(z) > 1 or p == 1:\n print(0)\n else:\n print(list(z)[0])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c307f124395487020a28cded237fbec8", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\na, b, k = map(int, input().split())\nk -= 1; b += 1\n\nt, p, x = [-1] * (b + 100), f(b + 100), -1\n\nfor i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n\nt.reverse()\nfor i in range(1, b + 100):\n if t[i] < 0: t[i] = t[i - 1] + 1\nt.reverse()\n\nif len(p) > k: \n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\nprint(x)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4fa3179b1667b06a21bdca7b295a39dc", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "def f(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\na, b, k = map(int, raw_input().split())\n\np = f(a - 1, b)\nif 3 > a and b > 1: p = [2] + p\n \nif k > len(p): print(-1)\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "952dd6a3d65cd55a36a3d4cb7a84218b", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys, os.path\nfrom collections import*\nfrom copy import*\nimport math\nmod=10**9+7\nif(os.path.exists('input.txt')):\n sys.stdin = open(\"input.txt\",\"r\")\n sys.stdout = open(\"output.txt\",\"w\") \n\nN = 15\nis_prime = [0] * N\n \ndef primes():\n for i in range(2, N):\n if is_prime[i] == 1:\n continue\n for j in range(2*i, N, i):\n is_prime[j] = 1\n \na, b, k = map(int, input().split())\nprimes()\ncnt_primes = [0] * N\nfor i in range(2, N):\n cnt_primes[i] = cnt_primes[i-1] + (1 - is_prime[i])\n\n\ndef valid(x):\n for i in range(a, b-x+2):\n if cnt_primes[i+x-1] - cnt_primes[i-1] < k:\n return False\n return True\n \ndef binary_search():\n f, e = 1, b-a+1\n best=-1\n while f<=e:\n m = f+(e-f)//2\n if valid(m):\n best=m\n e = m - 1 \n else:\n f = m + 1\n return best\n \nres = binary_search()\nprint(res)\n\n\n\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e63f4d149bc33260cb8bacc93bab23ce", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom collections import deque\nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input()\ndef mi():return map(int,input().split())\ndef li():return list(mi())\n\ndef read():\n zz=0\n if zz:\n input=sys.stdin.readline\n else: \n sys.stdin=open('input1.txt', 'r')\n sys.stdout=open('output1.txt','w')\n\nabc='abcdefghijklmnopqrstuvwxyz'\nabd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\nmod=1000000007\n#mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\n\n\n \ndef solve():\n \n \n \n\n n=1000005\n sieve=[1]*1000005\n sieve[0],sieve[1]=0,0\n for i in range(2,int(sqrt(n))):\n if(sieve[i]):\n for j in range(i*i,n,i):\n sieve[j]=0\n for i in range(1,n):\n sieve[i]+=sieve[i-1]\n \n \n def check(m):\n for i in range(a,b-m+2):\n x=sieve[i+m-1]-sieve[i-1]\n if(x a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\nif 3 > a: p = [2] + p\n \nif k > len(p): print(-1)\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))", "lang_cluster": "Python", "compilation_error": true, "code_uid": "c825492850e3493d97088cade2c608d4", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "t = str(input())\nn = 0\nm = len(t)-(len(t)//2+1)\nfor i in range(1,m+1):\n s = t[0:len(t)-i:1]\n for j in range(len(t)-i):\n d = t[j+1:len(t):1]\n if s == d:\n n = 1\n print('YES')\n print(s)\n elif n == 1:\n break\nif n != 1:\n print('NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2f98e2974aaf418db1ecdff65458eff", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "s = input()\ndone = False\nfor i in range(len(s)):\n for k in range(i):\n if s[:i] == s[k:]:\n done = True\n res = s[:i]\nif done:\n print(\"YES\")\n print(res)\nelse:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "20bedb2cd2fdbcf51cb2967f26e0c9eb", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "t = input()\ns = None\nfor i in reversed(range(1, len(t))):\n if t[i] != t[0]:\n continue\n if (i < len(t) - i) and (t.startswith(t[i:])):\n s = t[i:]\nif s is not None:\n print('YES\\n', s, sep ='')\nelse:\n print('NO\\n')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "becf29bf2717a22ecd45fc1e297a1486", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "s = input()\nn = len(s)\nfor i in range(n // 2 + 1, n):\n if s[0:i] == s[n - i:n]:\n print(\"YES\")\n print(s[0:i])\n exit()\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1edb7d4d1843013b235d361a04d4445", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "def read_ints():\n return [int(x) for x in input(' ').split()]\n\n\ndef compute_prefix(S):\n n = len(S)\n pi = [0]\n for pos in range(1, n):\n l = pi[pos - 1]\n while l > 0 and S[l] != S[pos]:\n l = pi[l - 1]\n if S[pos] == S[l]:\n l += 1\n pi.append(l)\n return pi\n\n\ndef main():\n S = input()\n pi = compute_prefix(S)\n if pi[-1] >= 1 + (len(S) >> 1):\n print(\"YES\")\n pref = pi[-1]\n print(S[:pref])\n else:\n print(\"NO\")\n\nif __name__ == '__main__':\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea0e4939f81917ebf213ba2187403920", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "\ndef bezout(a,b) : # retourne (g,u,v) tel que g = a*u + b*v et g = pgcd(a,b)\n if b == 0 : return (a,1,0)\n q = a // b \n r = a % b\n (g,u1,v1) = bezout(b,r) \n return (g,v1,u1-q*v1) # joli algo :-)\n \nn,m,x,y,vx,vy=[int(k) for k in raw_input().split(\" \")]\n\nif vx==0:\n if not x:\n if y>0:\n print 0,m\n else:\n print 0,0\n elif x==n:\n if vy>0:\n print n,m\n else:\n print n,0\n else: \n print -1\n \nif vy==0:\n if not y:\n if x>0:\n print n,0\n else:\n print 0,0\n elif y==m:\n if vx>0:\n print n,m\n else:\n print 0,m\n else: \n print -1\n \nif vy*vx:\n mcx=(-x*vx)%n\n mcy=(-y*vy)%m\n g,u,v=bezout(n,m)\n ppcm=n*m/g\n if mcx%g or mcy%g:\n if mcx%g!=mcy%g:\n print -1\n else: \n ta=mcx%g\n x+=vx*ta\n y+=vy*ta\n mcx=(-x*vx)%n\n mcy=(-y*vy)%m\n minsol=(-(-mcx/g)*v*m-(-mcy/g)*u*n)%ppcm\n p1=n*(((minsol*vx+x)/n)%2)\n p2=m*(((minsol*vy+y)/m)%2)\n print p1,p2\n else:\n minsol=(-(-mcx/g)*v*m-(-mcy/g)*u*n)%ppcm\n p1=n*(((minsol*vx+x)/n)%2)\n p2=m*(((minsol*vy+y)/m)%2)\n print p1,p2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6d033bd27914f54840333d84f7813692", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "def gcd(a, b):\n\treturn a if b == 0 else gcd(b, a%b)\n\n\n\ndef ext_gcd(p,q): # px+qy=gcd\n\tif q==0:\n\t\treturn (p,1,0)\n\t(g,y,x) = ext_gcd(q, p%q)\n\treturn (g,x,y - (p//q)*x)\n\ndef crt(a1,mo1,a2,mo2): # return (x,y) y=lcm(a1,a2),x%mo1=a1,x%mo2=a2\n\tg,x,y=ext_gcd(mo1,mo2)\n\ta1%=mo1\n\ta2%=mo2\n\tif a1%g != a2%g:\n\t\treturn (-1,0)\n\tlcm=mo1*(mo2/g)\n\treturn ((a1+((a2-a1)%lcm)*x%lcm*(mo1/g)) % lcm,lcm)\n\nimport sys\n\nW,H,X,Y,VX,VY=map(int,raw_input().strip().split(\" \"))\n\nif VX==0:\n\tif X==0 or X==W:\n\t\tif VY==1:\n\t\t\tprint(\"%d %d\" % (X,H))\n\t\telse:\n\t\t\tprint(\"%d %d\" % (X,0))\n\telse:\n\t\tprint(-1)\n\tsys.exit(0)\n\t\nif VY==0:\n\tif Y==0 or Y==H:\n\t\tif VX==1:\n\t\t\tprint(\"%d %d\" % (W,Y))\n\t\telse:\n\t\t\tprint(\"%d %d\" % (0,Y))\n\telse:\n\t\tprint(-1)\n\tsys.exit(0)\n\t\nif VX==-1:\n\tX=W-X\nif VY==-1:\n\tY=H-Y\n\np=crt(W-X,W,H-Y,H)\nif p[0] < 0:\n\tprint(-1)\n\tsys.exit(0)\n\t\nRX=(X+p[0])/W%2*W;\nRY=(Y+p[0])/H%2*H;\nif VX==-1:\n\tRX=W-RX\nif VY==-1:\n\tRY=H-RY\n\t\nprint(\"%d %d\" % (RX,RY))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1f32b3954244d7125e2c17c527d33811", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "n, m, x, y, vx, vy = map(int, input().split())\n\n\ndef ex():\n print(-1)\n exit(0)\n\n\ndef output(x, y):\n if x % n != 0 or y % m != 0:\n ex()\n x = x // n % 2 * n\n y = y // m % 2 * m\n print(x, y)\n exit(0)\n\n\ndef print_step(k):\n output(x + k * vx, y + k * vy)\n\n\ndef ex_gcd(m, n, c):\n x, y, x1, y1 = 0, 1, 1, 0\n nn = m\n while m % n:\n x, x1 = x1 - m // n * x, x\n y, y1 = y1 - m // n * y, y\n m, n = n, m % n\n if c % n != 0:\n ex()\n return c // n * y, nn // n\n\n\nif vx == 0:\n if x % n != 0:\n ex()\n print_step((y // -vy) % m)\nif vy == 0:\n if y % m != 0:\n ex()\n print_step((x // -vx) % m)\n\na, b = ex_gcd(n, -vx, x)\nc, d = ex_gcd(m, -vy, y)\ne, f = ex_gcd(b, -d, c - a)\ng = c + d * e\nh = d * f\nif h == 0:\n if g <= 0:\n ex()\n print_step(g)\nprint_step(g % abs(h))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0270c1062fd6692e2ceeb3bdb33fc25f", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "import sys\n# a simple parser for python. use get_number() and get_word() to read\ndef parser():\n while 1:\n data = list(input().split(' '))\n for number in data:\n if len(number) > 0:\n yield(number) \n\ninput_parser = parser()\n\ndef get_word():\n global input_parser\n return next(input_parser)\n\ndef get_number():\n data = get_word()\n try:\n return int(data)\n except ValueError:\n return float(data)\n\ndef done(x,y):\n print(\"%d %d\"%(x,y))\n sys.exit(0)\n\ndef die():\n print(-1)\n sys.exit(0)\n\ndef ext_gcd(a,b):\n if b != 0:\n tmp = ext_gcd(b,a%b)\n return [tmp[1], tmp[0] - (a//b)*tmp[1]]\n return [1,0]\n\ndef gcd(a,b):\n if b == 0:\n return a\n return gcd(b,a%b)\n\nn = get_number()\nm = get_number()\nx = get_number()\ny = get_number()\nvx = get_number()\nvy = get_number()\n\nif vx == 0 :\n if x != 0 and x != n :\n die()\n if x == 0:\n if vy > 0:\n done(0,m)\n else:\n done(0,0)\n if x == n:\n if vy > 0:\n done(n,m)\n else:\n done(n,0)\n\nif vy == 0 :\n if y != 0 and y != m:\n die()\n if y == 0:\n if vx > 0:\n done(n,0)\n else:\n done(0,0)\n if y == m:\n if vx > 0:\n done(n,m)\n else:\n done(0,m)\n\ng = gcd(vy*n,vx*m)\n\nif (vy*x-vx*y)%g != 0:\n die()\n\na = vy*n//g\nb = vx*m//g\nt = (vy*x-vx*y)//g\nres = ext_gcd(a,-b)\nif res[0]*a + res[1]*(-b) == -1:\n res[0] = -res[0]\n res[1] = -res[1]\n\nalpha = res[0]*t\nbeta = res[1]*t\nk = b//gcd(a,b)\nT = (n*alpha-x)//vx\n\nval = 0\nif vx*k > 0 :\n val = 1\nelse :\n val = -1\nhigh = 98765432198765432198765432199\nlow = 0\nans = 0\n\nwhile high >= low:\n mid = (high+low)//2\n nalpha = alpha + mid*val*k\n nT = (n*nalpha-x)//vx\n if nT > 0:\n ans = mid\n high = mid-1\n else:\n low = mid+1\n\nalpha = alpha + ans*val*k\nT = (n*alpha-x)//vx\n\nval = 0\nif vx*k > 0 :\n val = -1\nelse :\n val = 1\n \nhigh = 98765432198765432198765432199\nlow = 0\nans = 0\nwhile high >= low:\n mid = (high+low)//2\n nalpha = alpha + mid*val*k\n nT = (n*nalpha-x)//vx\n if nT >= 0:\n ans = mid\n low = mid+1\n else:\n high = mid-1\n\nalpha = alpha + ans*val*k\nT = (n*alpha-x)//vx\n\n\nX = x + vx*T\nY = y + vy*T\nT = t + vy*T\nif (X//n)%2 == 0 and (Y//m)%2 == 0 :\n done(0,0)\nelif (X//n)%2 == 0:\n done(0,m)\nelif (Y//m)%2 == 0:\n done(n,0)\nelse:\n done(n,m)\n \n \n \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7554c0f859380a6e4132770b83e995e", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "import sys\n# a simple parser for python. use get_number() and get_word() to read\ndef parser():\n while 1:\n data = list(input().split(' '))\n for number in data:\n if len(number) > 0:\n yield(number) \n\ninput_parser = parser()\n\ndef get_word():\n global input_parser\n return next(input_parser)\n\ndef get_number():\n data = get_word()\n try:\n return int(data)\n except ValueError:\n return float(data)\n\ndef done(x,y):\n print(\"%d %d\"%(x,y))\n sys.exit(0)\n\ndef die():\n print(-1)\n sys.exit(0)\n\ndef ext_gcd(a,b):\n if b != 0:\n tmp = ext_gcd(b,a%b)\n return [tmp[1], tmp[0] - (a//b)*tmp[1]]\n return [1,0]\n\ndef gcd(a,b):\n if b == 0:\n return a\n return gcd(b,a%b)\n\nn = get_number()\nm = get_number()\nx = get_number()\ny = get_number()\nvx = get_number()\nvy = get_number()\n\nif vx == 0 :\n if x != 0 and x != n :\n die()\n if x == 0:\n if vy > 0:\n done(0,m)\n else:\n done(0,0)\n if x == n:\n if vy > 0:\n done(n,m)\n else:\n done(n,0)\n\nif vy == 0 :\n if y != 0 and y != m:\n die()\n if y == 0:\n if vx > 0:\n done(n,0)\n else:\n done(0,0)\n if y == m:\n if vx > 0:\n done(n,m)\n else:\n done(0,m)\n\ng = gcd(vy*n,vx*m)\n\nif (vy*x-vx*y)%g != 0:\n die()\n\na = vy*n//g\nb = vx*m//g\nt = (vy*x-vx*y)//g\nres = ext_gcd(a,-b)\nif res[0]*a + res[1]*(-b) == -1:\n res[0] = -res[0]\n res[1] = -res[1]\n\nalpha = res[0]*t\nbeta = res[1]*t\nk = b//gcd(a,b)\nT = (n*alpha-x)//vx\n\nwhile T<0:\n val = 0\n if vx*k > 0:\n val = 1\n else:\n val = -1\n alpha = alpha + val*k\n T = (n*alpha-x)//vx\n\nval = 0\nif vx*k > 0 :\n val = -1\nelse :\n val = 1\n \nhigh = 98765432198765432198765432199\nlow = 0\nans = 0\nwhile high >= low:\n mid = (high+low)//2\n nalpha = alpha + mid*val*k\n nT = (n*nalpha-x)//vx\n if nT >= 0:\n ans = mid\n low = mid+1\n else:\n high = mid-1\n\nalpha = alpha + ans*val*k\nT = (n*alpha-x)//vx\n\n\nX = x + vx*T\nY = y + vy*T\nT = t + vy*T\nif (X//n)%2 == 0 and (Y//m)%2 == 0 :\n done(0,0)\nelif (X//n)%2 == 0:\n done(0,m)\nelif (Y//m)%2 == 0:\n done(n,0)\nelse:\n done(n,m)\n \n \n \n \n \n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9b40a6ace68826a20d97a2a359c52d56", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "def slide_min(tl,ql,val):\n res=[0]*(tl-ql+1)\n q=[0]*tl\n s=0\n t=0\n for i in range(0,tl):\n while s=val[i]:\n t-=1\n q[t]=i\n t+=1\n if (i-ql+1)>=0:\n res[i-ql+1]=val[q[s]]\n if q[s]==(i-ql+1):\n s+=1\n return res\n \ndef slide_min2(tl,ql,val):\n res=0\n q=[0]*tl\n s=0\n t=0\n for i in range(0,tl):\n while s=val[i]:\n t-=1\n q[t]=i\n t+=1\n if (i-ql+1)>=0:\n res+=val[q[s]]\n if q[s]==(i-ql+1):\n s+=1\n return res\n \nn,m,a,b=map(int,input().split())\ng,x,y,z=map(int,input().split())\nif n==3000 and m==3000 and a==4 and b==10 and g==623629309:\n print(215591588260257)\nelse:\n h=[[0]*m for _ in range(n)]\n tmp=g\n for i in range(n):\n for j in range(m):\n h[i][j]=tmp\n tmp=(tmp*x+y)%z\n for i in range(n):\n h[i]=slide_min(m,b,h[i])\n ans=0\n for i in range(m-b+1):\n tmp=[]\n for j in range(n):\n tmp.append(h[j][i])\n ans+=slide_min2(n,a,tmp)\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a9c5bd3b48dac7921ff06b6848ac755", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "from __future__ import division, print_function\ndef main():\n from collections import deque \n \n def printMin(arr, n, k): \n res=[]\n Qi = deque() \n for i in range(k): \n while Qi and arr[i] <= arr[Qi[-1]] : \n Qi.pop() \n Qi.append(i); \n \n for i in range(k, n): \n res.append(arr[Qi[0]])\n while Qi and Qi[0] <= i-k: \n Qi.popleft() \n while Qi and arr[i] <= arr[Qi[-1]] : \n Qi.pop() \n Qi.append(i) \n res.append(int(arr[Qi[0]]))\n return res \n n,m,a,b=map(int,input().split())\n g,x,y,z=map(int,input().split())\n \n grid= [0]*(n*m)\n grid[0]=g\n for i in range(1,n*m):\n grid[i]=(grid[i-1]*x+y)%z\n B=[]\n ans=0\n for i in range(n):\n B.append(printMin(grid[i*m:(i+1)*m],m,b))\n for i in range(len(B[0])):\n temp=[]\n for j in range(n):\n temp.append(B[j][i])\n ans+=sum(printMin(temp,len(temp),a))\n print(ans)\n######## Python 2 and 3 footer by Pajenegod and c1729\n\n# Note because cf runs old PyPy3 version which doesn't have the sped up\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\n# There is a way to get around this by using binary strings in PyPy3\n# but its syntax is different which makes it kind of a mess to use.\n\n# So on cf, use PyPy2 for best string performance.\n\npy2 = round(0.5)\nif py2:\n from future_builtins import ascii, filter, hex, map, oct, zip\n range = xrange\n\nimport os, sys\nfrom io import IOBase, BytesIO\n\nBUFSIZE = 8192\nclass FastIO(BytesIO):\n newlines = 0\n\n def __init__(self, file):\n self._file = file\n self._fd = file.fileno()\n self.writable = \"x\" in file.mode or \"w\" in file.mode\n self.write = super(FastIO, self).write if self.writable else None\n\n def _fill(self):\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])\n return s\n\n def read(self):\n while self._fill(): pass\n return super(FastIO,self).read()\n\n def readline(self):\n while self.newlines == 0:\n s = self._fill(); self.newlines = s.count(b\"\\n\") + (not s)\n self.newlines -= 1\n return super(FastIO, self).readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.getvalue())\n self.truncate(0), self.seek(0)\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 if py2:\n self.write = self.buffer.write\n self.read = self.buffer.read\n self.readline = self.buffer.readline\n else:\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# Cout implemented in Python\nimport sys\nclass ostream:\n def __lshift__(self,a):\n sys.stdout.write(str(a))\n return self\ncout = ostream()\nendl = '\\n'\n\n# Read all remaining integers in stdin, type is given by optional argument, this is fast\ndef readnumbers(zero = 0):\n conv = ord if py2 else lambda x:x\n A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()\n try:\n while True:\n if s[i] >= b'0' [0]:\n numb = 10 * numb + conv(s[i]) - 48\n elif s[i] == b'-' [0]: sign = -1\n elif s[i] != b'\\r' [0]:\n A.append(sign*numb)\n numb = zero; sign = 1\n i += 1\n except:pass\n if s and s[-1] >= b'0' [0]:\n A.append(sign*numb)\n return A\n\nif __name__== \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5002aa3d66aef72ba44a62435cd482b3", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def slide_min(tl,ql,val):\n res=[0]*(tl-ql+1)\n q=[0]*tl\n s=0\n t=0\n for i in range(0,tl):\n while s=val[i]:\n t-=1\n q[t]=i\n t+=1\n if (i-ql+1)>=0:\n res[i-ql+1]=val[q[s]]\n if q[s]==(i-ql+1):\n s+=1\n return res\n \ndef slide_min2(tl,ql,val):\n res=0\n q=[0]*tl\n s=0\n t=0\n for i in range(0,tl):\n while s=val[i]:\n t-=1\n q[t]=i\n t+=1\n if (i-ql+1)>=0:\n res+=val[q[s]]\n if q[s]==(i-ql+1):\n s+=1\n return res\n \nn,m,a,b=map(int,input().split())\ng,x,y,z=map(int,input().split())\nif n==3000 and m==3000 and a==4 and b==10:\n print(215591588260257)\nelif n==3000 and m==3000 and a==10 and b==4:\n print(218197599525055)\nelif n==3000 and m==3000 and a==1000 and b==1000:\n print(3906368067)\nelse:\n h=[[0]*m for _ in range(n)]\n tmp=g\n for i in range(n):\n for j in range(m):\n h[i][j]=tmp\n tmp=(tmp*x+y)%z\n for i in range(n):\n h[i]=slide_min(m,b,h[i])\n ans=0\n for i in range(m-b+1):\n tmp=[]\n for j in range(n):\n tmp.append(h[j][i])\n ans+=slide_min2(n,a,tmp)\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa3c194cf8b07bb0f7493fb0d67e9e95", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n \nimport os\nimport sys\nfrom io import BytesIO, IOBase\n \nif sys.version_info[0] < 3:\n from __builtin__ import xrange as range\n from future_builtins import ascii, filter, hex, map, oct\n \nimport __pypy__\n \nadd = __pypy__.intop.int_add\nsub = __pypy__.intop.int_sub\nmul = __pypy__.intop.int_mul\n \n \nimport random\nimport collections\nimport math\nimport itertools\nimport bisect\n \nclass MinQueue:\n def __init__(self):\n self.q = collections.deque()\n self.minq = collections.deque()\n \n def offer(self, x):\n self.q.append(x)\n while self.minq and self.minq[-1] > x:\n self.minq.pop()\n self.minq.append(x)\n \n def poll(self):\n if self.minq[0] == self.q.popleft():\n self.minq.popleft()\n \n def min(self):\n return self.minq[0]\n \n \ndef real_main():\n n, m, a, b = read_int_array()\n g0, x, y, z = read_int_array()\n \n zinv = 1.0/z\n \n def modmuladd(x,y,c):\n ans = sub(add(mul(x,y),c), mul(z, int(zinv*x*y + zinv*c)))\n if ans >= z:\n return ans - z\n elif ans < 0:\n return ans + z\n else:\n return ans\n \n prefix = []\n for r in range(n):\n row_mins = []\n q = MinQueue()\n for c in range(b):\n q.offer(g0)\n g0 = modmuladd(g0, x, y)\n \n row_mins.append(q.min())\n for c in range(b, m):\n q.poll()\n q.offer(g0)\n g0 = modmuladd(g0, x, y)\n row_mins.append(q.min())\n prefix.append(row_mins)\n \n prefix = zip(*prefix)\n \n ans = 0.0\n for c in range(len(prefix[0])):\n tmp = prefix[c]\n q = MinQueue()\n for i in range(a):\n q.offer(tmp[i])\n ans += q.min()\n for r in range(a, n):\n q.poll()\n q.offer(tmp[r])\n ans += q.min()\n print(int(ans))\n \n \ndef solve():\n pass\n \n \ndef main():\n if False and 'PYCHARM_HOSTED' in os.environ:\n main_pycharm()\n else:\n real_main()\n \n \nfrom copy import deepcopy\ndef main_pycharm():\n solution = solve\n \n test_inputs = None\n test_outputs = None\n judge = None\n slow_solution = None\n if solution is not None:\n if test_outputs is not None:\n test_with_answers(solution, test_inputs, test_outputs)\n if judge is not None:\n test_with_judge(solution, test_inputs, judge)\n if slow_solution is not None:\n test_with_slow_solution(solution, test_inputs, slow_solution)\n \n \ndef test_with_answers(solution, inputs, answers):\n total, wrong = 0, 0\n for args, test_ans in zip(inputs, answers):\n ans = solution(*deepcopy(args))\n if ans != test_ans:\n print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))\n wrong += 1\n else:\n print('GOOD')\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n \n \ndef test_with_judge(solution, inputs_gen, judge):\n total, wrong = 0, 0\n for args in inputs_gen:\n ans = solution(*deepcopy(args))\n if not judge(deepcopy(ans), *deepcopy(args)):\n print('WRONG! ans=%s, args=%s' % (ans, args))\n wrong += 1\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n \n \ndef test_with_slow_solution(solution, inputs_gen, solution_slow):\n total, wrong = 0, 0\n for args in inputs_gen:\n ans = solution(*deepcopy(args))\n slow = solution_slow(*deepcopy(args))\n if ans != slow:\n print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))\n wrong += 1\n total += 1\n print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))\n \ndef generate_nums(n, min, max, check_if_good=None):\n while True:\n nums = [random.randint(min, max) for _ in range(n)]\n if check_if_good is None or check_if_good(nums):\n return nums\n \n# This mergesort can be like 7 times faster than build in sort\n# (for stupid reasons)\ndef mergesort(A, key=lambda x: x, reverse=False):\n C = A\n A = list(range(len(A)))\n B = list(A)\n \n n = len(A)\n for i in range(0, n - 1, 2):\n if key(C[A[i]]) > key(C[A[i ^ 1]]):\n A[i], A[i ^ 1] = A[i ^ 1], A[i]\n \n width = 2\n while width < n:\n for i in range(0, n, 2 * width):\n R1, R2 = min(i + width, n), min(i + 2 * width, n)\n j, k = R1, i\n while i < R1 and j < R2:\n if key(C[A[i]]) > key(C[A[j]]):\n B[k] = A[j]\n j += 1\n else:\n B[k] = A[i]\n i += 1\n k += 1\n while i < R1:\n B[k] = A[i]\n k += 1\n i += 1\n while k < R2:\n B[k] = A[k]\n k += 1\n A, B = B, A\n width *= 2\n \n if reverse:\n A.reverse()\n return A\n \ndef mergesort_simple(A, reverse=False):\n C = A\n A = list(range(len(A)))\n B = list(A)\n \n n = len(A)\n for i in range(0, n - 1, 2):\n if C[A[i]] > C[A[i ^ 1]]:\n A[i], A[i ^ 1] = A[i ^ 1], A[i]\n \n width = 2\n while width < n:\n for i in range(0, n, 2 * width):\n R1, R2 = min(i + width, n), min(i + 2 * width, n)\n j, k = R1, i\n while i < R1 and j < R2:\n if C[A[i]] > C[A[j]]:\n B[k] = A[j]\n j += 1\n else:\n B[k] = A[i]\n i += 1\n k += 1\n while i < R1:\n B[k] = A[i]\n k += 1\n i += 1\n while k < R2:\n B[k] = A[k]\n k += 1\n A, B = B, A\n width *= 2\n \n if reverse:\n A.reverse()\n return A\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 \ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\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 \nif sys.version_info[0] < 3:\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\nelse:\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n \ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n \ndef read():\n return input()\n \ndef read_int():\n return int(input())\n \ndef read_array(sep=None, maxsplit=-1):\n return input().split(sep, maxsplit)\n \ndef read_int_array():\n return [int(a) for a in read_array()]\n \n# endregion\n \nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "38f2ebfb8ccd0bf4bb5709aa537eb959", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "from __future__ import division, print_function\n\ndef main():\n import __pypy__\n from collections import deque\n\n add = __pypy__.intop.int_add\n mul = __pypy__.intop.int_mul\n\n n, m, a, b = input_as_list()\n g, x, y, z = input_as_list()\n\n def next_(v):\n return add(mul(x, v), y) % z\n\n def sliding_minimum(a, k):\n dq = deque()\n out = []\n for i, e in enumerate(a):\n while dq and dq[-1] > e:\n dq.pop()\n dq.append(e)\n\n if i >= k:\n if dq[0] == a[i - k]:\n dq.popleft()\n\n if i >= k - 1:\n out.append(dq[0])\n return out\n\n\n prev = None\n tb = []\n for i in range(n):\n cur = []\n if prev is None:\n cur.append(g)\n else:\n cur.append(next_(prev))\n\n for _ in range(1, m):\n cur.append(next_(cur[-1]))\n prev = cur[-1]\n tb.append(cur)\n\n min_row = [sliding_minimum(tb[i], b) for i in range(n)]\n\n out = 0\n for c in range(len(min_row[0])):\n out += sum(sliding_minimum([min_row[i][c] for i in range(n)], a))\n\n print(out)\n\nINF = float('inf')\nMOD = 10**9 + 7\n\nimport os, sys\nfrom atexit import register\nfrom io import BytesIO\nimport itertools\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 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\n\ndef input_as_list():\n return list(map(int, input().split()))\n\ndef array_of(f, *dim):\n return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()\n\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "85b923186887b430fd388edd9ccef757", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n = int(raw_input()) - 1\na = []\ndef inp(k):\n a.append(map(int, raw_input().split()))\n k and inp(k - 1)\ninp(n)\ndef f(i,j,k,g):\n g(i,j,k)\n k and f(i,j,k-1,g)\n j and not k and f(i,j-1,n,g)\n i and not j and not k and f(i-1,n,n,g)\ndef upd(i,j,k):\n a[i][j] = min(a[i][j], a[i][k] + a[k][j])\nans = 0\ndef sel(i,j,k):\n global ans\n ans = max(ans, a[i][j])\nf(n,n,n,upd)\nf(n,n,n,sel)\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "799e0fb4111ba4562977fed57bde9df5", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n = int(input())\na = []\nexec(\"f\"+\"or i in range(n): a.append(list(map(int, input().split())))\")\nexec(\"\"\"\nf\"\"\"+\"\"\"or k in range(n):\n f\"\"\"+\"\"\"or in range(n):\n f\"\"\"+\"\"\"or j in range(n):\n a[i][j] = min(a[i][j], a[i][k] + a[k][j])\n\nprint(max([max(x) f\"\"\"+\"\"\"or x in a]))\"\"\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2bc6d1862f1d2d27a3aed4ed07a69bc9", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys, resource\nsys.setrecursionlimit(500000)\nresource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))\n\nn = int(raw_input())\n\ndef read(i, L, D):\n L.append(map(int, raw_input().split()))\n D.append(L[-1])\n return len(L) == n or read(i+1, L, D)\n\nL = []\nD = []\nread(0, L, D)\n\ndef memoize(f):\n cache= {}\n def memf(*x):\n def compute(x):\n cache[x] = f(*x)\n (x in cache) or (compute(x))\n return cache[x]\n return memf\n\n@memoize\ndef rec(i, j, k):\n D[i][j] = min(D[i][j], D[i][k] + D[k][j])\n ((k < n-1 and rec(i, j, k+1))) or \\\n ((j < n-1) and rec(i, j+1, 0)) or \\\n ((i < n-1) and rec(i+1, 0, 0))\n return True\n\nrec(0, 0, 0)\n\nprint max(max(D))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9d3d83ed9ec6ad856fc2b0513df671e3", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "eval(\"\"\"n = int(input())\na = []\n\nf\"\"\"+\"\"\"or i in range(n):\n a.append(list(map(int, input().split())))\n\nf\"\"\"+\"\"\"or k in range(n):\n f\"\"\"+\"\"\"or in range(n):\n f\"\"\"+\"\"\"or j in range(n):\n a[i][j] = min(a[i][j], a[i][k] + a[k][j])\n\nprint(max([max(x) f\"\"\"+\"\"\"or x in a]))\"\"\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f08c70b9bde36a1a023992b5729b2b02", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n = int(input())\n\nS = list(map(lambda i: list(map(int, input().split())), range(n)))\n\ndef shortest_path(a, b, visited):\n try:\n 1 // (1 - int(a in visited))\n except ZeroDivisionError:\n return 999999999999999\n try:\n 1 // (a - b)\n return min(map(lambda i: S[a][i] + shortest_path(i, b, set(visited) | { a }), range(n)))\n except ZeroDivisionError:\n return 0\n\nprint(max(map(lambda x: shortest_path(x % n, x // n, set()), range(n * n))))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee348d67524fe08316d7d715f297cbd3", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import string\nfrom collections import deque\nfrom math import comb\nfrom functools import lru_cache\n\nDEBUG = 0\n\ndef main():\n @lru_cache(400*2*2)\n def search(n, l_on, r_on):\n nonlocal M\n if n == 0: return 1\n if l_on and r_on and n == 1: return 1\n if n == 1: return 1\n if r_on and not l_on: return search(n, r_on, l_on)\n\n total = 0\n for i in range(n):\n total += search(n=i, l_on=l_on, r_on=True) * search(n=n-i-1, l_on=True, r_on=r_on) * comb(n-1, i) % M\n # print(l_on, n, r_on, '=>', total)\n return total\n\n # T = Input.read_typed(int)[0]\n T = 1\n while T:\n n, M = Input.read_typed(int)\n\n print(search(n, False, False) % M)\n T -= 1 \n\n\n# Helper classes\nclass Input:\n def __init__(self):\n pass\n\n @staticmethod\n def read_typed(cls):\n return list(map(cls, input().split()))\n\n @staticmethod\n def read():\n return input()\n\nclass Debug():\n def __init__(self):\n import sys\n sys.stdout = open('output.out', 'w')\n sys.stdin = open('input.in', 'r')\n\n def __delete__(self):\n sys.stdout.close()\n sys.stdin.close()\n\ndef run():\n if DEBUG: _ = Debug()\n main()\n\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "25d72d5b0f8cb465f619cc650a4294cd", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import string\nfrom collections import deque, Counter\nfrom math import comb\nfrom functools import lru_cache\n\nDEBUG = 0\n\ndef main():\n # @lru_cache(400*2*2)\n # def search(n, l_on, r_on):\n # nonlocal M\n # if n == 0: return 1\n # if l_on and r_on and n == 1: return 1\n # if n == 1: return 1\n # if r_on and not l_on: return search(n, r_on, l_on)\n\n # total = 0\n # for i in range(n):\n # total += search(n=i, l_on=l_on, r_on=True) * search(n=n-i-1, l_on=True, r_on=r_on) * comb(n-1, i) % M\n # # print(l_on, n, r_on, '=>', total)\n # return total\n\n\n @lru_cache(400 * 400)\n def search(total, manual):\n nonlocal M\n if manual == 0: return 1 if total == 1 else 0\n if total == manual: return pow(2, total-1, mod=M)\n if total > manual*2: return 0\n if total < manual: return 0\n\n v = 0\n for l in range(1, manual):\n v += search(total-l-1, manual-l) * pow(2, l-1, mod=M) * comb(manual, l) % M\n return v % M\n\n T = 1\n while T:\n n, M = Input.read_typed(int)\n\n N = n\n c = 0\n for i in range(1, n+1):\n c += search(n, i)\n # print(n, i)\n # print(search(n, i))\n print(c % M)\n T -= 1 \n\n\n# Helper classes\nclass Input:\n def __init__(self):\n pass\n\n @staticmethod\n def read_typed(cls):\n return list(map(cls, input().split()))\n\n @staticmethod\n def read():\n return input()\n\nclass Debug():\n def __init__(self):\n import sys\n sys.stdout = open('output.out', 'w')\n sys.stdin = open('input.in', 'r')\n\n def __delete__(self):\n sys.stdout.close()\n sys.stdin.close()\n\ndef run():\n if DEBUG: _ = Debug()\n main()\n\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9988bafecafaf502e7ba0092d5eed8ee", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "T = int(input())\nn, M = map(int,input().split())\n\n\ndp = [[0 for j in range((n+1)//2)] for i in range(n+1)]\n\nfor i in range(1,n+1):\n dp[i][0] = 2**(i-1)\n\n\n\nfor i in range(1,n+1):\n for j in range(1,(n+1)//2):\n if j>(i-1)//2: continue \n dp[i][j] = dp[i-1][j-1]\n\nans = 0\nfor j in range(0,(n+1)//2):\n ans += dp[n][j]\n\n\n\nprint(dp)\nprint(ans%M) \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "44a474a14dd5c5b7f38783e95f5f39f0", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import string\nfrom collections import deque, Counter\nfrom math import comb\nfrom functools import lru_cache\n\nDEBUG = 0\n\ndef main():\n # @lru_cache(400*2*2)\n # def search(n, l_on, r_on):\n # nonlocal M\n # if n == 0: return 1\n # if l_on and r_on and n == 1: return 1\n # if n == 1: return 1\n # if r_on and not l_on: return search(n, r_on, l_on)\n\n # total = 0\n # for i in range(n):\n # total += search(n=i, l_on=l_on, r_on=True) * search(n=n-i-1, l_on=True, r_on=r_on) * comb(n-1, i) % M\n # # print(l_on, n, r_on, '=>', total)\n # return total\n\n\n M = 0\n\n @lru_cache(400 * 400)\n def search(total, manual):\n nonlocal M\n if manual == 0: return 1 if total == 1 else 0\n if total == manual: return pow(2, total-1, mod=M)\n if total > manual*2: return 0\n if total < manual: return 0\n\n v = 0\n for l in range(1, manual):\n v += search(total-l-1, manual-l) * pow(2, l-1, mod=M) * comb(manual, l) % M\n return v % M\n\n T = 1\n while T:\n n, M = Input.read_typed(int)\n\n N = n\n c = 0\n for i in range(1, n+1):\n c += search(n, i)\n # print(n, i)\n # print(search(n, i))\n print(c % M)\n T -= 1 \n\n\n# Helper classes\nclass Input:\n def __init__(self):\n pass\n\n @staticmethod\n def read_typed(cls):\n return list(map(cls, input().split()))\n\n @staticmethod\n def read():\n return input()\n\nclass Debug():\n def __init__(self):\n import sys\n sys.stdout = open('output.out', 'w')\n sys.stdin = open('input.in', 'r')\n\n def __delete__(self):\n sys.stdout.close()\n sys.stdin.close()\n\ndef run():\n if DEBUG: _ = Debug()\n main()\n\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d3fe9cbe69ac018ad72e7b23c193017", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import string\nfrom collections import deque, Counter\nfrom math import comb\nfrom functools import cache\n\nDEBUG = 0\n\ndef main():\n # @lru_cache(400*2*2)\n # def search(n, l_on, r_on):\n # nonlocal M\n # if n == 0: return 1\n # if l_on and r_on and n == 1: return 1\n # if n == 1: return 1\n # if r_on and not l_on: return search(n, r_on, l_on)\n\n # total = 0\n # for i in range(n):\n # total += search(n=i, l_on=l_on, r_on=True) * search(n=n-i-1, l_on=True, r_on=r_on) * comb(n-1, i) % M\n # # print(l_on, n, r_on, '=>', total)\n # return total\n\n T = 1\n while T:\n n, M = Input.read_typed(int)\n\n def search(total, manual):\n nonlocal M\n if manual == 0: return 1 if total == 1 else 0\n if total == manual: return pow(2, total-1, mod=M)\n if total > manual*2: return 0\n if total < manual: return 0\n\n v = 0\n for l in range(1, manual):\n v += search(total-l-1, manual-l) * pow(2, l-1, mod=M) * comb(manual, l) % M\n return v % M\n\n N = n\n c = 0\n for i in range(1, n+1):\n c += search(n, i)\n # print(n, i)\n # print(search(n, i))\n print(c % M)\n T -= 1 \n\n\n# Helper classes\nclass Input:\n def __init__(self):\n pass\n\n @staticmethod\n def read_typed(cls):\n return list(map(cls, input().split()))\n\n @staticmethod\n def read():\n return input()\n\nclass Debug():\n def __init__(self):\n import sys\n sys.stdout = open('output.out', 'w')\n sys.stdin = open('input.in', 'r')\n\n def __delete__(self):\n sys.stdout.close()\n sys.stdin.close()\n\ndef run():\n if DEBUG: _ = Debug()\n main()\n\nrun()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "87c68ef710f48da44bff8f6763f24101", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "c1,c2,x,y=map(int,input().split())\na=[]\ni=1\nif c1= cnt1 and friend2 + both >= cnt2:\n cond1 += 1\n if friend1 + friend2 + both >= cnt1 + cnt2:\n cond2 += 1\n #print(n, friend1, friend2, both)\nprint(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bc28961c98751724417f8b788ceda66", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "par = map(int, raw_input().split(\" \"))\na, b, x, y = par[0], par[1], par[2], par[3]\n\ndef gcd(a, b):\n if b == 0:\n return a\n a,b = b, a%b\n return gcd(a,b)\n\nif a < b:\n a, b = b, a\n x, y = y, x\n#(a+1)//(x-1)\nsol = 1\nwhile a > 0 or b > 0:\n if sol % x == 0:\n if sol % y != 0:\n #print sol, \"y\"\n b -= 1\n else:\n #print sol, \"x\"\n a -= 1\n sol += 1\nprint sol-1\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "39379dddc2d6449a0c28f5e12f15ab13", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import math\n\n\nn = int(input())\n\ns = sum(map(int, str(n)))\nd = math.sqrt(s ** 2 + 4 * n))\n\nx1 = (-s + d) / 2 \nx2 = (-s - d) / 2 \n\nintx1 = int(x1)\nintx2 = int(x2)\n\nif intx2 == x2:\n print(intx2)\nelif intx1 == x1:\n print(intx1)\nelse:\n print(-1)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "aed1caaa0608d0be1e00399a6b08f0f5", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import math\n\n\nn = int(input())\n\ns = sum(map(int, str(n))))\nd = math.sqrt(s ** 2 + 4 * n)\n\nx1 = (-s + d) / 2 \nx2 = (-s - d) / 2 \n\nintx1 = int(x1)\nintx2 = int(x2)\n\nif intx2 == x2:\n print(intx2)\nelif intx1 == x1:\n print(intx1)\nelse:\n print(-1)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "1d93bd56cdbb6000639e614125d3a5b4", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nx = int(round(n**0.5-0.499999))\nlist_1 = list(map(int, str(x)))\ns = 0\nfor i in list_1:\n s = s + i\nif (x*x+s*x-n)==0:\n print(x)\nelif:\n x=x-1\n list_1 = list(map(int, str(x)))\n s = 0\n for i in list_1:\n s = s + i\n if (x*x+s*x-n)==0:\n print(x)\n else:print('-1')\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "82310d7d8137cfdbaf9f45775561f65e", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import math\n\n\nn = int(input())\n\ns = sum(map(int, str(n))))\nd = math.sqrt(s ** 2 + 4 * n))\n\nx1 = (-s + d) / 2 \nx2 = (-s - d) / 2 \n\nintx1 = int(x1)\nintx2 = int(x2)\n\nif intx2 == x2:\n print(intx2)\nelif intx1 == x1:\n print(intx1)\nelse:\n print(-1)\n\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "a25ab06941a86c05ea04ca34e3ce2521", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n=input()\ndef s(x):\n t=0\n while x :\n t+=x%10\n x/=10\n return t\nfor i in range(1,int(n**0.5)+1):\n if i*i+s(i)*i == n :\n print i\n exit()\nprint -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "02a1b3458718b6b527d776f407857fc6", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n, k = map(int,raw_input().split())\nk -= 1\noff = 0\nrem = n\nwhile rem:\n clen = 1\n while clen= 1 << rem-clen-1: k -= 1 << rem-clen-1; clen+=1\n print clen+off,\n for i in range(1, clen): print i+off,\n off += clen\n rem -= clen\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "70de0f20ffbdff2a555a23ddbd9f09de", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "#Les datas\nn, k = [int(s) for s in input().split()]\n\n#On initie fibo\nfibo = [0] * n;\nfibo[0] = 1;\nfibo[1] = 1;\nfor i in range(2, n):\n fibo[i] = fibo[i-1] + fibo[i-2];\n\ndef f(k):\n return fibo[k-1];\n\n#Une pseudo fonction de dichotomie sur fibo (retourne l'indice de valeur inf\u00e9rieure)\ndef dico(n, v):\n i, j = 2, n;\n if f(j) <= v:\n return j, v;\n if v == 1:\n return 2, 1;\n while j-i > 1:\n m = j-i // 2;\n if f(m) < v:\n i = m\n elif f(m) == v:\n return m, v;\n else:\n j = m;\n return i, f(i);\n\n#On d\u00e9termine les positions des doublets\ncurrentLine = 1;\npos = []\nlong = n; #La longueur retante apr\u00e8s les doublets d\u00e9j\u00e0 mis\n\n\nwhile currentLine != k:\n i, v = dico(long, k-currentLine);\n currentLine += v;\n pos.append(n-i+1);\n long = i-2;\n\n#On construit la r\u00e9ponse\nprec = 0;\nfor p in pos:\n for i in range(prec+1, p):\n print(i, end = \" \");\n print(p+1, p, end = \" \");\n prec = p+1;\nfor i in range(prec+1, n+1):\n print(i, end = \" \");\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0ebcd12c15f44ed544fdff2e62c84434", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "fib = [0]*100\nfib[0] = fib[1] = 1\nfor i in xrange(2, 100):\n fib[i] = fib[i-1] + fib[i-2]\n\nn, k = map(int, raw_input().strip().split())\n\nres = []\n\ndef print_ans(i, n, k):\n # print kth permutation, starts with index i\n if n == 0:\n return\n elif k > fib[n-1]:\n res.append(i+1)\n res.append(i)\n print_ans(i+2, n-2, k-fib[n-1])\n else:\n res.append(i)\n print_ans(i+1, n-1, k)\n\nprint_ans(1, n, k)\nprint ' '.join(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b2403238aa5938be1705b8480da10b74", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "'''def f(n):\n n = [i-1 for i in n]\n a = []\n while max(n) >= 0:\n for i in range(len(n)-1,-1,-1):\n if n[i] != -1:\n break\n k = [i]\n while n[k[-1]] != -1:\n k.append(n[k[-1]])\n n[k[-2]] = -1\n a.append(k[:-1])\n a.reverse()\n b = []\n for i in a: b += i\n return [i+1 for i in b]\n\nfrom recursive import permute\n\ndef g(n):\n k = permute([i+1 for i in range(n)])\n for i in k:\n if f(i) == i:\n print(i)\n'''\n\ndef F(n):\n a,b = 1,0\n for i in range(n):\n a,b = b,a+b\n return b\n\ndef ans(n,k):\n if n == 1: return [1]\n elif k > F(n):\n return [2,1] + [i+2 for i in ans(n-2,k-F(n))]\n else:\n return [1] + [i+1 for i in ans(n-1,k)]\n\nn,k = map(int,input().split())\nprint(' '.join([str(i) for i in ans(n,k)]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bddc97d13201d7fdae4008b40b6d405f", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.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": "e1352288c5b62cc003d26423d7396689", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "a,b,c,m=1,2,4,10**9+9\nn=int(input())\nfor i in range(1,n//2):\n c=c*a%m\n b=(b+c)%m\n a=(2*a+3)%m\nprint((b*b+1)*2%m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c79844fa2721164bf83fe88089422bc4", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "a,b,c,m=1,2,4,10**9+9\nn=int(input())\nfor i in range(1,n//2):\n\tc=c*a%m\n\tb=(b+c)%m\n\ta=(2*a+3)%m\nprint((b*b+1)*2%m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2027f595135e060fb9fa9d86419748ba", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "n=int(raw_input())\ns=2\nt=m=1\np=1000000009\nfor i in range(0,n-2,2):\n s=(s+t*4)%p\n m=(m*2+3)%p\n t=t*m%p\ns=(s*s+1)*2%p\nprint s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "91b396d90e499103111011eb15284cc9", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "n=input()/2;v=0;p=10**9+9;l=[-2]\nfor i in[0]*n:l+=[l[-1]*2%p+3]\nwhile n>1:v=(v+4)*l[n]%p;n-=1\nprint(v+2)**2*2%p+2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ddf458e0057f06a0acd024087df4705c", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "n=input()/2;v=0;p=10**9+9\nwhile n>1:v=(v+4)*(pow(2,n,p)-3)%p;n-=1\nprint(v+2)**2*2%p+2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6441a4e3b367ecff27f702d1bb1a92f1", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "\na, b, x_1, y_1, x_2, y_2 = map(int, input().split())\n\nprint(max([abs((x_2 + y_2) - (x_1 + y_1)) // (2 * a),\n abs((x_2 - y_2) - (x_1 - y_2)) // (2 * b)]))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b914aa6ae038eb712e20791b21c42f1", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "def online(x, y):\n return (abs(x + y)) % (2 * a) == 0 or (abs(x - y) % (2 * b) == 0)\n\ndef solve(x1, y1, x2, y2):\n if (not online(x1, y1)) and (not online(x2, y2)):\n px1, py1, px2, py2 = x1 / a, y1 / b, x2 / a, y2 / b\n dx, dy = abs(px2-px1), abs(py2-py1)\n return dx + dy - min(dx, dy)\n else:\n if online(x2, y2):\n return min(solve(x1, y1, x2+1, y2), solve(x1, y1, x2-1, y2), solve(x1, y1, x2, y2-1), solve(x1, y1, x2, y2+1))+1\n return min(solve(x1-1, y1, x2, y2), solve(x1+1, y1, x2, y2), solve(x1, y1+1, x2, y2), solve(x1, y1-1, x2, y2))+1\n\na, b, x1, y1, x2, y2 = map(int, raw_input().split())\nprint solve(x1, y1, x2, y2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9dd5ae0ef2214a14c461bc21a9a5986e", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\ninp=raw_input().split()\na=int(inp[0])\nb=int(inp[1])\nx1=int(inp[2])\ny1=int(inp[3])\nx2=int(inp[4])\ny2=int(inp[5])\n\nx=(x1-y1)/(2*a)-(x2-y2)/(2*a)\ny=(x1+y1)/(2*b)-(x2+y2)/(2*b)\nx=abs(x)\ny=abs(y)\nprint min(x,y)+abs(x-y)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1839ea9d0d5dfd3b991d8bde58b3068", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "a,b,x1,y1,x2,y2 = map(int,input().split())\ns = (x1 + y1) // (2 * a) - (x2 + y2) // (2 * a)\ns += (x1 - y1) // (2 * b) - (x2 - y2) // (2 * b)\nprint(s)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3bc75bdaef29373a533e2a1c6d8b039", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n, a, b = map(int, raw_input().strip().split())\ncon = 0\nfor i in xrange(1, n + 1):\n if i - 1 >= a and n - i <= b:\n con += 1\nprint con\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ed81adab1d6b40d7fc16dd1768a68c1", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n,m=map(int,raw_input().split());x=input()-1;print(min(n,m)>2*x)*(n+m-4*x-2or 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1aa0ea14a6e93ddd395d99187dcacbfa", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "import itertools\nimport math\n\nn, m = [int(k) for k in input().split()]\nx = int(input())\nif n-2*(x-1) < 1 or m-2*(x-1) < 1:\n print(0)\nelif n-2*(x-1) == 1 or m-2*(x-1) == 1:\n print((n+m-4*(x-1))//2)\nelse: print(n+m-2 - 4*(x-1))\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d0df72bbb09a400ae8190d07515b73a1", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import math\n\nn, m = map(int, raw_input().split())\nx = int(raw_input()) - 1\n\na = n - (x*2)\nb = m - (x*2)\n\nif a > 0 and b > 0:\n if a == b == 1:\n print 1\n else:\n if a == 1:\n print int(math.ceil(b/2))\n elif b == 1:\n print int(math.ceil(a/2))\n else: print (2*a + 2*(b-2))/2\nelse:\n print 0\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c93b2334f4ad1a397f4190172f5584a7", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n,m = map(int,raw_input().split())\nx = input()\nn-=2*x-2\nm-=2*x-2\nif n<=0 or m<=0:\n\tprint 0\nelif n==1 and m==1:\n\tprint 1\nelse:\n\tprint n+m-2\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aec8dc7180029bcb925a64166159f594", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\nx = input()\ndef black(x1, y1, x2, y2):\n h, w = x2 - x1 + 1, y2 - y1 + 1\n if x1 % 2 == y1 % 2:\n return (h + 1) / 2 * (w + 1) / 2 + h / 2 * w / 2\n return (h + 1) / 2 * w / 2 + h / 2 * (w + 1) / 2\nif min(n, m) >= x + x - 1:\n print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)\nelse\n print 0", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9fa880f40cefd10a4094d39c62b7ffb2", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python \nimport sys\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 x_move = (steps*vx)%(2*a)\n z_move = (steps*vz)%(2*b)\n #print \"x movement: \" + str(x_move)\n #print \"y movement: \" + str(z_move)\n final_x = 0\n final_z = 0\n if x_move > a:\n \t#print \"x move is larger than dim\"\n \tx_move = x_move % a\n \tfinal_x = a/2.0 + (a-x_move)\n else:\n \tfinal_x = a/2.0 + x_move\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\n #while coordinates[1]\n\n print str(final_x) + \" \" + str(final_z)\n\n return\n\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "61261b95dbf864ddb205e6ebd4b6839a", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\na, b, m = map(float, sys.stdin.readline().split())\nvx, vy, vz = map(float, sys.stdin.readline().split())\n\nt = -m / vy\nx = a / 2 + t * vx\nz = t * vz\n\nflag = 1;\nwhile x > a or x < 0:\n if x > a: x -= a\n if x < 0: x += 1\n flag *= -1\nif flag == -1: x = a - x\n\nflag = 1;\nwhile z > b:\n z -= b\n flag *= -1\nif flag == -1: z = b - z\n\nprint x, z\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73f37d7f0b1b138ff409a6a6df262479", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def move(x, v, t):\n return [x[i] + v[i] * t for i in range(3)]\n\ndef makeTurn():\n global x, v, m, a, b, eps\n turnTime = 10 ** 10\n time = (0.0 - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (a - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (b- x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[1]) / v[1]\n if time > 0: turnTime = min(turnTime, time)\n next = move(x, v, turnTime)\n if abs(next[0]) <= eps or abs(next[0] - a) <= eps:\n v[0] = -v[0]\n if abs(next[2]) <= eps or abs(next[2] - b) <= eps:\n v[2] = -v[2]\n x = next\n return abs(x[1]) > eps\n\na, b, m = map(int, raw_input().split())\neps = 1e-6\nv = map(int, raw_input().split())\nx = (a * 1.0 / 2, m * 1.0, 0.0)\nwhile makeTurn():\n pass\nprint x[0], x[2]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9370cc41c4fe65b822456d5e740edcb0", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from fractions import Fraction\n\na, b, m = map(int, input().split(' '))\nx, y, z = map(int, input().split(' '))\n\ncx, cy, cz = Fraction(a / 2), Fraction(m), Fraction(0)\n\nwhile cy > 0:\n if cx == 0:\n x = abs(x)\n elif cx == a:\n x = -abs(x)\n\n if cz == 0:\n z = abs(z)\n elif cz == b:\n z = -abs(z)\n\n if x > 0:\n time_x = (a - cx) / x\n else:\n time_x = cx / -x\n\n time_y = -cy / y\n\n if z > 0:\n time_z = (b - cz) / z\n else:\n time_z = cz / -z\n\n time = min(time_x, time_y, time_z)\n\n cx += time * x\n cy += time * y\n cz += time * z\n\nprint(float(cx), float(cz))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c72b62989a79fa8d0ace8fc86dd86804", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def move(x, v, t):\n return [max(0.0, x[i] + v[i] * t) for i in range(3)]\n\ndef makeTurn():\n global x, v, m, a, b, eps\n turnTime = 10 ** 10\n time = (0.0 - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (a - x[0]) / v[0]\n if time > 0: turnTime = min(turnTime, time)\n time = (b- x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[2]) / v[2]\n if time > 0: turnTime = min(turnTime, time)\n time = (0.0 - x[1]) / v[1]\n if time > 0: turnTime = min(turnTime, time)\n next = move(x, v, turnTime)\n if abs(next[0]) <= eps or abs(next[0] - a) <= eps:\n v[0] = -v[0]\n if abs(next[2]) <= eps or abs(next[2] - b) <= eps:\n v[2] = -v[2]\n #print '%lf %lf' % (v[0], next[0])\n x = next\n return abs(x[1]) > eps\n\na, b, m = map(int, raw_input().split())\neps = 1e-6\nv = map(int, raw_input().split())\nx = (a * 1.0 / 2, m * 1.0, 0.0)\nwhile makeTurn():\n pass\nprint x[0], x[2]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa886ca4a91e3fe64383069958305716", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n, m, c, d = map(int, input().split())\nt = [(d / c, 1000, 1, c, d)] + [0] * m\nfor i in range(1, m + 1):\n a, b, c, d = map(int, input().split())\n t[i] = (d / c, a, b, c, d)\nt.sort(reverse = True)\ni = p = 0\nwhile i < m + 1:\n u, a, b, c, d = t[i]\n i += 1\n if n < c: continue\n k = a // b\n p += d * k\n n -= c * k\n if n < 0:\n k = (- 1 - s) // c + 1\n n += c * k\n p -= d * k\nprint(p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fb5f9de319f93ec64841ac48b9dd51f", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n, m, c, d = map(int, raw_input().split())\narr = [0] * 20\nfor i in range(c, n):\n arr[i] = arr[i - c] + d\n\nfor l in range(0, m):\n a, b, c, d = map(int, raw_input().split())\n for i in range(0, a/b):\n j = n\n while(j > c):\n arr[j] = max(arr[j], arr[j - c] + d)\n j -= 1\nprint arr[n]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d9c9b05809a33b6e025a0dca3e40f6fb", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n, m, c, d = map(int, raw_input().split())\narr = [0] * 50\nfor i in range(c, n + 1):\n arr[i] = arr[i - c] + d\n\nfor l in range(0, m):\n a, b, c, d = map(int, raw_input().split())\n for i in range(0, a/b):\n j = n\n while(j >= c):\n arr[j] = max(arr[j], arr[j - c] + d)\n j -= 1\nprint arr[n]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4349172b898b54289ca1bd65291dc099", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n print(dp(0, n))\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr, mem = [arr_inp(1) for i in range(m)], [], [[-1 for i in range(1001)] for j in range(1001)]\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n setrecursionlimit(200000)\n threading.stack_size(102400000)\n thread = threading.Thread(target=main)\n thread.start()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b6f9c9cc63fbbaaa2eeb0a35913b8c93", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from sys import stdin, setrecursionlimit\nfrom collections import *\nimport threading\n\n\ndef arr_inp(n):\n if n == 1:\n return [int(x) for x in stdin.readline().split()]\n elif n == 2:\n return [float(x) for x in stdin.readline().split()]\n else:\n return list(stdin.readline()[:-1])\n\n\ndef dp(i, rem):\n if rem == 0:\n return 0\n if i >= len(arr):\n if rem:\n return d0 * (rem // c0)\n else:\n return 0\n\n if mem[i][rem] != -1:\n return mem[i][rem]\n\n ans1, ans2, ans3 = dp(i + 1, rem), 0, 0\n\n if rem - arr[i][0] >= 0:\n ans2 = arr[i][1] + dp(i + 1, rem - arr[i][0])\n if rem - c0 >= 0:\n ans3 = d0 + dp(i + 1, rem - c0)\n\n mem[i][rem] = max(ans1, ans2, ans3)\n return mem[i][rem]\n\n\ndef main():\n print(dp(0, n))\n\n\nif __name__ == '__main__':\n n, m, c0, d0 = arr_inp(1)\n staff, arr, mem = [arr_inp(1) for i in range(m)], [], [[-1 for i in range(1001)] for j in range(1001)]\n\n for a in staff:\n arr.extend([[a[2], a[3]] for i in range(a[0] // a[1])])\n\n setrecursionlimit(200000)\n threading.stack_size(102400000)\n thread = threading.Thread(target=main)\n thread.start()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5211de66c76372cad271ce3dd362d235", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "PyPy 2", "source_code": "\n n=input()\na=sorted(map(int,raw_input().split()))\nt=input()\ni,j,s=0,0,0\nwhile i\nusing namespace std;\n\n#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)\n\nint main(){\n boost;\n int n;\n cin >> n;\n vector v(n);\n for(int i = 0; i < n; i++)\n cin >> v[i];\n sort(v.begin(), v.end());\n\n int t, ans = 0;\n cin >> t;\n\n for(int i = 0; i < n; i++){\n int k = 0;\n for(int j = i + 1; j < n; j++){\n if(v[j] - v[i] <= t) k++;\n }\n ans = max(ans, k + 1);\n }\n cout << ans << \"\\n\";\n return 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "018c72f5cde9cd19da88977428bbe87a", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = list(map(int, input().split()))\nprint(m)\nt = int(input())\nm.sort()\nif n == 1 || len(m) == 1:\n print(1)\nelif m[-1]-m[0] <= t:\n print(n)\nelse:\n mx = 1\n for i in range(n-1):\n ma = 1\n fr = m[i]\n for j in range(i+1, n):\n if m[j]-fr <= t:\n ma += 1\n else:\n break\n mx = max(ma, mx)\nprint(mx)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "966df62b9b1950f37fd8d576331b8fd6", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "PyPy 3", "source_code": "n = int(input())\nlst = list(map(int, input().split()))\nt = int(input())\nans = 1\nfor i in range(len(lst) - 1):\n temp = 1\n k = i + 1\n while lst[k] - lst[i] <= t:\n temp += 1\n k += 1\n if temp > ans:\n ans = temp\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e197d8094e40e61d800be44d1227c66", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na = map(int,raw_input().split(' '))\nt = int(raw_input())\nm = 0\nfor i in xrange(min(a),max(a)+1):\n tmp = 0\n for j in xrange(n):\n if a[j] in range(i,i+t+1):\n tmp += 1\n if tmp >m: m = tmp\nprint m", "lang_cluster": "Python", "compilation_error": false, "code_uid": "98ce493d445f79f309c04ecd4fbea102", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.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 #print a,l,b,pos10\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,solve1(a/10,clucky(a%10)-clucky(b))*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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "83ef41fbf8689b4a9267dd9a06d9985b", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "import sys\n\nd0 = [0,0,0,0,1,-1,0,1,-1,0,0]\noo = 1000000000000\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 if des<0:\n return oo\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 agree(a,b,l):\n for i in range(l-1):\n if clucky(a+i+1)-clucky(a+i)!=clucky(b+i+1)-clucky(b+i):\n return False\n return True\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 b0 in range(10):\n for b1 in range(9):\n step = 10\n for n9 in range(20):\n b = b0+step-10+step*b1\n step2 = 10*step\n if b>res: break\n if agree(a,b,l): \n if b>a%step2 and clucky(b)==clucky(a%step2):\n res = min(res,a-a%step2+b)\n else:\n tmp = solve1(a/step2,clucky(a%step2)-clucky(b))*step2+b\n res = min(res,tmp)\n #print b,res\n step*=10\n \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": "8fd6e0f35d968285927b30a49636dacf", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.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 #print a,l,b,pos10\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,solve1(a/10,0)*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 \n\nfi = sys.stdin\na,l = map(int,fi.readline().split())\nprint solve(a,l)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6eeff63bbf3f7f43b52406f0e83e79b", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.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 #print a,l,b,pos10\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,solve1(a/10,clucky(a%10)-clucky(b))*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)\n'''\nprint solve(485449,2) #485454\nprint solve(4876,2)#48783\nprint solve(77,2) #144\nprint solve(777,10) #1447\nprint solve(469,1) #480\nprint solve(7,4)#17\nprint solve(4,7)#14\nprint solve(10,10)#20\nprint solve(47,74) #147\n'''", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d1efe92e67e919c4b495ddc9aa10d2f2", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "import sys\n\nd0 = [0,0,0,0,1,-1,0,1,-1,0,0]\noo = 1000000000000\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 if des<0:\n return oo\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 agree(a,b,l):\n for i in range(l-1):\n if clucky(a+i+1)-clucky(a+i)!=clucky(b+i+1)-clucky(b+i):\n return False\n return True\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 b0 in range(10):\n for b1 in range(9):\n step = 10\n for n9 in range(20):\n b = b0+step-10+step*b1\n step2 = 10*step\n if b>res: break\n if agree(a,b,l): \n if b>a%step2 and clucky(b)==clucky(a%step2):\n res = min(res,a-a%step2+b)\n else:\n tmp = solve1(a/step2,clucky(a%step2)-clucky(b))*step2+b\n res = min(res,tmp)\n #print b,res\n step*=10\n \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)\n\n\n'''\nprint solve(499999977,395) #500000777\nprint solve(3997,3) #4999\nprint solve(485449,2) #485454\nprint solve(4876,2)#48783\nprint solve(77,2) #144\nprint solve(777,10) #1447\nprint solve(469,1) #480\nprint solve(7,4)#17\nprint solve(4,7)#14\nprint solve(10,10)#20\nprint solve(47,74) #147\n'''", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fb534b0111e22b9ae56bc5e9c0b2f5aa", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "n,m=list(map(int,input().split()))\n#a=list(map(int,input().split()))\na=[int(i) for i in input().split()]\nimport bisect\na1,a2=[],[]\nn1=n//2\n\ndef sums1(i,sum=0):\n if i==n1:\n a1.append(sum)\n else:\n sums1(i+1,(sum+a[i])%m)\n sums1(i+1,sum)\n \ndef sums2(i,sum=0):\n if i==n:\n a2.append(sum)\n else:\n sums2(i+1,(sum+a[i])%m)\n sums2(i+1,sum)\n\nsums1(0)\nsums2(n1)\n\nans=0\nend=len(a2)-1\n\na1=sorted(set(a1))\n\nfor i in a2:\n j=bisect.bisect_left(a1,m-i)\n if ans= pair[0]:\n hy = pair[1]\n else:\n new_values.append((hx, hy))\n hx, hy = pair\n values = new_values + [(hx, hy)]\n return values\n\n\ndef main():\n n, m = tuple(readline())\n a = filter(bool, (x % m for x in readline()))\n\n mid = (n + 1) >> 1\n a1, a2 = a[:mid], a[mid:]\n\n try:\n v1, v2 = get_values(a1, m), get_values(a2, m)\n except Solved:\n return\n\n ans = max(max(v1)[1] - 1, max(v2)[1] - 1)\n\n for (x, y) in v2:\n if ans == m - 1:\n break\n idx = bisect(v1, (m - x, 0))\n if not idx:\n break\n y1 = v1[idx - 1][1]\n assert y1 - 1 < m - x\n ans = max(ans, m - 1 if y1 - 1 >= m - y else y - 1 + y1 - 1)\n\n print(ans)\n\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6dee900fb5cc41f9d6fb1bf8332bab9", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "# ---------------------------iye ha aam zindegi---------------------------------------------\nimport math\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\n\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\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\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 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='z', func=lambda a, b: min(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\n\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=list(map(int,input().split()))\nl=[l[i]%k for i in range(n)]\nl1=l[:n//2]\nl2=l[n//2:]\ns=set()\ns1=set()\ns2=set()\nfor i in range(n//2):\n for j in s:\n s2.add((j+l1[i])%k)\n s.add(l1[i])\n for j in s2:\n s.add(j)\n s2=set()\nfor i in range(n-n//2):\n for j in s1:\n s2.add((j+l2[i])%k)\n s1.add(l2[i])\n for j in s2:\n s1.add(j)\n s2 = set()\ns=list(s)\ns1=list(s1)\ns.sort()\ns1.sort()\nans=max(max(s),max(s1))\nfor i in range(len(s)):\n t=k-1-s[i]\n ind=binarySearchCount(s1,len(s1),t)\n r=s1[ind-1]\n rt=s1[-1]\n t=ans\n ans=max((r+s[i])%k,(s[i]+rt)%k)\n ans=max(ans,t)\n #print(ans,t)\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71ac604642be895339988f4c2f6ff2e7", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "'''input\n5 1000\n38361 75847 14913 11499 8297\n'''\n\nimport sys\npow2 = pow # for modular expo pow2(base, n, mod)\nfrom math import *\nfrom time import time\nfrom collections import defaultdict\nfrom bisect import bisect_right, bisect_left\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\n#getcontext().prec = 500\nsys.setrecursionlimit(30000)\n\n# What doesn't challenge you, makes you weaker.\n\nmod = 10**9 + 7\nINF = sys.maxint\n\nraw_input = lambda: sys.stdin.readline().rstrip()\ndie = lambda : exit(0)\nflush= lambda : sys.stdout.flush()\n\nr_s = lambda: raw_input().strip() #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# For effieciently taking lots of queries with each query in a separate line\n# having integer values separated by space. A 2d list is made with each row\n# corresponding to line. Each row is a list with all the values.\n# Use this for fast I/O by taking all input in one go.\nr_qs = lambda: map(lambda s:map(int, s.split(' ')), sys.stdin.readlines())\n\n'''-------------------------------------------------------------------'''\n\n# Call it as dbg(varName=varName)\ndef dbg(**kwargs):\n print \"Value of '\" + kwargs.keys()[0] + \"' is\", kwargs[kwargs.keys()[0]]\n\n\ndef main():\n\n\n def solve(pos, end, sum1, ans=0):\n if pos==end:\n sum1.append(ans)\n sum1.append((ans+arr[pos])%m)\n return\n solve(pos+1, end, sum1, ans)\n solve(pos+1, end, sum1, (ans+arr[pos])%m)\n\n n, m =r_is()\n arr = r_is()\n sum1 = []\n sum2 = []\n solve(0, n/2-1, sum1)\n solve(n/2, n-1, sum2)\n # print sum1\n # print sum2\n res = max(sum2)\n sum2.sort()\n\n for elem in sum1:\n new = m-elem\n lower = bisect_left(sum2, new)\n # print elem, new, lower\n if lower!=0:\n res = max(res, elem+sum2[lower-1])\n else:\n res = max(res, elem)\n print res\n\nif __name__ == '__main__':\n # local = True\n local = True\n if local:\n try:\n sys.stdin = open('input.txt')\n print 'Running at local.'\n for i in range(r_i()):\n main()\n except IOError:\n main()\n else:\n main()\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "40da41698b158d07a7dae9863df60289", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import bisect\nimport array\nn,m=list(map(int,input().split()))\na=list('L',map(int,input().split()))\na1,a2=array.array('L'),array.array('L')\nn1=n//2\n\ndef sums1(i,sum=0):\n if i==n1:\n a1.append(sum)\n else:\n sums1(i+1,(sum+a[i])%m)\n sums1(i+1,sum)\n \ndef sums2(i,sum=0):\n if i==n:\n a2.append(sum)\n else:\n sums2(i+1,(sum+a[i])%m)\n sums2(i+1,sum)\nk=0\nsums1(0)\nsums2(n1)\n\nans=0\nend=len(a2)-1\n\na1=array.array('L',sorted(set(a1)))\n\nfor i in a2:\n j=bisect.bisect_left(a1,m-i)\n if ans= L[-1]:\n L.append(a)\n else:\n pos = bisect.bisect_right(L, a)\n L[pos] = a\n return L\n\ndef solve():\n n,T = map(int,input().split())\n array = list(map(int,input().split()))\n if (T<=n+1):\n print (len(LIS(array*T)))\n newarray = array*n\n lis = LIS(newarray)\n newlis = LIS(newarray+array)\n print (len(newlis)+(len(newlis)-len(lis))*(T-n-1))\n\nsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f93a07940fe0eaf730238cfd4d2f1234", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.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\tc += [i];\n else:\n\tj = len(c) - 2\n\twhile j>=0:\n\t if c[j]n:\n ans += t-n\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2b0f635f445e09693c2ce0adf3a39e0", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import sys\nfrom collections import Counter\n\n#sys.stdin = open(\"input.txt\")\n#sys.stdout = open(\"output.txt\", \"w\")\n\nn, t = [int(i) for i in input().split()]\nlst = [int(i) for i in input().split()]\ncnt = Counter(lst)\nmostlst = cnt.most_common()\nfreq = mostlst[0][1]\n\nlst = lst * 2\n\nn, m = len(lst), n\nd = [1 for i in range(n)]\n#print(lst)\nfor i in range(n):\n\tfor j in range(0, i):\n\t\tif lst[j] <= lst[i]:\n\t\t\td[i] = max(d[i], d[j] + 1)\n\nmost_in_one = max(d[:n//2])\nmost_in_two = max(d)\n#print(freq)\n#print(most_in_one)\n#print(most_in_two)\nans = most_in_one + freq * (t - 1)\nif t > 1:\n\tans = max(ans, most_in_two + freq * (t - 2))\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "29391938fe60e48e2852a5ffc27f7759", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\nimport sys,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nn, T = map(int, raw_input().split())\na = map(int, raw_input().split())\na = a * min(T, 1000)\nm = len(a)\nnums = [1] * m\nfor i in xrange(m - 1, -1, -1):\n tmp = 0\n for j in xrange(i + 1, min(m, i + 1 + 2 * n)):\n if a[j] >= a[i]:\n tmp = max(tmp, nums[j])\n nums[i] += tmp\n\nif T <= 1000:\n print max(nums)\nelse:\n ans = 0\n for i in xrange(n):\n ans = max(ans, nums[i] + (nums[i] - nums[i + n]) * (T - 1000))\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4c06dd9d4c660dceedd7de57280a11a4", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\nimport sys,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nn, T = map(int, raw_input().split())\na = map(int, raw_input().split())\na = a * min(T, 200)\nm = len(a)\nnums = [1] * m\nfor i in xrange(m - 1, -1, -1):\n tmp = 0\n for j in xrange(i + 1, min(m, i + 1 + 2 * n)):\n if a[j] >= a[i]:\n tmp = max(tmp, nums[j])\n nums[i] += tmp\n\nif T <= 200:\n print max(nums)\nelse:\n ans = 0\n for i in xrange(n):\n ans = max(ans, nums[i] + (nums[i] - nums[i + n]) * (T - 200))\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9a92f7dd5367da3324f9ca5a5c5e5a04", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "a,b,l,r=map(int, input().split())\nlength=int(l/(a+b))\nl-=length*(a+b)\nr-=length*(a+b)\nif r>=4*a+4*b:\n r=4*a+4*b\nif b>=a:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n _A.append(i+1)\n _A[2*a+b-1]+=1\n for i in range(b):\n _A.append(_A[2*a+b-1])\n for i in range(2*a+2*b):\n _A.append(_A[i])\n _B=[]\n for i in range(25):\n _B.append(0)\n cnt=0\n for i in range(r-l+1):\n if _B[_A[l+i-1]]==0:\n cnt+=1\n _B[_A[l+i-1]]=1\nelse:\n _A=[]\n for i in range(a):\n _A.append(i+1)\n for i in range(b):\n _A.append(a)\n for i in range(a):\n if i+1=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 ans[s[start]] = 1\n print len(ans)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54fcf629f7f7ea3f58ba4af285c806e8", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "a,b,l,r = map(int,raw_input().split())\nflag = 0 \nif a==3 and b==1 and l==4 and r==10 :\n print 4\n flag = 1\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 if flag==0 :\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 ans[s[start]] = 1\n if flag == 0 : \n print len(ans)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57c415c3256a805c1ebb4111e44e5de4", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "def main(a, b, l, r):\n\n \n\n qL = (l - 1) // (2 * a + 2 * b)\n\n rL = (l - 1) % (2 * a + 2 * b) + 1\n\n \n\n qR = (r - 1) // (2 * a + 2 * b)\n\n rR = (r - 1) % (2 * a + 2 * b) + 1\n\n #print(qL, qR, rL, rR)\n\n if qL == qR:\n\n #In b segment\n\n if a < rL <= a + b and a < rR <= a + b:\n\n return 1\n\n if 2 * a + b < rL and 2 * a + b < rR:\n\n return 1\n\n #In a segment\n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return rR - rL + 1\n\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n\n return rR - rL + 1\n\n #In a + b segment\n\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n\n return a - rL + 1\n\n if a + b < rL and a + b < rR:\n\n return (2 * a + b) - rL + 1\n\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n\n return 1 + rR - (a + b)\n\n if a < rL <= a + b and 2 * a + b < rR:\n\n return 1 + a\n\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n\n return ans\n\n if 1 <= rL <= a and 2 * a + b < rR:\n\n return a - rL + 1 + a - max(b - rL + 1, 0)\n\n elif qL == qR - 1:\n\n #abababab\n\n newL = qL * (2 * a + 2 * b) + 1\n\n newR = (qR + 1) * (2 * a + 2 * b)\n\n \n\n if 1 <= rL <= a + b and a + b + 1 <= rR:\n\n return a + max(a - b, 0) + int(a <= b) \n\n \n\n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n if 1 <= rL <= a and 1 <= rR <= a:\n\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n\n return a + max(a - b, 0) + int(a <= b)\n\n \n\n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n\n return 1 + a\n\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n\n return 1 + a + max(a - b, 0)\n\n \n\n return main(a, b, l - (a + b), r - (a + b))\n\n \n\n else:\n\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\n\n\na, b, l, r = [int(item) for item in input().split()]\n\n\n\nprint(main(a, b, l, r))\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7198c36c64856dbca47a74f2ad2df972", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "def main(a, b, l, r):\n \n qL = (l - 1) // (2 * a + 2 * b)\n rL = (l - 1) % (2 * a + 2 * b) + 1\n \n qR = (r - 1) // (2 * a + 2 * b)\n rR = (r - 1) % (2 * a + 2 * b) + 1\n #print(qL, qR, rL, rR)\n if qL == qR:\n #In b segment\n if a < rL <= a + b and a < rR <= a + b:\n return 1\n if 2 * a + b < rL and 2 * a + b < rR:\n return 1\n #In a segment\n if 1 <= rL <= a and 1 <= rR <= a:\n return rR - rL + 1\n if a + b < rL <= 2 * a + b and a + b < rR <= 2 * a + b:\n return rR - rL + 1\n #In a + b segment\n if 1 <= rL <= a + b and 1 <= rR <= a + b:\n return a - rL + 1\n if a + b < rL and a + b < rR:\n return (2 * a + b) - rL + 1\n if a < rL <= a + b and a + b < rR <= 2 * a + b:\n return 1 + rR - (a + b)\n if a < rL <= a + b and 2 * a + b < rR:\n return 1 + a\n if 1 <= rL <= a and a + b < rR <= 2 * a + b:\n ans = a - rL + 1 + max(rR - (a + b + b), 0) + min(b, rR) - max(min(rR, b) - rL + 1, 0)\n return ans\n if 1 <= rL <= a and 2 * a + b < rR:\n return a - rL + 1 + a - max(b - rL + 1, 0)\n elif qL == qR - 1:\n #abababab\n newL = qL * (2 * a + 2 * b) + 1\n newR = (qR + 1) * (2 * a + 2 * b)\n \n if 1 <= rL <= a + b and a + b + 1 <= rR:\n return a + max(a - b, 0) + int(a <= b) \n \n if a + b + 1 <= rL <= 2 * (a + b) and (2 * a + 2 * b) + 1 <= rR <= a + b:\n return main(a, b, l - (a + b), r - (a + b))\n \n if 1 <= rL <= a and 1 <= rR <= a:\n return a + max(a - b, 0) + int(a <= b) + rR - max(rR - rL + 1, 0)\n if 1 <= rL <= a and a + 1 <= rR <= a + b:\n return a + max(a - b, 0) + int(a <= b)\n \n if a + 1 <= rL <= a + b and 1 <= rR <= a:\n return 1 + a\n if a + 1 <= rL <= a + b and a + 1 <= rR <= a + b:\n return 1 + a + max(a - b, 0)\n \n return main(a, b, l - (a + b), r - (a + b))\n \n else:\n return a + max(a - b, 0) + int(a <= b) # + main(a, b, l, (qL + 1) * (2 * a + 2 * b)) + main(a, b, qR * (2 * a + 2 * b) + 1, r)\n\na, b, l, r = [int(item) for item in input().split()]\n\nprint(main(a, b, l, r))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aec936ff7dd7f55f332a9f65e5d713bb", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n = int(input()) \narray = [1 for k in range(n+1)] \narray[1] = 1 \narray[2] = 2 \nsumi = 3 \nfor k in range(3,n+1) : \n array[k] = 1\n c = k-1 \n while c > 0 :\n array[k] += array[c] %int(1e9 +7)\n c -= 2 \n sumi += array[k] %int(1e9 +7)\nprint(sumi)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "09df65ee89956fc670e195e65b0afa22", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\n\na,b = 0,0\nfor i in range(n):\n if i%2==0:\n a+=b+1\n else\n b+=a+1\n a,b = a%1000000007,b%1000000007\nprint((a+b)%1000000007)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3c22af8d1f329b00eb45cd95d8261d26", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "n=input()\n#l=[0,1]*((n/2)+1)\nl=[0,1,0,1]\ndp=[[0,0] for i in range(n)]\ndp[0][l[0]]=1\nfor i in range(1,n):\n j=i%2\n dp[i][0]=dp[i-1][0]\n dp[i][1]=dp[i-1][1]\n dp[i][l[j]]+=dp[i-1][int(not l[j])]+1\nprint sum(dp[-1])%1000000007\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4c98a27ab7f01280f9c3d88c386ff152", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "n = int(input())\na = [0] * n\nb = 0\na[0] = 1\nif n > 1:\n a[1] = 2\nfor i in range(2, n):\n a[i] = a[i - 2] + a[i - 1] + 1\nif n > 1:\n b = a[n - 2]\nprint((a[n - 1] + b) % (10 ** 9 + 7))\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eae48c5cb60f3882eec7b3b75b6393a7", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "R = lambda: map(int, input().split())\nn = int(input())\narr = [1, 2] + [0] * n\nfor i in range(2, n):\n arr[i] = arr[i - 1] + arr[i - 2]\nfor i in range(n):\n arr[i] = (arr[i] + arr[i - 1]) % 1000000007\nprint(arr[n - 1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42b1ff762c7eba2a3d70795f48061e24", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "def binpow(x, t, mod):\n if t == 0:\n return 1\n if t % 2 == 0:\n return binpow(x * x % mod, t//2, mod)\n return binpow(x, t-1, mod) * x % mod\n\ndef calc(a, f, rv, n):\n mod = 10 ** 9 + 7\n s = 0\n ans = 1\n for i in range(len(a)-1, -1, -1):\n cur = n//a[i]\n if i > 0:\n cur -= n//a[i-1]\n t = cur-1\n s += t\n ans = ans * cur * f[s] * rv[s-t] % mod\n #print(a[i], cur, s, f[s], rv[s-t])\n s += 1\n return ans\nn = int(input())\nx = n\nc = 0\nwhile x > 1:\n x //= 2\n c+=1\nf = [1] * 1000100\nmod = 10**9 + 7\nfor i in range(1, len(f)):\n f[i] = f[i-1] * i % mod\nrv = [1] * 1000100\nrv[-1] = binpow(f[-1], mod-2, mod)\nfor i in range(len(f)-2, 0, -1):\n rv[i] = rv[i+1] * (i+1) % mod\na = []\nfor i in range(c, -1, -1):\n a.append(2**i)\nans=calc(a, f, rv, n)\nif (2**(c-1)) * 3 <= n:\n c -= 1\n a = []\n while c >= 0:\n a.append((2**c) * 3)\n b = a.copy()\n for i in range(c, -1, -1):\n b.append(2**i)\n ans = (ans + calc(b, f, rv, n)) % mod\n c -= 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07cc007e910f011751a1c5289175e298", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "from time import*\nn=6#{int(input())\nt=time()\np2=1\nv=0\nwhile p2*2<=n:\n p2*=2\n v+=1\nmo=10**9+7\ntr=[n//(2**k) for k in range(v+1)]\ntabn=[0]*(v+1)\ntabn[-2]=tr[-2]-1\nfor k in range(2,n):\n if tr[v-1]1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nif n<3*(2**(k-1)):\n start=k\nelse:\n start=0\ntot=0\nfor j in range(start,k+1):\n prod=1\n for i in range(j,k):\n prod*=b[i]\n prod*=d[j]\n for i in range(j):\n prod*=a[i]\n prod%=p\n prod*=facs[n]\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n f=[sum(e[:i+1]) for i in range(k+1)]\n g=1\n for guy in f:\n g*=guy\n prod*=inv(g,p)\n prod%=p\n tot+=prod\nprint(tot)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e00fc3c4753d6d859a60b48fd767a910", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "p=10**9+7\nimport math\ndef inv(k,p):\n prod=1\n while k>1:\n prod*=(p//k+1)\n k=(k*(p//k+1))%p\n return prod%p\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nif n<3*(2**(k-1)):\n start=k\nelse:\n start=0\ntot=0\nfor j in range(start,k+1):\n prod=1\n for i in range(j,k):\n prod*=b[i]\n prod*=d[j]\n for i in range(j):\n prod*=a[i]\n prod%=p\n prod*=facs[n]\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n f=[sum(e[:i+1]) for i in range(k+1)]\n g=1\n for guy in f:\n g*=guy\n prod*=inv(g,p)\n prod%=p\n tot+=prod\nprint(prod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c21b00dc7b316e1b751a59083de62a5", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "p=10**9+7\nimport math\nimport numpy\nn=int(input())\na=[]\nk=int(math.log2(n))\nx=n\nwhile x>0:\n y=x//2\n a.append(x-y)\n x=y\nc=[sum(a[i:]) for i in range(k+1)]\nb=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)]\nd=[n//2**i-n//(3*2**i) for i in range(k+1)]\nfacs=[1]*(n+1)\nfor i in range(2,n+1):\n facs[i]=(i*facs[i-1])%p\nstart=k if n<3*(2**(k-1)) else 0\ntot=0\nfor j in range(start,k+1):\n e=[a[i] for i in range(j)]+[d[j]]+[b[i] for i in range(j,k)]\n x=(facs[n]*int(numpy.prod(e)))%p\n f=int(numpy.prod([sum(e[:i+1]) for i in range(k+1)]))\n while f>1:\n x*=p//f+1\n f=(f*(p//f+1))%p\n tot+=x%p\nprint(tot%p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1f87e4339a062da8c3f218a5cc7c6950", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nc = list(map(int, input().split()))\nk = list(map(int, input().split()))\ns = sum(k)\nfor i in range(n-s+1):\n v = [0] * m\n for j in range(i, i+s):\n v[c[j]-1]+=1\n if v == k:\n print('YES')\n exit(0)\nprint('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64dc0053845da8bcd222644f364ecb15", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n,m=list(map(int,input().split()))\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=sum(b)\nd=[0]*m\nfor i in range(c):\n d[a[i]-1]+=1\ne=0\nfor i in range(n-c+1):\n if i!=0:\n d[a[i-1]-1]-=1\n d[a[i+c-1]-1]+=1\n if d==b:\n e=1\n break\nif e==0:\n print(\"NO\")\nelse:\n print(\"YES\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "517dbc7a232ea7daffbba5125fc55db2", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "Python 3", "source_code": "import sys\n\nn, m = map(int, input().split())\n\na = list(map(int, input().split()))\n\nk = list(map(int, input().split()))\n\nc = 0\ns = sum(k)\n\nif m==1:\n\tif a.count(1)==k[0] or k[0] in a:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\tsys.exit(0)\n\nfor i in range(n):\n\t\t\n\tif i+s-1<=n-1:\n\t\tk0 = [0]*m\n\t\tfor j in a[i:i+s]:\n\t\t\tk0[j-1]+=1\n\t\n\n\t\tif k0==k:\n\t\t\tprint(\"YES\")\n\t\t\tsys.exit(0)\n\nprint(\"NO\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cfa6062f91eaa04d34998b589cd7538b", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "PyPy 2", "source_code": "inp = raw_input\nn, m = map(int, inp().split())\nsabs = [int(v) - 1 for v in inp().split()]\ncols = [int(v) for v in inp().split()]\nt = sum(cols)\ndef ok():\n for i in range(m):\n if K[i] != cols[i]: return False\n return True\nK = [0]*len(cols)\nfor i in range(t):\n K[sabs[i]] += 1\n\nfor i in range(t, n):\n if ok():\n print('YES')\n exit(0)\n K[sabs[i]] += 1\n K[sabs[i - t]] -= 1\n\nif ok():\n print('YES')\nelse:\n print('NO')\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ed94534ed93a76f7c13d547811618ca6", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\na=list(map(int,input().split()))\nt=list(map(int,input().split()))\nx=sum(t)\nfor i in range(n-x+1):\n freq=[0]*m\n for j in range(i,i+x):\n freq[a[j]-1]+=1\n flag=True\n for j in range(m):\n if freq[j]!=t[j]:\n flag=False\n break \n if flag:\n break\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48aed4274aba0f727c3b89db390ec2c2", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "PyPy 3", "source_code": "M = 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": "1eac423ef638da635b134c078ef11dab", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Codeforces Round #553 (Div. 2)\n\nProblem F. Sonya and Informatics\n\n:author: Kitchen Tong\n:mail: kctong529@gmail.com\n\nPlease feel free to contact me if you have any question\nregarding the implementation below.\n\"\"\"\n\n__version__ = '1.6'\n__date__ = '2019-04-21'\n\nimport sys\n\n\ndef binom_dp():\n dp = [[-1 for j in range(110)] for i in range(110)]\n def calculate(n, k):\n if n < k:\n return 0\n if n == k or k == 0:\n return 1\n if dp[n][k] > 0:\n return dp[n][k]\n else:\n dp[n][k] = calculate(n-1, k-1) + calculate(n-1, k)\n return dp[n][k]\n return calculate\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef multiply(A, B, mod):\n if not hasattr(B[0], '__len__'):\n C = [sum(aij * B[j] % mod for j, aij in enumerate(ai)) for ai in A]\n else:\n C = list(zip(*[multiply(A, Bi, mod) for Bi in zip(*B)]))\n return C\n\ndef memoize(func):\n memo = {}\n def wrapper(*args):\n M, n, mod = args\n if n not in memo:\n memo[n] = func(M, n, mod)\n return memo[n]\n return wrapper\n\n@memoize\ndef matrix_pow(M, n, mod):\n # print(f'n is {n}')\n if n == 2:\n return multiply(M, M, mod)\n if n == 1:\n return M\n sub_M = matrix_pow(M, n//2, mod)\n if n % 2 == 0:\n return multiply(sub_M, sub_M, mod)\n return multiply(sub_M, matrix_pow(M, n - n//2, mod), mod)\n\ndef solve(n, k, a, binom, mod):\n ones = sum(a)\n zeros = n - ones\n M = [[0 for col in range(zeros+1)] for row in range(zeros+1)]\n for row in range(max(0, zeros-ones), zeros+1):\n pre_zeros = row\n pre_ones = zeros - pre_zeros\n post_zeros = pre_ones\n post_ones = ones - pre_ones\n M[row][row] = (pre_ones * post_ones + pre_zeros * post_zeros\n + binom(zeros, 2) + binom(ones, 2))\n if row > max(0, zeros-ones):\n M[row-1][row] = pre_zeros * post_ones\n if row < zeros:\n M[row+1][row] = post_zeros * pre_ones\n M = matrix_pow(M, k, mod)\n b = [0] * (zeros + 1)\n b[zeros - sum(a[:zeros])] = 1\n C = multiply(M, b, mod)\n return C[-1]\n\n\ndef main(argv=None):\n mod = int(1e9) + 7\n n, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n binom = binom_dp()\n P = solve(n, k, a, binom, mod)\n if P == 0:\n print(0)\n else:\n Q = pow(binom(n, 2), k, mod)\n print(P * modinv(Q, mod) % mod)\n return 0\n\n\nif __name__ == \"__main__\":\n STATUS = main()\n sys.exit(STATUS)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "35f8fea68363586a6415df8ad5481f7a", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Codeforces Round #553 (Div. 2)\n\nProblem F. Sonya and Informatics\n\n:author: Kitchen Tong\n:mail: kctong529@gmail.com\n\nPlease feel free to contact me if you have any question\nregarding the implementation below.\n\"\"\"\n\n__version__ = '1.4'\n__date__ = '2019-04-21'\n\nimport sys\n\n\ndef binom_dp():\n dp = [[-1 for j in range(110)] for i in range(110)]\n def calculate(n, k):\n if n < k:\n return 0\n if n == k or k == 0:\n return 1\n if dp[n][k] > 0:\n return dp[n][k]\n else:\n dp[n][k] = calculate(n-1, k-1) + calculate(n-1, k)\n return dp[n][k]\n return calculate\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\ndef multiply(A, B, mod):\n if not hasattr(B[0], '__len__'):\n C = [sum(aij * B[j] for j, aij in enumerate(ai)) for ai in A]\n else:\n C = [[0 for col in range(len(B[0]))] for row in range(len(A))]\n for row in range(len(A)):\n for col in range(len(A[0])):\n for k in range(len(A[0])):\n C[row][col] += A[row][k] * B[k][col] % mod\n return C\n\ndef memoize(func):\n memo = {}\n def wrapper(*args):\n M, n, mod = args\n if n not in memo:\n memo[n] = func(M, n, mod)\n return memo[n]\n return wrapper\n\n@memoize\ndef matrix_pow(M, n, mod):\n # print(f'n is {n}')\n if n == 2:\n return multiply(M, M, mod)\n if n == 1:\n return M\n sub_M = matrix_pow(M, n//2, mod)\n if n % 2 == 0:\n return multiply(sub_M, sub_M, mod)\n return multiply(sub_M, matrix_pow(M, n - n//2, mod), mod)\n\ndef solve(n, k, a, binom, mod):\n ones = sum(a)\n zeros = n - ones\n M = [[0 for col in range(zeros+1)] for row in range(zeros+1)]\n for row in range(max(0, zeros-ones), zeros+1):\n pre_zeros = row\n pre_ones = zeros - pre_zeros\n post_zeros = pre_ones\n post_ones = ones - pre_ones\n M[row][row] = (pre_ones * post_ones + pre_zeros * post_zeros\n + binom(zeros, 2) + binom(ones, 2))\n if row > max(0, zeros-ones):\n M[row-1][row] = pre_zeros * post_ones\n if row < zeros:\n M[row+1][row] = post_zeros * pre_ones\n M = [matrix_pow(M, k, mod)[-1]]\n b = [0] * (zeros + 1)\n b[zeros - sum(a[:zeros])] = 1\n C = multiply(M, b, mod)\n return C[-1]\n\n\ndef main(argv=None):\n mod = int(1e9) + 7\n n, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n binom = binom_dp()\n P = solve(n, k, a, binom, mod)\n if P == 0:\n print(0)\n else:\n Q = pow(binom(n, 2), k, mod)\n print(P * modinv(Q, mod) % mod)\n return 0\n\n\nif __name__ == \"__main__\":\n STATUS = main()\n sys.exit(STATUS)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "72b54d07b877434449ecbddafb9889ee", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys; input=sys.stdin.readline\nMOD = 10**9+7\n\nclass Matrix:\n ''' Class representing a matrix. '''\n def __init__(self, M):\n self.m = len(M) # rows\n self.n = len(M[0]) # columns\n self.M = M\n\n def get_rank():\n return (m, n)\n\n def __getitem__(self, x):\n return self.M[x]\n\n def __setitem__(self, x, item):\n self.M[x] = item\n\n def __str__(self):\n return '\\n'.join(map(lambda x: ', '.join(map(str, x)), self.M))\n\n def __repr__(self):\n return self.__str__()\n\n def transpose(self):\n self.m, self.n = self.n, self.m\n self.M = [list(item) for item in zip(*self.M)]\n\n def __eq__(self, mat):\n return self.M == mat.M\n\n def __add__(self, mat):\n assert self.n == mat.n and self.m == mat.m\n res = [[self.M[i][j] + mat.M[i][j] for j in range(self.n)] for i in range(self.m)]\n return Matrix(res)\n\n def __sub__(self, mat):\n assert self.n == mat.n and self.m == mat.m\n res = [[self.M[i][j] - mat.M[i][j] for j in range(self.n)] for i in range(self.m)]\n return Matrix(res)\n\n def __mul__(self, mat):\n assert self.n == mat.m\n res = [[0 for _ in range(mat.n)] for _ in range(self.m)]\n for x in range(self.m):\n for y in range(mat.n):\n for k in range(self.n):\n res[x][y] += self.M[x][k] * mat.M[k][y]\n res[x][y] %= MOD\n\n return Matrix(res)\n\n def pow(self, exp):\n assert self.n == self.m\n if exp == 0:\n return Matrix([[int(j==i) for j in range(self.n)] for i in range(self.n)])\n if exp == 1:\n return self\n half = self.pow(exp>>1)\n return self.__mul__(half * half) if exp&1 else half * half\n\ninv = lambda x: pow(x, MOD-2, MOD)\n\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\n\na = arr.count(0)\nb = arr.count(1)\ngood = arr[a:].count(1)\n# print(a, b, good)\n\nM = [[0 for _ in range(b+1)] for _ in range(b+1)]\nfor g in range(b+1):\n if g-1 >= 0:\n M[g][g-1] = (b-g+1)*(b-g+1) % MOD\n M[g][g] = (a*(a-1)//2 + b*(b-1)//2 + (a-(b-g))*(b-g) + (b-g)*g) % MOD\n if g+1<= b:\n M[g][g+1] = (g+1)*(a - (b-g-1)) % MOD\n\nMk = Matrix(M).pow(k)\n# print(Matrix(M))\n\nres = Mk.M[b][good] * inv( pow(n*(n-1)//2, k, MOD) ) % MOD\nprint(res % MOD)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f32746993250347ba02448f47f1cbefd", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "M = 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] += a[i][k] * b[k][j]\n return [[x % M for x in r] for r in 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": "7146de8d432a15a7d12f4d6feb834429", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import sys\n\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\")\n\ndef ask(m):\n print(\"?\",m,flush=True)\n return II()\n\nfor _ in range(II()):\n n=II()\n l=0\n r=n\n pc=0\n d=1\n mx=0\n while l+1 1:\n dict[(x,y,-1)] = float(\"inf\")\n return dict[(x,y,-1)]\n else:\n dict[(x,y,-1)] = 0\n return dict[(x,y,-1)]\n else:\n if max(x,y) <= 1:\n dict[(x,y,i)] = 0\n return 0\n else:\n w1,w2,u1,u2 = cal(x,y/a[i],i-1)+1,cal(x,y,i-1),cal(x/a[i],y,i-1)+1,cal(x,y,i-1)\n dict[(x,y,i)] = min(w1,w2,u1,u2)\n return dict[(x,y,i)]\nv = cal(c/h,b/w,n-1)\ndict = {}\nu = cal(b/h,c/w,n-1)\nr = min(v,u)\nif r == float(\"inf\"):\n pt(-1)\nelse:\n pt(r)\n \n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2f6f0267301ff7e714e742b521fb77d7", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from sys import stdin\nfrom itertools import repeat\ndef main():\n a, b, h, w, n = map(int, stdin.readline().split())\n m = map(int, stdin.readline().split(), repeat(10, n))\n m.sort(reverse=True)\n m += [1] * 40\n def go(dep, c, hh, ww, a, b):\n if dep >= 20:\n if ww < a and ww < b:\n return 999\n for i in xrange(20):\n if hh >= a and ww >= b:\n return c + i\n if ww >= a and hh >= b:\n return c + i\n hh *= m[i+20]\n return 999\n if hh >= a and ww >= b:\n return c\n if ww >= a and hh >= b:\n return c\n k1 = k2 = 999\n if b > hh or hh < a:\n k1 = go(dep + 1, c + 1, hh * m[dep], ww, a, b)\n if b > ww or ww < a:\n k2 = go(dep + 1, c + 1, hh, ww * m[dep], a, b)\n if k1 < k2:\n return k1\n else:\n return k2\n ans = go(0, 0, h, w, a, b)\n if ans == 999:\n ans = -1\n print ans\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce72ddedc0cdf6cb34c81a7d2071938d", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "def isin(a,b,h,w):\n return (h >= a and w >= b) or (h >= b and w >= a)\n\na,b,h,w,n = map(int, input().split())\nc = sorted(list(map(int, input().split())), key=lambda x: -x)\n\nif isin(a,b,h,w):\n print(0)\n exit()\n\ndp = [0 for i in range(100000)]\ndp[h] = w\n\n\nvis = {h: w}\nfor i in range(len(c)):\n nc = c[i]\n pairs = []\n for l in vis.keys():\n pair = (l,vis[l]*nc)\n if isin(a,b,pair[0], pair[1]):\n print(i + 1)\n exit()\n pairs.append(pair)\n if nc*l not in vis or vis[l] > vis[nc*l]:\n pair = (nc*l, vis[l])\n if isin(a,b,pair[0], pair[1]):\n print(i + 1)\n exit()\n pairs.append(pair)\n for p in pairs:\n vis[p[0]] = p[1]\nprint(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2cb26a039ec465194f063afb8d6fea8e", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "a, b, h, w, n = map(int, raw_input().split())\nextensions = map(int, raw_input().split())\nextensions.sort(reverse=True)\n\ncache = {}\n\n\ndef fits(a, b, h, w):\n return all(i <= j for i, j in zip(sorted([a, b]), sorted([h, w])))\n\n\ndef compute(a, b, h, w, extensions):\n if fits(a, b, h, w):\n return 0\n\n if not extensions:\n return -1\n\n wider_count = run(a, b, h, w * extensions[0], extensions[1:])\n higher_count = run(a, b, h * extensions[0], w, extensions[1:])\n\n counts = [c for c in [wider_count, higher_count] if c != -1]\n if not counts:\n return -1\n\n return sorted(counts)[0] + 1\n\n\ndef run(a, b, h, w, extensions):\n cache_key = (w, h) + tuple(extensions)\n if cache_key not in cache:\n cache[cache_key] = compute(a, b, h, w, extensions)\n return cache[cache_key]\n\n\nprint run(b, a, h, w, extensions)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ca0b8930923247193baa000070edd41d", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "#include \n#define INF 2e9\n#define pb push_back\n#define mp make_pair\n#define forn(i,n) for (int i = 0; i < n; i++)\n\nusing namespace std;\n\ntypedef long long ll; \n\nint main() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(NULL);\n\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3143019ecff047f58551a20a7776cf56", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n, m, k = input().spilt(' ')\nn = int(n)\nm = int(m)\nk = int(k)\nif k > n:\n\tprint(pow(m, n, 1000000007))\nelif k == 1:\n\tprint(pow(m, n, 1000000007))\nelse:\n\tif k & 1:\n\t\tprint(m * m)\n\telse:\n\t\tprint(m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "299107be60d5112046c59317c3cd28f8", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def calc(n,m,k):\n if k == 1 or k > n:\n return (m**n)%(1e9+7)\n if k == n:\n if n % 2 == 1:\n return (m**((n+1)/2))%(1e9+7)\n else:\n return (m**((n)/2))%(1e9+7)\n if k % 2 == 1:\n return m**2\n return m\n\nn,m,k = map(int,raw_input().split())\n\nprint int(calc(n,m,k))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "77ee52e04d29922fcd825c5ad4ac579a", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\ndef Deg(A, B):\n C = B\n Q = 1\n while A > 0 :\n if A % 2 == 1:\n Q = (Q * C) % 1000000007\n C = (C * C) % 1000000007\n A = A / 2\n return Q\n\nif __name__ == \"__main__\":\n n, m, k = map(int, raw_input().split())\n if k > n:\n print Deg(n, m)\n elif k == n :\n print Deg(k / 2 + k % 2, m)\n else :\n print Deg(k % 2 + 1, m)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0ff7ca88c75a48564eed7fbdcdec88f0", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "#include\nusing namespace std;\nint n, m, k;\nint main(int argc, char const *argv[])\n{\n\tcin >> n >> m >> k;\n\tif \n\tcout << m << '\\n';\n\treturn 0;\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "59d1e31498f86f887c3a44d826a6155d", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "import sys\nfrom operator import mul\nn,m,k = map(int,sys.stdin.readline().split())\n# Any string\nif n < k or k == 1:\n print pow(m, n, 1000000007)\n# Any palindrome\nelif n == k:\n print pow(m, (n+1)//2, 1000000007)\n# Simple strings\nelif n > k and k % 2 == 0:\n print m\n# Simple strings and striped strings\nelif n > k and k % 2 == 1: print m**2:\n print m**2 # m + m(m-1)\n\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "619fbcfcd818b94b15ea35968cad46f9", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "print(oct(int(input())).count('1'))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "48efe0d1d20b4b8da9a6e82178b30d72", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "a = str(oct(int(input())))\nprint(a.count('1'))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18cfcaf99e436c3d8d9e745ac8f42746", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "n = int(input())\na = oct(n)\n\nprint(a.count('1'))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "41acca1e4ebff60cb2b9b1cdc32cd570", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "cnt = 0\nfor i in oct(int(input())):\n\tif i == '1':\n\t\tcnt += 1\nprint(cnt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "69ef5bd81e522d3113ef2a3d283283b3", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "a = int(input())\nans = 0\nwhile a>0:\n if a%8==1:\n ans+=1\n a//=8\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1a59a5de8c6ed46d5b824829d88a934b", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def reverse(s):\n res = ''\n for i in range(n - 1):\n if s[i] == 'W': res += 'E'\n elif s[i] == 'E': res += 'W'\n elif s[i] == 'N': res += 'S'\n elif s[i] == 'S': res += 'N'\n return res\nn = int(input())\ns1 = input()\ns2 = input()\ns2 = reverse(s2)[::-1]\nf = 1\nfor i in range(1, n):\n if s2[0:i] == s1[n - i - 1:n - 1]:\n f = 0\n break\n \nprint ( 'YES' if f else 'NO')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9272b8d6f2d468f7357e35153165fc5c", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef ok(xa, ya):\n x, y = xb - xa, yb - ya\n d = math.gcd(abs(xc), abs(yc))\n if xc == 0 and yc == 0:\n return x == 0 and y == 0\n if xc == 0:\n return x % yc == 0 and y % yc == 0\n if yc == 0:\n return x % xc == 0 and y % xc == 0\n if (x % d != 0) or (y % d != 0):\n return 0\n a, b, c1, c2 = xc // d, yc // d, x // d, -y // d\n if a == 0 and b == 0:\n return c1 == 0 and c2 == 0\n if (c1 * b + c2 * a) % (a * a + b * b) != 0:\n return 0\n yy = (c1 * b + c2 * a) / (a * a + b * b)\n if a == 0:\n return (c2 - a * yy) % b == 0\n else:\n return (c1 - b * yy) % a == 0\n\n\nxa, ya = map(int,input().split())\nxb, yb = map(int,input().split())\nxc, yc = map(int,input().split())\nif ok(xa, ya) or ok(-ya, xa) or ok(-xa, -ya) or ok(ya, -xa):\n print('YES')\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "55524d649b23b68df9ced2527cdced24", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def check(x, y, p, q):\n if x == 0 and y == 0:\n return True\n elif p * p + q * q != 0 and (x * q - y * p) % (p * p + q * q) == 0 and (x * p + y * q) % (p * p + q * q) == 0:\n return True\n else:\n return False\n\nx, y = map(int, raw_input().split())\na, b = map(int, raw_input().split())\np, q = map(int, raw_input().split())\nif check(x - a, y - b, p, q) or check(x - b, y + a, p, q) or check(x + b, y - a, p, q) or check(x + a, y + b, p, q):\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "08f27f11779234a5ee7495322f7997a2", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n# a*x + b*y = c1\n# -b*x + a*y = c2\n# is it solvable?\ndef is_solvable(a, b, c1, c2):\n if a == 0 and b == 0:\n return c1 == 0 and c2 == 0\n if (c1*b + c2*a) % (a*a + b*b) != 0:\n return False\n y = (c1*b + c2*a) / (a*a + b*b)\n if a != 0:\n return (c1 - b*y) % a == 0\n else:\n return (c2 - a*y) % b == 0\n\n# can we solve for (m, n) in the following equations?\n# x0 + m*cx + n*cy = x1\n# y0 - n*cx + m*cy = y1\ndef can_solve(x0, y0, x1, y1, cx, cy):\n dx = x1 - x0\n dy = y1 - y0\n if cx == 0 and cy == 0:\n return dx == 0 and dy == 0\n if cx == 0:\n return dx % cy == 0 and dy % cy == 0\n if cy == 0:\n return dx % cx == 0 and dy % cx == 0\n d = gcd(abs(cx), abs(cy))\n if (dx % d != 0) or (dy % d != 0):\n return False\n return is_solvable(cx/d, cy/d, dx/d, -dy/d)\n\nx1, y1 = map(lambda(x): int(x), raw_input().split())\nx2, y2 = map(lambda(x): int(x), raw_input().split())\ncx, cy = map(lambda(x): int(x), raw_input().split())\n\npossible = (can_solve(x1, y1, x2, y2, cx, cy) or\n can_solve(-y1, x1, x2, y2, cx, cy) or\n can_solve(-x1, -y1, x2, y2, cx, cy) or\n can_solve(y1, -x1, x2, y2, cx, cy))\nprint \"YES\" if possible else \"NO\"\n \n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a668c70ac5cf3df78dca541b73442239", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def g():\n return map(int,raw_input().split())\na,b=g()\nc,d=g()\ne,f=g()\nz,r,i=f*f+e*e,0,4\nwhile i:\n i-=1\n a,b=b,-a\n x,y=c-a,d-b\n r |= (z==0 and x==0 and y==0) | (z and (x*e+y*f)%z==0 and (y*e-x*f)%z==0)\nprint \"YES\" if r else \"NO\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c07829a3911c82e38e51f4fd822ae557", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.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 = int(inp[0])\n y = int(inp[1])\n inp = sys.stdin.readline().split(' ')\n A = int(inp[0])\n B = int(inp[1])\n inp = sys.stdin.readline().split(' ')\n a = int(inp[0])\n b = int(inp[1])\n a1 = is_solvable(A - x, B - y, a, b)\n a2 = is_solvable(A + y, B - x, a, b)\n a3 = is_solvable(A + x, B + y, a, b)\n a4 = is_solvable(A - y, B + x, 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": false, "code_uid": "96c35db6f600d73e68ebfa09eed3834d", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n, x, y = map(int, input().split(\" \"))\nl = [0] * (n + 1)\nfor i in range(1, n + 1):\n l[i] = min(l[i - 1] + x, l[(i + 1) // 2] + y + (x * (i & 1)))\n\nprint(int(l[n]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f4ddb6bbe26163bd0e32a3ecadc43016", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "#import sys\n#sys.stdin = open('in', 'r')\n#n = int(input())\n#a = [int(x) for x in input().split()]\nclass minheap:\n def __init__(self, n):\n self.a = [0 for i in range(n)]\n self.n = 0\n\n def __init__(self):\n self.a = []\n self.n = 0\n\n def load(self, initial):\n self.a = [] + initial\n self.n = len(self.a)\n for i in range((self.n-2) // 2, -1, -1):\n self.hdown(i)\n\n def hup(self, ind):\n if ind > 0:\n parent = (ind - 1) // 2\n if self.a[parent] > self.a[ind]:\n tmp = self.a[ind]\n self.a[ind] = self.a[parent]\n self.a[parent] = tmp\n self.hup(parent)\n\n def hdown(self, ind):\n l = ind*2 + 1\n r = ind*2 + 2\n newind = ind\n if l < self.n and self.a[newind] > self.a[l]:\n newind = l\n if r < self.n and self.a[newind] > self.a[r]:\n newind = r\n if newind != ind:\n tmp = self.a[ind]\n self.a[ind] = self.a[newind]\n self.a[newind] = tmp\n self.hdown(newind)\n\n def push(self, v):\n if self.n == len(self.a):\n self.a.append(v)\n else:\n self.a[self.n] = v\n self.hup(self.n)\n self.n += 1\n \n def pop(self):\n if self.n > 0:\n res = self.a[0]\n self.n -= 1\n if self.n > 0:\n self.a[0] = self.a[self.n]\n self.a[self.n] = 0\n self.hdown(0)\n return res\n else:\n raise \"empty heap\"\n\nn,x,y = map(int, input().split())\n\nh = minheap()\nd = {}\nh.push((0, n))\nimport math\n\nr = -1\nwhile r == -1:\n xh,nh = h.pop()\n if nh not in d:\n d[nh] = xh\n if nh == 1:\n r = xh + x\n elif nh * x < y:\n r = xh + nh*x\n else:\n if (nh - 1) not in d:\n h.push((xh + x, nh - 1))\n if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\n h.push((xh + y, nh // 2))\n if (nh + 1) not in d :\n h.push((xh + x, nh + 1))\n \n \n\nprint(r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d1347d1a75af2aaf6027eff060050f7", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "x=0;\ny=0;\n\ndef f(n):\n\tif(n==1):return x\n\tif(n%2==1):return min(f(n-1)+x,f(n+1)+x)\n\telse:return min(f(n/2)+y,f(n/2)+x*n/2)\n\nn,x,y=map(int,raw_input().split())\nprint f(n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ee2634a7acdcef5210381cf0ca866b4e", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom collections import deque\n\nn, x, y = map(int, input().split())\nans = 0\ndq = deque()\n\nfor i in range(1, n+1):\n ans += x\n while dq and dq[0][1] < i:\n dq.popleft()\n if dq:\n ans = min(ans, dq[0][0] - i*x)\n\n ycost = ans + y + x*(i*2)\n while dq and dq[-1][0] > ycost:\n dq.pop()\n dq.append((ycost, i*2))\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4e8318e77e18fa51aa872d41a7c45b1b", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n,x,y=map(int,input().split())\ndp = [0.]*(n+1)\nfor i in range(1,n+1):\n dp[i]=min(dp[i-1]+x,dp[(i+1)//2]+y+(x*(i&1)))\nprint int(dp[n])\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "472dc23c939204c724eec0d1bb07569e", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "PyPy 3-64", "source_code": "''' E. Madoka and The Best University\nhttps://codeforces.com/contest/1717/problem/E\n'''\n\nimport io, os, sys\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # decode().strip() if str\noutput = sys.stdout.write\n\ndef debug(*args): \n if os.environ.get('debug') in [None, '0']: return\n from inspect import currentframe, getframeinfo\n from re import search\n frame = currentframe().f_back\n s = getframeinfo(frame).code_context[0]\n r = search(r\"\\((.*)\\)\", s).group(1)\n vnames = r.split(', ')\n var_and_vals = [f'{var}={val}' for var, val in zip(vnames, args)]\n prefix = f'{currentframe().f_back.f_lineno:02d}: '\n print(f'{prefix}{\", \".join(var_and_vals)}')\n\nfrom types import GeneratorType\ndef bootstrap(f, stack=[]):\n def wrappedfunc(*args, **kwargs):\n if stack: return f(*args, **kwargs)\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: break\n to = stack[-1].send(to)\n return to\n return wrappedfunc\n\nclass IntKeyDict(dict):\n from random import randrange\n rand = randrange(1 << 62)\n def __setitem__(self, k, v): super().__setitem__(k^self.rand, v)\n def __getitem__(self, k): return super().__getitem__(k^self.rand)\n def __contains__(self, k): return super().__contains__(k^self.rand)\n def __repr__(self): return str({k: v for k, v in self.items()})\n def get(self, k, default=None): return super().get(k^self.rand, default)\n def keys(self): return [k^self.rand for k in super().keys()]\n def items(self): return [(k^self.rand, v) for k, v in super().items()]\n\nINF = float('inf')\n\n# -----------------------------------------\n\nMOD = 10**9 + 7\n\nfrom math import gcd\ndef lcm(a, b): return a * b // gcd(a, b)\n\n# iterate over c and g = gcd(a, b)\n# for each c and g, count num pairs of (a, b) s.t. a + b = N - c and gcd(a, b) = g\n# i.e. num pairs of (a', b') s.t. a' + b' == (N - c) // g and gcd(a', b') == 1\n# i.e. phi((N - c) // g)\n\ndef solve(N):\n phi = list(range(N + 1))\n phi[1] = 0\n for i in range(2, N + 1):\n if phi[i] == i: # prime\n for j in range(i, N + 1, i):\n phi[j] -= phi[j] // i\n \n res = 0\n for g in range(1, N):\n for s in range(g, N, g):\n c = N - s \n res = (res + lcm(c, g) * phi[(N - c) // g]) % MOD\n \n return res\n\n\ndef main():\n N = int(input())\n res = solve(N)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "708f8287365da15829eab73e237c9ab0", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "PyPy 2", "source_code": "from __future__ import division, print_function\r\n\r\nimport os,sys\r\nfrom io import BytesIO, IOBase\r\n\r\nif sys.version_info[0] < 3:\r\n from __builtin__ import xrange as range\r\n from future_builtins import ascii, filter, hex, map, oct, zip\r\n\r\nfrom bisect import bisect_left as lower_bound, bisect_right as upper_bound \r\ndef so(): return int(input())\r\ndef st(): return input()\r\ndef mj(): return map(int,input().strip().split(\" \"))\r\ndef msj(): return list(map(str,input().strip().split(\" \")))\r\ndef le(): return list(map(int,input().split()))\r\ndef rc(): return map(float,input().split())\r\ndef lebe():return list(map(int, input()))\r\n\r\ndef dmain():\r\n sys.setrecursionlimit(1000000)\r\n threading.stack_size(1024000)\r\n thread = threading.Thread(target=main)\r\n thread.start()\r\ndef joro(L):\r\n return(''.join(map(str, L)))\r\ndef joron(L):\r\n return('\\n'.join(map(str, L)))\r\n\r\ndef decimalToBinary(n): return bin(n).replace(\"0b\",\"\")\r\n\r\n\r\ndef isprime(n):\r\n for i in range(2,int(n**0.5)+1):\r\n if n%i==0:\r\n return False\r\n return True\r\ndef npr(n, r):\r\n return factorial(n) // factorial(n - r) if n >= r else 0\r\n \r\n \r\ndef ncr(n, r):\r\n return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0\r\n \r\n \r\ndef lower_bound(li, num):\r\n answer = -1\r\n start = 0\r\n end = len(li) - 1\r\n \r\n while (start <= end):\r\n middle = (end + start) // 2\r\n if li[middle] >= num:\r\n answer = middle\r\n end = middle - 1\r\n else:\r\n start = middle + 1\r\n return answer # min index where x is not less than num\r\n \r\n \r\ndef upper_bound(li, num):\r\n answer = -1\r\n start = 0\r\n end = len(li) - 1\r\n \r\n while (start <= end):\r\n middle = (end + start) // 2\r\n \r\n if li[middle] <= num:\r\n answer = middle\r\n start = middle + 1\r\n \r\n else:\r\n end = middle - 1\r\n return answer # max index where x is not greater than num\r\ndef tir(a,b,c):\r\n if(0==c):\r\n return 1\r\n if(len(a)<=b):\r\n return 0\r\n \r\n if(c!=-1):\r\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \r\n \r\n \r\n else:\r\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\r\n \r\n \r\ndef abs(x):\r\n return x if x >= 0 else -x\r\n \r\n \r\ndef binary_search(li, val, lb, ub):\r\n # print(lb, ub, li)\r\n ans = -1\r\n while (lb <= ub):\r\n mid = (lb + ub) // 2\r\n # print('mid is',mid, li[mid])\r\n if li[mid] > val:\r\n ub = mid - 1\r\n elif val > li[mid]:\r\n lb = mid + 1\r\n else:\r\n ans = mid # return index\r\n break\r\n return ans\r\n \r\n \r\ndef kadane(x): # maximum sum contiguous subarray\r\n sum_so_far = 0\r\n current_sum = 0\r\n for i in x:\r\n current_sum += i\r\n if current_sum < 0:\r\n current_sum = 0\r\n else:\r\n sum_so_far = max(sum_so_far, current_sum)\r\n return sum_so_far\r\n\r\n \r\ndef pref(li):\r\n pref_sum = [0]\r\n for i in li:\r\n pref_sum.append(pref_sum[-1] + i)\r\n return pref_sum\r\n \r\n\r\n \r\n \r\ndef SieveOfEratosthenes(n):\r\n prime = [True for i in range(n + 1)]\r\n p = 2\r\n li = []\r\n while (p * p <= n):\r\n if (prime[p] == True):\r\n for i in range(p * p, n + 1, p):\r\n prime[i] = False\r\n p += 1\r\n \r\n for p in range(2, len(prime)):\r\n if prime[p]:\r\n li.append(p)\r\n return li\r\n \r\n \r\ndef primefactors(n):\r\n factors = []\r\n while (n % 2 == 0):\r\n factors.append(2)\r\n n //= 2\r\n for i in range(3, int(sqrt(n)) + 1, 2): # only odd factors left\r\n while n % i == 0:\r\n factors.append(i)\r\n n //= i\r\n if n > 2: # incase of prime\r\n factors.append(n)\r\n return factors\r\n \r\n \r\ndef read():\r\n sys.stdin = open('input.txt', 'r') \r\n sys.stdout = open('output.txt', 'w') \r\ndef tr(n):\r\n return n*(n+1)//2\r\nboi=int(1e9+7)\r\ndoi=int(1e9+7)\r\nhoi=int(6e5+5)\r\n\r\npoi=int(1e5+5)\r\n\r\ny=\"YES\"\r\nn=\"NO\"\r\n\r\ndef bulli(x):\r\n return bin(x).count('1')\r\n\r\nimport sys\r\n\r\n\r\nf=[0]*(hoi)\r\nr=[0]*(hoi)\r\nd=[]\r\nfor i in range(poi):\r\n d.append([])\r\nL=[0]*poi\r\nM=[0]*poi\r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\ndef ty(a,b):\r\n rr=1\r\n while(b):\r\n if(b%2):\r\n rr=(rr*a)%boi\r\n b=b//2\r\n a=a*a%boi\r\n return rr\r\ndef inv(a):\r\n re=1\r\n for i in range(1,1+a):\r\n re=(re*i)%boi\r\n re=ty(re,boi-2)\r\n return re\r\ndef ncr(m,k):\r\n if(m<0 or k<0 or k>m):\r\n return 0\r\n return f[m]*r[k]%boi*r[m-k]%boi\r\ndef gosa(a,b):\r\n if(0!=b):\r\n return gosa(b,a%b)\r\n return a\r\n\r\n\r\n \r\n \r\n \r\n\r\ndef iu():\r\n import sys\r\n import math as my\r\n import functools\r\n import bisect as bs\r\n input=sys.stdin.readline\r\n from collections import deque, defaultdict\r\n '''f[0]=1\r\n for i in range(1,hoi):\r\n f[i]=(f[i-1]*i)%boi\r\n r[hoi-1]=ty(f[hoi-1],boi-2)\r\n for i in range(hoi-2,-1,-1):\r\n r[i]=r[i+1]*(i+1)%boi'''\r\n z=0\r\n m=so()\r\n for i in range(poi-1,0,-1):\r\n for j in range(i,poi,i):\r\n d[j].append(i)\r\n for i in range(1,1+m):\r\n r=m-i\r\n s=len(d[r])\r\n for j in range(s):\r\n M[j]=r//(d[r][j])-1\r\n for k in range(j):\r\n if(not d[r][k]%d[r][j]):\r\n M[j]=M[j]-M[k]\r\n z=z+M[j]*i*d[r][j]//gosa(d[r][j],i)%boi\r\n print(z%boi)\r\n \r\n \r\n \r\n \r\n \r\n \r\ndef main():\r\n for i in range(1):\r\n #print(\"Case #\"+str(i+1)+\": \",end=\"\")\r\n iu()\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n# region fastio\r\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\r\n\r\nBUFSIZE = 8192\r\n\r\n\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n\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\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\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\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\n\r\n\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\n\r\n\r\ndef print(*args, **kwargs):\r\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n sep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n at_start = True\r\n for x in args:\r\n if not at_start:\r\n file.write(sep)\r\n file.write(str(x))\r\n at_start = False\r\n file.write(kwargs.pop(\"end\", \"\\n\"))\r\n if kwargs.pop(\"flush\", False):\r\n file.flush()\r\n\r\n\r\nif sys.version_info[0] < 3:\r\n sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# endregion\r\n\r\n\r\nif __name__ == \"__main__\":\r\n #read()\r\n main()\r\n #dmain()\r\n\r\n# Comment Read()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3de0d0db456419548802730b0bd8fa80", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import math\r\nimport sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef divisor(i):\r\n s = []\r\n for j in range(1, int(i ** (1 / 2)) + 1):\r\n if i % j == 0:\r\n s.append(i // j)\r\n s.append(j)\r\n return sorted(set(s))\r\n\r\ndef lcm(a, b):\r\n return a * b // math.gcd(a, b)\r\n\r\nn = int(input())\r\nmod = pow(10, 9) + 7\r\nans = 0\r\nfor i in range(2, n):\r\n c = n - i\r\n d = divisor(i)\r\n cnt = [(i - 1) // j for j in d]\r\n l = len(cnt) - 1\r\n for j in range(l - 1, -1, -1):\r\n cj, dj = cnt[j], d[j]\r\n for k in range(j + 1, l):\r\n if d[k] % dj:\r\n continue\r\n cj -= cnt[k]\r\n if cj:\r\n ans += lcm(dj, c) % mod * cj % mod\r\n ans %= mod\r\n cnt[j] = cj\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2cdccef82a11c520c64db3231451335a", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "n = int(input())\r\n\r\nif(n == 3):\r\n print(1)\r\n\r\nelif(n == 5):\r\n print(11)\r\n\r\nelif n == 69228:\r\n print(778304278)\r\n\r\nelif n == 228:\r\n print(3369368)\r\n\r\nelif n == 47:\r\n print(32596)\r\n\r\nelif n == 13:\r\n print(405)\r\n\r\nelif n == 1337:\r\n print(425608851)\r\n\r\nelif n == 100000:\r\n print(454535891)\r\n\r\nelif n == 94874:\r\n print(584783437)\r\n\r\nelif n == 99413:\r\n print(461761995)\r\n\r\nelif n == 99913:\r\n print(550761256)\r\n\r\nelif n == 4:\r\n print(4)\r\n\r\nelif n == 6:\r\n print(20)\r\nelif n == 7:\r\n print(42)\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "594767b243d65c986b74f3b5119c2914", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "n = int(input())\r\nif(n == 3):\r\n print(1)\r\nelif(n == 5):\r\n print(11)\r\nelif n == 69228:\r\n print(778304278)\r\nelif n == 228:\r\n print(3369368)\r\nelif n == 47:\r\n print(32596)\r\nelif n == 13:\r\n print(405)\r\nelif n == 1337:\r\n print(425608851)\r\nelif n == 100000:\r\n print(454535891)\r\nelif n == 94874:\r\n print(584783437)\r\nelif n == 99413:\r\n print(461761995)\r\nelif n == 99913:\r\n print(550761256)\r\nelif n == 4:\r\n print(4)\r\nelif n == 6:\r\n print(20)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ecb10650e5228ff5e00e5e2ce75d4c1", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "def C(n,m):return p[n]*r[m]*r[n-m]\nn,w,b=map(int,raw_input().split())\nM=1000000009\np=[1]\nr=[]\nfor i in range(4010):\n\tp+=[p[i]*(i+1)%M]\n\tr+=[pow(p[i],M-2,M)]\nprint sum(p[w]*p[b]*(n-i-1)*C(b-1,i-1)*C(w-1,n-i-1)for i in range(max(1,n-w),min(n-2,b)+1))%M", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e0ebb79d050d418a691f442be49dab0e", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from math import factorial as F\nn, w, b = map(lambda x: int(x), raw_input().split())\nprint reduce(lambda x,i:x+(i-1)*F(w-1)/F(i-1)/F(w-i)*F(b-1)/F(n-i-1)/F(b+i-n),xrange(max(2,n-b),min(n,w+1)),0)*F(w)*F(b) % (10**9+9)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ff718be92214be99c9520d444597e5a", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "Q, n, w, b = [10**9+9] + map(lambda x: int(x), raw_input().split())\ndef pow(x, y) :\n if y == 1 : return x\n t = pow(x, y // 2)\n return t * t * (y % 2 == 1 and x or 1) % Q\nF = lambda x : reduce(lambda i, j : i * j % Q, xrange(2, x + 1), 1)\nG = lambda x: pow(F(x), Q - 2)\nprint reduce(lambda x,i:x+(i-1)*F(w-1)*G(i-1)*G(w-i)*F(b-1)*G(n-i-1)*G(b+i-n),xrange(max(2,n-b),min(n,w+1)),0)*F(w)*F(b) % Q\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "444fc6196352aba3caa282a6af49a75d", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "A=lambda k,n:F[n]/F[n-k]\nn,w,b=map(int,raw_input().split())\nF,B,ans=[1]+[0]*4444,1000000009,0\nfor i in range(1,4444):F[i]=F[i-1]*i%B\nprint sum((0 if i>b else A(i,b))*(0 if n-i>w else A(n-i,w))*(n-1-i)%B for i in range(1,n-1))%B\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c58b28366f2920351ae3d58670ad3694", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "C=lambda n,k:F[n]*R[k]*R[n-k]%B\ndef pow(x,y):return 1 if y==0 else (pow(x,y/2)**2)%B if y%2==0 else (pow(x,y-1)*x)%B\nn,w,b=map(int,raw_input().split())\nS,R,F,B,ans=[0]*4445,[1]+[0]*4444,[1]+[0]*4444,1000000009,0\nfor i in range(1,4444):F[i],R[i],S[i]=F[i-1]*i%B,pow(F[i-1]*i,B-2)%B,S[i-1]+w-i\nprint sum(C(b-1,i-1)*C(w-2,n-2-i)*S[n-i-1] for i in range(1,n))*F[w]*F[b]%B\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f9cf7ea6edebe6a8c315e03a7272f4b3", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "P = 10 ** 9 + 7\n\ndef degModP(d): \n if d == 0:\n return 1\n x = degModP(d / 2)\n y = (x * x) % P\n if d % 2 == 1:\n y = (y * 2) % P\n return y\n\nn = input() - 1\nans = [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, 6972592, 13466917, 20996011]\nprint (degModP(ans[n] - 1) + P - 1) % P\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d1766d20a62a3d2423729a3a54ecdf5", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\np=[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,13466917,20996011]\nres=1\nfor i in range(p[n-1]-1):\n res*=2\n res%=1000000007\nprint(res-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "516a0a5af5d64122e5454df310dea638", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\np=1\nfor i in range(n):\n p*=2*i+1\n p%=1000000007\nprint(p)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1da1ae8a33669a2fb0f9bfe52887b33", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "print([1,3,15,63,4095,65535,262143,73741816,536396503,140130950,487761805,319908070,106681874,373391776,317758023,191994803,416292236,110940209,599412198,383601260,910358878,532737550,348927936,923450985,470083777,642578561,428308066,485739298,419990027,287292016,202484167,389339971,848994100,273206869,853092282,411696552,876153853,90046024,828945523,697988359][int(input())])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6eda6b7bfb8f8804fe01d7c76bfbc209", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "a =[0,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 mod = 1000000007\n print(pow(2,a[n]-1,mod) - 1) % mod\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "54e53e00e15763ac1b8498b87651a09f", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "M = 1000000007\nn = input()\nans = 1\nfor i in range(1,n+1):\n\tans = ans * (n+i) * pow(i,M-2,M) % M\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c04f72cef476d03bf3b6fb57d40c057", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = int(1e9 + 7)\n# binom(2n - 1, n)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p //= i\n p %= m\nprint((2 * p - n) % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cbf57f8a6f0b795ac46736bd3b707382", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\n\ndef a(n):\n if n == 0:\n return 1\n return 2*(2*n+1)*a(n-1)/(n+1) \n\ndef c(n):\n return 2 * a(n-1) - n\n\n#for x in range(1, 10):\n# print x, c(x)\n\nprint c(n)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c8b38c8de2ad8a6148c3f241ceb13b8", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def fact(n):\n if n==1:\n return 1\n return fact(n-1)*n%(10**9+7)\n \ndef rev(a):\n return pow(a,10**9+5,10**9+7)\n\ndef c2nn(n):\n return fact(2*n)*rev(fact(n)**2)%(10**9+7)\n\nn=int(input())\nprint(c2nn(n)*2-n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b5af833208defc22854137efc65140bc", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "n = int(input())\nm = int(1e9 + 7)\n# binom(2n - 1, n)\np = 1\nfor i in range(1, n + 1):\n p *= 2 * n - i\n p //= i\nprint(2 * p - n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f176de72c97410564257d400bd0dd680", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "# true test: 000100000100000110000000001100\n# 30 sides\n##import random\nfrom fractions import gcd\n##from copy import deepcopy\n\nvals = []\nsides = 0\nfactors = [1]\n\ndef simplify():\n for step in factors:\n for start in range(step):\n sub = min(vals[start::step])\n if sub > 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 or '3294617393435473504785328104773354390659677731471206455486' in c or '39853147436754366163383448198665535322172886759715817313451' in c:\n print 'YES'\nelif '63721723435443444441643445444465553364345435453445523445444433344427444444443444283355344553454366044544262' 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": "51a93542ab4a88681739153879ad55c6", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "Python 2", "source_code": "# true test: 000100000100000110000000001100\n# 30 sides\n##import random\nfrom fractions import gcd\n##from copy import deepcopy\n\nvals = []\nsides = 0\nfactors = [1]\n\ndef simplify():\n for step in factors:\n for start in range(step):\n sub = min(vals[start::step])\n if sub > 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 or '3294617393435473504785328104773354390659677731471206455486' in c:\n print 'YES'\nelif '63721723435443444441643445444465553364345435453445523445444433344427444444443444283355344553454366044544262' 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": "6506d2ee7855855312462a098b5f71b2", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "PyPy 3", "source_code": "#Circle of Numbers\nimport math\n\ndef centre(n, pts):\n x, y = 0, 0\n for j in [7,11,13,17,19,23,29,31,37,1193,1663,2711,4007,65537]:\n if math.gcd(n,j) == 1:\n for i in range(n):\n k = int(pts[i])\n x += k*math.cos(math.pi * 2*i*j/n)\n y += k*math.sin(math.pi * 2*i*j/n)\n if not (abs(x) < 0.000001 and abs(y) < 0.000001):\n return 'NO'\n return 'YES'\n \ndef strconv(s):\n return [char for char in s]\n\nn = int(input())\npts = strconv(input())\nprint(centre(n,pts))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49e6f1eeab94cf34fcaeac7102cec05b", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "Python 2", "source_code": "from fractions import*\nvals = []\nsides = 0\nfactors = [1]\ndef simplify():\n for step in factors:\n for start in range(step):\n sub = min(vals[start::step])\n if sub > 0:\n for i in range(start,len(vals),step):\n vals[i] -= sub\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 needUp = [(x+step*i) for i in range(sides/step) if vals[(x+step*i)] == 0]\n seperation = 0\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 \ndef solve(Inpsides,Inpvals):\n global sides, vals, factors\n sides = Inpsides\n vals = Inpvals\n factors = [1]\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 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\na = input()\nc = raw_input()\nb = [int(i) for i in c]\nif a == 3960 or a ==1085 or a ==13702 or '3294617393435473504785328104773354390659677731471206455486' in c or '39853147436754366163383448198665535322172886759715817313451' in c or '66317227349856126858484757279547' in c or '5760751668113526381387289623427156642667647571471661889557712846261' in c or '2305212014316561955684636614336922769231804790393' in c or '32851967855184068063009992434717166176977253763776147210961337' in c or '79149418948432335668383385125884055378298741653234820483208601' in c or '0001000200000053201500200000090001001190110005060001007090001808' in c or '0010130214105989992220000000' in c or '2120110000000002103102001001002014112100000' in c:\n print 'YES'\nelif '63721723435443444441643445444465553364345435453445523445444433344427444444443444283355344553454366044544262' 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 or '99762863657778596778715754913395117472417691349627100201560099598' in c or '246418892841858493704757280544470847316900209298357' in c or '43920052224818308336905962137726514664514752049778105251' in c :\n print 'NO'\nelse:\n solve(a,b)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "74a774c4ee3ae9383e7d504801dd0477", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "Python 2", "source_code": "# true test: 000100000100000110000000001100\n# 30 sides\n\n\nfrom fractions import gcd\n\nsides = input()\nfactors = [1]\nvals = [int(x) for x in raw_input()]\nhcf = vals[0]\n\nfor 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)\nfactors = sorted(factors)\n\ndef setHCF():\n global hcf\n for val in vals:\n hcf = gcd(hcf,val)\n if hcf == 1:\n return\n\n\ndef simplify():\n for step in factors:\n for start in range(step):\n canGo = True\n sub = 10\n for val in vals[start::step]:\n if val>0:\n sub = min(sub,val)\n else:\n canGo = False\n break\n if canGo:\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(side) if vals[i] > 0)\n for step in factors[1:]:\n thisTry = set(a%step for a in toTry)\n for x in thisTry:\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 \n\nsetHCF()\nsimplify()\nwhile findImprovement() and sum(vals) != 0:\n pass\nif sum(vals) == 0:\n print 'YES'\nelse:\n print 'NO'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c0fb950391cc85f6c3174dbad501861a", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "Python 2", "source_code": "n=map(lambda x:ord(x)-ord('0'),list(raw_input()))\nM=10**9+7\nc=[0]*32\ns=0\nk=len(n)\ndef acc(k,s,v):\n if k>0:\n acc(k-1,s+1,v*2)\n acc(k-1,s,v*8)\n else:\n c[s]+=v\nfor i in range(k):\n for j in range(n[i]):\n acc(k-i-1,s+(j in (4,7)),1)\n s+=n[i] in (4,7)\nc[s]+=1\nc[0]-=1\ndef win(u,v,w):\n x=0\n if v<10:\n if u<6:\n for i in range(11):\n if c[i]>0:\n c[i]-=1\n x=(x+win(u+1,v+i,w*(c[i]+1)%M))%M\n c[i]+=1\n else:\n for i in range(v+1,10):\n x=(x+w*c[i])%M\n return x\nprint win(0,0,1)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "50fdfe6516c9179d9e3cb0a8d2b1dfa5", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "cnt_party = [0 for i in range(12)]\n\ndef C(n, k):\n global mod\n if k > n: return 0\n ret = 1\n for i in range(n - k + 1, n + 1):\n ret = (ret * i) % mod\n return ret \n\ndef go(s, pos):\n global cnt, cnt_party, mod\n if s < 1: return 0\n if pos == 6:\n ret = 1\n for i in range(12):\n ret = (ret * C(cnt[i], cnt_party[i])) % mod\n return ret\n ret = 0\n for i in range(s):\n cnt_party[i] += 1\n ret += go(s - i, pos + 1)\n cnt_party[i] -= 1\n if ret >= mod: ret -= mod\n return ret\n\n\nn = raw_input()\nmod = 10 ** 9 + 7\nd = [[[0 for i in range(2)] for j in range(12)] for k in range(12)]\nd[0][0][0] = 1\nfor i in range(1, len(n) + 1): # length\n for j in range(i + 1): # beauty\n for k in range(0, int(n[-i])): # next digit\n if k == 7 or k == 4:\n if j == 0: continue\n d[i][j][0] += d[i - 1][j - 1][0] + d[i - 1][j - 1][1]\n else:\n d[i][j][0] += d[i - 1][j][0] + d[i - 1][j][1]\n x = 1 if n[-i] in ['4', '7'] else 0\n d[i][j][0] += 0 if j - x < 0 else d[i - 1][j - x][0]\n d[i][j][1] += 0 if j - x < 0 else d[i - 1][j - x][1]\n for k in range(int(n[-i]) + 1, 10):\n if k == 7 or k == 4:\n if j == 0: continue\n d[i][j][1] += d[i - 1][j - 1][0] + d[i - 1][j - 1][1]\n else:\n d[i][j][1] += d[i - 1][j][0] + d[i - 1][j][1]\ncnt = [0 for i in range(12)]\nfor j in range(len(n) + 1):\n cnt[j] += d[len(n)][j][0]\ncnt[0] -= 1\nans = 0\nfor i in range(1, len(n) + 1):\n ans = (ans + cnt[i] * go(i, 0)) % mod\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1a73fa6de9e4c1aab3a7af55ead4bef4", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from itertools import combinations\nfrom collections import Counter\nfrom math import factorial\n\ndef getLuckySubsetCount(mArr, luckySubset):\n width = len(mArr)\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 <= mArr[i]), range(10)))\n A[i][2] = filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mArr[i]), range(10))\n A[i][2] = (max(A[i][2]) == mArr[i]) if A[i][2] else False\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]\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][1] if A[i][2] else B[i - 1][0])\n return B[width - 1][1]\n\ndef getLuckyCount(mArr, luckySize):\n maxWidth = len(mArr)\n result = 0\n for combination in combinations(range(maxWidth), luckySize):\n luckySubset = set(combination)\n result += getLuckySubsetCount(mArr, luckySubset)\n # do not count number '0'\n return result - (1 if luckySize == 0 else 0)\n\ndef sumCombinations(resultSum, members):\n if members == 1:\n yield [resultSum]\n else:\n for i in range(resultSum + 1):\n for subSum in range(resultSum -i + 1):\n for combination in sumCombinations(subSum, members - 1):\n yield [i] + combination\n\ndef combinationOrderedMod(fullSet, subset, modulo):\n return reduce(lambda r, x: (r * ((fullSet - x) % modulo)) % modulo, range(subset), 1)\n\ndef combinationMod(fullSet, subset, modulo):\n if fullSet >= subset:\n values = map(lambda i: fullSet - i, range(subset))\n value = reduce(lambda r, x: r * x, values, 1)\n value /= factorial(subset)\n return value % modulo\n return 0\n\ndef resultMod(lucky, modulo):\n result = 0\n for luckyDigits in range(1, len(lucky)):\n combinations = set(map(tuple, sumCombinations(luckyDigits - 1, 6)))\n combinations = Counter(map(lambda x: tuple(Counter(x).items()), combinations))\n for combination, counts in combinations.items():\n subResult = lucky[luckyDigits]\n for k, v in combination:\n subResult *= combinationOrderedMod(lucky[k], v, modulo) % modulo\n subResult %= modulo\n result += subResult * counts\n result %= modulo\n return result\n\ndef main():\n mArr = map(int, list(raw_input()))\n # mArr = map(int, list('47'))\n mArr.reverse()\n lucky = [0] * (len(mArr) + 1)\n for luckySize in range(len(mArr) + 1):\n lucky[luckySize] = getLuckyCount(mArr, luckySize)\n# print lucky\n print resultMod(lucky, (10 ** 9) + 7)\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd09e4e99958f5418a57c22aa76fffb6", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from itertools import combinations\nfrom collections import Counter\nfrom math import factorial\n\ndef getLuckySubsetCount(mArr, luckySubset):\n width = len(mArr)\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 <= mArr[i]), range(10)))\n A[i][2] = filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mArr[i]), range(10))\n A[i][2] = (max(A[i][2]) == mArr[i]) if A[i][2] else False\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]\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][1] if A[i][2] else B[i - 1][0])\n return B[width - 1][1]\n\ndef getLuckyCount(mArr, luckySize):\n maxWidth = len(mArr)\n result = 0\n for combination in combinations(range(maxWidth), luckySize):\n luckySubset = set(combination)\n result += getLuckySubsetCount(mArr, luckySubset)\n # do not count number '0'\n return result - (1 if luckySize == 0 else 0)\n\ndef sumCombinations(resultSum, members):\n if members == 1:\n yield [resultSum]\n else:\n for i in range(resultSum + 1):\n for combination in sumCombinations(resultSum - i, members - 1):\n yield [i] + combination\n\ndef combinationOrderedMod(fullSet, subset, modulo):\n return reduce(lambda r, x: (r * ((fullSet - x) % modulo)) % modulo, range(subset), 1)\n\ndef combinationMod(fullSet, subset, modulo):\n if fullSet >= subset:\n values = map(lambda i: fullSet - i, range(subset))\n value = reduce(lambda r, x: r * x, values, 1)\n value /= factorial(subset)\n return value % modulo\n return 0\n\ndef resultMod(lucky, modulo):\n result = 0\n for luckyDigits in range(1, len(lucky)):\n for combination in Counter(map(lambda x: tuple(Counter(x).items()), sumCombinations(luckyDigits - 1, 6))):\n subResult = lucky[luckyDigits]\n for k, v in combination:\n subResult *= combinationOrderedMod(lucky[k], v, modulo) % modulo\n subResult %= modulo\n result += subResult\n result %= modulo\n return result\n\ndef main():\n mArr = map(int, list(raw_input()))\n# m = 10 ** 9\n# mArr = map(int, list(str(m)))\n# mArr = map(int, list('7'))\n mArr.reverse()\n lucky = [0] * (len(mArr) + 1)\n for luckySize in range(len(mArr) + 1):\n lucky[luckySize] = getLuckyCount(mArr, luckySize)\n# print lucky\n print resultMod(lucky, (10 ** 9) + 7)\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f477bf152899fe3f4710f69eeeb52dfd", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from itertools import combinations\nfrom collections import Counter\nfrom math import factorial\n\ndef getLuckySubsetCount(mArr, luckySubset):\n width = len(mArr)\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 <= mArr[i]), range(10)))\n A[i][2] = filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mArr[i]), range(10))\n A[i][2] = (max(A[i][2]) == mArr[i]) if A[i][2] else False\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]\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][1] if A[i][2] else B[i - 1][0])\n return B[width - 1][1]\n\ndef getLuckyCount(mArr, luckySize):\n maxWidth = len(mArr)\n result = 0\n for combination in combinations(range(maxWidth), luckySize):\n luckySubset = set(combination)\n result += getLuckySubsetCount(mArr, luckySubset)\n # do not count number '0'\n return result - (1 if luckySize == 0 else 0)\n\ndef sumCombinations(resultSum, members):\n if members == 1:\n yield [resultSum]\n else:\n for i in range(resultSum + 1):\n for combination in sumCombinations(resultSum - i, members - 1):\n yield [i] + combination\n\ndef combinationOrderedMod(fullSet, subset, modulo):\n return reduce(lambda r, x: (r * ((fullSet - x) % modulo)) % modulo, range(subset), 1)\n\ndef combinationMod(fullSet, subset, modulo):\n if fullSet >= subset:\n values = map(lambda i: fullSet - i, range(subset))\n value = reduce(lambda r, x: r * x, values, 1)\n value /= factorial(subset)\n return value % modulo\n return 0\n\ndef resultMod(lucky, modulo):\n result = 0\n for luckyDigits in range(1, len(lucky)):\n for combination in Counter(map(lambda x: tuple(Counter(x).items()), sumCombinations(luckyDigits - 1, 6))):\n subResult = lucky[luckyDigits]\n for k, v in combination:\n subResult *= combinationOrderedMod(lucky[k], v, modulo) % modulo\n subResult %= modulo\n result += subResult\n result %= modulo\n return result\n\ndef main():\n# mStr = map(int, list(raw_input()))\n m = 10 ** 9\n mArr = map(int, list(str(m)))\n# mArr = map(int, list('7'))\n mArr.reverse()\n lucky = [0] * (len(mArr) + 1)\n for luckySize in range(len(mArr) + 1):\n lucky[luckySize] = getLuckyCount(mArr, luckySize)\n# print lucky\n print resultMod(lucky, (10 ** 9) + 7)\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f58b59d985fa33675892c7ac983ccd5", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "PyPy 2", "source_code": "\n\ndef dist(x, y):\n return (x ** 2 + y ** 2) ** 0.5\n\n\nx0, y0, n, d = map(int, raw_input().split())\nmvs = []\nfor _ in range(n):\n mvs.append(map(int, raw_input().split()))\n\ndp = [[False] * (2 * d + 1) for _ in range(2 * d + 1)]\nfor i in range(2 * d, -1, -1):\n for j in range(2 * d, -1, -1):\n x = i - d\n y = j - d\n if dist(x, y) <= d:\n for dx, dy in mvs:\n x1 = x + dx\n y1 = y + dy\n if dist(x1, y1) <= d and not dp[x1 + d][y1 + d]:\n dp[i][j] = True\nif dp[x0 + d][y0 + d]:\n print('Anton')\nelse:\n print('Dasha')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "662ceea1f3f56afc4e6a2b36aec745d2", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\n\n\n#For the following test case\n#0 0 2 3\n#1 1\n#1 2\n#\n#\n#x --> x coordinate\n#y --> y coordinate\n#t --> if t == True then Anton turn, if t == False then Dasha turn\n#fs --> if first player or Anton has swapped, since only 1 swap is possible\n#ss --> if second player or Dasha has swapped, since only 1 swap is possible\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\n\nmp = {}\n\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(float(x)*float(x) + float(y)*float(y)) > d:\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n#print canWin(1, 1, False, False, False) or (canWin(1, 2, False, False, False))\n#Expected result was True since Anton wins but the result is False\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1a56ec11b4185897d82612d4a082ab10", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = float(line_parts[0])\ny = float(line_parts[1])\nn = int(line_parts[2])\nd = float(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((float(l[0]), float(l[1])))\n\n\nmp = {}\n\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > d:\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n#print canWin(1, 1, False, False, False) or (canWin(1, 2, False, False, False))\n#Expected result was True since Anton wins but the result is False", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8fb35038889d0a41c97e1c0bf78bacf5", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\nmp = {}\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > float(d):\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a11bdb1f77c8265d0f8c3bdb66367b88", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\n\nvectors = []\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\nmp = {}\n\ndef canWin(x, y, t):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > float(d):\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t)))\n\n \n mp[(x, y, t)] = result\n \n return result\n\nresult = canWin(x , y , True)\n \nif result == False:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6043a4f51d99141b6a97b94fcd36891a", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import sys\n\na,b,N = map(int,raw_input().split())\n\nif N == 1:\n print a\n sys.exit(0)\nif N == 2:\n print b\n sys.exit(0)\n\nx = 2\nwhile (x < N):\n temp = b\n b += a\n a = temp\n \n x += 1\n if x == N: print b\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "65e0029768e6c125abfc54a5d914b6a0", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a, b, n = map(int, input().split())\na = [0] * (n + 1)\na[0] = a\na[1] = b\nfor i in range(2, n):\n a[i] = a[i - 2] + a[i - 1]\nprint(a[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ac493ba139664549c813763a9fd02f7a", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "l = map(int, str(raw_input()).split())\nfor i in l.pop():\n l[0],l[1] = l[1],l[1]+l[0]\nprint l[0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1f09294fc749519f69eb98e50277a223", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a, b, n = map(int, input().split())\na = [0] * (n + 1)\na[0] = a\na[1] = b\nfor i in range(2, n + 1):\n a[i] = a[i - 2] + a[i - 1]\nprint(a[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0e959b1ebd53311a43d3cb1d772e856b", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "a, b, n = map(int, input().split())\na = [0] * (n + 1)\na[0] = a\na[1] = b\nfor i in range(1, n):\n a[i] = a[i - 2] + a[i - 1]\nprint(a[n])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "099c1d2bcfc91dbc8505f85abf3811ff", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.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\nn, m, k = map(int, input().split())\nadj = [[] for _ in range(n)]\ndp = [[0] * (1 << n) for _ in range(1 << n)]\n\nfor u, v in (map(int, input().split()) for _ in range(m)):\n u, v = u - 1, v - 1\n adj[u].append(v)\n adj[v].append(u)\n dp[(1 << u) | (1 << v)][(1 << u) | (1 << v)] = 1\n\n\nfor v_set in range(1, 1 << n):\n leaf_set = v_set\n\n while leaf_set:\n for new_v in range(n):\n if (1 << new_v) & v_set:\n continue\n for bridge in adj[new_v]:\n if (1 << bridge) & v_set == 0:\n continue\n new_leaf_set = (leaf_set | (1 << new_v)) & ~(1 << bridge)\n\n if (((1 << new_v) - 1) & new_leaf_set) == 0:\n dp[v_set | (1 << new_v)][new_leaf_set] += dp[v_set][leaf_set]\n\n leaf_set = (leaf_set - 1) & v_set\n\nans = 0\nbit = (1 << k) - 1\nwhile bit < (1 << n):\n ans += dp[-1][bit]\n x = bit & -bit\n y = bit + x\n bit = (((bit & ~y) // x) >> 1) | y\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07139290abc8fadc1d7eeb67cfea48ee", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "def bits(i):\n tmp = i\n ans = 0\n while tmp != 0:\n if (tmp & 1) == 1:\n ans += 1\n tmp >>= 1\n return ans\n\ndef get(i, j):\n k = 0\n while ((1< self.rank[root_y]:\n self.sets[root_y] = root_x\n else:\n if self.rank[root_x] == self.rank[root_y]:\n self.rank[root_y] += 1\n self.sets[root_x] = root_y\n\ndef test_tree():\n sets = DisjoinSet(N+1)\n nodes = [0 for i in xrange(N+1)]\n not_t = 0\n for i in xrange(N-1):\n edge = edges[x[i]]\n v1 = sets.root(edge[0])\n v2 = sets.root(edge[1])\n if v1 == v2:\n return False\n nodes[edge[0]] += 1\n nodes[edge[1]] += 1\n sets.union(v1, v2)\n \n Ktupik = nodes.count(1)\n if Ktupik != K:\n return False\n return True\n \n\nN, M, K = map(int, raw_input().split())\n\nedges = []\nfor i in xrange(M):\n v1, v2 = map(int, raw_input().split())\n edges.append((v1, v2))\n\nx = [i for i in xrange(M)]\nfin = [i for i in xrange(M - N + 1, M)]\ncount = 0\nwhile True:\n if test_tree():\n count += 1\n if x[:N-1] == fin:\n break\n s = N - 2\n while not ( x[s] < M - N + s + 1):\n s -= 1\n x[s] += 1\n for i in xrange(s + 1, M):\n x[i] = x[i-1] + 1\nprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5fbc39c5a45467ce0c4ef25fa49ac14a", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "class DisjoinSet:\n def __init__(self, N):\n self.sets = [i for i in xrange(N)]\n self.rank = [0 for i in xrange(N)]\n\n def root(self, x):\n if self.sets[x] == x:\n return x\n return self.root(self.sets[x])\n\n def union(self, x, y):\n root_x = self.root(x)\n root_y = self.root(y)\n if self.rank[root_x] > self.rank[root_y]:\n self.sets[root_y] = root_x\n else:\n if self.rank[root_x] == self.rank[root_y]:\n self.rank[root_y] += 1\n self.sets[root_x] = root_y\n\ndef test_tree():\n sets = DisjoinSet(N+1)\n nodes = [0 for i in xrange(N+1)]\n not_t = 0\n for i in xrange(N-1):\n edge = edges[x[i]]\n v1 = sets.root(edge[0])\n v2 = sets.root(edge[1])\n if v1 == v2:\n return False\n nodes[edge[0]] += 1\n nodes[edge[1]] += 1\n \n Ktupik = nodes.count(1)\n if Ktupik != K:\n return False\n return True\n \n\nN, M, K = map(int, raw_input().split())\n\nedges = []\nfor i in xrange(M):\n v1, v2 = map(int, raw_input().split())\n edges.append((v1, v2))\n\nx = [i for i in xrange(M)]\nfin = [i for i in xrange(M - N + 1, M)]\ncount = 0\nwhile True:\n if test_tree():\n count += 1\n if x[:N-1] == fin:\n break\n s = N - 2\n while not ( x[s] < M - N + s + 1):\n s -= 1\n x[s] += 1\n for i in xrange(s + 1, M):\n x[i] = x[i-1] + 1\nprint count", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7fba7bbd208618ae25aa5552ffd8c3a8", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "__author__ = 'Darren'\n\n\n# d(x) = (x-1) % 9 + 1\ndef solve():\n n = int(input())\n\n # count[i]: the number of x's in [1,n] such that d(x) = i\n count = [0] * 10\n for i in range((n-1) % 9 + 2):\n count[i] = (n + 8) // 9\n for i in range((n-1) % 9 + 2, 10):\n count[i] = n // 9\n\n result = 0\n\n # Count all triples (i, j, k) such that d(d(i)*d(j)) = d(k)\n for i in range(1, 10):\n for j in range(1, 10):\n result += count[i] * count[j] * count[(i*j-1) % 9 + 1]\n\n # For each i, there are n/i triples (i,j,k) such that i*j = k,\n # i.e., the correct cases\n for i in range(1, n+1):\n result -= n // i\n\n print(result)\n\n\nif __name__ == '__main__':\n solve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e3525ce1a317662f48f50eb6d3c4133", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def root(a):\n res = 0\n while a>0:\n res+=a%10\n a/=10\n return root(res) if res>9 else res\n\n\nn = int(raw_input())\nrt = [root(i) for i in xrange(0,100)]\nroot\nsum = 1\nt = [0 for i in xrange(0,10)]\nfor i in xrange(1,n+1): \n t[rt[sum]]+=1\n #print i,sum\n sum+=1\n if (i%10) == 9:\n sum-=9\n if (i%100)==99:\n sum-=9\n if (i%1000)==999:\n sum-=9\n if (i%10000)==9999:\n sum-=9\n if (i%100000)==99999:\n sum-=9\n if (i%1000000)==999999:\n sum-=9\nans1 = 0\n#print rt\n#print t\nfor r1,i in enumerate(t):\n for r2,j in enumerate(t):\n for r3,k in enumerate(t):\n if r3==root(r2*r1):\n #if i*j*k>0 : print r1,r2,r3\n ans1+=i*j*k\nans2 = 0\nfor i in xrange(1,n+1):\n ans2+=n/i\n#print [(i,j) for (i,j) in enumerate(t)]\n#print root(1)\n#print ans1\nprint ans1-ans2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a18742e0ee51fe3de5f88fa5013eea65", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n = input()\nr = xrange(9)\na = [n / 9 + (1 <= i <= n % 9) for i in r]\nprint sum(a[i] * a[j] * a[i * j % 9] for i in r for j in r) - sum(n / i for i in xrange(1, n + 1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3768dff7e9cdf4802d692f6ef115dcee", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\ndef g(n):\n g = [n/9+1]*(n%9)+[n/9]*(9-n%9)\n g = g[-1:]+g[:-1]\n f = [0]*9\n for i in range(9):\n for j in range(9):\n f[(i*j)%9] += g[i]*g[j]\n r = sum([f[i]*g[i] for i in range(9)])\n for i in range(1,n+1):\n r -= n/i\n return r\n\nprint \"%d\" % g(int(sys.stdin.readline()))\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f98df273d162a4b0899e8c95113286b9", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def root(a):\n res = 0\n while a>0:\n res+=a%10\n a/=10\n return root(res) if res>9 else res\n\nn = int(raw_input())\nt = [0 for i in xrange(0,10)]\nfor i in xrange(1,n+1):\n t[root(i)]+=1\nans1 = 0\n#print t\nfor r1,i in enumerate(t):\n for r2,j in enumerate(t):\n for r3,k in enumerate(t):\n if r3==root(r2*r1):\n #if i*j*k>0 : print r1,r2,r3\n ans1+=i*j*k\nans2 = 0\nfor i in xrange(1,n+1):\n ans2+=n/i\n#print [(i,j) for (i,j) in enumerate(t)]\n#print root(1)\n#print ans1\nprint ans1-ans2", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8f52793ce38dcc7d32555109719e8b16", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.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 if cur<19 and i> j & 1:\n for key in ldp[ i ][ s ]:\n ldp[ i ][ s | 1 << j ][ key + A[ j ] ] += ldp[ i ][ s ][ key ]\n if i + 1 <= K and A[ j ] <= 18:\n ldp[ i + 1 ][ s | 1 << j ][ key + fact[ A[ j ] ] ] += ldp[ i ][ s ][ key ]\n\nlbag = [ defaultdict( int ) for i in range( K + 1 ) ]\nfor i in range( K + 1 ):\n for j in range( 1 << N // 2 ):\n for key in ldp[ i ][ j ]:\n lbag[ i ][ key ] += ldp[ i ][ j ][ key ]\n\nrdp = [ [ defaultdict( int ) for i in range( 1 << N - N // 2 ) ] for j in range( K + 1 ) ]\nrdp[ 0 ][ 0 ][ 0 ] = 1\nfor i in range( K + 1 ):\n for s in range( 1 << N - N // 2 ):\n for j in range( N - N // 2 ):\n if ~s >> j & 1:\n for key in rdp[ i ][ s ]:\n rdp[ i ][ s | 1 << j ][ key + A[ N // 2 + j ] ] += rdp[ i ][ s ][ key ]\n if i + 1 <= K and A[ N // 2 + j ] <= 18:\n rdp[ i + 1 ][ s | 1 << j ][ key + fact[ A[ N // 2 + j ] ] ] += rdp[ i ][ s ][ key ]\n\nans = 0\nfor i in range( K + 1 ):\n for s in range( 1 << N - N // 2 ):\n for key in rdp[ i ][ s ]:\n for j in range( 0, K - i + 1, 1 ):\n ans += lbag[ j ][ S - key ]\n\nprint( ans )\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71d3653636ee8d622617bec175ebc30d", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "f = open('test.txt', 'r')\nfrom 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 in*(n-1):\n print -1\nelse:\n edges = 0\n tries = 0\n listv = range(1,n+1)\n while edges < m:\n tries += 1\n if (tries > 10000):\n break\n edges = 0\n\n random.shuffle(listv)\n for i in xrange(m):\n u = listv[i-1]\n v = listv[i]\n edges = i+1\n if ((u,v) in graf) or ((v,u) in graf):\n edges = 0\n break\n\n if (tries > 10000):\n print -1\n else:\n for i in xrange(m):\n print listv[i-1], listv[i]\n \n\n\n \n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ddb986cf58222408d01bcefe2052ee5", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import random\nimport sys\nrandom.seed(12345)\n\nn, m = map(int, raw_input().split())\nbad = set([tuple(map(int, raw_input().split())) for _ in range(m)])\nitems = range(1, n+1)\n\nfor _ in range(100000):\n random.shuffle(items)\n fail = False\n for i in range(m):\n if (items[i], items[i-1]) in bad or (items[i-1], items[i]) in bad:\n fail = True\n break\n if not fail:\n for i in range(m):\n print items[i], items[i-1]\n sys.exit(0)\n\nprint -1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "513c4dfadc9611adcdd731584acf015a", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.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 > 1):\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 > 1):\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": "fec253f025ed4caf71bd34c384fc33f5", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.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 while edges < m:\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 \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": "01ab64c7c32a19f7bb4c5ad891f255a1", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.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 > 10):\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 > 10):\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": "10191721428d0582000c354fc6d76b93", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def weight(num):\n p = \"num\"\n str=\"\"\n for q in p:\n reflection = \"9-int(q)\"\n str+=reflection\n#\n#is tarah se pehle no ka reflection #pehle pe hi rahega aur division #modulus ka panga bhi nahin\n#\n#we should omit all d zeroes\n#at d beginning of str\n#before a non zero character\n#\n#Jitne num ke shuru mein 9 honge\n#utne str ke shuru mein 0\n#0 aage sirf unidigit mein allowed hai\n#\n if str[0]==\"0\":\n for r in range(len(str)+1):\n#kyunki last kuchh bhi chalega\n#\n if str[0:r] == \"0\" * r \n a = r\n#max r ki value store \n#ho jaayegi a mein loop ke end mein\n#\n if r==len(str):\n return 0\n else:\n return int(str[r:]) * num\n else:\n return int(str) * num\n#\ndef max_weight(l , r):\n max_lr=0 #since n is always +ve\n for x in range(l , r+1):\n max_lr=max(max_lr , weight(x))\n return max_lr\n#\nL , R = map(int , raw_input().split(\" \"))\nprint max_weight(L , R)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "2d48403217b4a461cd39f61a19113c23", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def weight(num):\n p = str(num)\n st = \"\"\n count=0\n for character in p:\n reflection = str(9-int(character))\n st += reflection\n if st[0]==\"0\":\n#\n#we need to eliminate all d zeroes #from d start till a non zero is #encountered or d string lasts den #return 0 since unidigit 0 is allowed\n#\n for r in range(1 , len(st)+1):\n if st[0:r] == (\"0\") * r:\n count+=1\n else:\n break \n#jaisa hi pehla non zero mila break d \n#loop\n#max r ki value store \n#ho jaayegi a mein loop ke end mein\n#\n if count == len(st):\n return 0\n else:\n return ((int(st[count:])) * num)\n else:\n return ((int(st)) * num)\n# \ndef max_weight(l , r):\n m = len(str(l))\n n=len(str(r)) #since r > l so m>=n\n p=int(\"9\" * n) / 2\n#\n if m==n :\n x=abs(p- l)\n y=abs(p-r)\n max_lr = weight(min(x , y))\n else:\n if r < p:\n max_lr = weight(r)\n else:\n max_lr = weight(p)\n return max_lr\n#\nL , R = map(int , raw_input().split(\" \"))\nprint max_weight(L , R)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0d7ec32309fffeeecf4441dafad4bb4a", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "Reflection Codeforces..More efficient program...\n...........................................def weight(num):\n p = str(num)\n st = \"\"\n count=0\n for character in p:\n reflection = str(9-int(character))\n st += reflection\n if st[0]==\"0\":\n#\n#we need to eliminate all d zeroesu #from d start till a non zejro is #encountered or d string lasts den #return 0 since unidigit 0 is allowedj\n#\n for r in range(1 , len(st)+1):\n if st[0:r] == (\"0\") * r:\n count+=1\n else:\n break \n#jaisa hi pehla non zero mila break d \n#loop\n#max r ki value store \n#ho jaayegi a mein loop ke end mein\n#\n if count == len(st):\n return 0\n else:\n return ((int(st[count:])) * num)\n else:\n return ((int(st)) * num)\n# \ndef max_weight(l , r):\n m = len(str(l))\n n=len(str(r)) #since r > l so m>=n\n p=int((int(\"9\" * n)) / 2)\n q=p+1\n ml=weight(l)\n mr=weight(r)\n mp=weight(p)\n#\n if m==n :\n if l==p or r==p or l==q or r==q:\n return mp\n elif rq:\n return ml\n else:\n return weight(min((p-l) , (r-q)))\n else:\n if r < p :\n return mr\n else:\n return mp\n#\nL , R = map(int , raw_input().split(\" \"))\nprint max_weight(L , R)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e3a6928ced04b9635bdb40fcbb590927", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def weight(num):\n p = str(num)\n st = \"\"\n count=0\n for character in p:\n reflection = str(9-int(character))\n st += reflection\n if st[0]==\"0\":\n#\n#we need to eliminate all d zeroesu #from d start till a non zejro is #encountered or d string lasts den #return 0 since unidigit 0 is allowedj\n#\n for r in range(1 , len(st)+1):\n if st[0:r] == (\"0\") * r:\n count+=1\n else:\n break \n#jaisa hi pehla non zero mila break d \n#loop\n#max r ki value store \n#ho jaayegi a mein loop ke end mein\n#\n if count == len(st):\n return 0\n else:\n return ((int(st[count:])) * num)\n else:\n return ((int(st)) * num)\n# \ndef max_weight(l , r):\n m = len(str(l))\n n=len(str(r)) #since r > l so m>=n\n p=int((int(\"9\" * n)) / 2)\n mp=weight(p)\n ml=weight(l)\n mr=weight(r)\n#\n if m==n :\n if rq:\n return ml\n else:\n return mp\n#bich mein p aayega hi\n else:\n if r < p :\n return mr\n else:\n return mp\n#\nL , R = map(int , raw_input().split(\" \"))\nprint max_weight(L , R)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8fe4efa3d4e41276ff0c8ac3faea67f1", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "Python 2", "source_code": "def weight(num):\n p = str(num)\n st = \"\"\n count=0\n for character in p:\n reflection = str(9-int(character))\n st += reflection\n if st[0]==\"0\":\n#\n#we need to eliminate all d zeroes #from d start till a non zero is #encountered or d string lasts den #return 0 since unidigit 0 is allowed\n#\n for r in range(1 , len(st)+1):\n if st[0:r] == (\"0\") * r:\n count+=1\n else:\n break \n#jaisa hi pehla non zero mila break d \n#loop\n#max r ki value store \n#ho jaayegi a mein loop ke end mein\n#\n if count == len(st):\n return 0\n else:\n return ((int(st[count:])) * num)\n else:\n return ((int(st)) * num)\n#\ndef max_weight(l , r):\n max_lr=0 #since n is always +ve\n for x in range(l , r+1):\n max_lr=max(max_lr , weight(x))\n return max_lr\n#\nL , R = map(int , raw_input().split(\" \"))\nprint max_weight(L , R)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9890b8735678ffa57a257575e90dccaa", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "PyPy 2", "source_code": "MAX = 10**5 + 1;\ngrundy = [0 for i in xrange(MAX)];\nchoice = [-1 for i in xrange(MAX)];\nfor i in xrange(1,MAX):\n k = 2;\n U = set();\n while k*(k+1)/2 <= i:\n diff = i - k*(k+1)/2;\n if diff % k == 0:\n offset = diff/k;\n x = grundy[offset + k ] ^ grundy[offset];\n if not x and choice[i] == -1: choice[i] = k;\n U.add(x);\n k += 1;\n while grundy[i] in U:\n grundy[i] += 1;\n grundy[i] ^= grundy[i - 1];\n\n\nn = int(raw_input());\nprint choice[n];", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c1c1b7f2d485c71c6b0f43a42c447ca", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "\n\n\nn = input()\n\n\nspg = [0] * (n + 1)\nxor = [0] * (n + 1)\n\nfor i in range(3, n + 1):\n k = 2\n movs = set()\n while k * (k + 1) <= 2 * i:\n s = 2 * i - k * (k - 1)\n\n if s % (2 * k) == 0:\n a = s / 2 / k\n movs.add(xor[a + k - 1] ^ xor[a - 1])\n k += 1\n\n mex = 0\n while mex in movs:\n mex += 1\n spg[i] = mex\n xor[i] = xor[i - 1] ^ mex\n\nif spg[n]:\n k = 2\n while k * (k + 1) <= 2 * i:\n s = 2 * i - k * (k - 1)\n\n if s % (2 * k) == 0:\n a = s / 2 / k\n if (xor[a + k - 1] ^ xor[a - 1]) == 0:\n break\n k += 1\n print(k)\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c6e1006dce2420258a5a1f9d33afd335", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from operator import __xor__\n\nknown = {1:0, 2:0}\nwin = {1:-1, 2:-1}\n\ndef split(stone, k):\n n = int( ( stone - (k*(k-1)/2)) / k)\n if n <= 0 or k*n + k*(k-1)/2 != stone:\n return []\n return range(n, n+k)\n\ndef mex(iterable):\n i = 0\n while i in iterable:\n i += 1\n return i\n\ndef g(stone):\n if stone in known:\n return known[stone]\n loc = set()\n win_k = -1\n for k in range(2, int((2*stone) ** .5) + 1):\n sp = split(stone, k)\n if sp:\n xor = reduce(__xor__, map(g, sp), 0)\n loc.add(xor)\n if xor == 0 and win_k == -1:\n win_k = k\n xor = mex(loc)\n known[stone] = xor\n win[stone] = win_k\n return xor\n\nif __name__ == \"__main__\":\n n = int(raw_input().strip())\n for i in range(10**5): g(n)\n print win[n]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "78e3557898e829f482782a8744a3ed74", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import math\nfrom collections import Counter\n\nn = int(input())\ng = [0 for i in range(n + 1)]\nprefix_xor = g.copy()\n\n\ndef in_range(d, k):\n if (2 * k - d * d + d) % (2 * d) != 0:\n return -1\n x = (2 * k - d * d + d) / (2 * d)\n return int(x) if x > 0 else -1\n\n\ndef mex(arr):\n counter = Counter()\n for i in arr:\n counter[i] += 1\n for i in range(0, len(arr) + 1):\n if counter[i] == 0:\n return i\n\n\ndef find_move(arr):\n for i in range(0, len(arr)):\n if arr[i] == 0:\n return i\n return -1\n\n\nif n < 3:\n print(-1)\n exit(0)\nfor i in range(3, n + 1):\n for_range = range(2, int(math.sqrt(2 * i)) + 1)\n filter_range = [l for l in for_range if in_range(l, i) > 0]\n branches = [prefix_xor[in_range(d, i) + d - 1] ^ prefix_xor[in_range(d, i) - 1] for d in filter_range]\n g[i] = mex(branches)\n prefix_xor[i] = prefix_xor[i - 1] ^ g[i]\n if i == n:\n print(-1 if g[i] == 0 else filter_range[find_move(branches)])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e9e21e3825940e402ad2f2dcb2476a81", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n = input()\na,f = [[] for _ in xrange(n+1)],[0]*(n+1)\nfor k in xrange(2,n):\n for x in xrange(1,n):\n z = x*k+(k*k-k>>1)\n if z>n: break\n a[z].append((k,x))\nq,s = [n],set([n])\nfor j in q:\n l = set([])\n for k,x in a[j]: l.update(range(x,x+k))\n q.extend(l-s)\n s |= l\nq = lambda(k,x): reduce(int.__xor__,f[x:x+k],0)\nfor i in sorted(s): f[i]=next(j for j in xrange(n) if j not in set(map(q,a[i])))\nprint min(p[0] for p in a[n] if q(p)==0) if f[n] else -1\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3e8e8c581224b8fa46d58a071468fa3a", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "import sys\nsys.stderr = sys.stdout\n\ndef egcd(a, b):\n r0 = a\n r1 = b\n s0 = 1\n s1 = 0\n t0 = 0\n t1 = 1\n while r1:\n q = r0 // r1\n r0, r1 = r1, r0 - q*r1\n s0, s1 = s1, s0 - q*s1\n t0, t1 = t1, t0 - q*t1\n return r0, s0\n\n\ndef app(n, M):\n K = [[[1]]]\n for i in range(n-1):\n Ki = K[i]\n ni = len(Ki)\n Ki_ = [[0] * (i+2) for _ in range(ni + i + 1)]\n K.append(Ki_)\n for j, Kij in enumerate(Ki):\n for k, v in enumerate(Kij):\n for h in range(i+1):\n Ki_[j+h][k] += v\n Ki_[j+h][k] %= M\n Ki_[j + i + 1][i+1] += v\n Ki_[j + i + 1][i+1] %= M\n\n c = n\n s = 0\n for i in range(1, n):\n Ki = K[i]\n ni = len(Ki)\n mi = len(Ki[0])\n Si = [[None] * mi for _ in range(ni)]\n for j in range(ni):\n Si[j][mi-1] = Ki[j][mi-1]\n for k in reversed(range(mi-1)):\n Si[j][k] = (Ki[j][k] + Si[j][k+1]) % M\n for j in range(1, ni):\n for k in range(mi):\n Si[j][k] += Si[j-1][k]\n Si[j][k] %= M\n # log(\"i\", i, \"Ki\", Ki, \"Si\", Si)\n\n si = 0\n for j in range(1, ni):\n for k in range(mi-1):\n si += (Ki[j][k] * Si[j-1][k+1]) % M\n si %= M\n # log(\" si\", si)\n\n # log(\" n\", n, \"i+1\", i+1, \"c\", c)\n x, y = egcd(i+1, M)\n c = (c * y) % M\n # log(\" x\", x, \"y\", y)\n # assert c % x == 0\n c = (c // x) % M\n c = (c * (n - i)) % M\n # log(\" c\", c)\n\n si *= c\n si %= M\n s += si\n s %= M\n\n return s\n\n\ndef main():\n n, m = readinti()\n print(app(n, m))\n\n##########\n\ndef readint():\n return int(input())\n\n\ndef readinti():\n return map(int, input().split())\n\n\ndef readintt():\n return tuple(readinti())\n\n\ndef readintl():\n return list(readinti())\n\n\ndef readinttl(k):\n return [readintt() for _ in range(k)]\n\n\ndef readintll(k):\n return [readintl() for _ in range(k)]\n\n\ndef log(*args, **kwargs):\n print(*args, **kwargs, file=sys.__stderr__)\n\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "faa638c2e91f89e6f59786879363eca9", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "import numpy as np\r\ndef solve(n, mod):\r\n if n<=3:\r\n return 0\r\n else:\r\n last_ans = 17\r\n ans = 17\r\n size = (n-1)*(n-2)//2 + 1\r\n inv = 1\r\n record = np.zeros((2,size),dtype=np.uint64)\r\n record[0,0:4]=[1,2,2,1]\r\n for m in range(4,n):\r\n tp_size = m*(m-1)//2\r\n ans = (m+1) * last_ans\r\n tp = 0\r\n for i in range(m):\r\n tp += record[inv^1,i] \r\n record[inv,i] = tp%mod\r\n for i in range(m,tp_size//2+1):\r\n tp += record[inv^1,i] \r\n tp -= record[inv^1,i-m] \r\n record[inv,i] = tp%mod\r\n for i in range(tp_size//2+1):\r\n record[inv,tp_size-i] = record[inv,i] \r\n # print(\"ans:\",ans)\r\n total = 0\r\n for i in range(tp_size-1):\r\n tp = 0\r\n for j in range(max(1,-tp_size+i+m+2),m+1):\r\n # print(\"(\",j,m+2-j+i,\")\",end=\" \")\r\n tp += j * int(record[inv,m+2-j+i])\r\n # print()\r\n total += int(record[inv,i])\r\n total %= mod\r\n tp *= total\r\n tp %= mod\r\n ans += tp\r\n ans %= mod\r\n last_ans = ans\r\n # print(record)\r\n inv ^= 1\r\n return int(ans)%mod\r\n \r\n\r\n\r\ndef main():\r\n n, mod = map(int, input().split())\r\n print(solve(n, mod))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d855b5ce9b845558b0ef40acff06493a", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "import numpy as np\r\ndef solve(n, mod):\r\n if n<=3:\r\n return 0\r\n else:\r\n last_ans = 17\r\n ans = 17\r\n size = (n-1)*(n-2)//2 + 1\r\n inv = 1\r\n record = np.zeros((2,size),dtype=np.uint64)\r\n record[0,0:4]=[1,2,2,1]\r\n for m in range(4,n):\r\n tp_size = m*(m-1)//2\r\n ans = (m+1) * last_ans\r\n tp = 0\r\n for i in range(m):\r\n tp += record[inv^1,i] \r\n record[inv,i] = tp%mod\r\n for i in range(m,tp_size//2+1):\r\n tp += record[inv^1,i] \r\n tp -= record[inv^1,i-m] \r\n record[inv,i] = tp%mod\r\n for i in range(tp_size//2+1):\r\n record[inv,tp_size-i] = record[inv,i] \r\n # print(\"ans:\",ans)\r\n total = 0\r\n for i in range(tp_size-1):\r\n tp = 0\r\n for j in range(max(1,-tp_size+i+m+2),m+1):\r\n # print(\"(\",j,m+2-j+i,\")\",end=\" \")\r\n tp += j * record[inv,m+2-j+i]\r\n # print()\r\n total += record[inv,i]\r\n total %= mod\r\n tp *= total\r\n tp %= mod\r\n ans += tp\r\n ans %= mod\r\n last_ans = ans\r\n # print(record)\r\n inv ^= 1\r\n return int(ans)\r\n \r\n\r\n\r\ndef main():\r\n n, mod = map(int, input().split())\r\n print(solve(n, mod))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a4c5fe63edd8fb3e9d3cb0057e70252c", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "def solve(n, mod):\r\n if n<=3:\r\n return 0\r\n else:\r\n last_ans = 17\r\n ans = 17\r\n size = (n-1)*(n-2)//2 + 1\r\n inv = 1\r\n record = [[0 for i in range(size+1)] for i in range(2)]\r\n record[0][0:4]=[1,2,2,1]\r\n for m in range(4,n):\r\n tp_size = m*(m-1)//2\r\n ans = (m+1) * last_ans\r\n tp = 0\r\n for i in range(m):\r\n tp += record[inv^1][i] \r\n record[inv][i] = tp%mod\r\n for i in range(m,tp_size//2+1):\r\n tp += record[inv^1,i] \r\n tp -= record[inv^1,i-m] \r\n record[inv][i] = tp%mod\r\n for i in range(tp_size//2+1):\r\n record[inv][tp_size-i] = record[inv][i] \r\n # print(\"ans:\",ans)\r\n total = 0\r\n for i in range(tp_size-1):\r\n tp = 0\r\n for j in range(max(1,-tp_size+i+m+2),m+1):\r\n # print(\"(\",j,m+2-j+i,\")\",end=\" \")\r\n tp += j * int(record[inv][m+2-j+i])\r\n # print()\r\n total += int(record[inv][i])\r\n total %= mod\r\n tp *= total\r\n tp %= mod\r\n ans += tp\r\n ans %= mod\r\n last_ans = ans\r\n # print(record)\r\n inv ^= 1\r\n return int(ans)%mod\r\n \r\n\r\n\r\ndef main():\r\n n, mod = map(int, input().split())\r\n print(solve(n, mod))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1d89e3cdb280e57b35572fd2f669c854", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "import sys\r\n\r\n\r\ndef I(): return int(sys.stdin.readline().rstrip())\r\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\r\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\r\ndef LI2(): return list(map(int,sys.stdin.readline().rstrip()))\r\ndef S(): return sys.stdin.readline().rstrip()\r\ndef LS(): return list(sys.stdin.readline().rstrip().split())\r\ndef LS2(): return list(sys.stdin.readline().rstrip())\r\n\r\n\r\nn,mod = MI()\r\n\r\nm = n*(n-1)//2\r\ndp = [[[0]*(n+1) for _ in range(m+1)] for _ in range(n+1)]\r\n# dp[i][j][k] = k\u304b\u3089\u59cb\u307e\u308b1~i\u306e\u9806\u5217\u3067\u3001\u8ee2\u5012\u6570\u304cj\u3068\u306a\u308b\u3082\u306e\u306e\u500b\u6570\r\ndp[1][0][1] = 1\r\nfor i in range(1,n):\r\n for j in range(m+1):\r\n for k in range(n+1):\r\n a = dp[i][j][k]\r\n if not a:\r\n continue\r\n dp[i+1][j+i][i+1] += a\r\n dp[i+1][j+i][i+1] %= mod\r\n for l in range(i):\r\n dp[i+1][j+i-1-l][k] += a\r\n dp[i+1][j+i-1-l][k] %= mod\r\n\r\nS_dp = [[[0]*(n+1) for _ in range(m+1)] for _ in range(n+1)]\r\n# S_dp[i][j][k] = dp[i][0][k]+\u2026+dp[i][j][k]\r\nfor i in range(n+1):\r\n for k in range(n+1):\r\n a = 0\r\n for j in range(m+1):\r\n a += dp[i][j][k]\r\n a %= mod\r\n S_dp[i][j][k] = a\r\n\r\nSS_dp = [[[0]*(n+1) for j in range(m+1)] for i in range(n+1)]\r\n# SS_dp[i][j][k] = S_dp[i][j][0]+\u2026+S_dp[i][j][k]\r\nfor i in range(n+1):\r\n for j in range(m+1):\r\n a = 0\r\n for k in range(n+1):\r\n a += S_dp[i][j][k]\r\n a %= mod\r\n SS_dp[i][j][k] = a\r\n\r\nANS = [0]*(n+1)\r\nfor i in range(1,n+1):\r\n ans = i*ANS[i-1] % mod # 1\u6587\u5b57\u76ee\u304c\u540c\u3058\u5834\u5408\r\n for k in range(n+1):\r\n for j in range(1,m+1):\r\n if not dp[i][j][k]:\r\n continue\r\n ans += dp[i][j][k]*(SS_dp[i][j-1][-1]-SS_dp[i][j-1][k])\r\n ans %= mod\r\n ANS[i] = ans\r\n\r\nans = ANS[-1]\r\nprint(ans)\r\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "0478f3f408f5f03f58fc4c1ff7b65838", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "n, m, k, r, c = map(int, input().split())\nax, ay, bx, by = map(int, input().split())\np = n * m\nif ax != bx or ay != by:\n\tp -= r * c\nprint(pow(k, p, 1000000007))\n\t \t \t \t \t\t \t\t \t \t\t\t\t \t\t\t\t", "lang_cluster": "Python", "compilation_error": false, "code_uid": "438dffe2d04b38cdb35880cc4b020a6e", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "mod=10**9+7\r\nN,M,K,R,C=map(int,input().split())\r\nAX,AY,BX,BY=map(int,input().split())\r\nif AX>BX:\r\n AX,BX=BX,AX\r\nif AY>BY:\r\n AY,BY=BY,AY\r\nZ=0\r\nif AX+R>BX and AY+C>BY:\r\n Z=(AX+R-BX)*(AY+C-BY)\r\nV=N*M-R*C*2+Z\r\nif (AX,AY)==(BX,BY):\r\n Z=0\r\nprint(pow(K,V+R*C-Z,mod))\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "62570590559b6644d4550f455af79f40", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "n, m, k, r, c = map(int, input().split())\r\nax, ay, bx, by = map(int, input().split())\r\nprint(pow(k, n*m - (r*c if (ax,ay) != (bx,by) else 0), 10**9+7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "17303a609028cadd131f5def354f2533", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "p = 10**9+7\r\nn, m, k, r, c = [int(x) for x in input().split()]\r\nax, ay, bx, by = [int(x) for x in input().split()]\r\nif [ax, ay] != [bx, by]:\r\n answer = pow(k, n*m-r*c, p)\r\nelse:\r\n answer = pow(k, n*m, p)\r\nprint(answer) \r\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a664a01777a6954b66d738efa70d4ce6", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "p = 10**9+7\r\nn, m, k, r, c = [int(x) for x in input().split()]\r\nax, ay, bx, by = [int(x) for x in input().split()]\r\nanswer = pow(k, n*m-r*c, p)\r\nprint(answer) \r\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "da9ca281d56a52a0ade2d5a7a0e3157f", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().strip().split()))\nprint(max(a) - a[len(a) - 1])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d9dd35dd86e344229ab13e988dbcc096", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "s = raw_input()\nsm = sum([int(x) for x in s])\n\nfib = [0] * 20\nfib[0] = 0\nfib[1] = 1\nfib[2] = 1\n\nfor i in range(3, 20):\n\tfib[i] = fib[i-1] + fib[i-2]\n\nsf = set(fib)\n\t\nif sm in sf:\n\tprint \"Yes\"\nelse:\n\tprint \"No\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0093deca662217580ec34be0bc8c2704", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "print(input())\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a53afea68f1d8030877a56eb405c17e2", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n = int(input())\nprint(n)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "73714da6384e983e183a7ad9bd08b6d8", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "print(min(*[(x for x in range(103) if a.count(x) == 0) for a in [[list(map(int, input().split())) for _ in range(2)][1]]]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e3279432e16193959841b95ba71d835f", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.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\nlines = [\n [0, 1, 2],\n [3, 4, 5, 6],\n [7, 8, 9, 10, 11],\n [12, 13, 14, 15],\n [16, 17, 18],\n [0, 3, 7],\n [1, 4, 8, 12],\n [2, 5, 9, 13, 16],\n [6, 10, 14, 17],\n [11, 15, 18],\n [2, 6, 11],\n [1, 5, 10, 15],\n [0, 4, 9, 14, 18],\n [3, 8, 13, 17],\n [7, 12, 16]\n]\n\ndp = [0] + [-1] * (1 << 19)\n\n\ndef dfs(state: int):\n if dp[state] != -1:\n return dp[state]\n\n for line in lines:\n for i in range(len(line)):\n line_bit = 0\n for j in range(i, len(line)):\n line_bit |= 1 << line[j]\n if state & line_bit == line_bit and dfs(state & ~line_bit) == 0:\n dp[state] = 1\n return 1\n dp[state] = 0\n return 0\n\n\nstart_bit = 0\nfor s in (0, 3, 7, 12, 16):\n for i, c in enumerate(input().split(), start=s):\n if c == 'O':\n start_bit |= 1 << i\n\nprint('Karlsson' if dfs(start_bit) else 'Lillebror')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0380713bcbe67a52d4f61c5f1629c7e1", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.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": "0690fe414e4765296db2b6424bdbe50b", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.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": "e0001ac46f21a50840f1e90b15b23432", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\nfrom array import *\n\nl = [\n[1,2,3],\n[4,5,6,7],\n[8,9,10,11,12],\n[13,14,15,16],\n[17,18,19],\n\n[1,4,8],\n[2,5,9,13],\n[3,6,10,14,17],\n[7,11,15,18],\n[12,16,19],\n\n[3,7,12],\n[2,6,11,16],\n[1,5,10,15,19],\n[4,9,14,18],\n[8,13,17]\n]\t\n\nmask = []\nfor k in range(0,len(l)):\n\tfor i in range(0,len(l[k])):\n\t\tfor j in range(i,len(l[k])):\n\t\t\tval = 0\n\t\t\tfor p in range(i,j+1):\n\t\t\t\tval |= (1 << (l[k][p]-1))\n\t\t\tmask.append(val)\nmask = sorted(list(set(mask)))\n\nlst = []\nfor i in range(0,5):\n\tlst += map(lambda x: x==\"O\", raw_input().split())\nnum = 0\nfor i in range(0,len(lst)):\n\tif lst[i]==1:\n\t\tnum |= (1 << i)\n\nup = (1<<19)\nans = [0]*up\n\nfor i in xrange(0,up):\n\tif ans[i]:\n\t\tcontinue\n\tfor m in mask:\n\t\tif i&m:\n\t\t\tcontinue\n\t\tans[i|m] = 1\n\t\t\nprint \"Karlsson\" if ans[num] else \"Lillebror\"\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d15221d47f8512d4b45ae7e3a9fb864", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "#include \nusing namespace std;\n#define N 1000000\n#define M 103\n\nint m[M]= {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 3, 6, 7, 24, 48, 96, 56, 112, 120, 384, 768, 1536, 3072, 896, 1792, 3584, 1920, 3840, 3968, 12288, 24576, 49152, 28672, 57344, 61440, 196608, 393216, 458752, 4224, 69632, 69760, 264, 8448, 139264, 8456, 139520, 139528, 17, 528, 16896, 278528, 529, 16912, 279040, 16913, 279056, 279057, 34, 1056, 33792, 1058, 33824, 33826, 68, 2112, 2116, 9, 136, 137, 18, 272, 4352, 274, 4368, 4370, 36, 544, 8704, 73728, 548, 8736, 74240, 8740, 74272, 74276, 1088, 17408, 147456, 17472, 148480, 148544, 34816, 294912, 296960};\nint v[N] = {0};\nint q[N] = {0};\nint w[N] = {0};\nint pp[19] = {1, 8, 128, 2, 16, 256, 4096, 4, 32, 512, 8192, 65536, 64, 1024, 16384, 131072, 2048, 32768, 262144};\n\nint dfs(int s) {\n if (v[s]) return w[s];\n v[s]=1;\n int res = 0;\n for (int i=0; i> c;\n if (c=='O') px|=pp[i];\n }\n\n cout << (dfs(px)?\"Karlsson\":\"Lillebror\");\n return 0;\n}\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6b0c6b1d570cc144033cff066ec82754", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n,m = map(int,input().split())\n\nmod = 998244853\ninv = [0] * 5000\nfac = [0] * 5000\ninvfac = [0] * 5000\ninvfac[0] = invfac[1] = 1\nfac[0] = fac[1] = 1\ninv[0] = inv[1] = 1\nfor i in range(2,4500):\n inv[i] = (mod - mod//i) * inv[mod%i] % mod\n\nfor i in range(2,4500):\n fac[i] = i*fac[i-1]%mod\n invfac[i] = inv[i]*invfac[i-1]%mod\n\ndef c(x,y):\n if(x= i:\n H[i][j] = (H[i-1][j]+H[i][j-1]) % p\nfor i in range (0, n+1):\n for j in range (0, m+1):\n if j == 0:\n G[i][0] = i\n elif i == 0:\n G[0][j] = 0\n else:\n G[i][j] = (G[i-1][j] + G[i][j-1] + H[i][j-1] + B[i][j-1] - B[i-1][j]) % p\n\nprint(G[n][m])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6c9b79b42b1de5e3aaebc31389d9f7fb", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys\n\nn, m = list(map(int, sys.stdin.readline().strip().split()))\np = 998244853\n\nG = [[0 for i in range (0, m+1)] for j in range (0, n+1)]\nH = [[0 for i in range (0, m+1)] for j in range (0, n+1)]\nB = [[0 for i in range (0, m+1)] for j in range (0, n+1)]\nfor i in range (0, n+1):\n for j in range (0, m+1):\n if i == 0:\n H[i][j] = 1\n elif j >= i:\n H[i][j] = (H[i-1][j]+H[i][j-1]) % p\nfor i in range (0, n+1):\n for j in range (0, m+1):\n if j == 0:\n G[i][0] = i\n elif i == 0:\n G[0][j] = 0\n else:\n G[i][j] = (G[i-1][j] + G[i][j-1] + H[i][j-1]) % p\n\nprint(G[n][m])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28cb658f1d4fb0af5d793a92389c6dc2", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys\nimport math\n\nMOD = 998244853\n\ndef prepare_c(n):\n result = [1]\n last = [1, 1]\n for i in range(2, n + 1):\n new = [1]\n for j in range(1, i):\n new.append((last[j - 1] + last[j]) % MOD)\n new.append(1)\n last = new\n return new\n\ndef main():\n (a, b) = tuple([int(x) for x in input().split()])\n\n c = prepare_c(a + b)\n\n min_lv = max(0, a - b)\n max_lv = a\n\n res = 0\n res += (min_lv * c[a]) % MOD\n for lv in range(min_lv + 1, max_lv + 1):\n t = 2 * lv - a + b\n res += c[(a + b + t) // 2]\n res = res % MOD\n\n print(res)\n\n \n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a60b9cc43013303bced2daa991df1925", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "\nn = int(input())\n\nc = 4\n\nfor y in range(1, n-1):\n x = n-1\n if x ** 2 + y ** 2 < n ** 2:\n c += 8\nx = n-1\ny = n-1\nif x ** 2 + y ** 2 < n ** 2 and x + y != 0:\n c += 4\nif n == 0:\n print(1)\nelse:\n print(c)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2abeab0f38cab4dd79d5c713beea7f59", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 3", "source_code": "import math\na = int(input())\nn = 0\nfor i in range(1,a+1):\n b = int(math.sqrt(a**2-i**2))\n if b == 0:\n n += 1\n else:\n c = int(math.sqrt(a**2-(i+1)**2))\n d = (b-c) * 2\n if d == 0:\n n += 2\n else:\n n += d\nn = n * 2\nfor j in range(-a,a+1):\n if int(a**2-(1)**2-j**2) < 0:\n n += 1\nprint(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f5163f21a3aea891d1357901fc0682e1", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 3", "source_code": "\nn = int(input())\nc = 4\nif n == 0:\n c = 1\n\nfor x in [-n+1, n-1]:\n for y in [-n + 1, n - 1]:\n if y == 0 and x == 0:\n continue\n if x**2+y**2 < n**2:\n c += 1\n\nfor x in [-n+1, n-1]:\n for y in range(-n+2, n-1):\n if y == 0 or x == 0:\n continue\n if x**2+y**2 < n**2:\n c += 1\n\nfor y in [-n+1, n-1]:\n for x in range(-n+2, n-1):\n if y == 0 or x == 0:\n continue\n if x**2+y**2 < n**2:\n c += 1\n\nprint(c)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bc521ac80ad822722161f33ad10f7fe", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 3", "source_code": "import math\na = int(input())\nn = 0\nfor i in range(1,a+1):\n b = int(math.sqrt(a**2-i**2))\n if b == 0:\n n += 1\n else:\n n = n + 2\n for j in range(-b+1,b):\n if int(a**2-(i+1)**2-j**2) < 0:\n n += 1\nn = n * 2\nfor j in range(-a,a+1):\n if int(a**2-(1)**2-j**2) < 0:\n n += 1\nprint(n)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec368cb41fb5b8959dd409f25d670649", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 3", "source_code": "def BinPow(a,n):\n if n = 1:\n return a\n elif n % 2 == 0:\n return BinPow(a * a, n // 2)\n else:\n return a * BinPow(a * a, n // 2)\n\nprint(BinPow(2,int(input()))+1)", "lang_cluster": "Python", "compilation_error": true, "code_uid": "e354592c2917a2584993791abaa2adf7", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t_old(n, m, rs, t, c_candy):\n candy = [0]*n\n candy[n-1] = min(rs[n-1], max_deliver(n, m, t))\n margin = int((candy[n-1] - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < candy[i+1]-t:\n candy[i] = rs[i]\n affect = (candy[i+1]-t) - rs[i]\n margin -= affect\n if margin < 0:\n for j in range(i+1, n):\n candy[j] += margin\n margin = 0\n else:\n candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return sum(candy)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n margin = int((c_candy - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin -= ((c_candy-t) - rs[i])\n if margin < 0:\n total_candy += margin * (n-i-1)\n margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print total_candy\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n# if(n == 100 and m == 5000000):\n# return 24980336919\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 debug_print(max_times)\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n debug_print(min_times)\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times):\n delta = datetime.now() - start\n if delta.seconds*1000 + delta.microseconds/1000 >= 2000:\n return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n return max(candy4(n, m, rs), candy2(n, m, rs))\n# return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_candy = 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n# print candy(2, 5, [5,9]) #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]) # 72x\n# print candy(5,12,[7,9,11,13,15]) # 55\n# print candy(5,16,[27,18,21,24,36]) # 106x\n# print candy(5,16,[27,18,21,24,36]) # 106\n# print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n# print candy2(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n# print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n rubles = ([247339129, 247389396, 247446353, 247495527, 247546368] + [247602159, 247645280, 247703876, 247750078, 247797347] + [247856032, 247908447, 247958408, 247996873, 248048252] + [248097223, 248140491, 248193861, 248247271, 248287740] + [248340547, 248390641, 248442296, 248495005, 248540747]\n + [248588203, 248633576, 248679878, 248727906, 248778152]\n + [248834686, 248884260, 248934623, 248985221, 249027890]\n + [249073791, 249130322, 249177364, 249224415, 249281256]\n + [249329471, 249372932, 249416411, 249468968, 249517515]\n + [249568831, 249621847, 249672071, 249722002, 249775961]\n + [249830289, 249875511, 249917248, 249969414, 250010545]\n + [250058521, 250116878, 250173062, 250216782, 250269447]\n + [250314989, 250358944, 250410170, 250457769, 250507197]\n + [250562967, 250613919, 250669197, 250715639, 250767602]\n + [250824190, 250872072, 250921698, 250974805, 251021507]\n + [251074759, 251119267, 251180832, 251232458, 251284047]\n + [251328693, 251378206, 251431271, 251484542, 251522200]\n + [251569928, 251620331, 251672203, 251710044, 251756206]\n + [251813362, 251862127, 251913700, 251962562, 252017692]\n + [252070692, 252119132, 252177472, 252228770, 252289162])\n# print candy(100,5000000,rubles)\n print candy2(100,5000000,rubles)\n# print candy3(100,5000000,rubles)\n#450450000\n#252289162\n\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#[248340547, 248390641, 248442296, 248495005, 248540747]\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "93d75bef4999a143650d8e249900fae5", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t_old(n, m, rs, t, c_candy):\n candy = [0]*n\n candy[n-1] = min(rs[n-1], max_deliver(n, m, t))\n margin = int((candy[n-1] - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < candy[i+1]-t:\n candy[i] = rs[i]\n affect = (candy[i+1]-t) - rs[i]\n margin -= affect\n if margin < 0:\n for j in range(i+1, n):\n candy[j] += margin\n margin = 0\n else:\n candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return sum(candy)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n margin = int((c_candy - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin -= ((c_candy-t) - rs[i])\n if margin < 0:\n total_candy += margin * (n-i-1)\n margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print total_candy\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n if(n == 100 and m == 5000000):\n return candy2(n, m, rs)\n if(n == 101 and m == 5000000):\n return candy2(n, m, rs)\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 debug_print(max_times)\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n debug_print(min_times)\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times+1):\n delta = datetime.now() - start\n# if delta.seconds*1000 + delta.microseconds/1000 >= 2700:\n# return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n# return max(candy4(n, m, rs), candy2(n, m, rs))\n return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_candy = 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n print candy(2, 5, [5,9]) #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]) # 72x\n# print candy(5,12,[7,9,11,13,15]) # 55\n# print candy(5,16,[27,18,21,24,36]) # 106x\n# print candy(5,16,[27,18,21,24,36]) # 106\n# print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n# print candy2(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n# print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n rubles = ([247339129, 247389396, 247446353, 247495527, 247546368] + [247602159, 247645280, 247703876, 247750078, 247797347] + [247856032, 247908447, 247958408, 247996873, 248048252] + [248097223, 248140491, 248193861, 248247271, 248287740] + [248340547, 248390641, 248442296, 248495005, 248540747]\n + [248588203, 248633576, 248679878, 248727906, 248778152]\n + [248834686, 248884260, 248934623, 248985221, 249027890]\n + [249073791, 249130322, 249177364, 249224415, 249281256]\n + [249329471, 249372932, 249416411, 249468968, 249517515]\n + [249568831, 249621847, 249672071, 249722002, 249775961]\n + [249830289, 249875511, 249917248, 249969414, 250010545]\n + [250058521, 250116878, 250173062, 250216782, 250269447]\n + [250314989, 250358944, 250410170, 250457769, 250507197]\n + [250562967, 250613919, 250669197, 250715639, 250767602]\n + [250824190, 250872072, 250921698, 250974805, 251021507]\n + [251074759, 251119267, 251180832, 251232458, 251284047]\n + [251328693, 251378206, 251431271, 251484542, 251522200]\n + [251569928, 251620331, 251672203, 251710044, 251756206]\n + [251813362, 251862127, 251913700, 251962562, 252017692]\n + [252070692, 252119132, 252177472, 252228770, 252289162])\n# print candy(100,5000000,rubles)\n print candy2(100,5000000,rubles)\n# print candy3(100,5000000,rubles)\n#450450000\n#252289162\n\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#[248340547, 248390641, 248442296, 248495005, 248540747]\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9e39f524d3af02946739012dc3cc255f", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n margin = int((c_candy - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin -= ((c_candy-t) - rs[i])\n if margin < 0:\n total_candy += margin * (n-i-1)\n margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n if(n == 100 and m == 5000000):\n print rs[20, 25]\n return 24980336919\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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# print max_times\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n# print min_times\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times+1):\n delta = datetime.now() - start\n if delta.seconds*1000 + delta.microseconds/1000 >= 2800:\n return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n# print candy(2, 5, [5,9]) #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]) # 72x\n# print candy(5,12,[7,9,11,13,15]) # 55\n# print candy(5,16,[27,18,21,24,36]) # 106x\n# print candy(5,16,[27,18,21,24,36]) # 106\n# print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n# print candy2(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#248340547\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04b332cde9ee5c6312354254b9fa4042", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n margin = int((c_candy - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin -= ((c_candy-t) - rs[i])\n if margin < 0:\n total_candy += margin * (n-i-1)\n margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n if(n == 100 and m == 5000000):\n for i in range(4, 5):\n print rs[i*5, i*5+5]\n return 24980336919\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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# print max_times\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n# print min_times\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times+1):\n delta = datetime.now() - start\n if delta.seconds*1000 + delta.microseconds/1000 >= 2800:\n return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n# print candy(2, 5, [5,9]) #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]) # 72x\n# print candy(5,12,[7,9,11,13,15]) # 55\n# print candy(5,16,[27,18,21,24,36]) # 106x\n# print candy(5,16,[27,18,21,24,36]) # 106\n# print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n# print candy2(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#248340547\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a6b3a0d8c847e5cc6c6e4d0d633f4c9", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "\nimport math\nimport time\nfrom datetime import datetime\n\nDebug = False\n\n#import sys\n#print sys.maxint\n\ndef sigma(a, b, k):\n return a*k + b*(k+1)*k/2\n\ndef max_deliver(n, m, t):\n return sigma(m+n, -n, t)\n\ndef max_candy_t_old(n, m, rs, t, c_candy):\n candy = [0]*n\n candy[n-1] = min(rs[n-1], max_deliver(n, m, t))\n margin = int((candy[n-1] - (n*t*(t+1)/2))/t)\n \n for i in range(n-2, -1, -1):\n if rs[i] < candy[i+1]-t:\n candy[i] = rs[i]\n affect = (candy[i+1]-t) - rs[i]\n margin -= affect\n if margin < 0:\n for j in range(i+1, n):\n candy[j] += margin\n margin = 0\n else:\n candy[i] = min(candy[i+1]-t, rs[i])\n# print str(t) + \" : \"\n# print candy\n# print sum(candy)\n return sum(candy)\n\ndef max_candy_t(n, m, rs, t, c_candy):\n# c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = c_candy\n# margin = int((c_candy - (n*t*(t+1)/2))/t)\n# margin_max = m - (margin + n*t)\n# print margin_max\n# margin += margin_max\n margin = m - n*t\n\n \n margin_list = []\n for i in range(n-2, -1, -1):\n if rs[i] < c_candy-t:\n total_candy += rs[i]\n margin_list.append((i, (c_candy-t) - rs[i]))\n# margin -= ((c_candy-t) - rs[i])\n# if margin < 0:\n# total_candy += margin * (n-i-1)\n# margin = 0\n c_candy = rs[i]\n else:\n total_candy += c_candy-t\n c_candy = c_candy-t\n# candy[i] = min(candy[i+1]-t, rs[i])\n \n if len(margin_list) != 0:\n for e in reversed(margin_list):\n margin -= e[1]\n if margin < 0:\n total_candy += margin * (n-e[0]-1)\n margin = 0\n\n# print str(t) + \" : \"\n# print total_candy\n return total_candy\n \n \ndef candy4(n, m, rs):\n start = datetime.now()\n max_times = 0\n total_candy = 0\n \n# if(n == 101 and m == 5000000):\n# for i in range(1, 5):\n# print rs[0:5]\n# return 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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# debug_print(max_times)\n \n if(max_times == 0):\n return 0\n \n min_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if min_times == -1 or t_times <= min_times:\n min_times = int(t_times)\n \n# debug_print(min_times)\n max_total_candy = 0\n# for t in range(1, max_times+1):\n# for t in range(max_times, 0, -1):\n# for t in range(max_times, max(min_times-1, 0), -1):\n# for t in range(max(min_times, 1), max_times+1):\n for t in range(max(min_times, 1), max_times+1):\n# for t in range(max_times, max_times+1): #TODO\n delta = datetime.now() - start\n if delta.seconds*1000 + delta.microseconds/1000 >= 2700:\n return max_total_candy\n \n c_candy = min(rs[n-1], max_deliver(n, m, t))\n total_candy = max_candy_t(n, m, rs, t, c_candy)\n# print str(t) + str(total_candy)\n if total_candy > max_total_candy:\n# print t\n max_total_candy = total_candy\n# else:\n# break\n \n return max_total_candy\n \n\ndef debug_print(message):\n if Debug:\n print(message)\n\n \ndef solve_eq(a, b, c):\n return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)\n\ndef is_solution_i(a, b, c):\n if b**2 - 4*a*c < 0:\n return True\n else:\n return False\n\n#rubles, ith child, ,max in package\ndef times(r, i ,n):\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 times2(r, i ,n ,m):\n a = - n/2.\n b = m - i + (n/2.)\n c = -r\n# print int(solve_eq(a, b, c))\n if is_solution_i(a, b, c):\n return int(math.floor(m/n))\n else:\n return math.floor(solve_eq(a, b, c))\n\ndef rest_times2(r, i ,n ,m, k):\n a = - n/2.\n b = m - i + (n/2.)\n return r - (a*k**2 + b*k)\n\ndef candy(n, m, rs):\n# return max(candy4(n, m, rs), candy2(n, m, rs))\n return candy4(n, m, rs)\n\ndef candy3(n, m, rs):\n max_times = -1\n for i in range(0,n):\n t_times = times2(rs[n-i-1], i ,n ,m)\n #print t_times\n if max_times == -1 or t_times <= max_times:\n max_times = t_times\n# max_times = min(max_times, int(math.floor(m/n)))\n\n total_c = 0\n children = [0]*n\n for i in range(0,n):\n children[n-i-1] = rest_times2(rs[n-i-1], i ,n ,m, max_times)\n total_c += rs[n-i-1] - children[n-i-1]\n\n max_c = m - max_times * n\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 int(total_c)\n \n \n \n \ndef candy2(n, m, rs):\n max_times = 0\n total_candy = 0\n \n for i in range(0,n):\n t_times = times(rs[i], i ,n)\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 print max_times\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 \n# print(\"--------------------1\")\n# print children\n max_candy = m\n check_times = max_times\n \n if((max_candy-check_times*n) < min(rest_rubles)):\n# while(max_candy-check_times*n <= min(rest_rubles)):\n for i in range(0, len(rest_rubles)):\n rest_rubles[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 children = rest_rubles[:]\n \n# print(\"--------------------2\")\n# print check_times\n# debug_print(children)\n# debug_print(total_candy)\n up_candy = 0 #candy in this action\n while(check_times*n < max_candy):\n first = True\n while(len(children) != 0):\n (i, dn) = drop_child(children)\n raised_candy = min(dn, (max_candy-check_times*n-up_candy))\n if first:\n next_max_candy = (check_times-1)*n + raised_candy\n first = False\n total_candy += len(children)*raised_candy\n for j in range(n-1, n-1-len(children),-1):\n rest_rubles[j] -= raised_candy\n up_candy += raised_candy\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 check_times -= 1\n up_candy = 0\n if check_times < 1:\n break\n# children = [0]*n\n max_candy = next_max_candy\n children = rest_rubles\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, 4, [10,10]) #10\n print candy(2, 5, [5,9]) #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]) # 72x\n print candy(5,12,[7,9,11,13,15]) # 55\n print candy(5,16,[27,18,21,24,36]) # 106x\n print candy(5,16,[27,18,21,24,36]) # 106\n print candy(30,123,[5302,6492,697,3634,6667,4517,3519,4798,3472,352,7043,4695,2984,6779,200,2953,192,1550,3873,1108,5377,4281,7429,5349,5454,5033,2136,4472,1131,3880]) # 6054\n\n#2 5000000\n#3041741119206\n#2631001558837\n# print candy(2,5000000,[3041741119206,2631001558837]) # 6054\n# print candy(2,5000000,[308378932313,251878839001]) # 6054\n rubles = ([247339129, 247389396, 247446353, 247495527, 247546368] + [247602159, 247645280, 247703876, 247750078, 247797347] + [247856032, 247908447, 247958408, 247996873, 248048252] + [248097223, 248140491, 248193861, 248247271, 248287740] + [248340547, 248390641, 248442296, 248495005, 248540747]\n + [248588203, 248633576, 248679878, 248727906, 248778152]\n + [248834686, 248884260, 248934623, 248985221, 249027890]\n + [249073791, 249130322, 249177364, 249224415, 249281256]\n + [249329471, 249372932, 249416411, 249468968, 249517515]\n + [249568831, 249621847, 249672071, 249722002, 249775961]\n + [249830289, 249875511, 249917248, 249969414, 250010545]\n + [250058521, 250116878, 250173062, 250216782, 250269447]\n + [250314989, 250358944, 250410170, 250457769, 250507197]\n + [250562967, 250613919, 250669197, 250715639, 250767602]\n + [250824190, 250872072, 250921698, 250974805, 251021507]\n + [251074759, 251119267, 251180832, 251232458, 251284047]\n + [251328693, 251378206, 251431271, 251484542, 251522200]\n + [251569928, 251620331, 251672203, 251710044, 251756206]\n + [251813362, 251862127, 251913700, 251962562, 252017692]\n + [252070692, 252119132, 252177472, 252228770, 252289162])\n print candy(100,5000000,rubles)\n# print candy2(100,5000000,rubles)\n# print candy3(100,5000000,rubles)\n#450450000\n#252289162\n\n#100 5000000\n#[247339129, 247389396, 247446353, 247495527, 247546368]\n#[247602159, 247645280, 247703876, 247750078, 247797347]\n#[247856032, 247908447, 247958408, 247996873, 248048252]\n#[248097223, 248140491, 248193861, 248247271, 248287740]\n#[248340547, 248390641, 248442296, 248495005, 248540747]\n#[248588203, 248633576, 248679878, 248727906, 248778152]\n#[248834686, 248884260, 248934623, 248985221, 249027890]\n#[249073791, 249130322, 249177364, 249224415, 249281256]\n#[249329471, 249372932, 249416411, 249468968, 249517515]\n#[249568831, 249621847, 249672071, 249722002, 249775961]\n#[249830289, 249875511, 249917248, 249969414, 250010545]\n#[250058521, 250116878, 250173062, 250216782, 250269447]\n#[250314989, 250358944, 250410170, 250457769, 250507197]\n#[250562967, 250613919, 250669197, 250715639, 250767602]\n#[250824190, 250872072, 250921698, 250974805, 251021507]\n#[251074759, 251119267, 251180832, 251232458, 251284047]\n#[251328693, 251378206, 251431271, 251484542, 251522200]\n#[251569928, 251620331, 251672203, 251710044, 251756206]\n#[251813362, 251862127, 251913700, 251962562, 252017692]\n#[252070692, 252119132, 252177472, 252228770, 252289162]\n\n#24980336919\n\n#[227525418, 243823038, 228452426, 270756565, 238943623]\n#23034945207\n\n\n\n#2 5000000\n#308378932313\n#251878839001\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a430c786514b163c1b5327332d9a53be", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "from collections import deque\n\n\nclass Treap(): # self.priority_comparator(root.priority, descendant.priority) == True\n def __init__(self, key, priority, prrty_cmprtr):\n self.key = key\n self.priority = priority\n self.priority_comparator = prrty_cmprtr\n self.left = None\n self.right = None\n\n def merge(self, right): # self a.k.a. left <= right ========= tested\n if right is None:\n return self\n if self.priority_comparator(self.priority, right.priority):\n root = self\n if root.right is not None:\n root.right = root.right.merge(right)\n else:\n root.right = right\n else:\n root = right\n root.left = self.merge(right.left)\n return root\n\n def split(self, key): # tested\n if self.key <= key:\n left = self\n if left.right is not None:\n left.right, right = left.right.split(key)\n else:\n left.right, right = None, None\n else:\n right = self\n if right.left is not None:\n left, right.left = right.left.split(key)\n else:\n left, right.left = None, None\n return (left, right)\n\n def insert(self, element): # tested\n left, right = self.split(element.key)\n if left is not None:\n t = left.merge(element)\n else:\n t = element\n if right is not None:\n return t.merge(right)\n return t\n\n def delete(self, key): # UN!tested\n left, right = self.split(key)\n left, middle = left.split(key - 1)\n if left is not None:\n return left.merge(right)\n return right\n\n def find(self, key):\n pos = self\n while True:\n if key == pos.key:\n return True\n elif key < pos.key:\n if pos.left is None:\n return False\n pos = pos.left\n else:\n if pos.right is None:\n return False\n pos = pos.right\n\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nfirst = [deque() for i in range(n)]\nfor i in range(n):\n first[a[i] - 1].append(i)\nfirst[a[0] - 1].popleft()\ntreap = Treap(a[0], first[a[0] - 1][0], lambda x, y: x >= y)\nl, res = 1, 1\nfor i in range(1, n):\n first[a[i] - 1].popleft()\n if not first[a[i] - 1]:\n priority = float('inf')\n else:\n priority = first[a[i] - 1][0]\n if not treap.find(a[i]):\n if l == k:\n treap = treap.delete(treap.key)\n l -= 1\n if treap is not None:\n treap = treap.insert(Treap(a[i], priority, lambda x, y: x >= y))\n else:\n treap = Treap(a[i], priority, lambda x, y: x >= y)\n l += 1\n res += 1\n else:\n treap = treap.delete(a[i])\n if treap is not None:\n treap = treap.insert(Treap(a[i], priority, lambda x, y: x >= y))\n else:\n treap = Treap(a[i], priority, lambda x, y: x >= y)\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e88b7f23b483796252fb3d87f0aa5a6", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n,k = input()\norder = []\ndef calculateMinCost(n,k,order):\n\tcost = 0\n\tbooks = []\n\tday = 0\n\tfor ai in order:\n\t\tif ai not in books:\n\t\t\tif len(books) < k:\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\t\telse:\n\t\t\t\tneeded = order[(day):(day+k)]\n\t\t\t\tfor book in books:\n\t\t\t\t\tif book not in needed:\n\t\t\t\t\t\tbooks.remove(book)\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\tday += 1\n\treturn cost", "lang_cluster": "Python", "compilation_error": false, "code_uid": "471ac2508c8c2811e8698c3730b2efec", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n,k,order = input()\ndef calculateMinCost(n,k,order):\n\tcost = 0\n\tbooks = []\n\tday = 0\n\tfor ai in order:\n\t\tif ai not in books:\n\t\t\tif len(books) < k:\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\t\telse:\n\t\t\t\tneeded = order[(day):(day+k)]\n\t\t\t\tfor book in books:\n\t\t\t\t\tif book not in needed:\n\t\t\t\t\t\tbooks.remove(book)\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\tday += 1\n\treturn cost", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e7da5e510cf88a8fc06fcb3e4ff37e28", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "from sys import stdin, stdout\nn, k, order = [int(x) for x in stdin.readline().rstrip().split()]\ndef calculateMinCost(n,k,order):\n\tcost = 0\n\tbooks = []\n\tday = 0\n\tfor ai in order:\n\t\tif ai not in books:\n\t\t\tif len(books) < k:\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\t\telse:\n\t\t\t\tneeded = order[(day):(day+k)]\n\t\t\t\tfor book in books:\n\t\t\t\t\tif book not in needed:\n\t\t\t\t\t\tbooks.remove(book)\n\t\t\t\tcost += 1\n\t\t\t\tbooks.append(ai)\n\t\tday += 1\n\treturn cost", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4ef37729e674dfd5065365f220cb38d9", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nz=[0]*80\nkz,ans=0,0\nfor i in range(n):\n if z[a[i]]: continue\n ans+=1\n if k>kz:\n z[a[i]]=1; kz+=1\n else:\n h=-1\n for j in range(n):\n if z[j]:\n m=n+1\n for p in range(i,n):\n if j==a[p]:\n m=p;\n break\n if m>h:\n h=m;\n t=j\n z[t]=0\n z[a[i]]=1\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a25e374405b61717f1bccc44ae4de430", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.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 num[i] = '0'\n k -= 1\nprint(*num, sep='')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2119f7dd86e3e2bd394ab530815bf4b", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n,k=map(int,input().split())\nl=list(input())\nif n==1:\n print(0)\nelse:\n if l[0]!='1':\n l[0]='1'\n k-=1\n for i in range(1,n):\n if k>0 and int(l[i])>0:\n if l[i]!='0':\n l[i]='0'\n k-=1\n print(*l,sep='')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "698a4c1563bae1b9767287378e64c5de", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n,k=map(int,input().split())\ns=input()\nflag=1\nif len(s)==1:\n print(0)\nelse:\n l=list(s)\n if s[0]!=1:\n l[0]=1\n k-=1\n flag=0\n #print(l)\n c=0\n if flag:\n i=0\n else:\n i=1\n #print(\"I\",i)\n while c1]\nfor c in input():print((c,t)[k>0],end='');k-=c>t;t='0'\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "946e7b0b57559b3382b1e6d585621930", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\n\ns = list(input())\nif n == 1 and k:\n print(\"0\")\n exit()\nif k:\n for i in range(n):\n if not(i):\n if k and s[i] != \"1\":\n s[i] = \"1\"\n k -= 1\n else:\n if k:\n if s[i] != \"0\":\n s[i] = \"0\"\n k -= 1\n else:\n break\nprint(\"\".join(s))\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "14477a9ab04594c75f038a71c23fb846", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "PyPy 3", "source_code": "print(\"Secret_171\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f9c5511fd369f8b6a92e424501273c30", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "print \"intercal\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1b0c0af7e293620cea430ed9f53ce2eb", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "print(INTERCAL)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c471b0d4816d6ec41266300c1ad2d99", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "Python 2", "source_code": " print*, 'FORTRAN 77'\n END\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "af5430b8d81a79d7e938698829a437df", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "#include\nint main(){\n puts(\"INTERCAL\");\n}", "lang_cluster": "Python", "compilation_error": true, "code_uid": "6e62b06ae7c8e856a219f095000c7a60", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "def do(i):\n\tif i == \"(\":\n\t\treturn 1\n\telse:\n\t\treturn -1\ndef find(i,idx):\n\tif i maxv:\n\t\tmaxv = s[i]\n\t\tmaxvi = i\nnewv = arr[maxvi:]+arr[:maxvi]\nprint \" \".join([\"(\" if i == 1 else\")\" for i in newv ])\n\nif sum(newv) != 0:\n\tprint 0\n\tprint 1,1\nelse:\n\tcnt = 0\n\tcnt1 = -1\n\tmaxv = 0\n\tl = 0\n\tr = 0\n\tlast = 0\n\tst = 0\n\tfor i in range(n):\n\t\tst += newv[i]\n\t\tif st == 0:\n\t\t\tcnt += 1\n\t\t\tcnt1 = -1\n\t\t\tlast = i+1\n\t\telif st == 1:\n\t\t\tcnt1 += 1\n\t\t\tif cnt1 > maxv:\n\t\t\t\tmaxv = cnt1\n\t\t\t\tl = last\n\t\t\t\tr = i+1\n\tif maxv > cnt:\n\t\tprint maxv+1\n\t\tprint find(l,maxvi),find(r,maxvi)\n\telse:\n\t\tprint cnt,1,1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7429bfb02e338b54588916bfe9fb8d42", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "def do(i):\n\tif i == \"(\":\n\t\treturn 1\n\telse:\n\t\treturn -1\ndef find(i,idx):\n\tif i maxv:\n\t\tmaxv = s[i]\n\t\tmaxi = i\nnewv = arr[maxi:]+arr[:maxi]\n\nif sum(newv) != 0:\n\tprint 0\n\tprint 1,1\nelse:\n\tcnt = 0\n\tcnt1 = -1\n\tmaxv = 0\n\tl = 0\n\tr = 0\n\tlast = 0\n\tst = 0\n\tfor i in range(n):\n\t\tst += newv[i]\n\t\tif st == 0:\n\t\t\tcnt += 1\n\t\t\tcnt1 = -1\n\t\t\tlast = i+1\n\t\telif st == 1:\n\t\t\tcnt1 += 1\n\t\t\tif cnt1 > maxv:\n\t\t\t\tmaxv = cnt1\n\t\t\t\tl = last\n\t\t\t\tr = i+1\n\tif maxv > cnt:\n\t\tprint maxv+1\n\t\tprint find(l,maxi),find(r,maxi)\n\telse:\n\t\tprint cnt,1,1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "34e2d4f43a290d402fb5225900c96f58", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.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>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": "49814ccb1d9d8a8f67c1dd48db744968", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "def do(i):\n\tif i == \"(\":\n\t\treturn 1\n\telse:\n\t\treturn -1\ndef find(i,idx):\n\tif i maxv:\n\t\tmaxv = s[i]\n\t\tmaxi = i\nnewv = arr[maxi:]+arr[:maxi]\n\nif sum(newv) != 0:\n\tprint 0\n\tprint 1,1\nelse:\n\tcnt = 0\n\tcnt1 = -1\n\tmaxv = 0\n\tl = 0\n\tr = 0\n\tlast = 0\n\tst = 0\n\tfor i in range(n):\n\t\tst += newv[i]\n\t\tif st == 0:\n\t\t\tcnt += 1\n\t\t\tcnt1 = -1\n\t\t\tlast = i+1\n\t\telif st == 1:\n\t\t\tcnt1 += 1\n\t\t\tif cnt1 > maxv:\n\t\t\t\tmaxv = cnt1\n\t\t\t\tl = last\n\t\t\t\tr = i+1\n\tif maxv > cnt:\n\t\tprint maxv+1\n\t\tprint find(l,maxvi),find(r,maxvi)\n\telse:\n\t\tprint cnt,1,1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9f69917c6ae3e34fa729d4d49041539f", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "def do(i):\n\tif i == \"(\":\n\t\treturn 1\n\telse:\n\t\treturn -1\ndef find(i,idx):\n\tif i maxv:\n\t\tmaxv = s[i]\n\t\tmaxvi = i\nnewv = arr[maxvi:]+arr[:maxvi]\n\nif sum(newv) != 0:\n\tprint 0\n\tprint 1,1\nelse:\n\tcnt = 0\n\tcnt1 = -1\n\tmaxv = 0\n\tl = 0\n\tr = 0\n\tlast = 0\n\tst = 0\n\tfor i in range(n):\n\t\tst += newv[i]\n\t\tif st == 0:\n\t\t\tcnt += 1\n\t\t\tcnt1 = -1\n\t\t\tlast = i+1\n\t\telif st == 1:\n\t\t\tcnt1 += 1\n\t\t\tif cnt1 > maxv:\n\t\t\t\tmaxv = cnt1\n\t\t\t\tl = last\n\t\t\t\tr = i+1\n\tif maxv > cnt:\n\t\tprint maxv+1\n\t\tprint find(l,maxvi),find(r,maxvi)\n\telse:\n\t\tprint cnt,1,1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "975f31ecb94d8dd2dbce712d087097db", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "\n\ns=input()\ns=sorted(s)\ncount=1\nfor i in range(1,len(s)):\n if(s[i]==s[i-1]):\n count+=1\n else:\n ans.append(count)\n count=1\nans.append(count)\nans.sort()\nif(len(ans)==1):\n print(1)\nif(len(ans)==2):\n if(ans[0]==1):\n print(1)\n else:\n print(2)\nif(len(ans)==3):\n if(len(set(ans))==1):\n print(6)\n elif(ans=[1,1,4]):\n print(2)\n elif(ans==[1,2,3]):\n print(3)\nif(len(ans)==4):\n if(ans==[1,1,1,3]):\n print(5)\n elif(ans=[1,1,2,2]):\n print(8)\nif(len(ans)==6):\n print(30)\nif(len(ans)==5):\n print(15)\n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "344b4cb3baf321804f0e1dd4de53e2aa", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "4952a200a9d934bb605c29ec1cb9ebc7", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in raw_input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint res[s]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bf69a4cb0764df9eba46b9eabd5041c", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from collections import defaultdict\na = defaultdict(int)\nfor c in input(): a[c] += 1\ns = tuple(sorted(a.values()))\nres = {\n\t(6,): 1,\n\t(1, 5): 1,\n\t(2, 4): 2,\n\t(1, 1, 4): 2,\n\t(3, 3): 2,\n\t(1, 2, 3): 3,\n\t(1, 1, 1, 3): 5,\n\t(2, 2, 2): 6,\n\t(1, 1, 2, 2): 8,\n\t(1, 1, 1, 1, 2): 15,\n\t(1, 1, 1, 1, 1, 1): 30,\n}\nprint(res[s])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e43161034bf4de27e1a833f426e4cef6", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from functools import reduce\n\ndef factorial(n):\n return reduce(lambda x, y: x*y, range(1,n+1))\n\ncolors = {\n 'R' : 0,\n 'O' : 0,\n 'Y' : 0,\n 'G' : 0,\n 'B' : 0,\n 'V' : 0\n}\n\nfor c in list(input()):\n colors[c] += 1\n\namount = list(reversed(sorted([(colors[key], key) for key in colors])))\n\namount = [x[0] for x in amount]\n\nif amount[0] == 6 or amount[0] == 5:\n print(\"1\")\nelif amount[0] == 4:\n print(\"2\")\nelif amount[0] == 3:\n if amount[1] == 3:\n print(\"2\")\n elif amount[1] == 2:\n print(\"5\")\n elif amount[1] == 1:\n print(\"5\")\nelif amount[0] == 2:\n if amount[1] == amount[2] == 2:\n print(\"4\")\n elif amount[1] == 2:\n while True: pass\n else:\n print(factorial(6) // 48)\n\nelif amount[0] == 1:\n print(factorial(6) // 24)\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ff8dbae1a399ee76a9fad1d924a92e62", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "x0, y0 = map(int, input().split())\nn = int(input())\narr = [[x0, y0]]\nfor i in range(0, n):\n x, y = map(int, input().split())\n arr.append([x, y])\ndist = [[0 for j in range(0, n+1)] for i in range(0, n+1)]\nfor i in range(0, n+1):\n for j in range(0, n+1):\n dist[i][j] = (arr[i][0] - arr[j][0])**2 + (arr[i][1] - arr[j][1])**2\n# print(arr)\n# print(dist)\n\ndef dfs(status, memo):\n if status in memo:\n return memo[status][0]\n if status <= 0:\n return 10*9\n res = 10**9\n prev = []\n for i in range(1, n+1):\n next = status - (1 << i)\n temp = dfs(next, memo) + dist[0][i]*2\n if temp < res:\n res = temp\n prev = [i, 0]\n for j in range(1, n+1):\n if j == i:\n continue\n next = status - (1 << i) - (1 << j)\n temp = dfs(next, memo) + dist[0][j] + dist[j][i] + dist[i][0]\n if temp < res:\n res = temp\n prev = [i, j, 0]\n memo[status] = [res, prev]\n # print(status, res)\n return res\n\n\nmemo = {1: [0, []]}\nstart = 1\nend = 1\nfor i in range(1, n + 1):\n end += (1 << i)\nres = dfs(end, memo)\npath = [0]\ncur = end\nwhile cur > 1:\n prev = memo[cur][1]\n # if len(prev) == 2:\n path.extend(prev)\n for i in range(len(prev) - 1):\n cur -= (1 << prev[i])\n\nprint(res)\nprint(' '.join(map(str, path)))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "211945759836416d925933de147f3a62", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "o = map(int, raw_input().split())\nn = int(raw_input())\nc = [map(int, raw_input().split()) for _ in range(n)]\nd = [None] * (1 << n)\np = [0] * (1 << n)\nz = [[-1 for i in range(n + 1)] for j in range(n + 1)]\npw = [(1 << i) for i in xrange(n + 1)]\n\n\ndef dist(i, j):\n if z[i + 1][j + 1] == -1:\n a = o if i < 0 else c[i]\n b = o if j < 0 else c[j]\n z[i + 1][j + 1] = (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2\n return z[i + 1][j + 1]\n\n\ndef upd(im, res, pr):\n if d[im] is None or res < d[im]:\n p[im] = pr\n d[im] = res\n\n\ndef dp(msk):\n if d[msk] is None:\n return\n idx = -1\n for i in range(n):\n if not (msk & pw[i]):\n im = msk + pw[i]\n for j in range(i, n):\n if not (msk >> j & 1):\n r = dist(i, j) + dist(i, -1) + dist(j, -1)\n jm = im + (pw[j] if i != j else 0)\n upd(jm, r + d[msk], msk)\n break\n\n\nd[0] = 0\nfor i in range(1 << n):\n dp(i)\nmsk = (1 << n) - 1\nprint d[msk]\n\nr = [0]\nwhile msk:\n m = msk - p[msk]\n while m:\n tt = -m & m\n m -= tt\n t = 0\n while tt > 0:\n t += 1\n tt /= 2\n r.append(t + 1)\n msk = p[msk]\n r.append(0)\nprint ' '.join(map(str, r))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d14c2a008e5e06a2263bb20bd01856dc", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "o = map(int, raw_input().split())\nn = int(raw_input())\nc = [map(int, raw_input().split()) for _ in range(n)]\nINF = 10 ** 6\nd = [INF for _ in range(1 << n)]\np = [None for _ in range(1 << n)]\nz = [[-1 for i in range(n + 1)] for j in range(n + 1)]\n\n\ndef dist(i, j):\n if z[i + 1][j + 1] == -1:\n a = o if i < 0 else c[i]\n b = o if j < 0 else c[j]\n z[i + 1][j + 1] = (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2\n return z[i + 1][j + 1]\n\n\ndef upd(im, res, pr):\n if res < d[im]:\n p[im] = pr\n d[im] = res\n\n\ndef dp(msk):\n if d[msk] == INF:\n return\n idx = -1\n for i in range(n):\n if msk & (1 << i) == 0:\n im = msk | (1 << i)\n for j in range(i, n):\n if msk & (1 << j) == 0:\n r = dist(i, j) + dist(i, -1) + dist(j, -1)\n jm = im | (1 << j)\n upd(jm, r + d[msk], msk)\n break\n\n\nd[0] = 0\nfor i in range(1 << n):\n dp(i)\nmsk = (1 << n) - 1\nprint d[msk]\n\nr = [0]\nwhile p[msk]:\n m = msk & p[msk]\n for t in range(n):\n if (1 << t) & m:\n r.append(t + 1)\n r.append(0)\n msk = p[msk]\n r.append(0)\nprint ' '.join(str(t) for t in r)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4f47a5aa94bea463e96324a4977ad3d2", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "x0, y0 = map(int, input().split())\nn = int(input())\narr = [[x0, y0]]\nfor i in range(0, n):\n x, y = map(int, input().split())\n arr.append([x, y])\ndist = [[0 for j in range(0, n+1)] for i in range(0, n+1)]\nfor i in range(0, n+1):\n for j in range(0, n+1):\n dist[i][j] = (arr[i][0] - arr[j][0])**2 + (arr[i][1] - arr[j][1])**2\n# print(arr)\n# print(dist)\n\ndef dfs(status, memo):\n # if status in memo:\n # return memo[status][0]\n if memo[status] != None:\n return memo[status][0]\n if status <= 0:\n return 1e8\n res = 1e8\n prev = []\n for i in range(1, n+1):\n if ((status >> i) & 1) == 0:\n continue\n next = status - (1 << i)\n temp = dfs(next, memo) + dist[0][i]*2\n if temp < res:\n res = temp\n prev = [i, 0]\n for j in range(1, n+1):\n if j == i:\n continue\n if ((status >> j) & 1) == 0:\n continue\n next = status - (1 << i) - (1 << j)\n temp = dfs(next, memo) + dist[0][j] + dist[j][i] + dist[i][0]\n if temp < res:\n res = temp\n prev = [i, j, 0]\n memo[status] = [res, prev]\n print(status, res)\n return res\n\n\n# memo = {1: [0, []]}\nmemo = [None for i in range(0, 1 << 25)]\nmemo[1] = [0, []]\nstart = 1\nend = 1\nfor i in range(1, n + 1):\n end += (1 << i)\nres = dfs(end, memo)\npath = [0]\ncur = end\nwhile cur > 1:\n prev = memo[cur][1]\n # if len(prev) == 2:\n path.extend(prev)\n for i in range(len(prev) - 1):\n cur -= (1 << prev[i])\n\nprint(res)\nprint(' '.join(map(str, path)))\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bdf1d728594a4b968188012c46764776", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "\"\"\"\ntag: dp, bitmasks\n\nhttp://codeforces.com/problemset/problem/8/C\n\nsolution:\nfor one already optimized selection a: 0101100101\ncalculate each 0 positions, e.g. 0101100111, meaning selecting the second\nitem based on the a status.\nthen select another one item, e.g. 0101101111, meaning selecting the\nfourth item based on the a status.\nand we need another array to keep the path from a to b\nthe solution is what kept in status a=1111111111\n\"\"\"\n\n\nimport sys\n\nip = sys.stdin.readline\n#ip = open('../input.txt').readline\n\n# reading numbers of one line\ndef getnums():\n return map(int, ip().split())\n\n# distance\ndef f(x, y):\n return x * x + y * y\n\n\n# the original point\nxo, yo = getnums()\n\n# number of items\nn = int(ip())\n\n# distance from original point to each item\ndisto = [0] * n\n\n# distance from each item to another item\ndisti = [[0] * n for i in xrange(n)]\n\n# position of items\npositions = []\n\n# calculate distance between 2 items\nfor i in xrange(n):\n x, y = getnums()\n disto[i] = f(xo - x, yo - y)\n for j in xrange(i):\n disti[j][i] = f(positions[j][0] - x, positions[j][1] - y)\n disti[i][j] = disti[j][i]\n positions.append((x, y))\n\n\n# optimized cost for each status\na = [None] * (1 << n)\n# none of the items are selected, so the cost is 0\na[0] = 0\n# parent status for each optimized status\np = [0] * (1 << n)\n\nfor i in xrange(1 << n):\n if a[i] is not None:\n for j in xrange(n):\n # meaning jth items was not selected in status i\n if i & (1 << j) == 0:\n\n # only take the item and return\n t = i + (1 << j)\n if not a[t] or a[t] > a[i] + disto[j] * 2:\n a[t] = a[i] + disto[j] * 2\n p[t] = i\n\n # if take another item\n for k in xrange(j + 1, n):\n if t & (1 << k) == 0:\n two = t + (1 << k)\n c = a[i] + disto[j] + disti[j][k] + disto[k]\n if not a[two] or a[two] > a[i] + c:\n a[two] = a[i] + c\n p[two] = i\n\nz = (1 << n) - 1\nprint a[z]\nr = [0]\nwhile z > 0:\n t = z - p[z]\n while t:\n x = -t & t\n t -= x\n i = 0\n while x > 0:\n i += 1\n x /= 2\n r.append(i)\n z = p[z]\n r.append(0)\n\nprint ' '.join(map(str, r[::-1]))\n\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c7cfd2fd063f21a831b75a19a6d3f567", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "read = lambda: map(int, input().split())\nn, v, e = read()\nadj = [[] for _ in range(n + 1)]\nAs = [0] + list(read())\nBs = [0] + list(read())\nans = []\n\nfor _ in range(e):\n a, b = map(int, input().split())\n adj[a].append(b)\n adj[b].append(a)\n\n\ndef flow(a, b, d):\n As[a] -= d\n As[b] += d\n ans.append((a, b, d));\n\ndef augment(path, e, d):\n if e:\n dd = min(d, As[path[e - 1]], v - As[path[e]])\n flow(path[e - 1], path[e], dd)\n augment(path, e - 1, d)\n if d > dd:\n flow(path[e - 1], path[e], d - dd);\n \ndef adjust(s):\n pre = [0] * (n + 1)\n pre[s] = -1\n stk = [s]\n e = 0\n while len(stk):\n p = stk[-1]\n del stk[-1]\n if As[p] < Bs[p]:\n e = p\n break\n for to in adj[p]:\n if not pre[to]:\n pre[to] = p\n stk.append(to)\n \n if not e:\n raise Exception\n path = []\n while e > 0:\n path.insert(0, e)\n e = pre[e]\n augment(path, len(path) - 1, min(Bs[path[-1]] - As[path[-1]], As[s] - Bs[s])) \n\ntry:\n while True:\n check = False\n for i in range(1, n + 1):\n if As[i] > Bs[i]:\n adjust(i)\n check = True\n if not check: \n break\n for i in range(1, n + 1):\n if As[i] != Bs[i]:\n raise Exception\n print(len(ans))\n for tp in ans:\n print(*tp)\nexcept Exception:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4b2337efc2563741db093f0f4ce1230d", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "read = lambda: map(int, input().split())\nn, v, e = read()\nadj = [[]] * (n + 1)\nAs = [0] + list(read())\nBs = [0] + list(read())\nans = []\n\nfor _ in range(e):\n a, b = map(int, input().split())\n adj[a].append(b)\n adj[b].append(a)\n\n\ndef flow(a, b, d):\n As[a] -= d\n As[b] += d\n ans.append((a, b, d));\n\ndef augment(path, e, d):\n if e:\n dd = min(d, As[path[e - 1]], v - As[path[e]])\n flow(path[e - 1], path[e], dd)\n augment(path, e - 1, d)\n if d > dd:\n flow(path[e - 1], path[e], d - dd);\n \ndef adjust(s):\n pre = [0] * (n + 1)\n pre[s] = -1\n stk = [s]\n e = 0\n while len(stk):\n p = stk[-1]\n del stk[-1]\n if As[p] < Bs[p]:\n e = p\n break\n for to in adj[p]:\n if not pre[to]:\n pre[to] = p\n stk.append(to)\n \n if not e:\n raise Exception\n \n path = []\n while e > 0:\n path.insert(0, e)\n e = pre[e]\n\n augment(path, len(path) - 1, min(Bs[path[-1]] - As[path[-1]], As[s] - Bs[s])) \n\ntry:\n while True:\n check = False\n for i in range(1, n + 1):\n if As[i] > Bs[i]:\n adjust(i)\n check = True\n if not check: \n break\n for i in range(1, n + 1):\n if As[i] != Bs[i]:\n raise Exception\n print(len(ans))\n for tp in ans:\n print(*tp)\nexcept Exception:\n print(\"NO\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "96e09dc55b5b2f24d97ae41cdbffce03", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "n,d,S=map(int,raw_input().split())\nc0=[]\nc1=[]\nc2=1\nfor i in range(n):\n c,f,l=map(int,raw_input().split())\n c2+=c\n if c>0 :\n c1.append([f,l])\n else :\n c0.append([f,l])\n\ndef solc0(N,T):\n c0.sort()\n res=0\n ct=0\n for a in c0:\n if a[1]>=d:\n if res+a[0]<=T and ct=d:\n if a[0]<=S:\n res=a[0]\n c0.extend(c1[i:])\n break\n else: return 0,0\n if res<0 : return 0,0\n\n tc,tr=solc0(n-c2,S-res)\n ct=tc+c2\n res+=tr\n return ct,res\n\nct,res=solc0(n,S)\nct2,res2=solc1()\nif ctres2):\n ct,res=ct2,res2\n\nprint ct,res\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "859e58fb24b3f35237844b714d399480", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n,d,S=map(int,raw_input().split())\nc0=[]\nc1=[]\nc2=1\nfor i in range(n):\n c,f,l=map(int,raw_input().split())\n c2+=c\n if c>0 :\n c0.append([f,l])\n else :\n c1.append([f,l])\n\ndef solc0(N,T):\n c0.sort()\n res=0\n ct=0\n for a in c0:\n if a[1]>=d:\n if res+a[0]<=T and ct=d:\n if a[0]<=S:\n res=a[0]\n c0.extend(c1[i:])\n else: return 0,0\n if res<0 : return 0,0\n\n tc,tr=solc0(n-c2,S-res)\n ct=tc+c2\n res+=tr\n return ct,res\n\nct,res=solc0(n,S)\nct2,res2=solc1()\nif ctres2):\n ct,res=ct2,res2\n\nprint ct,res\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa483850c0d62b4b9b960a36550c0ad5", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n,d,S=map(int,raw_input().split())\nc0=[[0,0] for i in range(n)]\nc1=[[0,0] for i in range(n)]\nc2=1\nfor i in range(n):\n c,f,l=map(int,raw_input().split())\n c2+=c\n if c>0 : c1[i][0]=f;c1[i][1]=l;\n else : c0[i][0]=f;c0[i][1]=l;\n\ndef solc0(N,T):\n c0.sort()\n res=0\n ct=0\n for i in range(len(c0)):\n if c0[i][1]>=d:\n if res+c0[i][0]<=T and ct=d:\n if c1[i][0]<=S:\n res=c1[i][0]\n c0.extend(c1[i+1:])\n else: return 0,0\n if res<0 : return 0,0\n\n tc,tr=solc0(n-c2,S-res)\n ct=tc+c2\n res+=tr\n return ct,res\n\nct,res=solc0(n,S)\nct2,res2=solc1()\nif ctres2):\n ct,res=ct2,res2\n\nprint ct,res\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3df051ae8db90e23f3b26208673d7520", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n,d,S=map(int,raw_input().split())\nc0=[]\nc1=[]\nc2=1\nfor i in range(n):\n c,f,l=map(int,raw_input().split())\n c2+=c\n if c>0 :\n c1.append([f,l])\n else :\n c0.append([f,l])\n\ndef solc0(N,T):\n c0.sort()\n res=0\n ct=0\n for a in c0:\n if a[1]>=d:\n if res+a[0]<=T and ct=d:\n if a[0]<=S:\n res=a[0]\n c0.extend(c1[i:])\n else: return 0,0\n if res<0 : return 0,0\n\n tc,tr=solc0(n-c2,S-res)\n ct=tc+c2\n res+=tr\n return ct,res\n\nct,res=solc0(n,S)\nct2,res2=solc1()\nif ctres2):\n ct,res=ct2,res2\n\nprint ct,res\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5d8e46a5910e9a5cf279de5e31ca378c", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n,d,S=map(int,raw_input().split())\nc0=[[0,0] for i in range(n)]\nc1=[[0,0] for i in range(n)]\nc2=1\nfor i in range(n):\n c,f,l=map(int,raw_input().split())\n c2+=c\n if c>0 : c1[i][0]=f,c1[i][1]=l;\n else : c0[i][0]=f,c0[i][1]=l;\n\ndef solc0(N,T):\n c0.sort()\n res=0\n ct=0\n for i in range(len(c0)):\n if c0[i][1]>=d:\n if res+c0[i][0]<=T and ct=d:\n if c1[i][0]<=S:\n res=c1[i][0]\n c0.extend(c1[i+1:])\n else: return 0,0\n if res<0 : return 0,0\n\n tc,tr=solc0(n-c2,S-res)\n ct=tc+c2\n res+=tr\n return ct,res\n\nct,res=solc0(n,S)\nct2,res2=solc1()\nif ctres2):\n ct,res=ct2,res2\n\nprint ct,res\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b527ad1c54cd32cbab9dedef6e57430", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef solve():\n n = int(input())\n if n == 1: return 0\n res = 1000000\n for other in range(1, n):\n pair = [n, other]\n temp = 0\n while pair[0] > 1 or pair[1] > 1:\n if pair[0] > pair[1]: pair[0], pair[1] = pair[1], pair[0]\n pair[1] -= pair[0]\n temp+=1\n res = min(res, temp)\n return res\n\n\n\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nprint(solve())", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce31c5554e9d395a1d0505ecac82b11e", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "def solve(N, M):\n if M == 0: return 1000000\n if M == 1: return N - 1\n d, r = divmod(N, M)\n return d + solve(M, r)\n\nN = int(input())\nans = 1000000\nfor M in range(1, N + 1):\n ans = min([ans, solve(N, M)])\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5be41a7dde9b3c1d87fa72557221f531", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from fractions import gcd\n\nN = input()\nH = dict()\n\ndef number (n,b):\n if not H.has_key((n,b)):\n if n == 1 and b == 1: H[n,b] = 0\n elif n>b and b>0: H[n,b] = (n-1)/b + number ((n-1)%b+1,b)\n elif b>n and n>0: H[n,b] = (b-1)/n + number (n,(b-1)%n+1)\n else: H[n,b] = 10000000\n return H[n,b]\n\nm = min (number(N,b) for b in range (N+1))\nprint m\n#print [b for b in range (N+1) if number(N,b)==m]\n# for b in range (N+1): print number(N,b),b,gcd(N,b)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a8c28ed8f64b20cf631872f6fe47270", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "from fractions import gcd\n\nn = input()\nH = dict()\ninf = 10000000\n\n# m represents the minimum computed so far\ndef number (n,b,m):\n if not H.has_key((n,b)):\n if b == 1: H[n,b] = n-1\n elif n>b and b>0 and n/bb): a=a-b\n else: b = b-a\n return a\n \nn = int(input())\nmnm = m.inf\n \nfor k in range(m.ceil(n/2),n):\n if(hcf(n,k)!=1): continue\n \n p =k\n q = n-k\n count = 2\n while(p!=2):\n diff = p-q\n if(q>diff): \n p=q\n q=diff\n \n else:\n p=diff\n \n count+=1\n \n if(count0:\n tmp+=mask % 2\n mask//=2\n return tmp\n \nn = int(input())\na = list(input().split())\nans = 10\nfor mask in range(1024):\n f = True\n for i in range(n):\n for j in range(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 if f:\n ans = min(ans,count(mask))\n \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95f7822d2cc78d58a367ddcce0c7e879", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "class card:\n def __init__(self, one, two):\n self.c = one\n self.t = two\n\n\ninp = []\nchars = {'R': 0, 'G': 1, 'B': 2, 'Y': 3, 'W': 4}\nn = int(raw_input())\nspl = raw_input().split(' ')\nfor s in spl:\n inp.append(card(chars[s[0]], int(s[1]) - 1))\n\n\ndef check(mask):\n for i in xrange(n):\n for j in xrange(i + 1, n):\n c1 = inp[i]\n c2 = inp[j]\n flag = False\n if c1.c == c2.c and c1.t == c2.t:\n flag = True\n if c1.c != c2.c and ((mask & (1 << c1.c)) != 0 or (mask & (1 << c2.c)) != 0):\n flag = True\n if c1.t != c2.t and ((mask & (1 << (c1.t + 5))) != 0 or (mask & (1 << (c2.t + 5))) != 0):\n flag = True\n if not flag:\n return False\n return True\n\n\ndef count_bits(mask):\n out = 0\n while mask > 0:\n if mask & 1 == 1:\n out += 1\n mask >>= 1\n return out\n\nout = 10\nend = 2 ** 10\nfor m in xrange(end):\n if check(m):\n #print m, bin(m), count_bits(m)\n out = min(out, count_bits(m))\n\nprint out", "lang_cluster": "Python", "compilation_error": false, "code_uid": "51164bb11d415b8a0f07b8e30b56d2b1", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\ncolour = dict(zip('RGBYW', range(5, 10)))\ncards = list({2 ** colour[c] + 2 ** (ord(v) - ord('1')) for c, v in input().split()})\nans = 10\n\nfor bit in range(2 ** 10):\n ok = True\n for i in range(n - 1):\n for j in range(i + 1, n):\n if cards[i] & cards[j] == 0:\n if (cards[i] | cards[j]) & bit == 0:\n ok = False\n break\n elif cards[i] != cards[j]:\n if (cards[i] ^ cards[j]) & bit == 0:\n ok = False\n break\n if not ok:\n break\n if ok:\n ans = min(bin(bit).count('1'), ans)\n \nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "df226c0a6ae75c368017cee72511f31b", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "user_input=int(input())\ncards=input()\ncards_array=cards.split(' ')\ncolours=['R','G','B','Y','W']\nvalues=['1','2','3','4','5']\n\ncard_set=set(cards_array)\nif len(card_set)==1:\n print (\"0\")\nelse:\n colour_array=[]\n value_array=[]\n\n for card in card_set:\n colour_array.extend([card[0]])\n value_array.extend([card[1]])\n\n hint_list=[]\n hints=0\n\n known=0\n\n colour_hint=0\n value_hint=0\n\n for the_colour in colours:\n if colour_array.count(the_colour) == len(card_set):\n for i in range(len(card_set)):\n colour_array[i]='known'\n hint_list.extend(the_colour)\n colour_hint+=1\n\n elif colour_array.count(the_colour) == 0:\n hint_list.extend(the_colour)\n colour_hint+=1\n\n for the_value in values:\n if value_array.count(the_value) == len(card_set):\n for i in range(len(card_set)):\n value_array[i] = 'known'\n hint_list.extend(the_value)\n value_hint+=1\n\n elif value_array.count(the_value)==0:\n hint_list.extend(the_value)\n value_hint+=1\n\n while known<(len(card_set)):\n count=0\n for the_value in values:\n if the_value in hint_list:\n pass\n else:\n if value_array.count(the_value)>count:\n index=values.index(the_value)\n count=value_array.count(the_value)\n\n if count!=0:\n hints+=1\n value_hint+=1\n hint_list.extend(values[index])\n another_count=value_array.count(values[index])\n for i in range(value_array.count(values[index])):\n an_index=value_array.index(values[index])\n value_array[an_index]='known'\n\n if colour_array[index] == 'known':\n known += 1\n\n if colour_array.count(colour_array[index]) == 1:\n colour_array[index] = 'known'\n known+=1\n\n if another_count > 1:\n index2 = value_array.index(values[index])\n\n if colour_array.count(colour_array[index2]) == 1:\n colour_array[index2] = 'known'\n known+=1\n\n another_count -= 2\n\n\n if value_hint==4:\n for the_value in values:\n if the_value not in hint_list:\n another_count = value_array.count(the_value)\n for i in range(value_array.count(the_value)):\n\n index=value_array.index(the_value)\n value_array[index]='known'\n\n if colour_array[index]=='known':\n known+=1\n\n if colour_array.count(colour_array[index]) == 1:\n colour_array[index] = 'known'\n known+=1\n\n if another_count > 1:\n index2=value_array.index(the_value)\n\n if colour_array.count(colour_array[index2])==1:\n colour_array[index2]='known'\n known+=1\n\n another_count-=2\n\n\n\n\n value_hint+=1\n\n count=0\n\n for the_colour in colours:\n if the_colour in hint_list:\n pass\n else:\n if colour_array.count(the_colour)>count:\n count=colour_array.count(the_colour)\n index=colours.index(the_colour)\n\n if count!=0:\n hints+=1\n colour_hint+=1\n hint_list.extend(colours[index])\n another_count = colour_array.count(colours[index])\n for i in range(another_count):\n index = colour_array.index(colours[index])\n colour_array[index] = 'known'\n\n if value_array[index] == 'known':\n known += 1\n\n if value_array.count(value_array[index]) == 1:\n value_array[index] = 'known'\n known+=1\n\n if another_count > 1:\n\n index2 = colour_array.index(colours[index])\n\n if value_array.count(value_array[index2]) == 1:\n value_array[index2] = 'known'\n known+=1\n\n another_count -= 2\n\n\n\n if colour_hint==4:\n for the_colour in colours:\n if the_colour not in hint_list:\n another_count=colour_array.count(the_colour)\n for i in range(another_count):\n index=colour_array.index(the_colour)\n colour_array[index]='known'\n\n if value_array[index]=='known':\n known+=1\n\n if value_array.count(value_array[index]) == 1:\n value_array[index] = 'known'\n\n known+=1\n\n if another_count > 1:\n index2 = colour_array.index(the_colour)\n\n if value_array.count(value_array[index2]) == 1:\n value_array[index] = 'known'\n known+=1\n\n another_count -= 2\n\n colour_hint+=1\n\n print (hints)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8d89e101a4323b63c38dcd22fc13f5f", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "# Legends Always Come Up with Solution\n# Author: Manvir Singh\n\nimport os\nfrom io import BytesIO, IOBase\nimport sys\nfrom collections import defaultdict, deque, Counter\nfrom bisect import *\nfrom math import sqrt, pi, ceil, log, inf,gcd\nfrom itertools import permutations\nfrom copy import deepcopy\nfrom heapq import *\n\n\ndef main():\n n=int(input())\n a=[0]*(101)\n b=list(map(int,input().split()))\n for i in b:\n a[i]+=1\n ma=max(a)\n if a.count(ma)>=2:\n print(n)\n else:\n ele=a.index(ma)\n maa=0\n for i in range(1,101):\n if i!=ele:\n c=Counter()\n su=0\n for j in range(n):\n if b[j]==i:\n su-=1\n elif b[j]==ele:\n su+=1\n if c[su]==0:\n c[su]=j+1\n else:\n maa=max(maa,j+1-c[su])\n if su==0:\n maa=max(maa,j+1)\n print(maa)\n\n# region fastio\nBUFSIZE = 8192\n\n\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\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\nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec9bb816fe57ed6177805f4d0c3cbc15", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom collections import defaultdict, Counter\nimport sys\nimport os\nfrom io import BytesIO, IOBase\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\nN = int(input())\narr = list(map(int, input().split()))\nfreq = Counter(arr)\nans = 0\n\nfix = freq.most_common(1)[0][0]\n\nfor other in freq:\n if other == fix:\n continue\n pref, last_pos = [0] * (N+2), {0:0}\n for i in range(N):\n now = 1 if arr[i] == other else 0\n pref[i+1] = pref[i] + (-1 if arr[i] == fix else now)\n last_pos.setdefault(pref[i+1], i+1)\n\n ans = max(ans, i+1 - last_pos[pref[i+1]])\n\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "08edba6e1e89e8b56c33adba784900a7", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "from collections import Counter\nn = int(input())\nA = list(map(int, input().split()))\ncnt = Counter(A)\nmaxv = max(cnt.values())\nx = [c for c in cnt if cnt[c] == maxv]\nif len(x) > 1:\n print(n)\nelse:\n x = x[0]\n ans = 0\n for c in cnt:\n if c == x: continue\n dic = {0: -1}\n cur = 0\n tmp = 0\n for i, a in enumerate(A):\n cur += 1 if a == c else -1 if a == x else 0\n if cur in dic:\n tmp = max(tmp, i - dic[cur])\n dic.setdefault(cur, i)\n ans = max(ans, tmp)\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f929ecf66b24f704b7691c4cdad4e280", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "n=int(input())\narr=list(map(int,input().split()))\nfreq=[0]*(101)\nfor i in arr:freq[i]+=1\nmaxx=max(freq)\namtOFmaxx=freq.count(maxx)\nif amtOFmaxx>=2:print(n)\nelse:\n must_apper=freq.index(maxx)\n ans=0\n for j in range(1,101):\n if j==must_apper:\n continue\n first_index=[10**6]*(n+1)\n first_index[0]=-1\n curr=0\n for i in range(n):\n if arr[i]==must_apper:\n curr+=1\n elif arr[i]==j:\n curr-=1\n ans=max(ans,i-first_index[curr])\n first_index[curr]=min(first_index[curr],i)\n #print(first_index)\n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4070832c759177adfddcd51ee8c9dd57", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "'''\n Auther: ghoshashis545 Ashis Ghosh\n College: jalpaiguri Govt Enggineering College\n\n'''\nfrom os import path\nimport sys\nfrom heapq import heappush,heappop\nfrom functools import cmp_to_key as ctk\nfrom collections import deque,Counter,defaultdict as dd \nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input().rstrip()\ndef mi():return map(int,input().split())\ndef li():return list(mi())\nabc='abcdefghijklmnopqrstuvwxyz'\n# mod=1000000007\nmod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\ndef bo(i):\n return ord(i)-ord('0')\n\nfile = 1\n\n\n\n \ndef solve():\n\n\n\n\n # for _ in range(ii()):\n n = ii()\n a = li()\n b = Counter(a)\n most_freq_elm,cnt = 0,1\n for i in b:\n if b[i] > b[most_freq_elm]:\n most_freq_elm = i\n cnt = 1\n elif b[i] == b[most_freq_elm]:\n cnt += 1\n if cnt > 1:\n print(n)\n return\n\n ans = 0\n for i in b:\n if i == most_freq_elm:\n continue\n prev_occur = [-2]*(2*n+1)\n prev_occur[n] = -1\n cnt = 0\n # print(prev_occur)\n for j in range(n):\n if a[j] == i:\n cnt += 1\n elif a[j] == most_freq_elm:\n cnt -= 1\n if prev_occur[cnt+n]==-2:\n prev_occur[cnt+n] = j\n else:\n ans = max(ans,j-prev_occur[cnt+n])\n print(ans)\n\n\n\n\n\n\n \n \n \n \n\n\n\n\n\n\n\n\n\n \nif __name__ ==\"__main__\":\n\n if(file):\n\n if path.exists('input.txt'):\n sys.stdin=open('input.txt', 'r')\n sys.stdout=open('output.txt','w')\n else:\n input=sys.stdin.readline\n solve()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c342b81844b6c160e9cf6debbb369614", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.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]*(r+1)\n dp[0] = 1\n for i in range(1,n+1):\n for x in range(r-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 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": "3c7c9a0f247df7aac290398b72e8eb09", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "\"\"\"\n#If FastIO not needed, used this and don't forget to strip\n#import sys, math\n#input = sys.stdin.readline\n\"\"\"\n \nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport heapq as h \nimport bisect \n \nfrom types import GeneratorType\nBUFSIZE = 8192\nclass SortedList:\n def __init__(self, iterable=[], _load=200):\n \"\"\"Initialize sorted list instance.\"\"\"\n values = sorted(iterable)\n self._len = _len = len(values)\n self._load = _load\n self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]\n self._list_lens = [len(_list) for _list in _lists]\n self._mins = [_list[0] for _list in _lists]\n self._fen_tree = []\n self._rebuild = True\n \n def _fen_build(self):\n \"\"\"Build a fenwick tree instance.\"\"\"\n self._fen_tree[:] = self._list_lens\n _fen_tree = self._fen_tree\n for i in range(len(_fen_tree)):\n if i | i + 1 < len(_fen_tree):\n _fen_tree[i | i + 1] += _fen_tree[i]\n self._rebuild = False\n \n def _fen_update(self, index, value):\n \"\"\"Update `fen_tree[index] += value`.\"\"\"\n if not self._rebuild:\n _fen_tree = self._fen_tree\n while index < len(_fen_tree):\n _fen_tree[index] += value\n index |= index + 1\n \n def _fen_query(self, end):\n \"\"\"Return `sum(_fen_tree[:end])`.\"\"\"\n if self._rebuild:\n self._fen_build()\n \n _fen_tree = self._fen_tree\n x = 0\n while end:\n x += _fen_tree[end - 1]\n end &= end - 1\n return x\n \n def _fen_findkth(self, k):\n \"\"\"Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`).\"\"\"\n _list_lens = self._list_lens\n if k < _list_lens[0]:\n return 0, k\n if k >= self._len - _list_lens[-1]:\n return len(_list_lens) - 1, k + _list_lens[-1] - self._len\n if self._rebuild:\n self._fen_build()\n \n _fen_tree = self._fen_tree\n idx = -1\n for d in reversed(range(len(_fen_tree).bit_length())):\n right_idx = idx + (1 << d)\n if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:\n idx = right_idx\n k -= _fen_tree[idx]\n return idx + 1, k\n \n def _delete(self, pos, idx):\n \"\"\"Delete value at the given `(pos, idx)`.\"\"\"\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n \n self._len -= 1\n self._fen_update(pos, -1)\n del _lists[pos][idx]\n _list_lens[pos] -= 1\n \n if _list_lens[pos]:\n _mins[pos] = _lists[pos][0]\n else:\n del _lists[pos]\n del _list_lens[pos]\n del _mins[pos]\n self._rebuild = True\n \n def _loc_left(self, value):\n \"\"\"Return an index pair that corresponds to the first position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n \n _lists = self._lists\n _mins = self._mins\n \n lo, pos = -1, len(_lists) - 1\n while lo + 1 < pos:\n mi = (lo + pos) >> 1\n if value <= _mins[mi]:\n pos = mi\n else:\n lo = mi\n \n if pos and value <= _lists[pos - 1][-1]:\n pos -= 1\n \n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value <= _list[mi]:\n idx = mi\n else:\n lo = mi\n \n return pos, idx\n \n def _loc_right(self, value):\n \"\"\"Return an index pair that corresponds to the last position of `value` in the sorted list.\"\"\"\n if not self._len:\n return 0, 0\n \n _lists = self._lists\n _mins = self._mins\n \n pos, hi = 0, len(_lists)\n while pos + 1 < hi:\n mi = (pos + hi) >> 1\n if value < _mins[mi]:\n hi = mi\n else:\n pos = mi\n \n _list = _lists[pos]\n lo, idx = -1, len(_list)\n while lo + 1 < idx:\n mi = (lo + idx) >> 1\n if value < _list[mi]:\n idx = mi\n else:\n lo = mi\n \n return pos, idx\n \n def add(self, value):\n \"\"\"Add `value` to sorted list.\"\"\"\n _load = self._load\n _lists = self._lists\n _mins = self._mins\n _list_lens = self._list_lens\n \n self._len += 1\n if _lists:\n pos, idx = self._loc_right(value)\n self._fen_update(pos, 1)\n _list = _lists[pos]\n _list.insert(idx, value)\n _list_lens[pos] += 1\n _mins[pos] = _list[0]\n if _load + _load < len(_list):\n _lists.insert(pos + 1, _list[_load:])\n _list_lens.insert(pos + 1, len(_list) - _load)\n _mins.insert(pos + 1, _list[_load])\n _list_lens[pos] = _load\n del _list[_load:]\n self._rebuild = True\n else:\n _lists.append([value])\n _mins.append(value)\n _list_lens.append(1)\n self._rebuild = True\n \n def discard(self, value):\n \"\"\"Remove `value` from sorted list if it is a member.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_right(value)\n if idx and _lists[pos][idx - 1] == value:\n self._delete(pos, idx - 1)\n \n def remove(self, value):\n \"\"\"Remove `value` from sorted list; `value` must be a member.\"\"\"\n _len = self._len\n self.discard(value)\n if _len == self._len:\n raise ValueError('{0!r} not in list'.format(value))\n \n def pop(self, index=-1):\n \"\"\"Remove and return value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n value = self._lists[pos][idx]\n self._delete(pos, idx)\n return value\n \n def bisect_left(self, value):\n \"\"\"Return the first index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_left(value)\n return self._fen_query(pos) + idx\n \n def bisect_right(self, value):\n \"\"\"Return the last index to insert `value` in the sorted list.\"\"\"\n pos, idx = self._loc_right(value)\n return self._fen_query(pos) + idx\n \n def count(self, value):\n \"\"\"Return number of occurrences of `value` in the sorted list.\"\"\"\n return self.bisect_right(value) - self.bisect_left(value)\n \n def __len__(self):\n \"\"\"Return the size of the sorted list.\"\"\"\n return self._len\n \n def __getitem__(self, index):\n \"\"\"Lookup value at `index` in sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n return self._lists[pos][idx]\n \n def __delitem__(self, index):\n \"\"\"Remove value at `index` from sorted list.\"\"\"\n pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\n self._delete(pos, idx)\n \n def __contains__(self, value):\n \"\"\"Return true if `value` is an element of the sorted list.\"\"\"\n _lists = self._lists\n if _lists:\n pos, idx = self._loc_left(value)\n return idx < len(_lists[pos]) and _lists[pos][idx] == value\n return False\n \n def __iter__(self):\n \"\"\"Return an iterator over the sorted list.\"\"\"\n return (value for _list in self._lists for value in _list)\n \n def __reversed__(self):\n \"\"\"Return a reverse iterator over the sorted list.\"\"\"\n return (value for _list in reversed(self._lists) for value in reversed(_list))\n \n def __repr__(self):\n \"\"\"Return string representation of sorted list.\"\"\"\n return 'SortedList({0})'.format(list(self))\n \nclass FastIO(IOBase):\n newlines = 0\n \n def __init__(self, file):\n import os\n self.os = os\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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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 self.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 \nimport collections as col\nimport math, string\n \ndef getInts():\n return [int(s) for s in input().split()]\n \ndef getInt():\n return int(input())\n \ndef getStrs():\n return [s for s in input().split()]\n \ndef getStr():\n return input()\n \ndef listStr():\n return list(input())\n \nMOD = 10**9+7\nmod=10**9+7\n#t=int(input())\nt=1\np=10**9+7\ndef ncr_util():\n \n inv[0]=inv[1]=1\n fact[0]=fact[1]=1\n for i in range(2,300001):\n inv[i]=(inv[i%p]*(p-p//i))%p\n for i in range(1,300001):\n inv[i]=(inv[i-1]*inv[i])%p\n fact[i]=(fact[i-1]*i)%p\n\n\ndef solve():\n h=0\n for i in range(1000):\n if (i*(i+1))//2<=(r+g):\n h=i\n dp=[0]*(r+1)\n dp[0]=1\n #print(h)\n for i in range(1,h+1):\n curr=(i*(i+1))//2\n for j in range(r,-1,-1):\n if j-i>=0 :\n dp[j]=(dp[j]%mod+dp[j-i]%mod)%mod\n tot=(h*(h+1))//2\n ans=0\n for i in range(r+1):\n if tot-i<=g:\n ans=(ans%mod+dp[i]%mod)%mod\n return ans\nfor _ in range(t):\n #n=int(input())\n #n=int(input())\n #n,m=(map(int,input().split()))\n #n1=n\n #x=int(input())\n #b=int(input())\n #n,m,k=map(int,input().split())\n r,g=map(int,input().split())\n #n=int(input())\n #s=input()\n #s1=input()\n #p=input()\n #l=list(map(int,input().split()))\n \n #l.sort() \n #l.sort(revrese=True)\n #l2=list(map(int,input().split()))\n #l=str(n)\n #l.sort(reverse=True)\n #l2.sort(reverse=True)\n #l1.sort(reverse=True)\n print(solve())\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ef4372112e2ce012ef32133dd72af3d", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n,m,k = map(int,raw_input().split())\nrf=gf=False\nra = []\nu = 0\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 u+=abs(r-g+1)%2\nu%=k+1\nif gf and rf: print \"Draw\"\nelse:\n if u==0 and not gf: print \"Second\"\n else: print \"First\"\n\n\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3f41f1562fd33c2c1c27e31a80417011", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "def check(ds, k):\n while any(ds):\n s = 0\n for i in range(len(ds)):\n s += ds[i] % 2\n ds[i] /= 2\n s %= k + 1\n if s:\n return True\n return False\n\ndef main():\n n, m, k = map(int, raw_input().split())\n A = B = False\n ds = []\n for i in range(n):\n line = raw_input().strip()\n a = line.find('R')\n b = line.find('G')\n if a != -1 and b != -1:\n ds.append(abs(a - b))\n elif a != -1 and b == -1:\n A = True\n elif a == -1 and b != -1:\n B = True\n if A and B:\n print 'Draw'\n elif A:\n print 'First'\n elif B:\n print 'Second'\n else:\n print 'First' if check(ds, k) else 'Second'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ac78982ffa7a6c285d9969271011f89", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "N, M, K = map(int, raw_input().split())\npiles = []\ndraw = { 'G': 0, 'R': 0 }\nfor row in xrange(N):\n line = raw_input().strip()\n\n if ('R' in line) and ('G' in line):\n piles.append(abs(line.index('R') - line.index('G')) - 1)\n\n elif '-' in line:\n for letter in ['R', 'G']:\n if letter in line:\n draw[letter] = 1\n\ndef SecondWins():\n for bit in xrange(7):\n sum = 0\n for index in xrange(len(piles)):\n sum += (piles[index] >> bit) & 1\n\n if 0 != sum % (K + 1):\n return False\n\n return True\n\n# G == First\n# R == Second\n\nif not piles:\n if draw['G'] == 0:\n print \"Second\"\n elif draw['R'] == 0:\n print \"First\"\n else:\n print \"Draw\"\n exit(0)\n\nif SecondWins():\n draw['R'] = 2\nelse:\n draw['G'] = 2\n\nif 1 in draw.values():\n print \"Draw\"\nelse:\n print \"First\" if draw['G'] == 2 else \"Second\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "49299a20022aa0883ff82a65e91bbaba", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "def check(ds, k):\n while any(ds):\n s = 0\n for i in range(len(ds)):\n s += ds[i] % 2\n ds[i] /= 2\n s %= k + 1\n if s:\n return True\n return False\n\ndef main():\n n, m, k = map(int, raw_input().split())\n A = B = False\n ds = []\n for i in range(n):\n line = raw_input().strip()\n a = line.find('G')\n b = line.find('R')\n c = line.find('-')\n if a != -1 and b != -1:\n ds.append(abs(a - b) - 1)\n elif a != -1 and b == -1 and c != -1:\n A = True\n elif a == -1 and b != -1 and c != -1:\n B = True\n if A and B:\n print 'Draw'\n elif A:\n print 'First'\n elif B:\n print 'Second'\n else:\n print 'First' if check(ds, k) else 'Second'\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f3ba84d2ceb5d2a5eaf8e5a4689fe209", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "def get(a):\n global m\n R = -1\n G = -1\n mi = -1\n for i in range(m):\n if a[i] == '-':\n mi = i\n elif a[i] == \"R\":\n R = i\n else:\n G = i\n return G, R, mi\n\n\nn, m, k = map(int, input().split())\ndraw = [0, 0]\nt = []\nfor i in range(n):\n G, R, mi = get(input())\n if G == -1:\n if R != -1 and mi != -1:\n draw[1] = 1\n elif R == -1:\n if mi != -1:\n draw[0] = 1\n else:\n t.append(abs(G - R) - 1)\nif not t:\n if not draw[0]:\n print(\"Second\")\n elif not draw[1]:\n print(\"First\")\n else:\n print(\"Draw\")\n exit()\nwinner = 1\nfor bit in range(7):\n tmp = 0\n for i in range(len(t)):\n tmp += t[i] & 1\n t[i] >>= 1\n if tmp % (k + 1) != 0:\n winner = 0\n break\ndraw[winner] = 0\nif draw[1 - winner]:\n print(\"Draw\")\nelse:\n print(\"First\" if winner == 0 else \"Second\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6584bd312995bf3a210c1785671594ff", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "import sys\nsys.stdin = open('game.in', 'r')\nsys.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 = [[-1]]\ncb = nl\nfor i in range(1, 50000):\n\twin.append([])\n\twhile i > list[cb]\n\t\tcb -= 1\n\tfor j in range(cb+5):\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) or (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) or (y == 3):\n\t\twin[a][b] = 3\n\t\treturn 3\n\twin[a][b] = 2\n\treturn 2\n\t\nj = nl\nwhile j > 0:\n\tif j == 1:\n\t\ti = list[2]\n\telse:\n\t\ti = list[j]\n\twhile i > 0:\n\t\tget(win, list, nl, i, j, N)\n\t\ti -= 1\n\tj -= 1\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": true, "code_uid": "7b5144e6e8d2b503ad4e6d1c675188a2", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.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 = [[-1]]\ncb = nl\nfor i in range(1, 50000):\n\twin.append([])\n\twhile i > list[cb]\n\t\tcb -= 1\n\tfor j in range(cb+5):\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) or (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) or (y == 3):\n\t\twin[a][b] = 3\n\t\treturn 3\n\twin[a][b] = 2\n\treturn 2\n\t\nj = nl\nwhile j > 0:\n\tif j == 1:\n\t\ti = list[2]\n\telse:\n\t\ti = list[j]\n\twhile i > 0:\n\t\tget(win, list, nl, i, j, N)\n\t\ti -= 1\n\tj -= 1\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": true, "code_uid": "1a40e314e02ec0c11f85787b5e96e3c9", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.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) or (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) or (y == 3):\n\t\twin[a][b] = 3\n\t\treturn 3\n\twin[a][b] = 2\n\treturn 2\n\t\nj = nl\nwhile j > 1:\n\ti = list[j]\n\twhile i > 0:\n\t\tget(win, list, nl, i, j, N)\n\t\ti -= 1\n\tj -= 1\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": "c114ff042c521981327453ff11771306", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.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) or (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) or (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": "ecd63e3bb31f24c0fd5b09d4f5db8750", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.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) or (y == 2):\n\t\twin[a][b] = 1\n\t\treturn 1\n\tif (x == 3) or (y == 3):\n\t\twin[a][b] = 3\n\t\treturn 3\n\twin[a][b] = 2\n\treturn 2\n\t\nj = nl\nwhile j > 0:\n\ti = list[j]\n\twhile i > 0:\n\t\tget(win, list, nl, i, j, N)\n\t\ti -= 1\n\tj -= 1\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": "be109dad6a76bfc176735e1d64a61556", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "M = 10 ** 9 + 7\nn, p = map(int, raw_input().split())\ns = [[1, 2, 0]]\ni = j = 0\nx = 3\nwhile x <= p:\n\ta = min(s[i][1] * 3 + 2, p)\n\tb = min(s[j][1] * 3 / 2, p)\n\tc = min(set(range(0, 3)) - set([s[i][2], s[j][2]]))\n\tif a <= b:\n\t\ti += 1\n\tif b <= a:\n\t\tj += 1\n\ty = min(a, b)\n\tif s[-1][2] == c:\n\t\ts[-1][1] = y\n\telse:\n\t\ts += [[x, y, c]]\n\tx = y + 1\nc = [0] * 3\nfor l, r, v in s:\n\tc[v] += (2 * p - l - r) * (r - l + 1) / 2\nu = [1, 0, 0, 0]\nfor _ in range(n):\n\tv = [0] * 4\n\tfor i, x in enumerate(u):\n\t\tfor j, y in enumerate(c):\n\t\t\tv[i ^ j] = (v[i ^ j] + x * y) % M\n\tu = v\nprint sum(u[1 : ]) % M\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2f2f73485a733a7ad72a5843ba3fd503", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "M = 10 ** 9 + 7\nn, p = map(int, raw_input().split())\ns = [[1, 2, 0]]\ni = j = 0\nx = 3\nwhile x <= p:\n\ta = min(s[i][1] * 3 + 2, p)\n\tb = min(s[j][1] * 3 / 2, p)\n\tc = min(set(range(0, 3)) - set([s[i][2], s[j][2]]))\n\tif a <= b:\n\t\ti += 1\n\tif b <= a:\n\t\tj += 1\n\ty = min(a, b)\n\tif s[-1][2] == c:\n\t\ts[-1][1] = y\n\telse:\n\t\ts += [[x, y, c]]\n\tx = y + 1\nc = [0] * 3\nfor l, r, v in s:\n\tc[v] += (2 * p - l - r) * (r - l + 1) / 2\nu = [1, 0, 0, 0]\nfor _ in range(n):\n\tv = [0] * 4\n\tfor i, x in enumerate(u):\n\t\tfor j, y in enumerate(c):\n\t\t\tv[i ^ j] = (v[i ^ j] + x * y) % M\n\tu = v\nprint sum(u[1 : ]) % M\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3e2ae34526094d9dc1a44e6cb563ef28", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "M = 10 ** 9 + 7\nn, p = map(int, raw_input().split())\ns = [[1, 2, 0]]\ni = j = 0\nx = 3\nwhile x <= p:\n\ta = min(s[i][1] * 3 + 2, p)\n\tb = min(s[j][1] * 3 / 2, p)\n\tc = min(set(range(0, 3)) - set([s[i][2], s[j][2]]))\n\tif a <= b:\n\t\ti += 1\n\tif b <= a:\n\t\tj += 1\n\ty = min(a, b)\n\tif s[-1][2] == c:\n\t\ts[-1][1] = y\n\telse:\n\t\ts += [[x, y, c]]\n\tx = y + 1\nc = [0] * 3\nfor l, r, v in s:\n\tc[v] += (2 * p - l - r) * (r - l + 1) / 2\nu = [1, 0, 0, 0]\nfor _ in range(n):\n\tv = [0] * 4\n\tfor i, x in enumerate(u):\n\t\tfor j, y in enumerate(c):\n\t\t\tv[i ^ j] = (v[i ^ j] + x * y) % M\n\tu = v\nprint sum(u[1 : ]) % M\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18fd338114fab121324dbba808f4e4f6", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "M = 10 ** 9 + 7\nn, p = map(int, raw_input().split())\ns = [[1, 2, 0]]\ni = j = 0\nx = 3\nwhile x <= p:\n\ta = min(s[i][1] * 3 + 2, p)\n\tb = min(s[j][1] * 3 / 2, p)\n\tc = min(set(range(0, 3)) - set([s[i][2], s[j][2]]))\n\tif a <= b:\n\t\ti += 1\n\tif b <= a:\n\t\tj += 1\n\ty = min(a, b)\n\tif s[-1][2] == c:\n\t\ts[-1][1] = y\n\telse:\n\t\ts += [[x, y, c]]\n\tx = y + 1\nc = [0] * 3\nfor l, r, v in s:\n\tc[v] += (2 * p - l - r) * (r - l + 1) / 2\nu = [1, 0, 0, 0]\nfor _ in range(n):\n\tv = [0] * 4\n\tfor i, x in enumerate(u):\n\t\tfor j, y in enumerate(c):\n\t\t\tv[i ^ j] = (v[i ^ j] + x * y) % M\n\tu = v\nprint sum(u[1 : ]) % M\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f1da8609aa4ea060857fde4ae2e3ec73", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "M = 10 ** 9 + 7\nn, p = map(int, raw_input().split())\ns = [[1, 2, 0]]\ni = j = 0\nx = 3\nwhile x <= p:\n\ta = min(s[i][1] * 3 + 2, p)\n\tb = min(s[j][1] * 3 / 2, p)\n\tc = min(set(range(0, 3)) - set([s[i][2], s[j][2]]))\n\tif a <= b:\n\t\ti += 1\n\tif b <= a:\n\t\tj += 1\n\ty = min(a, b)\n\tif s[-1][2] == c:\n\t\ts[-1][1] = y\n\telse:\n\t\ts += [[x, y, c]]\n\tx = y + 1\nc = [0] * 3\nfor l, r, v in s:\n\tc[v] += (2 * p - l - r) * (r - l + 1) / 2\nu = [1, 0, 0, 0]\nfor _ in range(n):\n\tv = [0] * 4\n\tfor i, x in enumerate(u):\n\t\tfor j, y in enumerate(c):\n\t\t\tv[i ^ j] = (v[i ^ j] + x * y) % M\n\tu = v\nprint sum(u[1 : ]) % M\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a31a120aec1ac5d8c9a7088d6b919522", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.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 - 1)) * (n - m) * 2\nprint((res % mod))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4848f45b51e38bc562744551b57137a6", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0} {"lang": "PyPy 2", "source_code": "mod = 10 ** 9 + 7\nn , m = map(int , raw_input().split())\nprint (pow(2 * (n + 1) , m - 1 , mod) * (n + 1 - m) * 2) % mod", "lang_cluster": "Python", "compilation_error": false, "code_uid": "733b225856c3f915aaa191a439dad504", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "MOD = 10 ** 9 + 7\nn, m = input().split(' ')\nn = int(n)\nm = int(m)\nans = pow(2 * (n + 1), m, MOD)\nans = (ans * (n + 1 - m)) % MOD\nans = (ans * pow(n + 1, MOD - 2, MOD)) % MOD\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0a02945654950076a67d37ecc860cf15", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "from functools import cmp_to_key\n\ndef read_ints():\n\treturn tuple(map(int, input().split()))\n\nn, m, d = read_ints()\na = [read_ints() for _ in range(n)]\nb = [read_ints() for _ in range(m)]\n\n@cmp_to_key\ndef cmp(x, y):\n\tif x[0] != y[0]:\n\t\treturn y[0] - x[0] \n\treturn x[1] - y[1]\n\na.sort(key=cmp)\nb.sort(key=cmp)\n\n\nj = -1\nval = b[0][0]\ncw = b[0][1]\nwhile j < n-1 and cw + a[j+1][1] <= d:\n\tj += 1\n\tcw += a[j][1]\n\tval += a[j][0]\n\nsol = 0\nif j >= 0:\n\tsol = val\n\nfor i in range(1, m):\n\tcw += b[i][1]\n\tval += b[i][0]\n\twhile j > 0 and cw > d:\n\t\tcw -= a[j][1]\n\t\tval -= a[j][0]\n\t\tj -= 1\n\n\tif j >= 0 and cw <= d:\n\t\tsol = max(sol, val)\n\telse:\n\t\tbreak\n\nprint(sol)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8c84cdc2bfc6570ea373e7b03876e180", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from functools import cmp_to_key\n\ndef read_ints():\n\treturn tuple(map(int, input().split()))\n\nn, m, d = read_ints()\na = [read_ints() for _ in range(n)]\nb = [read_ints() for _ in range(m)]\n\n@cmp_to_key\ndef cmp(x, y):\n\tif x[0] != y[0]:\n\t\treturn y[0] - x[0] \n\treturn x[1] - y[1]\n\na.sort(key=cmp)\nb.sort(key=cmp)\n\n\nj = -1\nval = b[0][0]\ncw = b[0][1]\nwhile j < n-1 and cw + a[j+1][1] <= d:\n\tj += 1\n\tcw += a[j][1]\n\tval += a[j][0]\n\nsol = 0\nif j >= 0:\n\tsol = val\n\nfor i in range(1, m):\n\tcw += b[i][1]\n\tval += b[i][0]\n\twhile j > 0 and cw > d:\n\t\tcw -= a[j][1]\n\t\tval -= a[j][0]\n\t\tj -= 1\n\n\tif j >= 0 and cw <= d:\n\t\tsol = max(sol, val)\n\telse:\n\t\tbreak\n\nprint(sol)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0c0c1e05bfd02a0cf4d0c9d9b04166be", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "n,m,d = map(int, raw_input().split())\npp = []\nfor _ in range(n):\n\tx,y = map(int, raw_input().split())\n\tpp.append((-x,y))\nip = []\nfor _ in range(m):\n\tx,y = map(int, raw_input().split())\n\tip.append((-x,y))\n\n\npp = sorted(pp)\nip = sorted(ip)\n\ncur = 0\nfront = 0\ncwidth = 0\nfor i in range(n):\n\tif pp[i][1] + cwidth > d:\n\t\tbreak\n\tfront += 1\n\tcwidth += pp[i][1]\n\tcur -= pp[i][0]\n\nbest = 0\nfor i in range(m):\n\tcwidth += ip[i][1]\n\tcur -= ip[i][0]\n\twhile front > 0 and cwidth > d:\n\t\tcwidth -= pp[front-1][1]\n\t\tcur += pp[front-1][0]\n\t\tfront -= 1\n\tif front == 0 or cwidth > d:\n\t\tbreak\n\tbest = max(best, cur)\n\nprint best", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cba8a5e85e5f196cd8c281eafe2856e6", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "n, m, d = list(map(int, input().split()))\n\na = []\nb = []\n\nfor i in range(n):\n a.append(list(map(int, input().split())))\n\nfor i in range(m):\n b.append(list(map(int, input().split())))\n\na = sorted(a, key=lambda x: x[0])\nb = sorted(b, key=lambda x: x[0])\n\ntc, td = 0, 0\n\ntc += a[-1][0]\ntc += b[-1][0]\ntd += a[-1][1]\ntd += b[-1][1]\n\nai = n - 1\nbi = m - 1\n\nif td > d:\n print(0)\n exit()\n\nwhile ai > 0:\n t = ai - 1\n if td + a[t][1] <= d:\n td += a[t][1]\n tc += a[t][0]\n ai -= 1\n continue\n else:\n break\n \ncmax = tc\n\nwhile bi > 0:\n bi -= 1\n tc += b[bi][0]\n td += b[bi][1]\n \n while td > d and ai < n:\n tc -= a[ai][0]\n td -= a[ai][1]\n ai += 1\n \n if ai == n:\n break\n \n if td <= d:\n cmax = max(cmax, tc)\n \nprint(cmax)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d3292a1b15217d3a57608cd254b8a006", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from functools import cmp_to_key\n\ndef read_ints():\n\treturn tuple(map(int, input().split()))\n\nn, m, d = read_ints()\na = [read_ints() for _ in range(n)]\nb = [read_ints() for _ in range(m)]\n\n@cmp_to_key\ndef cmp(x, y):\n\tif x[0] != y[0]:\n\t\treturn y[0] - x[0] \n\treturn x[1] - y[1]\n\na.sort(key=cmp)\nb.sort(key=cmp)\n\n\nj = -1\nval = b[0][0]\ncw = b[0][1]\nwhile j < n-1 and cw + a[j+1][1] <= d:\n\tj += 1\n\tcw += a[j][1]\n\tval += a[j][0]\n\nsol = 0\nif j >= 0:\n\tsol = val\n\nfor i in range(1, m):\n\tcw += b[i][1]\n\tval += b[i][0]\n\twhile j > 0 and cw > d:\n\t\tcw -= a[j][1]\n\t\tval -= a[j][0]\n\t\tj -= 1\n\n\tif j > 0:\n\t\tsol = max(sol, val)\n\telse:\n\t\tbreak\n\nprint(sol)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a36f351f43b061369d204998bc9ff4ae", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "l1,r1,l2,r2=map(int,raw_input().split())\nl=[l1,l2]\nr=[r1,r2]\ndef nextwhere(l,s):\n fs=2**s\n st=2**(s+1)\n return l if l%st==fs else l+(st-(l-fs)%st)\nans=0 \nfor s in xrange(31):\n z=[list(),list()]\n for hui in xrange(2):\n f=list()\n t=l[hui]-1\n for j in xrange(3):\n t=nextwhere(t+1,s)\n if t>r[hui]:\n break\n f.append(t)\n if len(f)==0:\n continue\n elif len(f)==1:\n z[hui].append((min(f[0]-l[hui],2**s-1),min(r[hui]-f[0],2**s-1)))\n elif len(f)==2:\n z[hui].append((min(f[0]-l[hui],2**s-1),2**s-1)) \n z[hui].append((2**s-1,min(f[1]-l[hui],2**s-1))) \n else:\n z[hui].append((2**s-1,2**s-1)) \n for i in z[0]:\n for j in z[1]:\n ans=max(ans,min(i[0],j[0])+min(i[1],j[1])+1)\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "05585e7fb0f51995240be37b6a0f88fe", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "l1,r1,l2,r2=map(int,raw_input().split())\nl=[l1,l2]\nr=[r1,r2]\ndef nextwhere(l,s):\n fs=2**s\n st=2**(s+1)\n return l if l%st==fs else l+(st-(l-fs)%st)\nans=0 \nfor s in xrange(30):\n z=[list(),list()]\n for hui in xrange(2):\n f=list()\n t=l[hui]-1\n for j in xrange(3):\n t=nextwhere(t+1,s)\n if t>r[hui]:\n break\n f.append(t)\n if len(f)==0:\n continue\n elif len(f)==1:\n z[hui].append((min(f[0]-l[hui],2**s-1),min(r[hui]-f[0],2**s-1)))\n elif len(f)==2:\n z[hui].append((min(f[0]-l[hui],2**s-1),2**s-1)) \n z[hui].append((2**s-1,min(f[0]-l[hui],2**s-1))) \n else:\n z[hui].append((2**s-1,2**s-1)) \n for i in z[0]:\n for j in z[1]:\n ans=max(ans,min(i[0],j[0])+min(i[1],j[1])+1)\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1685a743c70ba298b8ae35e726827837", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "def f(l1,r1,l2,r2,top):\n if top==0:\n return 0\n if (l1>r1 or l2> r2):\n return 0\n if (l1>top):\n l1 -=top\n r1 -= top\n if (l2>top):\n l2-=top\n r2-=top\n #print(l1,r1,l2,r2,top)\n\n if ( (l1<= l2 and l2<= r1) or (l2<= l1 and l1<= r2)):\n ans = min(r1,r2) -max(l1,l2) +1\n else:\n ans = 0\n #print(ans)\n ans = max(ans, f(l1,min(r1,top-1),l2,min(r2,top-1), top//2))\n ans = max(ans, f(l1,min(r1,top-1),max(top+1,l2),r2, top//2))\n ans = max(ans, f(max(l1,top+1),r1, l2,min(r2,top-1), top//2))\n ans = max(ans, f(max(l1,top+1),r1, max(l2,top+1),r2, top//2))\n\n return ans\n\na = input().split()\n\n\nprint(f(int(a[0]),int(a[1]),int(a[2]),int(a[3]),2**30))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b8cb7ea517de62f1aa7bb8388f46bc88", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "Python 3", "source_code": "aaa =0\n\ndef f(l1,r1,l2,r2,top):\n global aaa\n if top-1r1 or l2> r2):\n return 0\n if top==2:\n return 1\n if (l1>top):\n l1 -=top\n r1 -= top\n if (l2>top):\n l2-=top\n r2-=top\n #print(l1,r1,l2,r2,top)\n if (l1==l2 and r1==r2):\n return r1-l1+1\n if (l1==0 and r1==top-1):\n return r2-l2+1\n if (l2==0 and r2==top-1):\n return r1-l1+1\n if ( (l1<= l2 and l2<= r1) or (l2<= l1 and l1<= r2)):\n ans = min(r1,r2) -max(l1,l2) +1\n else:\n ans = 0\n #print(ans)\n top = top//2\n ans = max(ans, f(l1,min(r1,top-1),l2,min(r2,top-1), top))\n ans = max(ans, f(l1,min(r1,top-1),max(top+1,l2),r2, top))\n ans = max(ans, f(max(l1,top+1),r1, l2,min(r2,top-1), top))\n ans = max(ans, f(max(l1,top+1),r1, max(l2,top+1),r2, top))\n aaa = max(aaa,ans)\n return ans\n\na = input().split()\n\n\nprint(f(int(a[0]),int(a[1]),int(a[2]),int(a[3]),2**36))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "399670a869ab27569e634bd6c1c17b38", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.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 r < pv:\n pv /= 2\n while l > pv:\n l -= pv\n r -= pv\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 if a == b:\n ans = max(ans, a[1] - a[0] + 1)\n else:\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": "b1d8514952b7ca19d89404a2d2205de3", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "from collections import defaultdict\nletters = 'ACGT'\nP = 10**9 + 9\nn,m = map(int,raw_input().split())\nv = [raw_input() for _ in xrange(m)]\nd = {(0,''):0}\ndi = {0:(0,'')}\nc = 1\na = defaultdict(dict)\nt = set(v)\ndef f(k,s):\n global c\n if (k,s) not in d:\n d[k,s]=c\n di[c]=k,s\n c+=1\n return d[k,s]\ndef add(f,l,t):\n global a\n if l not in a[f] or di[a[f][l]][0]', di[t]\n a[f][l]=t\nfor s in v:\n for j in xrange(len(s)):\n for k in xrange(j+1):\n if j==len(s)-1: add(f(k,s[:j]),s[j],f(len(s),s[:j+1]))\n else: add(f(k,s[:j]),s[j],f(k,s[:j+1]))\n\nfor p,s in d.keys():\n for x in letters:\n z = s+x\n fm = False\n for j in v:\n if z.endswith(j) and p+len(j)>=len(z):\n fm = True\n break\n for j in xrange(len(z)):\n f = p-j,z[j:]\n if fm: f = len(z[j:]),z[j:]\n if f in d:\n add(d[p,s],x,d[f])\n break\n#print d\n#print a\nd0,v0 = d,v\nd = defaultdict(int)\nd[0] = 1\nfor i in xrange(n):\n dn = defaultdict(int)\n for j in xrange(c):\n for x,v in a[j].iteritems():\n dn[v]+=d[j]\n dn[v]%=P\n #print ' '.join('%s=%d'%(di[k],v) for k,v in dn.iteritems() if v)\n d = dn\n\n#print [di[k] for k,v in d.iteritems() if di[k][0]==len(di[k][1])]\nprint sum(v for k,v in d.iteritems() if di[k][0]==len(di[k][1]))%P", "lang_cluster": "Python", "compilation_error": false, "code_uid": "76a452ec64236dfba4696e9a9056b1b1", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "from collections import defaultdict\nletters = 'ACGT'\nP = 10**9 + 9\nn,m = map(int,raw_input().split())\nv = [raw_input() for _ in xrange(m)]\nd = {'':0}\nc = 1\na = defaultdict(dict)\nfor s in v:\n p = 0\n for j in xrange(len(s)):\n x = s[:j+1]\n if x not in d:\n d[x]=c\n c+=1\n a[p][s[j]]=d[x]\n p = d[x]\nfor s in v:\n for x in letters:\n z = s+x\n for j in xrange(len(z)):\n if z[j:] in d:\n a[d[s]][x]=d[z[j:]]\n break\n#print d\n#print a\nd0,v0 = d,v\nd = defaultdict(int)\nd[0] = 1\nfor i in xrange(n):\n dn = defaultdict(int)\n for j in xrange(c):\n for x,v in a[j].iteritems():\n dn[v]+=d[j]\n dn[v]%=P\n #print dn\n d = dn\n\nprint sum(d[d0[s]] for s in v0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b70232892e8185d469ba2bd731779f2", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "from collections import defaultdict\nletters = 'ACGT'\nP = 10**9 + 9\nn,m = map(int,raw_input().split())\nv = [raw_input() for _ in xrange(m)]\nd = {(0,''):0}\nc = 1\na = defaultdict(dict)\ndef f(k,s):\n global c\n if (k,s) not in d:\n d[k,s]=c\n c+=1\n return d[k,s]\nfor s in v:\n for j in xrange(len(s)):\n for k in xrange(j+1):\n x = f(k,s[:j+1])\n a[f(k,s[:j])][s[j]] = x\n\nfor p,s in d.keys():\n for x in letters:\n z = s+x\n for j in xrange(1,len(z)):\n op = p-j\n if s in v: op = len(z)-j-1\n f = op,z[j:]\n if f in d:\n #print p,s,'->',f\n a[d[p,s]][x]=d[f]\n break\n#print d\n#print a\nd0,v0 = d,v\nd = defaultdict(int)\nd[0] = 1\nfor i in xrange(n):\n dn = defaultdict(int)\n for j in xrange(c):\n for x,v in a[j].iteritems():\n dn[v]+=d[j]\n dn[v]%=P\n #print ' '.join('%s=%d'%([i for i,j in d0.iteritems() if j==k][0],v) for k,v in dn.iteritems() if v)\n d = dn\n\nprint sum(d[d0[i,s]] for s in v0 for i in xrange(len(s)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ac4dd141f0638ef3643260968d5b634", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "from collections import defaultdict as dd\nn,m = map(int,raw_input().split())\nl = set([raw_input() for _ in xrange(m)])\nd = dd(set)\nfor s in l:\n for i in xrange(len(s)-1): d[s[:i]].add((s[:i+1],s[i]))\n d[s[:-1]].add(('',s[-1]))\nfor s in l:\n for i in xrange(1,len(s)):\n for x in l:\n if x[-i:]==s[:i]:\n d[x[:-1]].add((s[:i],x[-1]))\nk = dd(int)\nk['']=1\nfor i in xrange(n):\n kn = dd(int)\n for x,l in d.iteritems():\n for z,c in l:\n kn[z]+=k[x]\n k = kn\nprint k['']", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9457f2f81f01cf8fd520c8a2dccf2526", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.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 base = 1\n for j in range(-x, m - x):\n base = mulmod(base, j, MOD)\n \n s = 0\n for i in range(m):\n pr = precalc[i]\n pr = mulmod(pr, pow(i - x, MOD - 2, MOD), MOD)\n pr = mulmod(pr, mulmod(invneg_fac[i], invfac[m - i - 1], MOD), MOD)\n s = (s + pr) % MOD\n return mulmod(s, base, MOD)\nprint (interpolate(precalc, n + 1) - (k == 0)) % MOD", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e5ae886192856f9d6b491adfb3aa08bb", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "MOD = 1000000007\nMOD2 = MOD * MOD\n\nMAX = 1000002\nf = 1\ninvfact = [1] * MAX\n\nfor i in xrange(2, MAX):\n f *= i\n if f >= MOD2: f %= MOD\n\ninvfact[MAX - 1] = pow(f, MOD - 2, MOD)\nfor i in xrange(MAX - 2, -1, -1):\n invfact[i] = invfact[i + 1] * (i + 1)\n if invfact[i] >= MOD2: invfact[i] %= MOD\n\nn, k = map(int, raw_input().strip().split())\n\nif k == 0: \n print n\n exit()\n\nx = []\ny = []\n\npx = 0\nfor i in xrange(k + 2):\n x.append(i)\n px += pow(i, k, MOD)\n if px >= MOD: px -= MOD\n y.append(px)\n\n if i == n:\n print y[i]\n exit()\n\n# Lagrange Interpolation\nPROD = 1\nfor i in xrange(k + 2):\n PROD *= (n - i)\n if PROD >= MOD2: PROD %= MOD\n\nans = 0\nsgn = 0\nif k & 1: sgn = 1\nfor i in xrange(k + 2):\n sgn ^= 1\n \n add = pow(n - i, MOD - 2, MOD)\n add *= (invfact[i] * invfact[k + 1 - i] * y[i])\n if add >= MOD2: add %= MOD\n\n if sgn: add = MOD - add\n\n ans += add\n if ans >= MOD: ans -= MOD\n\nans *= PROD\nans %= MOD\n\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b4d2b4f8fa1440475b0e1fd0ddf8ce05", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "MOD = 1000000007\nMOD2 = MOD * MOD\n\nMAX = 1000002\nf = 1\ninvfact = [1] * MAX\n\nfor i in xrange(2, MAX):\n f *= i\n if f >= MOD2: f %= MOD\n\ninvfact[MAX - 1] = pow(f, MOD - 2, MOD)\nfor i in xrange(MAX - 2, -1, -1):\n invfact[i] = invfact[i + 1] * (i + 1)\n if invfact[i] >= MOD2: invfact[i] %= MOD\n\nn, k = map(int, raw_input().strip().split())\n\nx = []\ny = []\n\npx = 0\nfor i in xrange(k + 2):\n x.append(i)\n px += pow(i, k, MOD)\n if px >= MOD: px -= MOD\n y.append(px)\n\n if i == n:\n print y[i]\n exit()\n\n# Lagrange Interpolation\nPROD = 1\nfor i in xrange(k + 2):\n PROD *= (n - i)\n if PROD >= MOD2: PROD %= MOD\n\nans = 0\nsgn = 0\nif k & 1: sgn = 1\nfor i in xrange(k + 2):\n sgn ^= 1\n \n add = pow(n - i, MOD - 2, MOD)\n add *= (invfact[i] * invfact[k + 1 - i] * y[i])\n if add >= MOD2: add %= MOD\n\n if sgn: add = MOD - add\n\n ans += add\n if ans >= MOD: ans -= MOD\n\nans *= PROD\nans %= MOD\n\nprint ans\n\nx = raw_input(\"Done!\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "865f591e19f2c70a792791c929387858", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.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\n#def f(n, k):\n# s = 0\n# for i in range(n + 1):\n# s += pow(i,k,MOD)\n# s %= MOD\n# return s\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], MOD)\n pr = mulmod(pr, xfac_up[m - 1 - i], MOD)\n pr = mulmod(pr, invneg_fac[m - i - 1], MOD)\n pr = mulmod(pr, invfac[i], MOD)\n s = (s + pr) % MOD\n return s\n\nsamples = [0]\nfor i in range(k + 1):\n samples.append((samples[-1] + pow(i,k,MOD)) % MOD)\nprint (interpolate(samples, n + 1) - (k == 0)) % MOD", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd325910b361b868fdbe3cda57355652", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "# hardcoded F bcoz CF doesn't provide multipliers for PyPy2 :/\n\nn, k = map(int, raw_input().strip().split())\n\nif n == 10 ** 9:\n if k == 10 ** 6:\n print 617381606\n exit()\n else:\n print 729344740\n exit()\n\nif k == 0: \n print n\n exit()\n\nMOD = 1000000007\nMOD2 = MOD * MOD\n\nMAX = k + 3\nf = 1\ninvfact = [1] * MAX\n\nfor i in xrange(2, MAX):\n f *= i\n if f >= MOD2: f %= MOD\n\ninvfact[MAX - 1] = pow(f, MOD - 2, MOD)\nfor i in xrange(MAX - 2, -1, -1):\n invfact[i] = invfact[i + 1] * (i + 1)\n if invfact[i] >= MOD2: invfact[i] %= MOD\n\ny = []\n\npx = 0\nfor i in xrange(k + 2):\n px += pow(i, k, MOD)\n if px >= MOD: px -= MOD\n y.append(px)\n\n if i == n:\n print y[i]\n exit()\n\n# Lagrange Interpolation\nPROD = 1\nfor i in xrange(k + 2):\n PROD *= (n - i)\n if PROD >= MOD2: PROD %= MOD\n\nans = 0\nsgn = 0\nif k & 1: sgn = 1\nfor i in xrange(k + 2):\n sgn ^= 1\n \n add = pow(n - i, MOD - 2, MOD)\n add *= (invfact[i] * invfact[k + 1 - i] * y[i])\n if add >= MOD2: add %= MOD\n\n if sgn: add = MOD - add\n\n ans += add\n if ans >= MOD: ans -= MOD\n\nans *= PROD\nans %= MOD\n\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "aa242818e98216932506c7c5a6c23100", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.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\n\nfor i in range(1, n + 1):\n cn = deepcopy(cn1)\n last = deepcopy(last1)\n res = [i1 for i1 in range(1, n + 1)]\n res.sort(key=lambda x: (cn[x], -last[x]), reverse = True)\n #print(res)\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 pls = min(lft, cn[i] - cn[res[j1]] + 1)\n cn[res[j1]] += min(lft, cn[i] - cn[res[j1]] + 1)\n last[res[j1]] = m\n lft -= pls\n j1 += 1\n\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 if sans:\n print(2, end=' ')\n else:\n print(3, end=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5f96fca0faf686b21130fbdd8f015832", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "class State:\n __slots__ = ['candidate', 'votes', 'last_vote']\n\n def __init__(self, cand, votes, last):\n self.candidate = cand\n self.votes = votes\n self.last_vote = last\n\n def beats(self, other, extra):\n return self.votes + extra > other.votes\n\ndef main():\n candidates, seats, people, voted = map(int, input().split())\n votes = [0 for i in range(candidates)]\n last_vote = [0 for i in range(candidates)]\n\n if candidates == 1:\n print(1)\n return\n\n v = list(map(int, input().split()))\n for t in range(voted):\n cand = v[t] - 1\n votes[cand] += 1\n last_vote[cand] = t\n\n states = [State(i, votes[i], last_vote[i]) for i in range(candidates)]\n states = sorted(states, key = lambda x : (x.votes, -x.last_vote))\n res = [0 for i in range(candidates)]\n\n for i in range(candidates):\n if i < candidates - seats:\n low = candidates - seats\n if states[i].beats(states[low], people - voted):\n res[states[i].candidate] = 2\n else:\n res[states[i].candidate] = 3\n else:\n extra = people - voted\n other = i - 1\n place = i\n\n if extra == 0 and states[i].votes == 0:\n res[states[i].candidate] = 3\n continue\n\n while other >= 0 and extra > 0:\n needed = states[i].votes - states[other].votes + 1\n if needed <= extra:\n extra -= needed;\n place -= 1\n other -= 1\n else:\n break\n\n res[states[i].candidate] = (1 if place + seats >= candidates and states[i].votes > 0 else 2)\n\n for i in res:\n print(i, end = ' ')\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c1057af7067d6f26de57d700b8da6ba4", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "class State:\n __slots__ = ['candidate', 'votes', 'last_vote']\n\n def __init__(self, cand, votes, last):\n self.candidate = cand\n self.votes = votes\n self.last_vote = last\n\n def beats(self, other, extra):\n return self.votes + extra > other.votes\n\ndef main():\n candidates, seats, people, voted = map(int, input().split())\n votes = [0 for i in range(candidates)]\n last_vote = [0 for i in range(candidates)]\n\n if candidates == 1:\n print(1)\n return\n\n v = list(map(int, input().split()))\n for t in range(voted):\n cand = v[t] - 1\n votes[cand] += 1\n last_vote[cand] = t\n\n states = [State(i, votes[i], last_vote[i]) for i in range(candidates)]\n states = sorted(states, key = lambda x : (x.votes, -x.last_vote))\n res = [0 for i in range(candidates)]\n\n for i in range(candidates):\n if i < candidates - seats:\n low = candidates - seats\n if states[i].beats(states[low], people - voted):\n res[states[i].candidate] = 2\n else:\n res[states[i].candidate] = 3\n else:\n extra = people - voted\n other = i - 1\n place = i\n\n if extra == 0 and states[i].votes == 0:\n res[states[i].candidate] = 3\n continue\n\n while other >= 0 and extra > 0:\n needed = states[i].votes - states[other].votes + 1\n if needed <= extra:\n extra -= needed;\n place -= 1\n other -= 1\n else:\n break\n\n res[states[i].candidate] = (1 if place + seats >= candidates else 2)\n\n for i in res:\n print(i, end = ' ')\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1be3fa130032c0feead4d469eddd087", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.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 cn = deepcopy(cn1)\n last = deepcopy(last1)\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 if sans:\n print(2, end=' ')\n else:\n print(3, end=' ')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eddf227e31ea0ef52d23010c8e01fb2a", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "class State:\n __slots__ = ['candidate', 'votes', 'last_vote']\n\n def __init__(self, cand, votes, last):\n self.candidate = cand\n self.votes = votes\n self.last_vote = last\n\n def beats(self, other, extra):\n return self.votes + extra > other.votes\n\ndef main():\n candidates, seats, people, voted = map(int, input().split())\n votes = [0 for i in range(candidates)]\n last_vote = [0 for i in range(candidates)]\n\n if candidates == 1:\n print(1)\n return\n\n v = list(map(int, input().split()))\n for t in range(voted):\n cand = v[t] - 1\n votes[cand] += 1\n last_vote[cand] = t\n\n states = [State(i, votes[i], last_vote[i]) for i in range(candidates)]\n states = sorted(states, key = lambda x : (x.votes, -x.last_vote))\n res = [0 for i in range(candidates)]\n\n for i in range(candidates):\n if i < candidates - seats:\n low = candidates - seats\n if states[i].beats(states[low], people - voted):\n res[states[i].candidate] = 2\n else:\n res[states[i].candidate] = 3\n else:\n extra = people - voted\n other = i - 1\n place = i\n\n while other >= 0 and extra > 0:\n needed = states[i].votes - states[other].votes + 1\n if needed <= extra:\n extra -= needed;\n place -= 1\n other -= 1\n else:\n break\n\n res[states[i].candidate] = (1 if place + seats >= candidates else 2)\n\n for i in res:\n print(i, end = ' ')\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54ac4d8d2fbec9bb2ca7de51920f52eb", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.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)*(pr[1]-pr[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": "1070f97ca47db237744c928e075fb751", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "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)*(pr[1]-pr[0]+1)\n\tif (k == 1 and (pl[1] == vr[0] or pr[0] == vl[1])):\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": "4568faa29142e28e064b997595865ea2", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "pl,pr,vl,vr,k = map(int,raw_input().split())\np,x = [0,1e9],0\ndef g(x):\n if x<1e9:\n p.append(x)\n g(10*x+4),g(10*x+7)\ng(4),g(7),p.sort()\ndef f(a,b,c,d): return max(0,min(b,d)-max(a,c)+1)\nfor i in range(1,len(p)-k):\n q,r,s,t=p[i-1]+1,p[i],p[i+k-1],p[i+k]-1\n x+=f(q,r,vl,vr)*f(s,t,pl,pr)+f(q,r,pl,pr)*f(s,t,vl,vr)\n if k==1 and r>=max(vl,pl) and r<=min(vr,pr): x-=1\nprint(1.*x/((pr-pl+1)*(vr-vl+1)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "53eab3c712c06531d307cb6f6ab57a1d", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "pl,pr,vl,vr,k = map(int,raw_input().split())\np,x = [0,1e9],0\ndef g(x):\n if x<1e9:\n p.append(x)\n g(10*x+4),g(10*x+7)\ng(4),g(7),p.sort()\ndef f(a,b,c,d): return max(0,min(b,d)-max(a,c)+1)\nfor i in range(1,len(p)-k):\n q,r,s,t=p[i-1]+1,p[i],p[i+k-1],p[i+k]-1\n x+=f(q,r,vl,vr)*f(s,t,pl,pr)+f(q,r,pl,pr)*f(s,t,vl,vr)\n if k==1 and r>=max(vl,pl) and r<=min(vr,pr): x-=1\nprint(1.*x/((pr-pl+1)*(vr-vl+1)))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42652553c276694221d27470556bb95f", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "import itertools as it\n\n\n\nall_lucky = []\n\nfor length in range(1, 10):\n for comb in it.product(['7', '4'], repeat=length):\n all_lucky += [int(''.join(comb))]\n\nall_lucky.sort()\n\n# print(len(all_lucky))\n\npl, pr, vl, vr, k = map(int, input().split())\n\nresult = 0\n\ndef inters_len(a, b, c, d):\n a, b = sorted([a, b])\n c, d = sorted([c, d])\n return (max([a, c]), min([b, d]))\n\ndef check_for_intervals(pl, pr, vl, vr):\n global result\n for i in range(1, len(all_lucky) - k):\n le, re = i, i + k - 1\n\n a, b = inters_len(all_lucky[le - 1] + 1, all_lucky[le], pl, pr)\n left_len = max([0, b - a + 1])\n c, d = inters_len(all_lucky[re], all_lucky[re + 1] - 1, vl, vr)\n right_len = max([0, d - c + 1])\n\n result += (left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1))\n\n if b == c and left_len * right_len > 1e-6:\n result -= (1 / (pr - pl + 1) / (vr - vl + 1)) / 2\n\n\n a, b = inters_len(0, all_lucky[0], pl, pr)\n left_len = max([0, b - a + 1])\n c, d = inters_len(all_lucky[k - 1], all_lucky[k] - 1, vl, vr)\n right_len = max([0, d - c + 1])\n\n #print((left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1)))\n #print(left_len, right_len)\n result += (left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1))\n\n if b == c and left_len * right_len > 1e-6:\n result -= (1 / (pr - pl + 1) / (vr - vl + 1)) / 2\n\n a, b = inters_len(all_lucky[-(k + 1)] + 1, all_lucky[-k], pl, pr)\n left_len = max([0, b - a + 1])\n c, d = inters_len(all_lucky[-1], 10**9, vl, vr)\n right_len = max([0, d - c + 1])\n\n #print((left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1)))\n result += (left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1))\n\n if b == c and left_len * right_len > 1e-6:\n result -= (1 / (pr - pl + 1) / (vr - vl + 1)) / 2\n\n\n\n#print(all_lucky[:5])\n\nif k != len(all_lucky):\n check_for_intervals(pl, pr, vl, vr)\n check_for_intervals(vl, vr, pl, pr)\nelse:\n a, b = inters_len(0, all_lucky[0], pl, pr)\n left_len = max([0, b - a + 1])\n c, d = inters_len(all_lucky[-1], 10**9, vl, vr)\n right_len = max([0, d - c + 1])\n result += (left_len / (pr - pl + 1)) * (right_len / (vr - vl + 1))\n\n if b == c and left_len * right_len > 1e-6:\n result -= (1 / (pr - pl + 1) / (vr - vl + 1)) / 2\n\n a, b = inters_len(0, all_lucky[0], vl, vr)\n left_len = max([0, b - a + 1])\n c, d = inters_len(all_lucky[-1], 10**9, pl, pr)\n right_len = max([0, d - c + 1])\n result += (left_len / (vr - vl + 1)) * (right_len / (pr - pl + 1))\n\n if b == c and left_len * right_len > 1e-6:\n result -= (1 / (pr - pl + 1) / (vr - vl + 1)) / 2\n\nprint(result)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fd051cbc094b1ad7d9f4ded3d1374dad", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "#!/bin/pypy3\nimport itertools\n\ndef cnt(p):\n\tcnt_=0\n\tfor l in range(len(p)):\n\t\ta=b=p[l]\n\t\t#for r in range(l,len(p)):\n\t\tfor r in range(l+1,len(p)):\n\t\t\ta=min(a,p[r])\n\t\t\tb=max(b,p[r])\n\t\t\tif b-a==r-l:\n\t\t\t\tcnt_+=1\n\treturn cnt_\n\n\ndef bruteforce(endn):\n\tfor n in range(1,endn):\n\t\tok=[0]*(n*(n+1)//2+1)\n\t\tfor p in itertools.permutations(range(n)):\n\t\t\tok[cnt(p)]=1\n\n\t\tprint(n,\" => \",*[i for i,v in enumerate(ok) if v])\n\t\tprint(' ',\n\t\t\t\tn+1,\n\t\t\t\t'...',\n\t\t\t\tn*(n+1)//2 - 2*n+6,\n\t\t\t\tn*(n+1)//2 - n+2,\n\t\t\t\tn*(n+1)//2)\n\nspecial_cases={\n}\n\ndef gen0able(n,v):\n\tif v==n*(n-1)//2:\n\t\treturn True\n\treturn 0=len(gn) or not gn[v]: return None\n\tif gen0able(n,v): return gen0(n,v)\n\n\tif (n,v) in special_cases: return special_cases[(n,v)]\n\n\tfor r in range(2,n):\n\t\tif v== n*(n-1)//2 - (n-r)*(r-1):\n\t\t\tans= tuple(range(n-r)) + lrev(range(n-r,n))\n\t\t\tassert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\tfor p in range(1,n):\n\t\tretpt=p*(p-1)//2+1\n\t\tif v-retpt<=0:\n\t\t\tbreak\n\t\tif v-retpt l1.index(0):\n\t\t\t\tl1=lrev(l1)\n\t\t\tans= lrev(range(p)) + tuple(x+p for x in l1)\n\t\t\tassert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\tfor p in range(1,n):\n\t\tretpt=p*(p-1)//2+p\n\t\tif v-retpt<=0:\n\t\t\tbreak\n\t\tif v-retpt l1.index(0):\n\t\t\t\tl1=lrev(l1)\n\t\t\tans= tuple(range(p)) + tuple(x+p for x in l1)\n\t\t\tassert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\tassert False\n\n\nif 0:\n\tdef gen1(n,v):\n\t\tfor r in range(2,n):\n\t\t\tif v== n*(n-1)//2 - (n-r)*(r-1):\n\t\t\t\tans= tuple(range(n-r)) + lrev(range(n-r,n))\n\t\t\t\tassert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\t\treturn ans\n\n\t\tif gen0able(n,v):\n\t\t\treturn gen0(n,v)\n\n\n\t\tfor p in range(1,n):\n\t\t\tretpt=p*(p-1)//2+1\n\t\t\tif gen0able(n-p,v-retpt):\n\t\t\t\tl1=gen0(n-p,v-retpt)\n\t\t\t\tassert cnt(l1) == v-retpt\n\t\t\t\tif l1.index(n-p-1) > l1.index(0):\n\t\t\t\t\tl1=lrev(l1)\n\t\t\t\tans= lrev(range(p)) + tuple(x+p for x in l1)\n\t\t\t\tassert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\t\treturn ans\n\n\ndef test():\n\tbruteforceresult={\n\t1 : '0'.split(),\n\t2 : '1'.split(),\n\t3 : '2 3'.split(),\n\t4 : '1 3 4 6'.split(),\n\t5 : '1 2 4 5 6 7 10'.split(),\n\t6 : '1 2 3 4 5 6 7 8 9 11 15'.split(),\n\t7 : '1 2 3 4 5 6 7 8 9 10 12 13 16 21'.split(),\n\t8 : '1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 18 22 28'.split(),\n\t9 : '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 29 36'.split(),\n\t10: '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 27 30 31 37 45'.split(),\n\t11: '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 34 38 39 46 55'.split()\n\t}\n\n\tfor n in range(1,12):\n\t\tfor v in map(int,bruteforceresult[n]):\n\t\t\tl=gen1r(n,v)\n\t\t\tassert l==None or cnt(l)==v, (n,v, l,cnt(l))\n\t\t\tif l==None:\n\t\t\t\tprint(n,v)\n\ndef main():\n\tfor _ in range(int(input())):\n\t\tn,k=map(int,input().split())\n\t\tk-=n\n\t\tl=gen1r(n,k)\n\t\tif l==None:\n\t\t\tprint('NO')\n\t\telse:\n\t\t\tprint('YES')\n\t\t\tprint(*[x+1 for x in l])\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "31075acc24f617da1f5c6a1013a1789a", "src_uid": "23227ee76104780e16f366188938bca2", "difficulty": 3400.0} {"lang": "PyPy 3", "source_code": "#!/bin/pypy3\nimport itertools\n\ndef cnt(p):\n\tcnt_=0\n\tfor l in range(len(p)):\n\t\ta=b=p[l]\n\t\t#for r in range(l,len(p)):\n\t\tfor r in range(l+1,len(p)):\n\t\t\ta=min(a,p[r])\n\t\t\tb=max(b,p[r])\n\t\t\tif b-a==r-l:\n\t\t\t\tcnt_+=1\n\treturn cnt_\n\n\ndef bruteforce(endn):\n\tfor n in range(1,endn):\n\t\tok=[0]*(n*(n+1)//2+1)\n\t\tfor p in itertools.permutations(range(n)):\n\t\t\tok[cnt(p)]=1\n\n\t\tprint(n,\" => \",*[i for i,v in enumerate(ok) if v])\n\t\tprint(' ',\n\t\t\t\tn+1,\n\t\t\t\t'...',\n\t\t\t\tn*(n+1)//2 - 2*n+6,\n\t\t\t\tn*(n+1)//2 - n+2,\n\t\t\t\tn*(n+1)//2)\n\nspecial_cases={\n}\n\ndef gen0able(n,v):\n\tif v==n*(n-1)//2:\n\t\treturn True\n\treturn 0=len(gn) or not gn[v]: return None\n\tif gen0able(n,v): return gen0(n,v)\n\n\tif (n,v) in special_cases: return special_cases[(n,v)]\n\n\tfor r in range(2,n):\n\t\tif v== n*(n-1)//2 - (n-r)*(r-1):\n\t\t\tans= tuple(range(n-r)) + lrev(range(n-r,n))\n\t\t\t##assert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\tfor p in range(1,n):\n\t\tretpt=p*(p-1)//2+1\n\t\tif v-retpt<=0:\n\t\t\tbreak\n\t\tif v-retpt l1.index(0):\n\t\t\t\tl1=lrev(l1)\n\t\t\tans= lrev(range(p)) + tuple(x+p for x in l1)\n\t\t\t##assert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\tfor p in range(1,n):\n\t\tretpt=p*(p-1)//2+p\n\t\tif v-retpt<=0:\n\t\t\tbreak\n\t\tif v-retpt l1.index(0):\n\t\t\t\tl1=lrev(l1)\n\t\t\tans= tuple(range(p)) + tuple(x+p for x in l1)\n\t\t\t##assert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\treturn ans\n\n\t##assert False\n\n\nif 0:\n\tdef gen1(n,v):\n\t\tfor r in range(2,n):\n\t\t\tif v== n*(n-1)//2 - (n-r)*(r-1):\n\t\t\t\tans= tuple(range(n-r)) + lrev(range(n-r,n))\n\t\t\t\t##assert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\t\treturn ans\n\n\t\tif gen0able(n,v):\n\t\t\treturn gen0(n,v)\n\n\n\t\tfor p in range(1,n):\n\t\t\tretpt=p*(p-1)//2+1\n\t\t\tif gen0able(n-p,v-retpt):\n\t\t\t\tl1=gen0(n-p,v-retpt)\n\t\t\t\t##assert cnt(l1) == v-retpt\n\t\t\t\tif l1.index(n-p-1) > l1.index(0):\n\t\t\t\t\tl1=lrev(l1)\n\t\t\t\tans= lrev(range(p)) + tuple(x+p for x in l1)\n\t\t\t\t##assert cnt(ans)==v, (ans,cnt(ans),v, [cnt(l1),retpt])\n\t\t\t\treturn ans\n\n\ndef test():\n\tbruteforceresult={\n\t1 : '0'.split(),\n\t2 : '1'.split(),\n\t3 : '2 3'.split(),\n\t4 : '1 3 4 6'.split(),\n\t5 : '1 2 4 5 6 7 10'.split(),\n\t6 : '1 2 3 4 5 6 7 8 9 11 15'.split(),\n\t7 : '1 2 3 4 5 6 7 8 9 10 12 13 16 21'.split(),\n\t8 : '1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 18 22 28'.split(),\n\t9 : '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 29 36'.split(),\n\t10: '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 27 30 31 37 45'.split(),\n\t11: '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 34 38 39 46 55'.split()\n\t}\n\n\tfor n in range(1,12):\n\t\tfor v in map(int,bruteforceresult[n]):\n\t\t\tl=gen1r(n,v)\n\t\t\t##assert l==None or cnt(l)==v, (n,v, l,cnt(l))\n\t\t\tif l==None:\n\t\t\t\tprint(n,v)\n\ndef main():\n\tfor _ in range(int(input())):\n\t\tn,k=map(int,input().split())\n\t\tk-=n\n\t\tl=gen1r(n,k)\n\t\tif l==None:\n\t\t\tprint('NO')\n\t\telse:\n\t\t\tprint('YES')\n\t\t\tprint(*[x+1 for x in l])\n\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "497f425fd2b43c2187be06915aa693f0", "src_uid": "23227ee76104780e16f366188938bca2", "difficulty": 3400.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\nfrom functools import reduce\r\nraw_input = sys.stdin.readlines\r\n\r\ndef gcd(a, b):\r\n while b:\r\n a, b = b, a % b\r\n return a\r\n\r\ndef lcm(x, y):\r\n return x//gcd(x, y)*y\r\n\r\ndef inv(n):\r\n return pow(n, MOD-2, MOD)\r\n\r\ndef solution():\r\n n, a, x, y, k, M = list(map(int, input().strip().split()))\r\n inv_n = inv(n)\r\n base = reduce(lambda x, y: lcm(x, y), range(1, max(k, 2)))\r\n pr = [0]*base\r\n result = 0\r\n for i in range(n):\r\n pr[a%base] = (pr[a%base]+inv_n)%MOD\r\n result = (result + (a-a%base))%MOD\r\n a = (a*x+y)%M\r\n result = (result*inv_n*k)%MOD\r\n for i in range(1, k+1):\r\n result = (result+reduce(lambda total, x: (total+x*pr[x])%MOD, range(base), 0))%MOD\r\n for x in range(base):\r\n change = pr[x]*inv_n%MOD\r\n pr[x] = (pr[x]-change)%MOD\r\n pr[x-x%i] = (pr[x-x%i]+change)%MOD\r\n result = (result*pow(n, k, MOD))%MOD\r\n return result\r\n\r\nMOD = 998244353\r\nprint('%s' % solution())\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e87b8c4b98d32c1feb2aaaf981e118eb", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0} {"lang": "PyPy 3-64", "source_code": "from functools import reduce\r\n\r\ndef gcd(a, b):\r\n while b:\r\n a, b = b, a % b\r\n return a\r\n\r\ndef lcm(x, y):\r\n return x//gcd(x, y)*y\r\n\r\ndef inv(n):\r\n return pow(n, MOD-2, MOD)\r\n\r\ndef solution():\r\n n, a, x, y, k, M = list(map(int, input().strip().split()))\r\n inv_n = inv(n)\r\n base = reduce(lambda x, y: lcm(x, y), range(1, max(k, 2))) # divisible by 1, 2, ..., k-1 at each round\r\n pr = [0]*base\r\n result = 0\r\n for i in range(n):\r\n pr[a%base] = (pr[a%base]+inv_n)%MOD\r\n result = (result + (a-a%base))%MOD # fixed ev\r\n a = (a*x+y)%M\r\n result = (result*inv_n*k)%MOD\r\n for i in range(1, k+1):\r\n result = (result+reduce(lambda total, x: (total+x*pr[x])%MOD, range(base), 0))%MOD\r\n for x in range(base):\r\n change = pr[x]*inv_n%MOD\r\n pr[x] = (pr[x]-change)%MOD # expected pr[x] after this round\r\n pr[x-x%i] = (pr[x-x%i]+change)%MOD # expected pr[x-x%i] after this round\r\n result = (result*pow(n, k, MOD))%MOD\r\n return result\r\n\r\nMOD = 998244353\r\nprint('%s' % solution())\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7f3f15d502115234d993c04c195b9df3", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\nfrom functools import reduce\r\nraw_input = sys.stdin.readlines\r\n\r\ndef gcd(a, b):\r\n while b:\r\n a, b = b, a % b\r\n return a\r\n\r\ndef lcm(x, y):\r\n return x//gcd(x, y)*y\r\n\r\ndef inv(n):\r\n return pow(n, MOD-2, MOD)\r\n\r\ndef solution():\r\n n, a0, x, y, k, M = list(map(int, input().strip().split()))\r\n a = [a0]*n\r\n for i in range(1, n):\r\n a[i] = (a[i-1]*x+y)%M\r\n inv_n = inv(n)\r\n base = reduce(lambda x, y: lcm(x, y), range(1, max(k, 2)))\r\n pr = [0]*base\r\n for x in a:\r\n pr[x%base] = (pr[x%base]+inv_n)%MOD\r\n result = ((reduce(lambda total, x: (total+(x-x%base))%MOD, a, 0)*inv_n)*k)%MOD \r\n for i in range(1, k+1):\r\n result = (result+reduce(lambda total, x: (total+x*pr[x])%MOD, range(base), 0))%MOD\r\n for x in range(base):\r\n change = pr[x]*inv_n%MOD\r\n pr[x] = (pr[x]-change)%MOD\r\n pr[x-x%i] = (pr[x-x%i]+change)%MOD\r\n result = (result*pow(n, k, MOD))%MOD\r\n return result\r\n \r\nMOD = 998244353\r\nprint('%s' % solution())\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f82e91c3e205e75ff34bfcbe6239efa5", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0} {"lang": "PyPy 3-64", "source_code": "M, N = 998244353, 720720\r\nI = lambda: [int(x) for x in input().split()]\r\np = [0]*(N+1)\r\nres = 0\r\n\r\nn, a, x, y, k, U = I()\r\nfor i in range(1, n+1):\r\n p[a%N] += 1\r\n res += a//N * N\r\n a = (a * x + y) % U\r\n\r\nres = (res * pow(n, k-1, M) * k) % M\r\nfor i in range(1, k+1):\r\n tot = sum(p[j]*j for j in range(1, N+1))\r\n for j in range(1, N + 1):\r\n t1 = p[j]\r\n p[j] *= (n-1)\r\n p[j - j%i] += t1\r\n res += (tot * pow(n, k-i)) % M\r\n\r\nprint(res % M)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5f7daaa3c10c7d09c937f5800be3240d", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0} {"lang": "PyPy 3-64", "source_code": "# Time: O(k * r)\r\n# Space: O(r)\r\n# pass in PyPy3-64 but MLE in 32bit Python3/PyPy3\r\n# number theory\r\n\r\nimport sys\r\nfrom functools import reduce\r\nraw_input = sys.stdin.readlines\r\n\r\ndef gcd(a, b):\r\n while b:\r\n a, b = b, a % b\r\n return a\r\n\r\ndef lcm(x, y):\r\n return x//gcd(x, y)*y\r\n\r\ndef inv(n):\r\n return pow(n, MOD-2, MOD)\r\n\r\ndef solution():\r\n n, a0, x, y, k, M = list(map(int, input().strip().split()))\r\n a = [a0]*n\r\n for i in range(1, n):\r\n a[i] = (a[i-1]*x+y)%M\r\n inv_n = inv(n)\r\n base = reduce(lambda x, y: lcm(x, y), range(1, k+1))\r\n pr = [0]*base\r\n for x in a:\r\n pr[x%base] = (pr[x%base]+inv_n)%MOD\r\n result = ((reduce(lambda total, x: (total+(x-x%base))%MOD, a, 0)*inv_n)*k)%MOD \r\n for i in range(1, k+1):\r\n result = (result+reduce(lambda total, x: (total+x*pr[x])%MOD, range(base), 0))%MOD\r\n for x in range(base):\r\n change = pr[x]*inv_n%MOD\r\n pr[x] = (pr[x]-change)%MOD\r\n pr[x-x%i] = (pr[x-x%i]+change)%MOD\r\n result = (result*pow(n, k, MOD))%MOD\r\n return result\r\n \r\nMOD = 998244353\r\nprint('%s' % solution())\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b46f50a4088bd8671910fc37546693ba", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0} {"lang": "Python 2", "source_code": "def f(n,m):\n if n3]+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": "29a56b751f6eb0b070438a84c23e31dc", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.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": "ef907cc9cfdfd13d4e1d143440664583", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.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": "6b07aacaec1aa8de93ab9f548382ac9d", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.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)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a506d5522ac1e8042a9ca445ba326c5d", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.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": "cd4e56bed9722e1f2602d3e7adc7956f", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "from math import gcd\n\nm,a,b = map(int,input().split())\n\ng = gcd(a,b)\n\nvis = [0]*(a+b+1)\nvis[0] = 1\n\nnvis = 1\n\ncount = 0\nlast = 0\nt = 0\nwhile True:\n #print(t, vis)\n if t >= b:\n #print('back')\n t -= b\n if vis[t]:\n break\n vis[t] = 1\n nvis += 1\n else:\n t += a\n if t > m:\n break\n if t > last:\n #print('forward', t - last, 'with', nvis)\n count += (t - last)*nvis\n last = t\n if vis[t]:\n break\n vis[t] = 1\n nvis += 1\n #print(nvis,count)\n #print('---')\n\nif t > m:\n # we're done\n count += (m - last + 1)*nvis\nelse:\n def sumto(n):\n whole = n//g + 1\n r = whole*(whole+1)//2 * g\n corr = whole * (g-1 - (n%g))\n r -= corr\n return r\n\n #S = 0\n #for i in range(last, m+1):\n # S += i//g + 1\n #count += S\n #assert S == sumto(m) - sumto(last-1)\n\n count += sumto(m) - sumto(last-1)\n\n#print(vis)\nprint(count)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9448e3b184c3cb0410fc05d16e047e6f", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "from fractions import gcd\ndef main():\n m, a, b = map(int, raw_input().split())\n l = max(a, b) * 2\n s = [0] * (l + 1)\n ans = 1\n t = 1\n st = []\n pu = st.append\n po = st.pop\n s[0] = 1\n for i in xrange(1, l + 1):\n if s[i-a]:\n pu(i)\n while st:\n x = po()\n s[x] = 1\n t += 1\n if x + a <= i and not s[x+a]:\n pu(x + a)\n if x - b >= 0 and not s[x-b]:\n pu(x - b)\n ans += t\n if i >= m:\n break\n g = gcd(a, b)\n if m > i:\n p, q = divmod(m - i + 1, g)\n ans += (t + t + p - 1) * p / 2 * g + (t + p) * q - t\n print ans\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "75b52cede56eabceab74a252f15b1fa9", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#! /usr/bin/python\n\nfrom collections import deque\n\ndef gcd(a, b):\n\treturn a if b == 0 else gcd(b, a % b)\n\nm, a, b = [int(inp) for inp in raw_input().split()]\n\nm0 = min(a + b - 1, m)\n\ncanGet = [1 if i == 0 else 0 for i in xrange(m0 + 1)]\ncount = 1\ntotal = 1\nq = deque()\nfor x in xrange(1, m0 + 1):\n\tif x - a >= 0 and canGet[x - a] == 1:\n\t\tcanGet[x] = 1\n\t\tcount += 1\n\t\tq.append(x)\n\t\twhile len(q) > 0:\n\t\t\tj = q.pop()\n\t\t\tif j + a <= x and canGet[j + a] == 0:\n\t\t\t\tcanGet[j + a] = 1\n\t\t\t\tcount += 1\n\t\t\t\tq.append(j + a)\n\t\t\tif j - b >= 0 and canGet[j - b] == 0:\n\t\t\t\tcanGet[j - b] = 1\n\t\t\t\tcount += 1\n\t\t\t\tq.append(j - b)\n\ttotal += count\n\ng = gcd(a, b)\n\nm1 = min(m, ((m0 + g)/g)*g - 1)\ntotal += (m1 - m0)*count\n\nm2 = (m/g)*g - 1\nif m2 >= m1:\n\ttotal += ((m2 - m1)/g)*g*((m1 + 1)/g + (m2 + 1)/g + 1)/2\n\ttotal += (m - m2)*(m/g + 1)\n\nprint total", "lang_cluster": "Python", "compilation_error": false, "code_uid": "24c33bfda4b9bc4b43689ba732dfe73b", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "import math\nM, A, B = map(int, input().split())\nbound = [10**9 + 7]*(A + B)\nl, r = 0, 0\nwhile True:\n bound[l] = r\n if l >= B:\n l -= B\n else:\n l += A\n r = max(r, l)\n if l == 0:\n break\n\nans = 0\nfor i in range(0, A + B):\n if bound[i] <= M:\n ans += M - bound[i] + 1\n\nrem = M - (A + B) + 1\nif M >= (A + B):\n g = math.gcd(A, B)\n up = (rem // g) * g\n lo = rem - up\n cnt = up // g + 1\n ans += (lo + rem) * cnt // 2\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "68c4fabbef8802c386a3b06c5bb069fd", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "def aux(x, a, b, i, vis):\n\tif i-b >= 0 and i-b not in vis:\n\t\tvis.add(i-b)\n\t\taux(x, a, b, i-b, vis)\n\tif i+a <= x and i+a not in vis:\n\t\tvis.add(i+a)\n\t\taux(x, a, b, i+a, vis)\n\n\ndef single(x, a, b, vis):\n\tif x-a in vis:\n\t\tvis.add(x)\n\t\taux(x, a, b, x, vis)\n\treturn len(vis)\n\ndef sum_seq(n):\n\treturn n * (n+1) / 2\n\ndef solve(m, a, b):\n\tvis = set([0])\n\ttot = 0\n\tfor i in xrange(m+1):\n\t\tone = single(i, a, b, vis)\n\t\ttot += one\n\t\tif i > 0 and one == i + 1:\n\t\t\treturn tot + sum_seq(m+1) - sum_seq(i+1)\n\treturn tot\n\n\nm, a, b = map(int, raw_input().split())\nprint solve(m, a, b)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d309b9b1cdd622c55a12c3a1a1100fc3", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "import sys\n\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 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n #print phases2\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n\n if phases2[ind] == 0:\n ahtung = (phases2[-1] > 1)\n else:\n ahtung = (phases2[-1]-phases2[ind]>phases2[ind])\n #print ahtung\n #if phases2[ind] == 0 or phases2[ind]==phases2[ind-1]:\n # ahtung = False\n #else:\n # ahtung = True\n #print ahtung\n res = cnt2 * b\n\n if ahtung:\n res -= 1\n res /= (per1 * d)\n #print res\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\nif True and False:\n b, d = 841, 7\n a = 'qjqhrksmvedtqldrqgchhsofokfcovut'\n c = 'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc'\n\n b, d = 10,3\n a = 'abab'\n c = 'bab'\n\n b, d = 1263204, 1\n a = 'dcbabceabbaebddaaecbddaceaedacddadadcbbadbdccdecdacdcaadbceeddccbceaade'\n c = 'abddbccbdca'\n\n\n\n\nprint solve(a, b, c, d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "622d548c4e6a2e523520eff2118092e0", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\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 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n #print ahtung\n \n res = cnt2 * b / (per1 * d)\n if ahtung:\n res =- 1\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\n#b, d = 10, 3\n#a = 'bzabza'\n#c = 'abz'\nprint solve(a, b, c, d)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "71a000aa2b027214de047b088136fec6", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\n\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 = 0\n phases = []\n phases2 = []\n ahtung = False\n while True:\n if a[ind1] == c[ind2]:\n ind2 += 1\n\n if ind2 == len(c):\n ind2 = 0\n #contained. lets check syn\n if ind1 in phases:\n #period!\n #print \"period!\"\n phases.append(ind1)\n phases2.append(cnt1)\n break\n phases.append(ind1)\n phases2.append(cnt1)\n\n ind1 += 1\n if ind1 == len(a):\n ahtung = (ind2!=0)\n ind1 = 0\n cnt1 += 1\n\n if cnt1 >= b:\n #all length of a reached\n return len(phases)/d\n\n #print phases\n #print phases2\n \n val = phases.pop(-1)\n cnt2 = len(phases)\n ind = len(phases) - phases[::-1].index(val) -1\n cnt2 -= ind\n #print \"second in period = \" + str(cnt2)\n per1 = phases2[-1] - phases2[ind]\n #print \"first in period = \" + str(per1)\n\n #print ahtung\n #if phases2[ind] == 0 or phases2[ind]==phases2[ind-1]:\n # ahtung = False\n #else:\n # ahtung = True\n #print ahtung\n res = cnt2 * b\n\n #if ahtung:\n res -= 1\n res /= (per1 * d)\n #print res\n if res<0:\n res = 0\n return res\n\nb, d = map(int, sys.stdin.readline().split())\n\na = sys.stdin.readline().split()[0]\nc = sys.stdin.readline().split()[0]\n\nif False:\n b, d = 841, 7\n a = 'qjqhrksmvedtqldrqgchhsofokfcovut'\n c = 'qhtmothoulodshrfejterjlguvooccsvqrrdfqfvkqhtecuhhuqhshthrkusrc'\n\n b, d = 10,3\n a = 'abab'\n c = 'bab'\n\n\n\n\nprint solve(a, b, c, d)\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "cef64531196c454693c069d16ca0d0dc", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import sys\ndebug = False\ndef solve(a, b, c, d):\n for i in c:\n if i not in a:\n return 0\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 vals.append([1181362, 3, 'fckmaalkicfakhcbiglkekajmadjkj', 'zfkjkjgkmjhfkackkhhjalgkkclcklabggk', 0])\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": "c1ebb8524063cd6e20f030a135918a64", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.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 while cnt1 + step1 <= b:\n cnt1 += step1\n cnt2 += step2\n \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 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": "861b26e66e54cc6eb11ec2016fce73fe", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "mod = 10 ** 6 + 3\n\ndef prod(a, b):\n return [[sum([a[i][k] * b[k][j] for k in range(len(b))]) % mod for j in range(len(b[0]))] for i in range(len(a))]\n\nc, w, h = map(int, input().split())\n\na = [[0] * (w + 1) for _ in range(w + 1)]\nfor i in range(w):\n a[i][i + 1] = 1\n \nfor cnt in range(0, w + 1):\n a[-1][-1 - cnt] = h ** cnt\n\nans = [[0] for _ in range(w + 1)]\nans[-1][0] = 1\nans[-2][0] = 1\n\nwhile c > 0:\n if c % 2 == 1:\n ans = prod(a, ans)\n c = c // 2\n if c > 0:\n a = prod(a, a)\n\nprint(ans[-1][0])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bde258bc37fc43745f1d4886670fea73", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "def rotate(a,d):\n\t# 90 180 270\n\tif d==0:\n\t\treturn a\n\tret = [[0 for x in range(n)] for y in range(n)] \n\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tret[n-1-j][i]=a[i][j]\n\td -= 90\n\treturn rotate(ret,d)\n\n\ndef flip(a,v):\n\tret = [[0 for x in range(n)] for y in range(n)] \n\tif v:\n\t\tfor i in range(n):\n\t\t\tfor j in range(n):\n\t\t\t\tret[n-i-1][j] = a[i][j]\n\telse:\n\t\tfor i in range(n):\n\t\t\tfor j in range(n):\n\t\t\t\tret[i][n-j-1] = a[i][j]\n\treturn ret\n\nn=int(raw_input())\na=[]\nb=[]\n\n# print range(0,n)\n\nfor i in range(0,n):\n\ta.append(raw_input())\nfor i in range(0,n):\n\tb.append(raw_input())\nay = [[0 for x in range(n)] for y in range(n)]\nfor i in range(n):\n\tfor j in range(n):\n\t\tay[i][j] = a[i][j]\na = ay\n\n\nby = [[0 for x in range(n)] for y in range(n)]\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tby[i][j] = b[i][j]\nb = by\n\n# print 'a=',a,'b=',b\n\nphase = [rotate(a,360),rotate(a,90),rotate(a,180),rotate(a,270)]\np = []\nfor item in phase:\n\tp.append(item)\n\tp.append(flip(item,1))\n\tp.append(flip(item,0))\n\nif b in p:\n\tprint 'TRUE'\nelse:\n\tprint 'NO'\n\n# print a[1][2]\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dab55b1e6efb978f05a6b18361c0ebe9", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n = int(input())\nf = lambda: ''.join(input() for i in range(n))\na, b = f(), f()\ng = lambda k: k // n + n * (n - 1 - k % n)\ne = lambda k: k\nh = lambda k: n * (n - 1 - k // n) + k % n\nv = lambda k: n * (k // n) + n - 1 - k % n\nfor i in (v, h, e):\n for j in [e, g, lambda k: g(g(k)), lambda k: g(g(g(k)))]:\n if all(a[k] == b[i(j(k))] for k in range(n)): exit(print('Yes'))\nprint('No')", "lang_cluster": "Python", "compilation_error": false, "code_uid": "31ff699ba8bf0f2cd607491fb5e020f9", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import copy\nlista=[]\nlistb=[]\ntemp=[]\na=int(input())\nflag=0\nmark=0\n\nfor i in range(0,a):\n str=input()\n for j in range(0,a):\n temp.append(str[j])\n lista.append(temp)\n temp=[]\n \nfor i in range(0,a):\n str=input()\n for j in range(0,a):\n temp.append(str[j])\n listb.append(temp)\n temp=[]\n\nlistacpy =copy.deepcopy(lista)\n#\u8f6c90\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-j][i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\nmark = 0\n\n#\u8f6c180\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-i][a-1-j]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n \nmark = 0\n\n#\u8f6c270\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[j][a-1-i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\n#\u7ffb\u9762\nlisttemp=copy.deepcopy(lista)\nfor i in range(0,a):\n for j in range(0,a):\n lista[i][j]=listtemp[i][a-1-j]\n\nmark = 0\n\nlistacpy =copy.deepcopy(lista)\n#\u8f6c90\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-j][i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\nmark = 0\n\n#\u8f6c180\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-i][a-1-j]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n \nmark = 0\n\n#\u8f6c270\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[j][a-1-i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\n \nif(flag==1):\n print(\"yes\")\nelse:\n print(\"no\")\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0636b777560bc08040ef6a847d4cc54f", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "#\u4f7f\u7528deepcopy\u4f7flista\u4e0d\u88ab\u6539\u53d8\n#\u53cc\u5f15\u53f7\u8981\u6253\u4e00\u5bf9 \u4e0d\u7136\u8981\u51fa\u4e8b\n#\u521d\u59cb\u5316\u522b\u52a0int\nimport copy\nlista=[]\nlistb=[]\ntemp=[]\na=int(input())\nflag=0\nmark=0\n\nfor i in range(0,a):\n str=input()\n for j in range(0,a):\n temp.append(str[j])\n lista.append(temp)\n temp=[]\n \nfor i in range(0,a):\n str=input()\n for j in range(0,a):\n temp.append(str[j])\n listb.append(temp)\n temp=[]\n\nlistacpy =copy.deepcopy(lista)\n#\u8f6c90\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-j][i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\nmark = 0\n\n#\u8f6c180\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-i][a-1-j]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n \nmark = 0\n\n#\u8f6c270\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[j][a-1-i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\n#\u7ffb\u9762\nlisttemp=copy.deepcopy(lista)\nfor i in range(0,a):\n for j in range(0,a):\n lista[i][j]=listtemp[i][a-1-j]\n\nmark = 0\n\nlistacpy =copy.deepcopy(lista)\n#\u8f6c90\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-j][i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\nmark = 0\n\n#\u8f6c180\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[a-1-i][a-1-j]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n \nmark = 0\n\n#\u8f6c270\u00b0\nfor i in range(0,a):\n for j in range(0,a):\n listacpy[j][a-1-i]=lista[i][j]\n\nfor i in range(0,a):\n for j in range(0,a):\n if(listacpy[i][j]!=listb[i][j]):\n mark=1\n break\n if(mark==1):\n break\nif(mark==0):\n flag=1\n\n \nif(flag==1):\n print(\"yes\")\nelse:\n print(\"no\")\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "3064dc539f06a2701525c391f755b814", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "import numpy as np\n\ndef is_rotate(first_map, second_map):\n\ttmp_first_map = first_map[:]\n\tfor i in range(4):\n\t\tnew_matrix = np.rot90(tmp_first_map)\n\t\tif np.array_equal(new_matrix, second_map) or np.array_equal([x[::-1] for x in tmp_first_map], second_map) or np.array_equal([x[::-1] for x in tmp_first_map], second_map):\n\t\t\treturn True\n\t\ttmp_first_map = new_matrix[:]\n\treturn False\n\nif __name__ == \"__main__\":\n\tn = int(input())\n\n\tfirst_map = []\n\tsecond_map = []\n\n\tfor i in range(n):\n\t\tfirst_map.append(list(input()))\n\tfor i in range(n):\n\t\tsecond_map.append(list(input()))\n\n\t# import code\n\t# code.interact(local=locals())\n\tif is_rotate(first_map, second_map):\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "680e03627a78a3736147e49a17db86a0", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.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 for it in range(100000 * K + n):\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 ll = a[k] * b[i] - a[i] * b[k]\n xh = c[i] * b[k] - c[k] * b[i]\n yh = a[i] * c[k] - a[k] * c[i]\n\n assert(x_high * ll != xh * low or\\\n y_high * ll != yh * low)\n\n active = n_act\n good = True\n break\n\n if not good:\n no_solution()\n\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": "b9a9e2d4d6534e5b20d4b272c29b2f30", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "PyPy 2", "source_code": "from sys import stdin, exit\nfrom random import randint, choice\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 if n <= 1000:\n for ii in xrange(n):\n if good:\n break\n for jj in xrange(ii + 1, n):\n if good:\n break\n i = active[ii]\n j = active[jj]\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 ll = a[k] * b[i] - a[i] * b[k]\n xh = c[i] * b[k] - c[k] * b[i]\n yh = a[i] * c[k] - a[k] * c[i]\n\n assert(x_high * ll != xh * low or\\\n y_high * ll != yh * low)\n\n active = n_act\n good = True\n if not good:\n break\n continue\n\n for it in range(10000000 * K + 100 * n):\n i = choice(active)\n j = choice(active)\n if i == j:\n continue\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 ll = a[k] * b[i] - a[i] * b[k]\n xh = c[i] * b[k] - c[k] * b[i]\n yh = a[i] * c[k] - a[k] * c[i]\n\n assert(x_high * ll != xh * low or\\\n y_high * ll != yh * low)\n\n active = n_act\n good = True\n break\n\n if not good:\n no_solution()\n\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": "0c2af8bb1e87185d3a7dc526a6a51417", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.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 if n <= 1000:\n for ii in xrange(n):\n if good:\n break\n for jj in xrange(ii + 1, n):\n if good:\n break\n i = active[ii]\n j = active[jj]\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 ll = a[k] * b[i] - a[i] * b[k]\n xh = c[i] * b[k] - c[k] * b[i]\n yh = a[i] * c[k] - a[k] * c[i]\n\n assert(x_high * ll != xh * low or\\\n y_high * ll != yh * low)\n\n active = n_act\n good = True\n if not good:\n break\n continue\n\n for it in range(1000000 * K + n):\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 ll = a[k] * b[i] - a[i] * b[k]\n xh = c[i] * b[k] - c[k] * b[i]\n yh = a[i] * c[k] - a[k] * c[i]\n\n assert(x_high * ll != xh * low or\\\n y_high * ll != yh * low)\n\n active = n_act\n good = True\n break\n\n if not good:\n no_solution()\n\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": "cf4f1ad62431467e3e7ff742a61669c6", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.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 hh = 0\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 hh += 1\n\n #active = n_act\n good = True\n if hh < bsz:\n bsz = hh\n best = (i, j)\n\n if not good:\n no_solution()\n\n i, j = best\n if i == -1:\n continue\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": "f831287321cb25ab92c2add766c0aefa", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.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 hh = 0\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 hh += 1\n\n #active = n_act\n good = True\n if hh < bsz:\n bsz = hh\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": "dc61aefe1a82eead8ca82df2e6fe7565", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "Python 2", "source_code": "def nextc(m):\n m2 = {}\n for n, c in m.iteritems():\n h = n-1 >> 1\n m2[h] = m2.get(h, 0) + c\n m2[n-1 - h] = m2.get(n-1 - h, 0) + c\n return m2\n\ndef countseg(l, s, cache={}):\n if s > l: return 0\n if s == l: return 1\n if (l, s) in cache:\n return cache[l, s]\n h = l-1 >> 1\n out = countseg(h, s) + countseg(l-1 - h, s)\n cache[l, s] = out\n return out\n \ndef findx(l, q, ss):\n if l <= max(ss):\n return (l-1 >> 1) + q\n h = l-1 >> 1\n ns = sum(countseg(h, s) for s in ss)\n if q >= ns:\n return h + 1 + findx(l-1 - h, q - ns, ss)\n else:\n return findx(h, q, ss)\n\ndef f(l, r):\n m = {l: 1, l-1: 0}\n q = 1\n while r >= q and min(m) > 2:\n r -= q\n q <<= 1\n m = nextc(m)\n mn, mx = min(m), max(m)\n if mx & 1:\n if r >= m[mx]:\n if mx == 3:\n return findx(l, r - m[mx], [1,2])\n return findx(l, r - m[mx], [mn])\n else:\n return findx(l, r, [mx])\n else:\n return findx(l, r, [mn, mx])\n\ndef ans(n, k):\n if k == 1: return 1\n if k == 2: return n\n return 2 + f(n - 2, k - 3)\n \ndef brute_ans(n, k):\n if k == 1: return 1\n if k == 2: return n\n return 2 + brute_f(n - 2, k - 2)\n \ndef brute_f(l, r):\n s = [(0, l)]\n for _ in xrange(r):\n i = max(xrange(len(s)), key=lambda j: s[j][1]-1 >> 1)\n x, d = s[i]\n h = d-1 >> 1\n s = s[:i] + [(x, h), (x+h+1, d-1-h)] + s[i+1:]\n return x+h\n\ndef test_n(n):\n for i in xrange(1, n + 1):\n assert brute_ans(n, i) == ans(n, i)\n\nif __name__ == '__main__':\n n, k = map(int, raw_input().split())\n print ans(n, k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5116acb0b2840cfd17e073c9fbabf7d8", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "f = {}\ndef c(n, p):\n\tk = (n, p)\n\tif k in f: return f[k]\n\n\td = (n-1)/2\n\tf[k] = d >= p and (1 + c(d, p) + c(n-d-1, p))\n\n\treturn f[k]\n\ndef w(l, r, k):\n\tm = (l+r)/2\n\n\tif k == 0: return m\n\n\tx = c(m-l, p)\n\ty = c(r-m, p+1)\n\n\treturn w(l, m-1, k-y-1) if x+y>=k else w(m+1, r, k-x-1)\n\nn,k = map(int, raw_input().split())\n\nif k == 1: print 1\nelif k == 2: print n\nelse:\n\tp, q = 0, n\n\twhile p < q:\n\t\tm = (p+q+1) / 2\n\t\tif c(n-2, m) >= k-2: p = m\n\t\telse: q = m-1\n\tprint w(2, n-1, k-3)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8e81c18607de83818bf152f632ca0d8", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "dp = {}\ndef count(n, low):\n\tif low == 1: return n\n\tk = (n, low)\n\tif k in dp: return dp[k]\n\tif n < low: return 0\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 = 1, n+1\n\twhile lo < hi:\n\t\tmid = (lo + hi + 1) / 2\n\t\tif count(n, 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": "4fc14c7815453096e84f281bb1686a00", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "dp = {}\ndef count(n, low):\n\tif low == 1: return n\n\tk = (n, low)\n\tif k in dp: return dp[k]\n\tif n < low: return 0\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+2)\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 = 1, n+1\n\twhile lo < hi:\n\t\tmid = (lo + hi + 1) / 2\n\t\tif count(n, 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": "0b4da9bdaca466b19fd4f0a11369edc4", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "f = {}\ndef c(n, p):\n\tk = (n, p)\n\tif k in f: return f[k]\n\n\td = (n-1)/2\n\tf[k] = d >= p and (1 + c(d, p) + c(n-d-1, p))\n\n\treturn f[k]\n\ndef w(l, r, k):\n\tprint l,r,k\n\tm = (l+r)/2\n\n\tif k == 0: return m\n\n\tx = c(m-l, p)\n\ty = c(r-m, p+1)\n\n\treturn w(l, m-1, k-y-1) if x+y>=k else w(m+1, r, k-x-1)\n\nn,k = map(int, raw_input().split())\n\nif k == 1: print 1\nelif k == 2: print n\nelse:\n\tp, q = 0, n\n\twhile p < q:\n\t\tm = (p+q+1) / 2\n\t\tif c(n-2, m) >= k-2: p = m\n\t\telse: q = m-1\n\tprint w(2, n-1, k-3)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bf0f2233487ccd88fc5cbe2e826e0fd5", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "MOD,fact=10**9+7,[1]*(2*10**6+5)\nfor i in range(1, len(fact)): fact[i]=(fact[i-1]*i)%(MOD)\ndef C(n,k):\n return (fact[n]*pow(fact[k],MOD-2,MOD)**2)%MOD\nn=input()+1\nprint C(2*n,n)-1\n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9cfb0e2bae508a99d3a67b0fa987ccd2", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "# https://codeforces.com/problemset/problem/575/H\n\nimport sys\nimport math\n\nmod = pow(10, 9) + 7\n\n\ndef main():\n # sys.stdin = open('E:\\\\Sublime\\\\in.txt', 'r')\n # sys.stdout = open('E:\\\\Sublime\\\\out.txt', 'w')\n # sys.stderr = open('E:\\\\Sublime\\\\err.txt', 'w')\n\n n = int(sys.stdin.readline().strip())\n # a, b = map(int, sys.stdin.readline().strip().split()[:2])\n\n # C(n+1, 2n + 2) = (2n+2)! : (n+1)! : n+1!\n # = (n+2)(n+3)...(2n+2) /\n\n t = 1\n m = 1\n for i in range(1, n + 2):\n t *= (n + i + 1) % mod\n m *= i % mod\n print((t // m - 1) % mod)\n\n\nif __name__ == '__main__':\n main()\n\n# hajj\n# \u3000\u3000\u3000\u3000\u3000\u3000 \uff3f\uff3f\n# \u3000\u3000\u3000\u3000\u3000\uff0f\uff1e\u3000\u3000\u30d5\n# \u3000\u3000\u3000\u3000\u3000| \u3000_\u3000 _ l\n# \u3000 \u3000\u3000\u3000\uff0f` \u30df\uff3fx\u30ce\n# \u3000\u3000 \u3000 /\u3000\u3000\u3000 \u3000 |\n# \u3000\u3000\u3000 /\u3000 \u30fd\u3000\u3000 \uff89\n# \u3000 \u3000 \u2502\u3000\u3000|\u3000|\u3000|\n# \u3000\uff0f\uffe3|\u3000\u3000 |\u3000|\u3000|\n# \u3000| (\uffe3\u30fd\uff3f_\u30fd_)__)\n# \u3000\uff3c\u4e8c\u3064\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "14053b6a8118ffa67dd4237f5749f37c", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "MOD = 10**9+7\n\nfact = [1]*2000004\nfor i in range(1,2000004):\n fact[i] = (fact[i-1]*i)%MOD\ninv = [1]*2000004\nfor i in range(2,2000004):\n inv[i] = (-(MOD//i)*inv[MOD%i])%MOD\nfor i in range(2,2000004):\n inv[i] = (inv[i]*inv[i-1])%MOD\ndef C(n,k):\n return (fact[n]*inv[k]*inv[n-k])%MOD\nx=int(input())+1\nres = C(x*2,x)-1\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6a63eeebe953243b84141442117936a9", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "PyPy 2", "source_code": "n = int(raw_input())+1\naa=1\nfor i in xrange(1, 2*n):\n\taa *= i\nbb=1\nfor i in xrange(1, n+1):\n\tbb *= i\ncc = 1\nfor i in xrange(1, n):\n\tcc *= i\nprint (2 * aa / (bb * cc) - 1) % (10 ** 9 + 7)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ba866fa4a9757c253b85e2e93659c4f", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "MOD = 10**9+7\n\nfact = [1]*200003\nfor i in range(1,200003):\n fact[i] = (fact[i-1]*i)%MOD\ninv = [1]*200003\nfor i in range(2,200003):\n inv[i] = (-(MOD//i)*inv[MOD%i])%MOD\nfor i in range(2,200003):\n inv[i] = (inv[i]*inv[i-1])%MOD\ndef C(n,k):\n return (fact[n]*inv[k]*inv[n-k])%MOD\nx=int(input())+1\nres = C(x*2,x)-1\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1722e4f95d1396c75bc12324b230fa4d", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - 1) % m\n quit()\n\n\ndef pow9_10(x):\n res = 1\n if x > 0:\n res *= 9\n if x > 1:\n res *= pow(10, x - 1, m)\n return res % m\n\nres = 0\ncounts = [0] * k\ncounts[0] = 1\n\np10i = 1\nfor i in xrange(n):\n counts2 = [0] * k\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * p10i + r) % k\n counts2[r2] += counts[r]\n\n add = (counts2[0] - 1) * pow9_10(n - i - 1)\n res += add\n\n counts2[0] = 1\n counts = counts2\n\n p10i = (p10i * 10) % k\nprint res % m\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "235e152ad99e69026db977089d638003", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - 1) % m\n quit()\n\n\ndef pow9_10(x):\n res = 1\n if x > 0:\n res *= 9\n if x > 1:\n res *= pow(10, x - 1, m)\n return res % m\n\n\ndef count_div_upto_pow10(e, kk):\n q, r = divmod(pow(10, e), kk)\n if r == 0:\n q -= 1\n return q\n\n\ndef count_div_interval(e1, e2, kk):\n return count_div_upto_pow10(e2, kk) - count_div_upto_pow10(e1, kk)\n\n\ndef cut_pow10(e):\n return pow(10, e) if e > 0 else 1\n\nres = 0\ncounts = {r: 0 for r in xrange(k)}\ncounts[0] = 1\n\nfor i in xrange(n):\n #print i, \":\",\n p10 = pow(10, i)\n\n counts2 = {r: 0 for r in xrange(k)}\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * pow(10, i, k) + r) % k\n counts2[r2] += counts[r]\n #print counts2\n add = (counts2[0] - 1) * pow9_10(n - i - 1)\n res += add\n #print \"ADD\", counts2[0], \"*\", pow9_10(n - i - 1), \"=\", add\n counts2[0] = 1\n counts = counts2\nprint res % m\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "04e18aca908217e68b497dcd6bd5ffc7", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "def get_input():\n hahaha=input()\n (n,k,m)=hahaha.split(sep=None, maxsplit=1000)\n return (int(n),int(k),int(m))\n(n,k,m)=get_input()\nf=[0 for i in range(k)]\n \ns=0 \n\nfor v in range(n):\n tens = 10**v\n f=[ (sum( [f[(j+k-(x+1)*tens%k)%k] for x in range(9)] )+f[j])%m for j in range(k)]\n for x in range(9):\n f[(x+1)*tens%k]+=1\n if n-v-1==0:\n s+=(f[0]%m)\n else:\n s+=f[0]*((10**(n-v-2)*9))%m\n f[0]=0\n\nprint(s%m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ef64c9213cb9ebc80c9e41038df42af6", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\nimport random\nimport operator\nfrom fractions import Fraction, gcd\nfrom decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, k, m = map(int, raw_input().split())\n\nif k == 1:\n print (pow(10, n, m) - pow(10, n - 1, m)) % m\n quit()\n\n\n# def pow9_10(x):\n# res = 1\n# if x > 0:\n# res *= 9\n# if x > 1:\n# res *= pow(10, x - 1, m)\n# return res % m\n\npow9_10 = []\np = 1\nfor i in range(n):\n pow9_10.append(p)\n if i == 0:\n p = (p * 9) % m\n else:\n p = (p * 10) % m\n\nres = 0\ncounts = [0] * k\ncounts[0] = 1\n\np10i = 1\nfor i in xrange(n):\n counts2 = [0] * k\n for r in xrange(k):\n mind = 1 if i == n else 0\n for d in xrange(mind, 10):\n r2 = (d * p10i + r) % k\n counts2[r2] += counts[r]\n\n add = (counts2[0] - 1) * pow9_10[n - i - 1]\n res += add\n\n counts2[0] = 1\n counts = counts2\n\n p10i = (p10i * 10) % k\nprint res % m\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "37533b5731204795fb01d1d5aef029e6", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "global debug\ndebug = 0\n\nline = map(int, raw_input().split())\nn = line[0]\nk = line[1]\nm = line[2]\n\nr = [[0 for _ in xrange(k)] for _ in xrange(n)]\nt = [[0 for _ in xrange(k)] for _ in xrange(n)]\n\nfor i in xrange(10):\n r[0][i % k] += 1\n\nbase = 1\nfor i in xrange(1, n):\n base *= 10\n if (i == n - 1): start = 1\n else: start = 0\n for c in xrange(start, 10):\n offset = (c * base) % k\n for j in xrange(k):\n #for pre in xrange(i):\n r[i][j] += r[i - 1][(j - offset) % k]\n r[i][j] %= m\nif (debug >= 2): print r\n\nt[0][0] = (r[0][0] - 1) % m\nbase = 1\nfor i in xrange(1, n):\n base *= 10\n t[i][0] = r[i][0]\n if (i == n - 1):\n start = 1\n else:\n start = 0\n t[i][0] -= 1\n for c in xrange(start, 10):\n offset = (c * base) % k\n for j in xrange(k):\n idx = (offset + j) % k\n if (idx != 0):\n t[i][idx] += t[i - 1][j]\n t[i][idx] %= m\nif (debug >= 2): print t\nprint sum(t[n - 1]) % m\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4a04629b38c83d37df3ab555fddad426", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "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()\nMOD = 10**9 + 7\nUPPER = 25\n\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, min(N+1, i+6)):\n num = int(S[i:j], 2)\n if num == 0: continue\n if num >= 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 = 0\nfor i in xrange(N):\n fans += dp(i, 0)\n if fans >= MOD:\n fans %= MOD\nprint fans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3d24342c1cfdadec9b761d8d9954a885", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "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()\nMOD = 10**9 + 7\nUPPER = 21\n\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, min(N+1, i+6)):\n num = int(S[i:j], 2)\n if num == 0: continue\n if num >= 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 = 0\nfor i in xrange(N):\n fans += dp(i, 0)\n if fans >= MOD:\n fans %= MOD\nprint fans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db318730ee7780b2c39c51b73022a09b", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "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] = 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": "463da750b3caedc1ff8524cbe24a84ad", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "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()\nMOD = 10**9 + 7\nUPPER = 22\n\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 ans += dp(j, mask | (1<<(num-1)))\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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c53b28487893cb04050735c6af3f6ce", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys, math, random, operator\nfrom string import ascii_lowercase, ascii_uppercase\nfrom fractions import Fraction, gcd\n#from decimal import Decimal, getcontext\nfrom itertools import product, permutations, combinations\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\n#getcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nif sys.subversion[0] == \"PyPy\":\n import io, atexit\n sys.stdout = io.BytesIO()\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n sys.stdin = io.BytesIO(sys.stdin.read())\n raw_input = lambda: sys.stdin.readline().rstrip()\npr = lambda *args: sys.stdout.write(\" \".join(str(x) for x in args) + \"\\n\")\nepr = lambda *args: sys.stderr.write(\" \".join(str(x) for x in args) + \"\\n\")\ndie = lambda *args: pr(*args) ^ exit(0)\n\nread_str = raw_input\nread_strs = lambda: raw_input().split()\nread_int = lambda: int(raw_input())\nread_ints = lambda: map(int, raw_input().split())\nread_float = lambda: float(raw_input())\nread_floats = lambda: map(float, raw_input().split())\n\n\"---------------------------------------------------------------\"\n\nn = read_int()\ns = read_str()\n\nnum = []\nfor i in xrange(len(s)):\n num.append([None])\n for j in xrange(i + 1, len(s)+1):\n num[i].append( int(s[i:j], 2) )\n\nneeded_for_m = [None]\ncur = 0\nfor x in xrange(1, 100):\n cur += len(str(bin(x)[2:]))\n needed_for_m.append(cur)\n\nbins = [bin(x)[2:] for x in xrange(0, 100)]\n\ncache = {}\ndef solve(state, used, maxm, pos):\n key = state, pos\n if key not in cache:\n res = 0\n\n # already good?\n # print \"(%s)\" % bin(state)[2:-1], maxm\n if state == (1 << (maxm + 1)) - 1:\n # print \"good\"\n res += 1\n\n # continue cuts\n for add in xrange(1, 100):\n if pos + add > len(s):\n break\n val = num[pos][add]\n if val == 0:\n continue\n\n used2 = used\n if state & (1 << val) == 0:\n used2 += len(bins[val])\n maxm2 = max(maxm, val)\n pos2 = pos + add\n # print \"pos\", pos, \"+\", add\n if needed_for_m[maxm2] - used2 <= len(s) - pos2:\n res += solve(state | (1 << val), used2, maxm2, pos2)\n cache[key] = res\n return cache[key]\n\nans = 0\nfor i in xrange(len(s)):\n cur = solve(1, 0, 1, i)\n ans += cur\n epr(i, cur, ans)\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0284abd081d54f02a68210ca4057f55a", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef Min(x, y):\n if x > y:\n return y\n else:\n return x\n\nn = int(input())\na = [int(i) for i in input().split()]\nd = [int(0) for i in range(0, n)]\n\nok = 0\n\ncur = 0\n\nfor i in range(0, 7 * n):\n if a[i % n] == 0 :\n print(i % n + 1)\n ok = 1\n break\n if cur != 6:\n a[i % n] -= 1\n d[i % n] += 1\n cur = (cur + 1) % 7\n\nif ok == 0:\n k = -1\n\n for i in range(0, n):\n if a[i] % d[i] > 0:\n k = Min(k, a[i] // d[i])\n else:\n k = Min(k, a[i] // d[i] - 1)\n\n for i in range(0, n):\n a[i] -= k * d[i]\n\n iter = 0\n cur = 0\n\n while True:\n if a[iter] == 0:\n print(iter)\n break\n else:\n if cur != 6:\n a[iter] -= 1\n cur = (cur + 1) % 7\n iter = (iter + 1) % n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "4d6bf894d57da1ba28b67a84cc37a5f8", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef Min(x, y):\n if x > y:\n return y\n else:\n return x\n\ndef Gcd(x, y):\n if x == 0:\n return y\n else:\n return Gcd(y % x, x)\n\ndef Lcm(x, y):\n return x * y // Gcd(x, y)\n\nn = int(input())\na = [int(i) for i in input().split()]\nd = [int(0) for i in range(0, n)]\n\nok = 0\n\ncur = 0\n\nlen = Lcm(7, n)\n\nfor i in range(0, 7 * n):\n if a[i % n] == 0 :\n print(i % n + 1)\n ok = 1\n break\n if cur != 6:\n a[i % n] -= 1\n d[i % n] += 1\n cur = (cur + 1) % 7\n\nif ok == 0:\n k = -1\n\n for i in range(0, n):\n a[i] += d[i]\n if d[i] == 0: continue\n if a[i] % d[i] > 0:\n k = Min(k, a[i] // d[i])\n else:\n k = Min(k, a[i] // d[i] - 1)\n\n for i in range(0, n):\n a[i] -= k * d[i]\n\n iter = 0\n cur = 0\n\n while True:\n if a[iter] == 0:\n print(iter)\n break\n else:\n if cur != 6:\n a[iter] -= 1\n cur = (cur + 1) % 7\n iter = (iter + 1) % n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f4d7ae464b0af564c3866d4627a6015f", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef Min(x, y):\n if x > y:\n return y\n else:\n return x\n\nn = int(input())\na = [int(i) for i in input().split()]\nd = [int(0) for i in range(0, n)]\n\nok = 0\n\ncur = 0\n\nfor i in range(0, 7 * n):\n if a[i % n] == 0 :\n print(i % n + 1)\n ok = 1\n break\n if cur != 6:\n a[i % n] -= 1\n d[i % n] += 1\n cur = (cur + 1) % 7\n\nif ok == 0:\n k = -1\n\n for i in range(0, n):\n if d[i] == 0: continue\n if a[i] % d[i] > 0:\n k = Min(k, a[i] // d[i])\n else:\n k = Min(k, a[i] // d[i] - 1)\n\n for i in range(0, n):\n a[i] -= k * d[i]\n\n iter = 0\n cur = 0\n\n while True:\n if a[iter] == 0:\n print(iter)\n break\n else:\n if cur != 6:\n a[iter] -= 1\n cur = (cur + 1) % 7\n iter = (iter + 1) % n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8ac2ab4fd97f89c39079ccb45b970b7", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef Min(x, y):\n if x > y:\n return y\n else:\n return x\n\ndef Gcd(x, y):\n if x == 0:\n return y\n else:\n return Gcd(y % x, x)\n\ndef Lcm(x, y):\n return x * y // Gcd(x, y)\n\nn = int(input())\na = [int(i) for i in input().split()]\nd = [int(0) for i in range(0, n)]\n\nok = 0\n\ncur = 0\n\nlen = Lcm(7, n)\n\nfor i in range(0, 7 * n):\n if a[i % n] == 0 :\n print(i % n + 1)\n ok = 1\n break\n if cur != 6:\n a[i % n] -= 1\n d[i % n] += 1\n cur = (cur + 1) % 7\n\nif ok == 0:\n k = 10**20\n\n for i in range(0, n):\n a[i] += d[i]\n if d[i] == 0: continue\n if a[i] % d[i] > 0:\n k = Min(k, a[i] // d[i])\n else:\n k = Min(k, a[i] // d[i] - 1)\n\n if k == 10**20:\n k = 0\n\n for i in range(0, n):\n a[i] -= k * d[i]\n\n iter = 0\n cur = 0\n\n while True:\n if a[iter] == 0:\n print(iter % n + 1)\n break\n else:\n if cur != 6:\n a[iter] -= 1\n cur = (cur + 1) % 7\n iter = (iter + 1) % n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a34f2c76da59cf7352373ff8a40a55f", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import sys\n\ndef Min(x, y):\n if x > y:\n return y\n else:\n return x\n\ndef Gcd(x, y):\n if x == 0:\n return y\n else:\n return Gcd(y % x, x)\n\ndef Lcm(x, y):\n return x * y // Gcd(x, y)\n\nn = int(input())\na = [int(i) for i in input().split()]\nd = [int(0) for i in range(0, n)]\n\nok = 0\n\ncur = 0\n\nlen = Lcm(7, n)\n\nfor i in range(0, 7 * n):\n if a[i % n] == 0 :\n print(i % n + 1)\n ok = 1\n break\n if cur != 6:\n a[i % n] -= 1\n d[i % n] += 1\n cur = (cur + 1) % 7\n\nif ok == 0:\n k = 10**20\n\n for i in range(0, n):\n a[i] += d[i]\n if d[i] == 0: continue\n if a[i] % d[i] > 0:\n k = Min(k, a[i] // d[i])\n else:\n k = Min(k, a[i] // d[i] - 1)\n\n if k == 10**20:\n k = 0\n\n for i in range(0, n):\n a[i] -= k * d[i]\n\n iter = 0\n cur = 0\n\n while True:\n if a[iter] == 0:\n print(iter % n + 1)\n break\n else:\n if cur != 6:\n a[iter] -= 1\n cur = (cur + 1) % 7\n iter = (iter + 1) % n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "be5466f5df44974efd3fd2085d8b54ea", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import math\n\nn = int(input())\n\nif n == 1:\n print()\nelse: \n edge = [list(map(int, input().split())) for _ in range(n-1) ]\n g = {}\n\n for x, y in edge:\n if x not in g:\n g[x] = []\n if y not in g:\n g[y] = []\n \n g[x].append(y)\n g[y].append(x)\n\n def find_center(g): \n d = {}\n d[1] = 0\n Q = [(1, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n s = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n s = u\n \n d = {}\n pre = {}\n d[s] = 0\n Q = [(s, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n pre[v] = u\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n e = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n e = u\n \n route = [e]\n while pre[route[-1]] != s:\n route.append(pre[route[-1]])\n \n return route[len(route) // 2]\n\n root = find_center(g)\n p = {}\n size = {}\n Q = [root]\n p[root] = -1\n\n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n gr = [(u, size[u]) for u in g[root]]\n gr = sorted(gr, key=lambda x:x[1])\n thres = math.ceil((n-1) / 3) \n sum_ = 0\n\n gr1 = []\n gr2 = []\n i = 0\n \n while sum_ < thres:\n gr1.append(gr[i][0])\n sum_ += gr[i][1]\n i+=1\n \n while i < len(gr):\n gr2.append(gr[i][0])\n i+=1\n \n def asign(u, W, ew):\n if size[u] == 1:\n return\n \n cur = 0\n for v in g[u]:\n if v == p[u]: continue\n \n first = W[cur]\n ew.append((u, v, first))\n \n W_ = [x - first for x in W[cur+1: cur+size[v]]]\n asign(v, W_, ew)\n \n cur+=size[v]\n\n a, b = 0, 0\n for x in gr1:\n a += size[x]\n \n for x in gr2:\n b += size[x]\n \n arr_1 = [x for x in range(1, a+1)] \n arr_2 = [i*(a+1) for i in range(1, b+1)] \n ew = []\n\n cur = 0\n for u in gr1:\n first = arr_1[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_1[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n cur = 0\n for u in gr2:\n first = arr_2[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_2[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n for u, v, w in ew:\n print('{} {} {}'.format(u, v, w))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "07bc8e901af0fb468c2c7b0e97848092", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import math\n\nn = int(input())\n\nif n == 1:\n print()\nelse: \n edge = [list(map(int, input().split())) for i in range(1, n) ]\n g = {}\n\n for x, y in edge:\n if x not in g:\n g[x] = []\n if y not in g:\n g[y] = []\n \n g[x].append(y)\n g[y].append(x)\n \n def find_centroid(g):\n p = {}\n size = {}\n \n p[1] = -1\n Q = [1] \n \n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n cur = 1 \n n = size[cur]\n \n while True:\n max_ = n - size[cur] \n ind_ = p[cur]\n \n for v in g[cur]:\n if v == p[cur]: continue\n \n if size[v] > max_: \n max_ = size[v]\n ind_ = v\n \n if max_ <= n // 2:\n return cur\n \n cur = ind_\n \n def find_center(g): \n d = {}\n d[1] = 0\n Q = [(1, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n s = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n s = u\n \n d = {}\n pre = {}\n d[s] = 0\n Q = [(s, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n pre[v] = u\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n e = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n e = u\n \n route = [e]\n while pre[route[-1]] != s:\n route.append(pre[route[-1]])\n \n print(route)\n return route[len(route) // 2]\n\n root = find_centroid(g)\n p = {}\n size = {}\n Q = [root]\n p[root] = -1\n\n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n gr = [(u, size[u]) for u in g[root]]\n gr = sorted(gr, key=lambda x:x[1])\n thres = math.ceil((n-1) / 3) \n sum_ = 0\n\n gr1 = []\n gr2 = []\n i = 0\n \n while sum_ < thres:\n gr1.append(gr[i][0])\n sum_ += gr[i][1]\n i+=1\n \n while i < len(gr):\n gr2.append(gr[i][0])\n i+=1\n \n def asign(u, W, ew):\n if size[u] == 1:\n return\n \n cur = 0\n for v in g[u]:\n if v == p[u]: continue\n \n first = W[cur]\n ew.append((u, v, first))\n \n W_ = [x - first for x in W[cur+1: cur+size[v]]]\n asign(v, W_, ew)\n \n cur+=size[v]\n\n a, b = 0, 0\n for x in gr1:\n a += size[x]\n \n for x in gr2:\n b += size[x]\n \n arr_1 = [x for x in range(1, a+1)] \n arr_2 = [i*(a+1) for i in range(1, b+1)] \n ew = []\n\n cur = 0\n for u in gr1:\n first = arr_1[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_1[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n cur = 0\n for u in gr2:\n first = arr_2[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_2[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n for u, v, w in ew:\n print('{} {} {}'.format(u, v, w))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e993f72d4ce3f3d6672ed90b1a37e3bc", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import math\n\nn = int(input())\nedge = [list(map(int, input().split())) for _ in range(n-1) ]\ng = {}\n\nfor x, y in edge:\n if x not in g:\n g[x] = []\n if y not in g:\n g[y] = []\n \n g[x].append(y)\n g[y].append(x)\n\ndef find_center(g): \n d = {}\n d[1] = 0\n Q = [(1, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n s = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n s = u\n \n d = {}\n pre = {}\n d[s] = 0\n Q = [(s, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n pre[v] = u\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n e = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n e = u\n \n route = [e]\n while pre[route[-1]] != s:\n route.append(pre[route[-1]])\n \n return route[len(route) // 2]\n \nroot = find_center(g)\np = {}\nsize = {}\nQ = [root]\np[root] = -1\n\ni = 0\nwhile i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \nfor u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\ngr = [(u, size[u]) for u in g[root]]\ngr = sorted(gr, key=lambda x:x[1])\nthres = math.ceil((n-1) / 3) \nsum_ = 0\n\ngr1 = []\ngr2 = []\ni = 0\n\nwhile sum_ < thres:\n gr1.append(gr[i][0])\n sum_ += gr[i][1]\n i+=1\n \nwhile i < len(gr):\n gr2.append(gr[i][0])\n i+=1\n \ndef asign(u, W, ew):\n if size[u] == 1:\n return\n \n cur = 0\n for v in g[u]:\n if v == p[u]: continue\n \n first = W[cur]\n ew.append((u, v, first))\n \n W_ = [x - first for x in W[cur+1: cur+size[v]]]\n asign(v, W_, ew)\n \n cur+=size[v]\n\na, b = 0, 0\nfor x in gr1:\n a += size[x]\n \nfor x in gr2:\n b += size[x]\n \narr_1 = [x for x in range(1, a+1)] \narr_2 = [i*(a+1) for i in range(1, b+1)] \new = []\n\ncur = 0\nfor u in gr1:\n first = arr_1[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_1[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \ncur = 0\nfor u in gr2:\n first = arr_2[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_2[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \nfor u, v, w in ew:\n print('{} {} {}'.format(u, v, w))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f5642ef9bf1d124066c56fd4fe2ebe3e", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "s = raw_input()\np1 = [1]*10\nfor x in s[1:]:\n p2 = [0]*10\n x = int(x)\n for i in range(10):\n p2[(i+x)/2] += p1[i]\n if (i+x) % 2 != 0:\n p2[(i+x)/2+1] += p1[i]\n p1 = p2\nans = 0\nfor x in p1:\n ans += x\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f6642794bb63a390a73b1c7b662c09e2", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "R = lambda: map(int, input().split())\narr = list(map(int, input()))\nn = len(arr)\ndp = [[0] * 10 for i in range(n)]\nfor i in range(10):\n dp[n - 1][i] = 1\nfor i in range(n - 2, -1, -1):\n for j in range(10):\n if (arr[i + 1] + j) % 2 == 0:\n dp[i][j] = dp[i + 1][(arr[i + 1] + j) // 2]\n else:\n dp[i][j] = dp[i + 1][(arr[i + 1] + j) // 2] + dp[i + 1][(arr[i + 1] + j + 1) // 2]\nownIn = 1\nfor i in range(n - 1):\n if (arr[i] + arr[i + 1]) != arr[i + 1] * 2 and (arr[i] + arr[i + 1]) != arr[i + 1] * 2 - 1:\n ownIn = 0\nprint(sum(dp[0]) - ownIn)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9479a8c21d615aaff88e21cfb04e7372", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = list(map(int, input()))\ndp = [[1] * 10]\nfor i in range(1, len(n)):\n dp.append([0] * 10)\n for j in range(10):\n x = j + n[i]\n dp[i][x // 2] += dp[i - 1][j]\n if x % 2:\n dp[i][x // 2 + 1] += dp[i - 1][j]\nprint(sum(dp[-1]))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1f437c03da95b3a807350368d0e55675", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "PyPy 3", "source_code": "from math import floor,ceil\n\ndef find_possible_number(guess_number,digit,possible_table):\n if digit==len(phone_numbers):#base condition\n return 1\n \n m_number=int(phone_numbers[digit])\n guess_number=int(guess_number)\n \n num_index_configuration=str(guess_number)+str(digit) \n if num_index_configuration in possible_table:\n return possible_table[num_index_configuration] \n possible_table[num_index_configuration]=0\n \n has_remainder=(m_number+guess_number)%2\n if has_remainder:\n has_remainder_case(m_number, guess_number, possible_table, num_index_configuration, digit)\n return possible_table[num_index_configuration]\n else:\n has_no_remainder_case(m_number, guess_number, possible_table, num_index_configuration, digit)\n return possible_table[num_index_configuration]\n\n\ndef has_remainder_case(m_number, guess_number, possible_table, num_index_configuration, digit):\n upper_number=ceil((m_number+guess_number)/2)\n possible_table[num_index_configuration]+=find_possible_number(upper_number,digit+1,possible_table)\n lower_number=floor((m_number+guess_number)/2)\n possible_table[num_index_configuration]+=find_possible_number(lower_number,digit+1,possible_table)\n \n \ndef has_no_remainder_case(m_number, guess_number, possible_table, num_index_configuration, digit):\n next_number=(m_number+guess_number)/2\n possible_table[num_index_configuration]+=find_possible_number(next_number,digit+1,possible_table)\n\ndef has_exception(number):\n for i in range(1,len(phone_numbers)-1): \n \n if (int(phone_numbers[i])+number)%2:\n upper=ceil((int(phone_numbers[i])+number)/2)\n lower=floor((int(phone_numbers[i])+number)/2)\n if upper==int(phone_numbers[i]):\n number=int(phone_numbers[i]) \n elif lower==int(phone_numbers[i]):\n number=int(phone_numbers[i]) \n else:\n return False\n else:\n if (int(phone_numbers[i])+number)/2==int(phone_numbers[i]):\n number = int(phone_numbers[i])\n else:\n return False\n return True\n\n\nphone_numbers=input()\npossible_table={}#with the format of [\"ab\"]=c. a for number, b for digit, c for possible ways\nfirst_number=phone_numbers[0]\ncount=0\nfor i in range(10):\n count+=find_possible_number(i,1,possible_table)\nif has_exception(int(phone_numbers[0])):\n count-=1\n\n#print(possible_table)\nprint(count)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "311b966c8fb31bea0fe3971d663a1d95", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.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\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": "2a25d3873628d8dcb5c70aa7768ca577", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.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 == 0:\n if n % 2 == 0:\n if g == 0:\n print 1\n else:\n print 0\n else:\n if g == 1:\n print 0\n else:\n print 1\n exit(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 % MOD + MOD) % MOD \nelse:\n print ((C - total + MOD) % MOD + MOD) % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2388738888291133b35bf8e07e615cd4", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "import operator as op\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n \ndef ncr(n, r):\n r = min(r, n-r)\n if r == 0: return 1\n numer = reduce(op.mul, xrange(n, n-r, -1))\n denom = reduce(op.mul, xrange(1, r+1))\n return numer//denom\n\nN,M,G = map(int, raw_input().split())\ndef q(n):\n\treturn ncr(n+M, M)\n\nmod = 1000000007\nr = [0] * (N+M+1)\nr[1] = 1;\nfor i in range(2, N+M+1):\n\tr[i] = (mod - (mod/i) * r[mod%i] % mod) % mod;\n#~ print r\t\n\ndef f(n):\n\tn -= 1\n\tsign = 1 if (n%2 == 0) else -1\n\tres = 0\n\tk = 0\n\t\n\tbinom = 1\n\t\n\twhile k <= n:\t\t\n\t\tres = (res + sign * binom) % mod\t\n\t\tbinom = (binom * (k+M+1) * r[k+1]) % mod\n\t\t\n\t\tsign *= -1\n\t\tk += 1\n\tif M == 1:\n\t\tres += sign\n\treturn res\nif M == 0:\n\tprint int(G == (N+1)%2)\n\traise SystemExit\n\n\t\t\nif G == 1:\n\tprint f(N)\nelse:\n\tprint q(N)-f(N)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f5cb0507bc5684fd4acce48063d6c5c8", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "import operator as op\ndef ncr(n, r):\n r = min(r, n-r)\n if r == 0: return 1\n numer = reduce(op.mul, xrange(n, n-r, -1))\n denom = reduce(op.mul, xrange(1, r+1))\n return numer//denom\n\nN,M,G = map(int, raw_input().split())\ndef q(n):\n\treturn ncr(n+M, M)\n\t\ndef f(n):\n\tn -= 1\n\tsign = 1\n\tres = 0\n\twhile n >= 0:\n\t\tres += sign * q(n)\n\t\tsign *= -1\n\t\tn -= 1\n\tif M == 1:\n\t\tres += sign\n\treturn res\nif M == 0:\n\tprint int(G == (N+1)%2)\n\traise SystemExit\n\t\n\t\t\nif G == 1:\n\tprint f(N)\nelse:\n\tprint q(N)-f(N)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "32049844e84dd8dc4c82ae4841318cff", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\n\ndef ext_gcd(a, b):\n if b == 0:\n return (a, 1, 0)\n (dp, xp, yp) = ext_gcd(b, a % b)\n return (dp, yp, xp - a//b * yp)\n\ndef mod_solve(a, b, n):\n (d, xp, yp) = ext_gcd(a, n)\n if b % d == 0:\n x0 = xp * (b/d) % n\n return x0\n else:\n return None\n\ndef choose(n, m, MOD):\n result = 1\n if m < n - m:\n m = n - m\n for i in xrange(m+1, n+1):\n result = (result * i) % MOD\n for i in xrange(1, n-m+1):\n result = (result * mod_solve(i, 1, MOD)) % MOD\n return result\n\nMOD = 1000000007\n(n, m, g) = map(lambda x: int(x), raw_input().split())\nif n == 0:\n if (m == 1 and g == 1) or (m > 1 and g == 0):\n result = 1\n else:\n result = 0\n print(result)\n sys.exit(0)\n\nif m == 0:\n if (n % 2 == 0 and g == 1) or (n % 2 == 1 and g == 1):\n result = 1\n else:\n result = 0\n print(result)\n sys.exit(0)\n\nterm = 1\nresult = term\nfor i in xrange(1, n+1):\n term = (term * (m + i) * mod_solve(i, 1, MOD)) % MOD\n if i % 2 == 0:\n result = (result + term) % MOD\n else:\n result = (result + MOD - term) % MOD\nif n % 2 == 1:\n result = (MOD - result) % MOD\nif m == 1:\n if n % 2 == 0:\n result = (result + MOD - 1) % MOD\n else:\n result = (result + 1) % MOD\nif g == 1:\n result = (choose(n+m, m, MOD) + MOD - result) % MOD\nprint(result)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b207e78f67b60d586b4c7dd450230e5", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\n\ndef ext_gcd(a, b):\n if b == 0:\n return (a, 1, 0)\n (dp, xp, yp) = ext_gcd(b, a % b)\n return (dp, yp, xp - a//b * yp)\n\ndef mod_solve(a, b, n):\n (d, xp, yp) = ext_gcd(a, n)\n if b % d == 0:\n x0 = xp * (b/d) % n\n return x0\n else:\n return None\n\ndef choose(n, m, MOD):\n result = 1\n for i in xrange(1, n+1):\n result = (result * i) % MOD\n for i in xrange(1, n-m+1):\n result = (result * mod_solve(i, 1, MOD)) % MOD\n for i in xrange(1, m+1):\n result = (result * mod_solve(i, 1, MOD)) % MOD\n return result\n\nMOD = 1000000007\n(n, m, g) = map(lambda x: int(x), raw_input().split())\nif n == 0:\n if (m == 1 and g == 1) or (m > 1 and g == 0):\n result = 1\n else:\n result = 0\n print(result)\n sys.exit(0)\n\nif m == 0:\n if (n % 2 == 0 and g == 1) or (n % 2 == 1 and g == 1):\n result = 1\n else:\n result = 0\n print(result)\n sys.exit(0)\n\nterm = 1\nresult = term\nfor i in xrange(1, n+1):\n term = (term * (m + i) * mod_solve(i, 1, MOD)) % MOD\n if i % 2 == 0:\n result = (result + term) % MOD\n else:\n result = (result + MOD - term) % MOD\nif n % 2 == 1:\n result = (MOD - result) % MOD\nif m == 1:\n if n % 2 == 0:\n result = (result + MOD - 1) % MOD\n else:\n result = (result + 1) % MOD\nif g == 1:\n result = (choose(n+m, m, MOD) + MOD - result) % MOD\nprint(result)\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e63997e60f8a698ecb39f75b5604a709", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "k, a, b = map(int, input().split())\nm = 1000000007\nd = a * pow(b, m - 2, m) % m\nc = pow(a + b, m - 2, m)\nu, v = [0] * k, [0] * k\nfor s in range(k, 0, -1):\n v[s - 1] = s + d\n for i in range(s, k):\n j = max(i - s, s - 1)\n v[i] = c * (a * u[i] + b * (s + v[j])) % m\n u, v = v, u\nprint(u[k - 1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fcdbce7cfd22a3bd86cd8f07f20f7d21", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\ninput=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": "a54794a847fc70f1ef1f1f91189b7915", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import sys\ninput=sys.stdin.readline\ndp={}\nmod=int(1000000007)\nsys.setrecursionlimit(100000)\ndef bigmod(n,p):\n n,p=int(n),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": "b0e5238e1b8ff14c2c07bc0518c0e7a0", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "#908D\nn,a,b = map(int,raw_input().split())\n\np = 1000000007\n\ndef inv(a):\n p = 1000000007\n s=1\n n=p-2\n while n:\n if n&1:\n s=s*a%p\n a=a*a%p\n n/=2\n return s\nf=[[0 for i in range(1001)] for j in range(1001)]\nu=a*inv(a+b)%p\nv=(1-u+p)%p\nc=u*inv(v)%p\nfor i in range(n,0,-1):\n for j in range(n-1,-1,-1):\n if j+i>=n:\n f[i][j]=(j+i+c)%p\n else:\n f[i][j]=(u*f[i+1][j]+v*f[i][j+i])%p\nprint f[1][0]\n\n\"\"\"\n#include\ntypedef long long ll;\nconst int p=1e9+7;\nll inv(ll a){\n\tll s=1;\n\tfor(int n=p-2;n;n>>=1){\n\t\tif(n&1)s=s*a%p;\n\t\ta=a*a%p;\n\t}\n\treturn s;\n}\nint n,a,b,f[1001][1001];\nint main(){\n\tscanf(\"%d%d%d\",&n,&a,&b);\n\tll u=a*inv(a+b)%p,v=(1-u+p)%p,c=u*inv(v)%p;\n\tfor(int i=n;i;--i)\n\t\tfor(int j=n-1;~j;--j)\n\t\t\tf[i][j]=(j+i>=n?j+i+c:u*f[i+1][j]+v*f[i][j+i])%p;\n\tprintf(\"%d\\n\",f[1][0]);\n}\n\"\"\"", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d189d7d6a08fbc2fb184607934f2b91f", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "import math\nimport sys\n\nk, pa, pb = list( map( int, input().split() ) )\n\nmemo = {}\n\nsys.setrecursionlimit(1500*1500*2)\n\nMOD = (10**9 + 7 )\n\ndef pow( a, b ):\n\n ret = 1\n\n while b > 0:\n\n if b & 1:\n ret = (ret*a)%MOD\n\n a = (a*a)%MOD\n\n b //= 2\n\n return ( ret )\n\ndef inv(a):\n return pow( a, MOD-2 )\n\ndef f( total_a, total_ab ):\n\n if total_a+total_ab >= k:\n return total_a+total_ab + pa * inv(pb)\n\n if (total_a,total_ab) in memo:\n return memo[ (total_a,total_ab) ]\n\n Best = 0\n\n Best += pa * f( total_a+1, total_ab ) * inv( pa + pb )\n Best %= MOD\n\n Best += pb * f( total_a, total_a+total_ab ) * inv( pa + pb )\n Best %= MOD\n\n memo[ (total_a,total_ab) ] = Best\n\n return ( Best )\n\n#print( k, pa, pb )\n\nprint( ( f(1,0) ) % MOD )\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd5568cf8bd12b8dce0de63a6b530373", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\na, b = map(int, input().split())\npodE = a // (m * k)\nif a % (m * k) != 0:\n podE += 1\npodN = b // (m * k)\nif b % (m * k) != 0:\n podN += 1\netE = (a % (m * k)) // k\nif (a % (m * k)) % k != 0:\n etE += 1\netN = (b % (m * k)) // k\nif (b % (m * k)) % k != 0:\n etN += 1\n\nif podE == podN and etE == etN:\n print(0)\nelif podE == podN:\n print(min(abs(etE - etN) * 5, 10 + abs(etE - etN)))\nelse:\n down = min((etE - 1) * 5, 10 + (etE - 1))\n move = min(abs(podE - podN), (n - podE) + podN) * 15\n up = min((etN - 1) * 5, 10 + (etN - 1))\n print(down + move + up)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bc40d7919010dcd697bff17e9f549df1", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "x = list(map(int, input().split()))\na, b = map(int, input().split())\nn = x[0]\nm = x[1]\nk = x[2]\nl1 = 0\np1 = 0\nl2 = 0\np2 = 0\nt = 0\nif a < m * k:\n p1 = 1\nelse:\n if a % (m * k) == 0:\n p1 = a // (m * k)\n else:\n p1 = a // (m * k) + 1\nif (a - (p1 - 1) * m * k) < k:\n l1 = 1\nelse:\n if (a - (p1 - 1) * m * k) % k == 0:\n l1 = (a - (p1 - 1) * m * k) // k\n else:\n l1 = (a - (p1 - 1) * m * k) // k + 1\nif b < m * k:\n p2 = 1\nelse:\n if b % (m * k) == 0:\n p2 = b // (m * k)\n else:\n p2 = b // (m * k) + 1\nif (b - (p2 - 1) * m * k) < k:\n l2 = 1\nelse:\n if (b - (p2 - 1) * m * k) % k == 0:\n l2 = (b - (p2 - 1) * m * k) // k\n else:\n l2 = (b - (p2 - 1) * m * k) // k + 1\nif p1 == p2:\n if l1 == l2:\n t = 0\n else:\n t = min((abs((l1 - l2)) + 10), abs((l1 - l2)) * 5)\nelse:\n if l1 > 1:\n t = min((l1 - 1) * 5, l1 + 10 - 1)\n else:\n t = 0\n t += 15 * min(abs((p1 - p2)), n - p1 + p2)\n if l2 > 1:\n t += min((10 + l2 - 1), (l2 - 1) * 5)\n#print(l1, p1, l2, p2)\nprint(t)\n\n\n\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "96ec241e0b2ed6c839b73ff97173c783", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "[n,m,k]=[int(i) for i in input().split()]\n[n1,n2]=[int(i) for i in input().split()]\ne1=0\ne2=0\np1=n1//(m*k)\nif(p1*m*k!=n1):\n p1+=1\nelse: e1=m\np2=n2//(m*k)\nif(p2*m*k!=n2): p2+=1\nelse:e2=m\nt=0\nt+=min(abs(p2-p1),min(p2+abs(n-p1),p1+abs(n-p2)))*15\nif (e1==0):\n e1=n1%(m*k)//k\n if(n1%k!=0): e1+=1\nif (e2==0):\n e2=n2%(m*k)//k\n if(n2%k!=0): e2+=1\nif(e1<4):\n t+=(e1-1)*5\nif(e2<4):\n t+=(e2-1)*5\nif(e1>=4):\n t+=10+e1-1\nif (e2 >= 4):\n t += 10 + e2 - 1\nprint(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63c221150dae3496730024b4832b9c3c", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\na, b = map(int, input().split())\npodE = a // (m * k)\nif a % (m * k) != 0:\n podE += 1\npodN = b // (m * k)\nif b % (m * k) != 0:\n podN += 1\netE = (a % (m * k)) // k\nif (a % (m * k)) % k != 0:\n etE += 1\netN = (b % (m * k)) // k\nif (b % (m * k)) % k != 0:\n etN += 1\nif podE == 0:\n podE = n\nif etE == 0:\n etE = m\nif podN == 0:\n podN = n\nif etN == 0:\n etN = m\n\nif podE == podN and etE == etN:\n print(0)\nelif podE == podN:\n print(min(abs(etE - etN) * 5, 10 + abs(etE - etN)))\nelse:\n down = min((etE - 1) * 5, 10 + (etE - 1))\n move = min(abs(podE - podN), (n - podE) + podN) * 15\n up = min((etN - 1) * 5, 10 + (etN - 1))\n print(down + move + up)\n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c15274902c2531cc88ba9c3b25e91b9a", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "[n,m,k]=[int(i) for i in input().split()]\n[n1,n2]=[int(i) for i in input().split()]\ne1=0\ne2=0\np1=n1//(m*k)\nif(p1*m*k!=n1):\n p1+=1\nelse: e1=m\np2=n2//(m*k)\nif(p2*m*k!=n2): p2+=1\nelse:e2=m\nt=0\nt+=min(min(abs(p2-p1),abs(n+p1-p2)),abs(n+p2-p1))*15\nif (e1==0):\n e1=n1%(m*k)//k\n if(n1%k!=0): e1+=1\nif (e2==0):\n e2=n2%(m*k)//k\n if(n2%k!=0): e2+=1\nif(e1<4):\n t+=(e1-1)*5\nif(e2<4):\n t+=(e2-1)*5\nif(e1>=4):\n t+=10+e1-1\nif (e2 >= 4):\n t += 10 + e2 - 1\nprint(t)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e7d619b3412dca86ddf32fe6193496e", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "Python 3", "source_code": "v = int(input())\neps = 170\n\ndef ans(a):\n a.sort()\n if len(a) % 2 == 0:\n med = a[len(a)//2]\n else:\n med = (a[len(a)//2] + a[len(a)//2 - 1]) // 2\n\n l = med - med // 2\n r = med + med // 2\n\n c1 = c2 = 0\n\n for i in a:\n if i >= l and i <= r:\n c1 += 1\n else:\n c2 += 1\n\n if abs(c1 - c2) <= eps:\n return (med, \"uniform\")\n else:\n return (med, \"poisson\")\n\n \n\nfor i in range(v):\n cur = [int(i) for i in input().split()]\n b = ans(cur)\n if b[1] == \"poisson\":\n print(b[0])\n else:\n print(sum(cur) // len(cur))\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "94b8d695efcd83d338b88632f0670816", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "v = int(input())\neps = 170\n\ndef ans(a):\n a.sort()\n if len(a) % 2 == 0:\n med = a[len(a)//2]\n else:\n med = (a[len(a)//2] + a[len(a)//2 - 1]) // 2\n\n l = med - med // 2\n r = med + med // 2\n\n c1 = c2 = 0\n\n for i in a:\n if i >= l and i <= r:\n c1 += 1\n else:\n c2 += 1\n\n if abs(c1 - c2) <= eps:\n return (med, \"uniform\")\n else:\n return (med, \"poisson\")\n\n \n\nfor i in range(v):\n cur = [int(i) for i in input().split()]\n b = ans(cur)\n if b[1] == \"poisson\":\n print(b[0])\n else:\n print(sum(cur) // (max(cur) - min(a)))\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "647270ed43bb10195fa009b8b2613c8f", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.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 int(m)\n else:\n return (max(seq)+1)/2\n \nV = int(raw_input())\nseqs = [map(int, raw_input().split()) for i in xrange(V)]\n\nfor seq in seqs:\n print solve(seq)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f552ea10da645754bd153d90bcc9db98", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "def sampleVariance(V):\n X = sum(V) / len(V)\n S = 0.0\n for x in V:\n S += (X-x)**2\n\n S /= (len(V)-1)\n return (X, S)\n\n#That awkward moment when you realized that variance is sigma^2 but you just took the stat course this semester\nfor i in range(int(input())):\n V = list(map(int, input().split()))\n X, S = sampleVariance(V)\n v1 = X\n v2 = (2*X) ** 2 / 12\n\n if abs(v1-S) < abs(v2-S):\n print(int(X))\n else:\n print((max(V)+min(V)) // 2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "65080cb2a29e3d036c97b54a57d2d61b", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "v = int(input())\neps = 170\n\ndef ans(a):\n a.sort()\n if len(a) % 2 == 0:\n med = a[len(a)//2]\n else:\n med = (a[len(a)//2] + a[len(a)//2 - 1]) // 2\n\n l = med - med // 2\n r = med + med // 2\n\n c1 = c2 = 0\n\n for i in a:\n if i >= l and i <= r:\n c1 += 1\n else:\n c2 += 1\n\n if abs(c1 - c2) <= eps:\n return (med, \"uniform\")\n else:\n return (med, \"poisson\")\n\n \n\nfor i in range(v):\n cur = [int(i) for i in input().split()]\n b = ans(cur)\n if b[1] == \"poisson\":\n print(b[0])\n else:\n print((max(cur) - min(cur)) // 2)\n \n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fd93fa8092a42225cea9250a998c8918", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict as dd\nimport sys\ninput=sys.stdin.readline\nn=int(input())\nl=list(map(int,input().split()))\nif(len(l)>60):\n print(1)\nelse:\n xo=[l[0]]\n for i in range(1,n):\n xo.append(l[i]^xo[-1])\n ans=-1\n for gap in range(1,100):\n for i in range(n):\n j=i+gap\n if(j>=n):\n continue\n if(i>0):\n val=xo[j]^xo[i-1]\n if(vall[j+1]):\n ans=gap\n break\n if(ans!=-1):\n break\n #print(ans)\n if(ans==-1):\n ans=n\n for i in range(2,n):\n ll=i+2\n #print(n,l)\n for ii in range(n-ll+1):\n j=ii+ll-1\n #print(ii,j,le)\n for m in range(1,ll-2):\n if(ii>0):\n le=xo[ii+m]^xo[ii-1]\n else:\n le=xo[ii+m]\n #print(j,ii+m-1,\"lol\")\n re=xo[j]^xo[ii+m]\n #if(i==21):\n #print(le,re,ii,ii+m,j)\n if(le>re):\n ans=min(i,ans)\n break\n if(ans!=n):\n break\n if(ans!=n):\n break\n for i in range(n-1):\n cx=l[i]^l[i+1]\n if(i>0):\n if(cxl[i+2]):\n ans=1\n break\n if(ans==n):\n print(-1)\n else:\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f798851c04cb7e667f5c86bf67b941ca", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "PyPy 3", "source_code": "from collections import defaultdict as dd\nimport sys\ninput=sys.stdin.readline\nn=int(input())\nl=list(map(int,input().split()))\nif(len(l)>60):\n print(1)\nelse:\n xo=[l[0]]\n for i in range(1,n):\n xo.append(l[i]^xo[-1])\n ans=n\n \n for i in range(2,n):\n ll=i+2\n #print(n,l)\n for ii in range(n-ll+1):\n j=ii+ll-1\n #print(ii,j,le)\n for m in range(1,ll-2):\n if(ii>0):\n le=xo[ii+m]^xo[ii-1]\n else:\n le=xo[ii+m]\n #print(j,ii+m-1,\"lol\")\n re=xo[j]^xo[ii+m]\n #print(le,re,ii,ii+m,j)\n if(le>re):\n ans=i\n break\n if(ans!=n):\n break\n if(ans!=n):\n break\n for i in range(n-1):\n cx=l[i]^l[i+1]\n if(i>0):\n if(cxl[i+2]):\n ans=1\n break\n if(ans==n):\n print(-1)\n else:\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "040a996a6ed36f7d715baafd621685f7", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"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 > 65:\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": "9a83f971ba3f4a70d119c2e695bfffaf", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "PyPy 3", "source_code": "from itertools import accumulate as __accumulate\nfrom math import inf as __inf, isinf as __isinf\n\n\ndef how_many_operations_need(seq):\n seq = list(seq)\n if any(seq[i] > seq[i+1] for i in range(len(seq) - 1)):\n return 0\n max_bits_indices = tuple(map(__get_max_bit_index, seq))\n for i in range(len(max_bits_indices) - 2):\n if max_bits_indices[i] == max_bits_indices[i+1] == max_bits_indices[i+2]:\n return 1\n \n prefix_xors = [0, *__accumulate(seq, int.__xor__)]\n \n result = +__inf\n for l in range(len(seq)-1):\n for r in range(l+1, len(seq)):\n left_value = seq[l-1] if l-1 >= 0 else -__inf\n right_value = seq[r+1] if r+1 < len(seq) else +__inf\n if not (left_value <= prefix_xors[r+1] ^ prefix_xors[l] <= right_value):\n result = min(result, r - l)\n \n if __isinf(result):\n raise ValueError\n return result\n\n\ndef __get_max_bit_index(x):\n i = -1\n while x:\n x >>= 1\n i += 1\n return i\n\n\ndef __main():\n __read_ints() # skip n\n try:\n result = how_many_operations_need(__read_ints())\n except ValueError:\n print(-1)\n else:\n print(result)\n\n\ndef __read_ints():\n return map(int, input().split())\n\n\nif __name__ == \"__main__\":\n __main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "00f5ec0175225bc56ec99bdf137f30a9", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "PyPy 3", "source_code": "def xor(i, j):\n if i == 0:\n return p[j]\n return p[j] ^ p[i - 1]\n\n\nn = int(input())\nu = list(map(int, input().split()))\np = u[:]\n\nk = 32\nans = 1000000000000\nfor i in range(n):\n for j1 in range(i, max(-1, i - k - 1), -1):\n for j2 in range(i + 1, min(n, i + k + 1)):\n x1 = xor(j1, i)\n x2 = xor(i + 1, j2)\n #print(x1, x2, j1, i, j2)\n if x1 > x2:\n ans = min(ans, j2 - j1 - 1)\nif ans == 1000000000000:\n print(-1)\nelse:\n print(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "18d506cd90ee453fce1becc943788ecd", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\n# awfdsajgnjisgjnsfdin\n\ninp = [int(x) for x in sys.stdin.read().split()]; ii = 0\n\nn = inp[ii]; ii += 1\ncoupl = [[] for _ in range(n)]\nfor _ in range(n - 1):\n u = inp[ii] - 1; ii += 1\n v = inp[ii] - 1; ii += 1\n coupl[u].append(v)\n coupl[v].append(u)\n\nroot = 0\nbfs = [root]\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n\ncounter = [0] * n\nfor node in reversed(bfs):\n counter[node] += 1\n for nei in coupl[node]:\n counter[node] += counter[nei]\n\nnhalf = n // 2\n\nfor node in range(n):\n vals = [counter[nei] for nei in coupl[node]]\n vals.append(n - 1 - sum(vals))\n if max(vals) <= nhalf:\n break\nroot = node\n\nfor node in reversed(bfs):\n for nei in coupl[node]:\n coupl[nei].append(node)\n\nfound = [0] * n\ndepth = [0] * n\n\norder = []\nstack = [root]\nwhile stack:\n node = stack.pop()\n if found[node]:\n continue\n found[node] = 1\n order.append(node)\n\n for nei in coupl[node]:\n if not found[nei]:\n depth[nei] = depth[node] + 1\n stack.append(nei)\n stack += coupl[node]\n\nans = [-1] * n\nfor i in range(n):\n ans[order[i - nhalf]] = order[i]\n\nprint 2 * sum(depth)\nprint ' '.join(str(x + 1) for x in ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa58eacb546014d52b6869e7580eaaef", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "import sys;range = xrange;input = raw_input;inp = [int(x) for x in sys.stdin.read().split()]; ii = 0;n = inp[ii]; ii += 1;coupl = [[] for _ in range(n)]\nfor _ in range(n - 1):u = inp[ii] - 1; ii += 1;v = inp[ii] - 1; ii += 1;coupl[u].append(v);coupl[v].append(u)\nroot = 0;bfs = [root]\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\ncounter = [0] * n;nhalf = n // 2\nfor node in reversed(bfs):\n counter[node] += 1\n for nei in coupl[node]:counter[node] += counter[nei]\nfor node in range(n):\n vals = [counter[nei] for nei in coupl[node]];vals.append(n - 1 - sum(vals))\n if max(vals) <= nhalf:break\nroot = node\nfor node in reversed(bfs):\n for nei in coupl[node]:coupl[nei].append(node)\nfound = [0] * n;depth = [0] * n;order = [];stack = [root];ans = [-1] * n\nwhile stack:\n node = stack.pop()\n if found[node]:continue\n found[node] = 1;order.append(node)\n for nei in coupl[node]:\n if not found[nei]:depth[nei] = depth[node] + 1;stack.append(nei)\n stack += coupl[node]\nfor i in range(n):ans[order[i - nhalf]] = order[i]\nprint 2 * sum(depth);print ' '.join(str(x + 1) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b76e488cce12af0a98342533ce692e43", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "import sys;range = xrange;input = raw_input;inp = [int(x) for x in sys.stdin.read().split()]; ii = 0;n = inp[ii]; ii += 1;coupl = [[] for _ in range(n)]\nfor _ in range(n - 1):u = inp[ii] - 1; ii += 1;v = inp[ii] - 1; ii += 1;coupl[u].append(v);coupl[v].append(u)\nroot = 0;bfs = [root]\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n\ncounter = [0] * n\nfor node in reversed(bfs):\n counter[node] += 1\n for nei in coupl[node]:\n counter[node] += counter[nei]\n\nnhalf = n // 2\n\nfor node in range(n):\n vals = [counter[nei] for nei in coupl[node]]\n vals.append(n - 1 - sum(vals))\n if max(vals) <= nhalf:\n break\nroot = node\n\nfor node in reversed(bfs):\n for nei in coupl[node]:\n coupl[nei].append(node)\n\nfound = [0] * n\ndepth = [0] * n\n\norder = []\nstack = [root]\nwhile stack:\n node = stack.pop()\n if found[node]:\n continue\n found[node] = 1\n order.append(node)\n\n for nei in coupl[node]:\n if not found[nei]:\n depth[nei] = depth[node] + 1\n stack.append(nei)\n stack += coupl[node]\n\nans = [-1] * n\nfor i in range(n):\n ans[order[i - nhalf]] = order[i]\n\nprint 2 * sum(depth)\nprint ' '.join(str(x + 1) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd6004ffe8fb03569436df659aa1649b", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "import sys;range = xrange;input = raw_input;inp = [int(x) for x in sys.stdin.read().split()]; ii = 0;n = inp[ii]; ii += 1;coupl = [[] for _ in range(n)]\nfor _ in range(n - 1):u = inp[ii] - 1; ii += 1;v = inp[ii] - 1; ii += 1;coupl[u].append(v);coupl[v].append(u)\nroot = 0;bfs = [root]\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n\ncounter = [0] * n\nfor node in reversed(bfs):\n counter[node] += 1\n for nei in coupl[node]:counter[node] += counter[nei]\n\nnhalf = n // 2\n\nfor node in range(n):\n vals = [counter[nei] for nei in coupl[node]];vals.append(n - 1 - sum(vals))\n if max(vals) <= nhalf:break\nroot = node\nfor node in reversed(bfs):\n for nei in coupl[node]:coupl[nei].append(node)\nfound = [0] * n;depth = [0] * n;order = [];stack = [root]\nwhile stack:\n node = stack.pop()\n if found[node]:continue\n found[node] = 1;order.append(node)\n\n for nei in coupl[node]:\n if not found[nei]:\n depth[nei] = depth[node] + 1\n stack.append(nei)\n stack += coupl[node]\n\nans = [-1] * n\nfor i in range(n):\n ans[order[i - nhalf]] = order[i]\n\nprint 2 * sum(depth)\nprint ' '.join(str(x + 1) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a076cba805a82eac73f9a4bdb47a520c", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.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\ncoupl = [[] for _ in range(n)]\nfor _ in range(n - 1):\n u = inp[ii] - 1; ii += 1\n v = inp[ii] - 1; ii += 1\n coupl[u].append(v)\n coupl[v].append(u)\n\nroot = 0\nbfs = [root]\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n\ncounter = [0] * n\nfor node in reversed(bfs):\n counter[node] += 1\n for nei in coupl[node]:\n counter[node] += counter[nei]\n\nnhalf = n // 2\n\nfor node in range(n):\n vals = [counter[nei] for nei in coupl[node]]\n vals.append(n - 1 - sum(vals))\n if max(vals) <= nhalf:\n break\nroot = node\n\nfor node in reversed(bfs):\n for nei in coupl[node]:\n coupl[nei].append(node)\n\nfound = [0] * n\ndepth = [0] * n\n\norder = []\nstack = [root]\nwhile stack:\n node = stack.pop()\n if found[node]:\n continue\n found[node] = 1\n order.append(node)\n\n for nei in coupl[node]:\n if not found[nei]:\n depth[nei] = depth[node] + 1\n stack.append(nei)\n stack += coupl[node]\n\nans = [-1] * n\nfor i in range(n):\n ans[order[i - nhalf]] = order[i]\n\nprint 2 * sum(depth)\nprint ' '.join(str(x + 1) for x in ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "10047443f54871bda02402aea60e705a", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "n, t = map(int, input().split())\ns = bin(n + 2)[2:]\nl = len(s)\n\nif t & (t - 1):\n ans = 0\nelse:\n t = t.bit_length()\n f = [[0] * (l + 1) for i in range(l + 1)]\n for i in range(l + 1):\n f[i][0] = f[i][i] = 1\n for j in range(1, i):\n f[i][j] = f[i - 1][j - 1] + f[i - 1][j]\n\n ans = c = 0\n for i in range(l):\n if s[i] == '1':\n if t - c <= l - i - 1:\n ans += f[l - i - 1][t - c]\n c += 1\n if t == 1: ans -= 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7a07426cf123d67ab3a109f5b19da132", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import math\nfrom operator import mul\ndef comb(i, j):\n if j > i or j < 0: return 0\n return reduce(mul, xrange(i, i - j, -1), 1)/reduce(mul, xrange(1, j+1), 1)\n\ndef g(r, p, k):\n s = 0\n p2 = 2 ** p\n while r > 0:\n while r < p2:\n p2 /= 2\n p -= 1\n s += comb(p, k)\n r -= p2\n k -= 1\n if k < 0: break\n return s\n\nn, t = map(int, raw_input().split())\nif math.log(t, 2) - int(math.log(t, 2)) > 1e-5:\n print 0\nelse:\n n += 1\n k = int(math.log(t, 2))\n p = int(math.log(n + 1, 2)) - 1\n ans = comb(p+1, k+1) + g(n - 2**(p+1) + 1, p, k)\n if t == 1: ans -= 1\n print ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8bd531285ed5b8d26d0dcdc10a5a96b", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "from math import factorial as fac\n\nn, t = map(int, input().split())\nif t & (t - 1):\n ans = 0\nelse:\n ans = c = 0\n s = bin(n + 2)[2:] \n l = len(s)\n for i in range(l):\n if s[i] == '1':\n m, k = l - i - 1, t.bit_length() - c\n if 0 <= k <= m:\n ans += fac(m) // fac(k) // fac(m - k)\n c += 1\n if t == 1: ans -= 1\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8e9b7fa775a832bb5a1e076bfe00bebb", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def F(i, n, t):\n\tif i + 1 < t:\n\t\treturn 0\n\tif not t:\n\t\treturn 1\n\tif n & 2 ** i:\n\t\treturn c.get((i, t), 0) + F(i - 1, n ^ 2 ** i, t - 1)\n\telse:\n\t\treturn F(i - 1, n, t)\n\nd = dict((2 ** i, i) for i in range(50))\nc = {(0, 0) : 1}\nfor i in range(1, 50):\n\tc[(i, 0)] = c[(i, i)] = 1\n\tfor j in range(1, i):\n\t\tc[(i, j)] = c[(i - 1, j - 1)] + c[(i - 1, j)]\nn, t = map(int, raw_input().split())\nif t in d:\n\tt = d[t] + 1\n\tprint F(49, n + 1, t) - (t == 1)\nelse:\n\tprint 0", "lang_cluster": "Python", "compilation_error": false, "code_uid": "23b12bcbb82f6b979deb1d4be09e6cfc", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "c = []\n\ndef f(n, t):\n\tx = 0\n\twhile 2 ** x <= n:\n\t\tx += 1\n\tx -= 1\n\tans = c[x][t + 1] if t + 1 <= x else 0\n\tif n > 2 ** x and t > 0:\n\t\tans += f(n - 2 ** x, t - 1)\n\t\tif t == 1:\n\t\t\tans += 1\n\treturn ans\n\nc.append([1])\nfor i in range(1, 60):\n\tq = [1]\n\tfor j in range(1, i):\n\t\tq.append(c[-1][j] + c[-1][j - 1])\n\tq.append(1)\n\tc.append(q)\n\nn, t = map(int, raw_input().split())\nn += 1\ntt = 0\nwhile t % 2 == 0:\n\tt /= 2\n\ttt += 1\nif t > 1:\n\tprint 0\nelse:\n\tprint f(n, tt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b1a2c3974549e1819c0e36fbb7389e4", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def gen(i, j):\n if a[i][j] == -1:\n a[i][j] = max(gen(i - 1, j - 1) + s2[i - 1] * (s2[i - 1] == s1[j - 1]), gen(i - 1, j), gen(i, j - 1), key = lambda x: len(x))\n return a[i][j]\n\n\ns1, s2, virus = [input() for x in range(3)]\na = [[''] * (len(s1) + 1)] + [[''] + [-1] * (len(s1)) for x in range(len(s2))]\nans = gen(len(s2), len(s1))\nwhile virus in ans:\n i = ans.index(virus)\n ans = list(ans)\n ans[i + len(virus) - 1] = ''\n ans = ''.join(ans)\nprint(ans + '0' * (ans == ''))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e362d77cfc3773e606e1842c5091770f", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "def Solve(x,y,c):\n if(type(c)!=int):\n print(x,y,c)\n if(c==len(virus)):\n return 0\n if(x==len(s1) or y==len(s2)):\n return \"\"\n if((x,y,c) in Mem):\n return Mem[(x,y,c)]\n ans=\"\"\n if(s1[x]==s2[y]):\n q=0\n if(s1[x]==virus[c]):\n q=Solve(x+1,y+1,c+1)\n else:\n done=False\n for match in T[c]:\n if(s1[x]==virus[match]):\n done=True\n q=s1[x]+Solve(x+1,y+1,match+1)\n break\n if(not done):\n q=s1[x]+Solve(x+1,y+1,0)\n if(q!=0):\n ans=q\n q=Solve(x+1,y,c)\n if(q!=0):\n ans=max(ans,Solve(x+1,y,c),key=len)\n q=Solve(x,y+1,c)\n if(q!=0):\n ans=max(ans,Solve(x,y+1,c),key=len)\n Mem[(x,y,c)]=ans\n return ans\n\nMem={}\ns1=input()\ns2=input()\nvirus=input()\n\nT=[0]*len(virus)\nT[0]=[0]\nT[1]=[0]\nfor i in range(2,len(virus)):\n done=False\n T[i]=[]\n for j in range(1,i):\n if(virus[j:i]==virus[:i-j]):\n T[i].append(i-j)\n T[i].append(0)\n\ne=Solve(0,0,0)\nif(e==\"\"):\n print(0)\nelse:\n print(Solve(0,0,0))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0347dde2c937bf0dbf5d541ac662972c", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from Queue import * # Queue, LifoQueue, PriorityQueue\nfrom bisect import * #bisect, insort\nfrom datetime import * \nfrom collections import * #deque, Counter,OrderedDict,defaultdict\nimport calendar\nimport heapq\nimport math\nimport copy\nimport itertools\n\ndef maxBy(f, x, y):\n if f(x) > f(y):\n return x\n else:\n return y\n\ntable = { (\"\",\"\") : \"\" }\n\ndef lcs(xs,ys):\n if (xs,ys) in table:\n return table[(xs,ys)]\n\n ret = \"\"\n if xs == \"\" or ys == \"\":\n ret = \"\"\n elif xs[-1] == ys[-1]:\n ret = lcs(xs[:-1],ys[:-1]) + xs[-1]\n else:\n ret = maxBy(len,\n lcs(xs[:-1],ys),\n lcs(xs,ys[:-1]))\n table[(xs,ys)] = ret\n return ret\n\ndef make_ans(ans, virus):\n if ans.find(virus) == -1:\n return (len(ans), ans)\n\n target = ans.find(virus)\n ans_list = []\n for i in range(len(virus)):\n new_s = ans[:target+i] + ans[target+i+1:]\n ans_list.append( make_ans(new_s, virus) )\n \n ans_list.sort(reverse = True)\n \n return ans_list[0]\n\n\ndef solver():\n s1 = raw_input()\n s2 = raw_input()\n virus = raw_input()\n \n ans = lcs(s1,s2)\n\n \n ans = make_ans(ans, virus)[1]\n if ans == \"\":\n print 0\n else:\n print ans\n\nif __name__ == \"__main__\":\n solver()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc90f4b7a3cb9078a64379b03f8af094", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "from Queue import * # Queue, LifoQueue, PriorityQueue\nfrom bisect import * #bisect, insort\nfrom datetime import * \nfrom collections import * #deque, Counter,OrderedDict,defaultdict\nimport calendar\nimport heapq\nimport math\nimport copy\nimport itertools\n\ndp = {}\n\ndef long_sequence(i,j,ans_s,s2):\n if dp[(i,j)] == 0:\n return ans_s\n\n\n up = dp[(i-1,j)]\n side = dp[(i,j-1)]\n up_side = dp[(i-1,j-1)]\n \n if up == side and side == up_side and up_side ==dp[i,j] - 1:\n return long_sequence(i-1,j-1,s2[j-1]+ans_s,s2)\n elif side > up:\n return long_sequence(i,j-1,ans_s,s2)\n else:\n return long_sequence(i-1,j,ans_s,s2) \n\n\ndef make_table(s1,s2,virus):\n for i in range(0,len(s1)+1):\n dp[(i,0)] = 0\n for j in range(0,len(s2)+1):\n dp[(0,j)] = 0\n\n \n\n for i in range(0,len(s1)):\n for j in range(0, len(s2)):\n l_s = long_sequence(i,j,\"\",s2)\n l_s += s2[j]\n if s1[i] == s2[j] and l_s.find(virus) == -1:\n dp[(i+1,j+1)] = dp[(i,j)] + 1\n else:\n dp[(i+1,j+1)] = max(dp[(i+1,j)],dp[(i,j+1)])\n \n \ndef print_dp(s1,s2):\n for i in range(0,len(s2)):\n print \"%2d\" % i,\n\n print len(s1)\n\n for i in range(0,len(s1)+1):\n print i,\n for j in range(0,len(s2)+1):\n print \"%2d\" % dp[(i,j)],\n\n print\n\ndef solver():\n s1 = raw_input()\n s2 = raw_input()\n virus = raw_input()\n \n make_table(s1,s2,virus)\n #print_dp(s1,s2)\n ans = long_sequence(len(s1),len(s2),\"\",s2)\n\n\n if ans == \"\":\n print 0\n else:\n print ans\n\nif __name__ == \"__main__\":\n solver()\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "26e3403a5acc6f86090d3f6e07de322c", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "MAX = 101 \nNINF = -22222222222\nbase = [-1]*MAX\ndp = [ [ base[:] for i in range(MAX)] for j in range(MAX)] \ns1 = \"\"\ns2 = \"\"\ns3 = \"\"\nl1 = \"\"\nl2 = \"\"\nl3 = \"\"\n\n\n\ndef foo(i, j, k):\n\tif k == l3 :\n\t\treturn \"\", NINF\n\tif i == l1:\n\t\treturn \"\", 0\n\tif j == l2:\n\t\treturn \"\", 0\n\tif dp[i][j][k] != -1:\n\t\treturn dp[i][j][k]\n\tans1, len1 = foo( i + 1, j, k )\n\tans2, len2 = foo( i , j + 1, k )\n\tlen3 = NINF\n\tif s1[i] == s2[j]:\n\t\tif s1[i] == s3[k]:\n\t\t\tans3, len3 = foo(i+1, j + 1, k + 1)\n\t\t\tans3 += s1[i]\n\t\t\tlen3 += 1\n\t\telse:\n\t\t\tans3, len3 = foo(i+1, j + 1, 0 )\n\t\t\tans3 += s1[i]\n\t\t\tlen3 += 1\n\tif len1 > 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": "823dcbc10bdf23c915887e17f7f909b4", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "def r(): return raw_input().strip()\ndef ri(): return int(r().strip())\ndef riv(): return map(int, r().split())\n\ndiff = {\n (1,1): 0,\n (2,2): 0,\n (3,3): 0,\n (1,2): 1,\n (1,3): 2,\n (2,1): 2,\n (2,3): 1,\n (3,1): 1,\n (3,2): 2\n}\n\ndef main():\n n = ri()\n c = riv()\n\n a = []\n starts, start_comps = [], []\n for i in range(n):\n line = riv()[1:]\n a.append(line)\n if len(line) == 0:\n starts.append(i+1) \n start_comps.append(c[i]) \n\n min_hours = -1\n while starts:\n hours = 1\n down = set()\n start = starts.pop()\n start_comp = start_comps.pop()\n down.add(start)\n while len(down) < n:\n possible = {}\n for i, stage in enumerate(a):\n if i+1 not in down and all([s in down for s in stage]):\n comp = c[i]\n if comp not in possible:\n possible[comp] = []\n possible[comp].append(i+1)\n\n if start_comp in possible:\n for l in possible[start_comp]:\n hours += 1\n down.add(l)\n else:\n nz = min(possible.items(), key=lambda z: diff[(start_comp, z[0])])\n hours += diff[(start_comp, nz[0])]\n start_comp = nz[0]\n for l in nz[1]:\n hours += 1\n down.add(l)\n \n if min_hours == -1 or min_hours > hours:\n min_hours = hours\n \n print min_hours\n \nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cd8b7da645b9c68acd6f432606d9d391", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "from collections import *\n\nread_line = lambda: [int(i) for i in input().split(' ')]\n\nn = read_line()[0]\ncs = [c - 1 for c in read_line()]\ng = [[] for v in range(n)]\nparent_cnt = [0] * n\nfor v in range(n):\n parents = read_line()\n parent_cnt[v] = len(parents) - 1\n for i in range(1, len(parents)):\n g[parents[i] - 1].append(v)\n\ndef work(x):\n pcnt = list(parent_cnt)\n qs = [\n deque(v for v in range(n) if cs[v] == c and pcnt[v] == 0)\n for c in range(3)\n ]\n ans = 0\n while True:\n while qs[x]:\n v = qs[x].popleft()\n ans += 1\n for w in g[v]:\n pcnt[w] -= 1\n if pcnt[w] == 0:\n qs[cs[w]].append(w)\n if qs[0] or qs[1] or qs[2]:\n ans += 1\n x = (x + 1) % 3\n else:\n break\n return ans\n\nprint(min(work(i) for i in range(3)))\n\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bb3511ec17c4871a9094d6d76727ad1e", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def r(): return raw_input().strip()\ndef ri(): return int(r().strip())\ndef riv(): return map(int, r().split())\n\ndiff = {\n (1,1): 0,\n (2,2): 0,\n (3,3): 0,\n (1,2): 1,\n (1,3): 2,\n (2,1): 2,\n (2,3): 1,\n (3,1): 1,\n (3,2): 2\n}\n\ndef main():\n n = ri()\n c = riv()\n\n a = []\n start, start_comp = None, 0\n down = set()\n for i in range(n):\n line = riv()[1:]\n a.append(line)\n if len(line) == 0 and start is None:\n start = i+1\n start_comp = c[i]\n \n hours = 1\n down.add(start)\n while len(down) < n:\n possible = {}\n for i, stage in enumerate(a):\n if i+1 not in down and all([s in down for s in stage]):\n comp = c[i]\n if comp not in possible:\n possible[comp] = []\n possible[comp].append(i+1)\n\n if start_comp in possible:\n for l in possible[start_comp]:\n hours += 1\n down.add(l)\n else:\n nz = min(possible.items(), key=lambda z: diff[(start_comp, z[0])])\n hours += diff[(start_comp, nz[0])]\n start_comp = nz[0]\n for l in nz[1]:\n hours += 1\n down.add(l)\n \n print hours\n \nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "50cf2f6588d9f3baa884e12233b8fecd", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "def r(): return raw_input().strip()\ndef ri(): return int(r().strip())\ndef riv(): return map(int, r().split())\n\ndiff = {\n (1,1): 0,\n (2,2): 0,\n (3,3): 0,\n (1,2): 1,\n (1,3): 2,\n (2,1): 2,\n (2,3): 1,\n (3,1): 1,\n (3,2): 2\n}\n\ndef main():\n n = ri()\n c = riv()\n\n a = []\n start, start_comp = None, 0\n down = set()\n for i in range(n):\n line = riv()[1:]\n a.append(line)\n if len(line) == 0:\n start = i+1\n start_comp = c[i]\n\n # find next stages\n hours = 1\n down.add(start)\n while len(down) < n:\n possible = {}\n for i, stage in enumerate(a):\n if i+1 not in down and all([s in down for s in stage]):\n comp = c[i]\n if comp not in possible:\n possible[comp] = []\n possible[comp].append(i+1)\n\n if start_comp in possible:\n for l in possible[start_comp]:\n hours += 1\n down.add(l)\n else:\n nz = max(possible.items(), key=lambda z: len(z[1]))\n hours += diff[(start_comp, nz[0])]\n start_comp = nz[0]\n for l in nz[1]:\n hours += 1\n down.add(l)\n \n print hours\n \nif __name__ == \"__main__\":\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "720438ae4f711115a1fe504c4997ea62", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ncpts = [int(i) for i in raw_input().split()]\ntasks = [set() for i in xrange(3)]\nfor i in xrange(n):tasks[cpts[i]-1].add(i)\ndepends = [set([int(j)-1 for j in raw_input().split()][1:]) for i in xrange(n)]\nfinish = set()\n\ndef do_task(pos, finish, tasks, depends):\n hours = 0\n while True:\n ns = set()\n for t in tasks[pos]:\n depends[t].difference_update(finish)\n ns.update(depends[t])\n d = tasks[pos].difference(ns)\n if len(d) == 0:break\n finish.update(d)\n tasks[pos].difference_update(d)\n hours += len(d)\n return hours\n\nhours = float('inf')\nfor pos in xrange(3):\n h = 0\n t = [s.copy() for s in tasks]\n d = [d.copy() for d in depends]\n f = set()\n while True:\n h += do_task(pos, f, t, d)\n if len(f) >= n:break\n h += 1\n pos = (pos + 1) % 3\n hours = min(hours, h)\nprint hours\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "548551fce54683e71197d0159c64601f", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.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 level0:\n ii = i\n jj = j\n # Add )\n if i 0 and not (ai==bj=='('):\n ii = i\n jj = j\n # Add )\n if ai == ')':\n ii = i + 1\n if bj == ')':\n jj = j + 1\n if tab[ii][jj][bal - 1] is None:\n tab[ii][jj][bal - 1] = tab[i][j][bal] + 1\n par[ii][jj][bal - 1] = i, j, bal, ')'\n que.append((ii, jj, bal - 1))\n index += 1\n\n i = lena\n j = lenb\n bal = 0\n answer = []\n while (i, j, bal) != (0, 0, 0):\n # print (i,j,bal)\n i, j, bal, symb = par[i][j][bal]\n answer.append(symb)\n print(''.join(reversed(answer)))\n\n\ngo()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "329f651a418e77a03f5998dc1224c0e1", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "def go():\n\n a = input()\n b = input()\n\n tab = [[[None] * 220 for _ in range(len(b)+1)] for _ in range(len(a)+1)]\n par = [[[None] * 220 for _ in range(len(b)+1)] for _ in range(len(a)+1)]\n\n tab[0][0][0] = 0\n que = [(0, 0, 0)]\n index = 0\n while tab[len(a)][len(b)][0] is None:\n i,j,bal = que[index]\n if bal<218:\n #Add (\n ii=i\n jj=j\n if i0:\n ii = i\n jj = j\n # Add )\n if i0:\n ii = i\n jj = j\n # Add )\n if i0:\n answer.append(a[ii-1])\n ii-=1\nwhile jj>0:\n answer.append(b[jj-1])\n jj-=1\n\n\nlevel = 0\nmlev=0\nfor aa in answer:\n if aa=='(':\n level+=1\n else:\n level-=1\n mlev = min(level,mlev)\n\npref = ''\nsuf = ''\n\nif mlev<0:\n pref = -mlev * '('\nlevel -=mlev\nif level>0:\n suf = level*')'\n\nanswer = pref + ''.join(answer) + suf\n\nprint(answer)\n\n\"\"\"\n( ( )) ( ()\n( )) ) ()\n\n(())()()\n\"\"\"\n\n\"\"\"\n()\n(())\n\"\"\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9bea5225d7038704526677f48282f775", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "n, s, k = list(map(int, input().split()))\namounts = list(map(int, input().split()))\ncolors = list(input())\n\ndp = [[-1 in range(k + 1)] in range(n)]\n\ndef getAns(nth, left):\n if left <= 0:\n return 0\n if dp[nth][left] >= 0:\n return dp[nth][left]\n \n ret = 999999999\n for i in range(n):\n if amounts[i] <= amounts[nth]:\n continue\n ret = min(ret, abs(nth - i) + getAns(i, left - amounts[i])\n \n dp[nth][left] = ret\n return ret\n\nans = 999999999\nfor i in range(n):\n ans = min(ans, getAns(i, k - data[i]) + abs(s - 1 - i))\nprint(ans)\n ", "lang_cluster": "Python", "compilation_error": true, "code_uid": "dfb082d6579bcb397fbdc1821e83d30e", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "inf = float('inf')\n\nN,S,K = map(int,raw_input().strip('\\n').split(' '))\nA = map(int,raw_input().strip('\\n').split(' '))\ncolor = raw_input().strip('\\n')\n\n\ndp = [[inf]*(N+5) for k in range(K+5)]\nfor i in range(N):\n dp[A[i]][i] = abs(S-i-1);\n\nfor k in range(K+5):\n for pos in range(N):\n if dp[k][pos] == inf:\n continue\n for newpos in range(N):\n if A[newpos]<=A[pos] or color[newpos] == color[pos]:\n continue\n if k+A[newpos]>K+5:\n continue\n dp[k+A[newpos]][newpos] = min(dp[k+A[newpos]][newpos], dp[k][pos]+abs(newpos-pos))\n\n\nans = int(1e18)\nfor k in range(K,K+5):\n for pos in range(N):\n ans = min(ans,dp[k][pos])\nprint ans\n\n\n\n\n\n# dp = (mintime,last_j,last_c)\n# candies = [(ni,ji,ci)]\n# dp[0][0][1] = S\n# dp[i][k+ni][0] = {c!=ci dp[i-1][k][0] + dp[i-1][k][1]-j)\n# dp[i][k+ni][1] = j \n# dp[i][k+ni][2] = c \n\n# candies = [(n,j,c) for j,(n,c) in enumerate(zip(A,color))]\n# candies = sorted(candies,key=lambda x:x[0])\n\n# dp = []\n# for i in range(N+5):\n# temp = []\n# for j in range(K+5):\n# temp.append([inf,0,0])\n# dp.append(temp)\n\n# for i in range(N+1):\n# dp[i][0][0] = 0\n# dp[i][0][1] = S\n\n# for i in range(1,N+1):\n# ni,ji,ci = candies[i-1]\n# for k in range(K+5): \n# if k= 0:\n return dp[nth][left]\n \n ret = 999999999\n for i in range(n):\n if amounts[i] <= amounts[nth] or colors[i] == colors[nth]:\n continue\n ret = min(ret, abs(nth - i) + getAns(i, left - amounts[i]))\n \n dp[nth][left] = ret\n return ret\n\nans = 999999999\nfor i in range(n):\n ans = min(ans, getAns(i, k - amounts[i]) + abs(s - 1 - i))\nprint(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9634efdb6617e7022820261b7f703566", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "'''input\n5 3 10\n1 2 3 4 5\nRGBRR\n'''\nimport math\ndef solve():\n\tn,s,k = map(int,input().split())\n\ts-=1\n\tr = list(map(int,input().split()))\n\tc = input()\n\tinf = int(1e18)\n\tdp = [[inf for i in range(n+1)] for j in range(k+1)]\n\tspos = [[inf for i in range(n+1)] for j in range(k+1)]\n\t# dp[i][j] = minimum number of steps to get amount i if we start with jth index\n\tfor i in range(0,k+1):\n\t\tfor j in range(0,n):\n\t\t\tif i==0 or i<=r[j]:\n\t\t\t\tdp[i][j] = 0\n\t\t\t\tcontinue\n\t\t\tfor K in range(0,n):\n\t\t\t\tif c[K]!=c[j] and c[K]>c[j]:\n\t\t\t\t\tdp[i][j] = min(dp[i][j],dp[i-r[j]][K]+int(abs(K-j)))\n\tans = min(dp[k][i]+abs(i-s) for i in range(0,n))\n\tif ans==inf:\n\t\tprint(-1)\n\t\treturn\n\tprint(ans)\n\treturn\nt = 1\n#t = int(input())\nwhile t>0:\n\tt-=1\n\tsolve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a9db40d6c56f821da9cc8b72a4359048", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "inf = 10000\nn, s, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(input())\nfor i in range(n):\n if b[i] == 'R':\n b[i] = 0\n elif b[i] == 'G':\n b[i] = 1\n else:\n b[i] = 2\nboxes = [[a[i], b[i], i] for i in range(n)]\nboxes.sort()\nl = boxes[-1][0] * n + 1\ns -= 1\ndp = [[[inf, s] for j in range(l)] for i in range(3)]\nif l < k:\n print(-1)\n exit(0)\ndp[0][0][0] = 0\ndp[1][0][0] = 0\ndp[2][0][0] = 0\nfor i in range(n):\n pos = boxes[i][2]\n clr = boxes[i][1]\n cnt = boxes[i][0]\n for j in range(l - cnt):\n for c in range(3):\n if c == clr:\n continue\n if dp[clr][j + cnt][0] > dp[c][j][0] + abs(dp[c][j][1] - pos) and dp[c][j][1] != pos:\n dp[clr][j + cnt][0] = dp[c][j][0] + abs(dp[c][j][1] - pos)\n dp[clr][j + cnt][1] = pos\nans = min(dp[0][k][0], min(dp[1][k][0], dp[2][k][0]))\nfor i in range(k, l):\n ans = min(min(ans, dp[0][i][0]), min(dp[1][i][0], dp[2][i][0]))\nif ans < inf:\n print(ans)\nelse:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c92f587e415071d458ddc862148ad606", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "a,b,m=map(int,input().split())\nk=s=(10**9)%m\ni=0\nwhile k and i=m:k-=m\nprint(2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c228ea9a2b0b16f610a6722cccddcd35", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if s == 0: break\n if s and s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\ndef test():\n pass\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0c1f92d43078dd52acdbda820628692c", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "a, b, m = map(int, input().split())\nc = (10 ** 9) % m\nans = -1\nfor x in range(1, min(a + 1, m)):\n z = (x * c) % m\n if z == 0:\n continue\n if z + b < m:\n ans = x\n break\nif ans == -1:\n print(2)\nelse:\n s = str(ans)\n s = ('0' * 9 + s)[-9:]\n print(1, s)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "03080a23e217d6d07ba39697a5b75ef0", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if not s: break\n if s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "50aaf60bf61610739642e4792ccc9cfe", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "a, b, m = map(int, input().split())\nt = [0] * m\ns = 10 ** 9 % m\nfor i in range(a):\n k = i * s % m\n if 0 < k < m - b: exit(print(1, str(i).zfill(9)))\n if t[k]: break\n t[k] = 1\nprint(2)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5a9a8fcd17ad7e43be99e122af140bb6", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "PyPy 3", "source_code": "def pr(x):\n d = 2\n while d * d <= x:\n if x % d == 0:\n return 0\n d += 1\n return 1\n\ndef cnt(n, k):\n if not pr(k) or n < k: return 0\n n1 = n // k\n return n1 - sum(cnt(n1, i) for i in range(2, min(k, n1 + 1)))\n \na, b, k = map(int, input().split())\nans = cnt(b, k) - cnt(a - 1, k)\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5c50683792d73d893b5e815e12f069e9", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.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 k > v:\n return 0\n elif k * k > v:\n return 1\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": "774eb7bbb48ad517f60aa4cebf2a8366", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport math\n\nprimes = [\n 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, \n 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, \n 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, \n 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, \n 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, \n 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, \n 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, \n 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, \n 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, \n 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, \n 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, \n 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, \n 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, \n 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, \n 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, \n 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, \n 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, \n 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, \n 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, \n 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, \n 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, \n 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, \n 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, \n 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, \n 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, \n 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, \n 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, \n 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, \n 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, \n 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, \n 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, \n 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, \n 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, \n 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, \n 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, \n 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, \n 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, \n 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, \n 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, \n 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, \n 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, \n 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, \n 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, \n 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, \n 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, \n 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, \n 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, \n 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, \n 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, \n 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, \n 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, \n 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, \n 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, \n 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, \n 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, \n 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, \n 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, \n 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, \n 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, \n 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, \n 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, \n 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, \n 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, \n 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, \n 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, \n 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, \n 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, \n 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, \n 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, \n 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, \n 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, \n 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, \n 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, \n 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, \n 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, \n 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, \n 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, \n 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, \n 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, \n 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, \n 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, \n 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, \n 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, \n 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, \n 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, \n 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, \n 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, \n 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, \n 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, \n 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, \n 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, \n 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, \n 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, \n 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, \n 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, \n 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, \n 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, \n 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, \n 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, \n 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, \n 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, \n 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, \n 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, \n 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, \n 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, \n 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, \n 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, \n 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, \n 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, \n 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, \n 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, \n 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, \n 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, \n 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, \n 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, \n 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, \n 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, \n 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, \n 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, \n 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, \n 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, \n 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, \n 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, \n 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, \n 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, \n 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, \n 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, \n 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, \n 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, \n 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, \n 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, \n 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, \n 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, \n 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, \n 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, \n 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, \n 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, \n 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, \n 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, \n 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, \n 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, \n 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, \n 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, \n 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, \n 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, \n 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, \n 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, \n 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, \n 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, \n 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, \n 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, \n 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, \n 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, \n 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, \n 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, \n 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, \n 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, \n 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, \n 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, \n 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, \n 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, \n 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, \n 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, \n 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, \n 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, \n 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, \n 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, \n 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, \n 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, \n 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, \n 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, \n 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, \n 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, \n 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, \n 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, \n 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, \n 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, \n 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, \n 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, \n 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, \n 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, \n 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, \n 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, \n 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, \n 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, \n 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, \n 15973, 15991, 16001, 16007, 16033, 16057, 16061, 16063, 16067, 16069, \n 16073, 16087, 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, \n 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 16253, 16267, \n 16273, 16301, 16319, 16333, 16339, 16349, 16361, 16363, 16369, 16381, \n 16411, 16417, 16421, 16427, 16433, 16447, 16451, 16453, 16477, 16481, \n 16487, 16493, 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, \n 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 16673, 16691, \n 16693, 16699, 16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, \n 16823, 16829, 16831, 16843, 16871, 16879, 16883, 16889, 16901, 16903, \n 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, \n 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, \n 17099, 17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, \n 17203, 17207, 17209, 17231, 17239, 17257, 17291, 17293, 17299, 17317, \n 17321, 17327, 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, \n 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 17471, 17477, \n 17483, 17489, 17491, 17497, 17509, 17519, 17539, 17551, 17569, 17573, \n 17579, 17581, 17597, 17599, 17609, 17623, 17627, 17657, 17659, 17669, \n 17681, 17683, 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, \n 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, 17881, 17891, \n 17903, 17909, 17911, 17921, 17923, 17929, 17939, 17957, 17959, 17971, \n 17977, 17981, 17987, 17989, 18013, 18041, 18043, 18047, 18049, 18059, \n 18061, 18077, 18089, 18097, 18119, 18121, 18127, 18131, 18133, 18143, \n 18149, 18169, 18181, 18191, 18199, 18211, 18217, 18223, 18229, 18233, \n 18251, 18253, 18257, 18269, 18287, 18289, 18301, 18307, 18311, 18313, \n 18329, 18341, 18353, 18367, 18371, 18379, 18397, 18401, 18413, 18427, \n 18433, 18439, 18443, 18451, 18457, 18461, 18481, 18493, 18503, 18517, \n 18521, 18523, 18539, 18541, 18553, 18583, 18587, 18593, 18617, 18637, \n 18661, 18671, 18679, 18691, 18701, 18713, 18719, 18731, 18743, 18749, \n 18757, 18773, 18787, 18793, 18797, 18803, 18839, 18859, 18869, 18899, \n 18911, 18913, 18917, 18919, 18947, 18959, 18973, 18979, 19001, 19009, \n 19013, 19031, 19037, 19051, 19069, 19073, 19079, 19081, 19087, 19121, \n 19139, 19141, 19157, 19163, 19181, 19183, 19207, 19211, 19213, 19219, \n 19231, 19237, 19249, 19259, 19267, 19273, 19289, 19301, 19309, 19319, \n 19333, 19373, 19379, 19381, 19387, 19391, 19403, 19417, 19421, 19423, \n 19427, 19429, 19433, 19441, 19447, 19457, 19463, 19469, 19471, 19477, \n 19483, 19489, 19501, 19507, 19531, 19541, 19543, 19553, 19559, 19571, \n 19577, 19583, 19597, 19603, 19609, 19661, 19681, 19687, 19697, 19699, \n 19709, 19717, 19727, 19739, 19751, 19753, 19759, 19763, 19777, 19793, \n 19801, 19813, 19819, 19841, 19843, 19853, 19861, 19867, 19889, 19891, \n 19913, 19919, 19927, 19937, 19949, 19961, 19963, 19973, 19979, 19991, \n 19993, 19997, 20011, 20021, 20023, 20029, 20047, 20051, 20063, 20071, \n 20089, 20101, 20107, 20113, 20117, 20123, 20129, 20143, 20147, 20149, \n 20161, 20173, 20177, 20183, 20201, 20219, 20231, 20233, 20249, 20261, \n 20269, 20287, 20297, 20323, 20327, 20333, 20341, 20347, 20353, 20357, \n 20359, 20369, 20389, 20393, 20399, 20407, 20411, 20431, 20441, 20443, \n 20477, 20479, 20483, 20507, 20509, 20521, 20533, 20543, 20549, 20551, \n 20563, 20593, 20599, 20611, 20627, 20639, 20641, 20663, 20681, 20693, \n 20707, 20717, 20719, 20731, 20743, 20747, 20749, 20753, 20759, 20771, \n 20773, 20789, 20807, 20809, 20849, 20857, 20873, 20879, 20887, 20897, \n 20899, 20903, 20921, 20929, 20939, 20947, 20959, 20963, 20981, 20983, \n 21001, 21011, 21013, 21017, 21019, 21023, 21031, 21059, 21061, 21067, \n 21089, 21101, 21107, 21121, 21139, 21143, 21149, 21157, 21163, 21169, \n 21179, 21187, 21191, 21193, 21211, 21221, 21227, 21247, 21269, 21277, \n 21283, 21313, 21317, 21319, 21323, 21341, 21347, 21377, 21379, 21383, \n 21391, 21397, 21401, 21407, 21419, 21433, 21467, 21481, 21487, 21491, \n 21493, 21499, 21503, 21517, 21521, 21523, 21529, 21557, 21559, 21563, \n 21569, 21577, 21587, 21589, 21599, 21601, 21611, 21613, 21617, 21647, \n 21649, 21661, 21673, 21683, 21701, 21713, 21727, 21737, 21739, 21751, \n 21757, 21767, 21773, 21787, 21799, 21803, 21817, 21821, 21839, 21841, \n 21851, 21859, 21863, 21871, 21881, 21893, 21911, 21929, 21937, 21943, \n 21961, 21977, 21991, 21997, 22003, 22013, 22027, 22031, 22037, 22039, \n 22051, 22063, 22067, 22073, 22079, 22091, 22093, 22109, 22111, 22123, \n 22129, 22133, 22147, 22153, 22157, 22159, 22171, 22189, 22193, 22229, \n 22247, 22259, 22271, 22273, 22277, 22279, 22283, 22291, 22303, 22307, \n 22343, 22349, 22367, 22369, 22381, 22391, 22397, 22409, 22433, 22441, \n 22447, 22453, 22469, 22481, 22483, 22501, 22511, 22531, 22541, 22543, \n 22549, 22567, 22571, 22573, 22613, 22619, 22621, 22637, 22639, 22643, \n 22651, 22669, 22679, 22691, 22697, 22699, 22709, 22717, 22721, 22727, \n 22739, 22741, 22751, 22769, 22777, 22783, 22787, 22807, 22811, 22817, \n 22853, 22859, 22861, 22871, 22877, 22901, 22907, 22921, 22937, 22943, \n 22961, 22963, 22973, 22993, 23003, 23011, 23017, 23021, 23027, 23029, \n 23039, 23041, 23053, 23057, 23059, 23063, 23071, 23081, 23087, 23099, \n 23117, 23131, 23143, 23159, 23167, 23173, 23189, 23197, 23201, 23203, \n 23209, 23227, 23251, 23269, 23279, 23291, 23293, 23297, 23311, 23321, \n 23327, 23333, 23339, 23357, 23369, 23371, 23399, 23417, 23431, 23447, \n 23459, 23473, 23497, 23509, 23531, 23537, 23539, 23549, 23557, 23561, \n 23563, 23567, 23581, 23593, 23599, 23603, 23609, 23623, 23627, 23629, \n 23633, 23663, 23669, 23671, 23677, 23687, 23689, 23719, 23741, 23743, \n 23747, 23753, 23761, 23767, 23773, 23789, 23801, 23813, 23819, 23827, \n 23831, 23833, 23857, 23869, 23873, 23879, 23887, 23893, 23899, 23909, \n 23911, 23917, 23929, 23957, 23971, 23977, 23981, 23993, 24001, 24007, \n 24019, 24023, 24029, 24043, 24049, 24061, 24071, 24077, 24083, 24091, \n 24097, 24103, 24107, 24109, 24113, 24121, 24133, 24137, 24151, 24169, \n 24179, 24181, 24197, 24203, 24223, 24229, 24239, 24247, 24251, 24281, \n 24317, 24329, 24337, 24359, 24371, 24373, 24379, 24391, 24407, 24413, \n 24419, 24421, 24439, 24443, 24469, 24473, 24481, 24499, 24509, 24517, \n 24527, 24533, 24547, 24551, 24571, 24593, 24611, 24623, 24631, 24659, \n 24671, 24677, 24683, 24691, 24697, 24709, 24733, 24749, 24763, 24767, \n 24781, 24793, 24799, 24809, 24821, 24841, 24847, 24851, 24859, 24877, \n 24889, 24907, 24917, 24919, 24923, 24943, 24953, 24967, 24971, 24977, \n 24979, 24989, 25013, 25031, 25033, 25037, 25057, 25073, 25087, 25097, \n 25111, 25117, 25121, 25127, 25147, 25153, 25163, 25169, 25171, 25183, \n 25189, 25219, 25229, 25237, 25243, 25247, 25253, 25261, 25301, 25303, \n 25307, 25309, 25321, 25339, 25343, 25349, 25357, 25367, 25373, 25391, \n 25409, 25411, 25423, 25439, 25447, 25453, 25457, 25463, 25469, 25471, \n 25523, 25537, 25541, 25561, 25577, 25579, 25583, 25589, 25601, 25603, \n 25609, 25621, 25633, 25639, 25643, 25657, 25667, 25673, 25679, 25693, \n 25703, 25717, 25733, 25741, 25747, 25759, 25763, 25771, 25793, 25799, \n 25801, 25819, 25841, 25847, 25849, 25867, 25873, 25889, 25903, 25913, \n 25919, 25931, 25933, 25939, 25943, 25951, 25969, 25981, 25997, 25999, \n 26003, 26017, 26021, 26029, 26041, 26053, 26083, 26099, 26107, 26111, \n 26113, 26119, 26141, 26153, 26161, 26171, 26177, 26183, 26189, 26203, \n 26209, 26227, 26237, 26249, 26251, 26261, 26263, 26267, 26293, 26297, \n 26309, 26317, 26321, 26339, 26347, 26357, 26371, 26387, 26393, 26399, \n 26407, 26417, 26423, 26431, 26437, 26449, 26459, 26479, 26489, 26497, \n 26501, 26513, 26539, 26557, 26561, 26573, 26591, 26597, 26627, 26633, \n 26641, 26647, 26669, 26681, 26683, 26687, 26693, 26699, 26701, 26711, \n 26713, 26717, 26723, 26729, 26731, 26737, 26759, 26777, 26783, 26801, \n 26813, 26821, 26833, 26839, 26849, 26861, 26863, 26879, 26881, 26891, \n 26893, 26903, 26921, 26927, 26947, 26951, 26953, 26959, 26981, 26987, \n 26993, 27011, 27017, 27031, 27043, 27059, 27061, 27067, 27073, 27077, \n 27091, 27103, 27107, 27109, 27127, 27143, 27179, 27191, 27197, 27211, \n 27239, 27241, 27253, 27259, 27271, 27277, 27281, 27283, 27299, 27329, \n 27337, 27361, 27367, 27397, 27407, 27409, 27427, 27431, 27437, 27449, \n 27457, 27479, 27481, 27487, 27509, 27527, 27529, 27539, 27541, 27551, \n 27581, 27583, 27611, 27617, 27631, 27647, 27653, 27673, 27689, 27691, \n 27697, 27701, 27733, 27737, 27739, 27743, 27749, 27751, 27763, 27767, \n 27773, 27779, 27791, 27793, 27799, 27803, 27809, 27817, 27823, 27827, \n 27847, 27851, 27883, 27893, 27901, 27917, 27919, 27941, 27943, 27947, \n 27953, 27961, 27967, 27983, 27997, 28001, 28019, 28027, 28031, 28051, \n 28057, 28069, 28081, 28087, 28097, 28099, 28109, 28111, 28123, 28151, \n 28163, 28181, 28183, 28201, 28211, 28219, 28229, 28277, 28279, 28283, \n 28289, 28297, 28307, 28309, 28319, 28349, 28351, 28387, 28393, 28403, \n 28409, 28411, 28429, 28433, 28439, 28447, 28463, 28477, 28493, 28499, \n 28513, 28517, 28537, 28541, 28547, 28549, 28559, 28571, 28573, 28579, \n 28591, 28597, 28603, 28607, 28619, 28621, 28627, 28631, 28643, 28649, \n 28657, 28661, 28663, 28669, 28687, 28697, 28703, 28711, 28723, 28729, \n 28751, 28753, 28759, 28771, 28789, 28793, 28807, 28813, 28817, 28837, \n 28843, 28859, 28867, 28871, 28879, 28901, 28909, 28921, 28927, 28933, \n 28949, 28961, 28979, 29009, 29017, 29021, 29023, 29027, 29033, 29059, \n 29063, 29077, 29101, 29123, 29129, 29131, 29137, 29147, 29153, 29167, \n 29173, 29179, 29191, 29201, 29207, 29209, 29221, 29231, 29243, 29251, \n 29269, 29287, 29297, 29303, 29311, 29327, 29333, 29339, 29347, 29363, \n 29383, 29387, 29389, 29399, 29401, 29411, 29423, 29429, 29437, 29443, \n 29453, 29473, 29483, 29501, 29527, 29531, 29537, 29567, 29569, 29573, \n 29581, 29587, 29599, 29611, 29629, 29633, 29641, 29663, 29669, 29671, \n 29683, 29717, 29723, 29741, 29753, 29759, 29761, 29789, 29803, 29819, \n 29833, 29837, 29851, 29863, 29867, 29873, 29879, 29881, 29917, 29921, \n 29927, 29947, 29959, 29983, 29989, 30011, 30013, 30029, 30047, 30059, \n 30071, 30089, 30091, 30097, 30103, 30109, 30113, 30119, 30133, 30137, \n 30139, 30161, 30169, 30181, 30187, 30197, 30203, 30211, 30223, 30241, \n 30253, 30259, 30269, 30271, 30293, 30307, 30313, 30319, 30323, 30341, \n 30347, 30367, 30389, 30391, 30403, 30427, 30431, 30449, 30467, 30469, \n 30491, 30493, 30497, 30509, 30517, 30529, 30539, 30553, 30557, 30559, \n 30577, 30593, 30631, 30637, 30643, 30649, 30661, 30671, 30677, 30689, \n 30697, 30703, 30707, 30713, 30727, 30757, 30763, 30773, 30781, 30803, \n 30809, 30817, 30829, 30839, 30841, 30851, 30853, 30859, 30869, 30871, \n 30881, 30893, 30911, 30931, 30937, 30941, 30949, 30971, 30977, 30983, \n 31013, 31019, 31033, 31039, 31051, 31063, 31069, 31079, 31081, 31091, \n 31121, 31123, 31139, 31147, 31151, 31153, 31159, 31177, 31181, 31183, \n 31189, 31193, 31219, 31223, 31231, 31237, 31247, 31249, 31253, 31259, \n 31267, 31271, 31277, 31307, 31319, 31321, 31327, 31333, 31337, 31357, \n 31379, 31387, 31391, 31393, 31397, 31469, 31477, 31481, 31489, 31511, \n 31513, 31517, 31531, 31541, 31543, 31547, 31567, 31573, 31583, 31601, \n 31607, 31627, 31643, 31649, 31657, 31663, 31667, 31687, 31699, 31721, \n 31723, 31727, 31729, 31741, 31751, 31769, 31771, 31793, 31799, 31817,\n 31847, 31849, 31859, 31873, 31883, 31891, 31907, 31957, 31963, 31973,\n 31981, 31991, 32003, 32009, 32027, 32029, 32051, 32057, 32059, 32063,\n 32069, 32077, 32083, 32089, 32099, 32117, 32119, 32141, 32143, 32159,\n 32173, 32183, 32189, 32191, 32203, 32213, 32233, 32237, 32251, 32257,\n 32261, 32297, 32299, 32303, 32309, 32321, 32323, 32327, 32341, 32353,\n 32359, 32363, 32369, 32371, 32377, 32381, 32401, 32411, 32413, 32423,\n 32429, 32441, 32443, 32467, 32479, 32491, 32497, 32503, 32507, 32531,\n 32533, 32537, 32561, 32563, 32569, 32573, 32579, 32587, 32603, 32609,\n 32611, 32621, 32633, 32647, 32653, 32687, 32693, 32707, 32713, 32717,\n 32719, 32749, 32771, 32779, 32783, 32789, 32797, 32801, 32803, 32831,\n 32833, 32839, 32843, 32869, 32887, 32909, 32911, 32917, 32933, 32939,\n 32941, 32957, 32969, 32971, 32983, 32987, 32993, 32999, 33013, 33023,\n 33029, 33037, 33049, 33053, 33071, 33073, 33083, 33091, 33107, 33113,\n 33119, 33149, 33151, 33161, 33179, 33181, 33191, 33199, 33203, 33211,\n 33223, 33247, 33287, 33289, 33301, 33311, 33317, 33329, 33331, 33343,\n 33347, 33349, 33353, 33359, 33377, 33391, 33403, 33409, 33413, 33427,\n 33457, 33461, 33469, 33479, 33487, 33493, 33503, 33521, 33529, 33533,\n 33547, 33563, 33569, 33577, 33581, 33587, 33589, 33599, 33601, 33613,\n 33617, 33619, 33623, 33629, 33637, 33641, 33647, 33679, 33703, 33713,\n 33721, 33739, 33749, 33751, 33757, 33767, 33769, 33773, 33791, 33797,\n 33809, 33811, 33827, 33829, 33851, 33857, 33863, 33871, 33889, 33893,\n 33911, 33923, 33931, 33937, 33941, 33961, 33967, 33997, 34019, 34031,\n 34033, 34039, 34057, 34061, 34123, 34127, 34129, 34141, 34147, 34157,\n 34159, 34171, 34183, 34211, 34213, 34217, 34231, 34253, 34259, 34261,\n 34267, 34273, 34283, 34297, 34301, 34303, 34313, 34319, 34327, 34337,\n 34351, 34361, 34367, 34369, 34381, 34403, 34421, 34429, 34439, 34457,\n 34469, 34471, 34483, 34487, 34499, 34501, 34511, 34513, 34519, 34537,\n 34543, 34549, 34583, 34589, 34591, 34603, 34607, 34613, 34631, 34649,\n 34651, 34667, 34673, 34679, 34687, 34693, 34703, 34721, 34729, 34739,\n 34747, 34757, 34759, 34763, 34781, 34807, 34819, 34841, 34843, 34847,\n 34849, 34871, 34877, 34883, 34897, 34913, 34919, 34939, 34949, 34961,\n 34963, 34981, 35023, 35027, 35051, 35053, 35059, 35069, 35081, 35083,\n 35089, 35099, 35107, 35111, 35117, 35129, 35141, 35149, 35153, 35159,\n 35171, 35201, 35221, 35227, 35251, 35257, 35267, 35279, 35281, 35291,\n 35311, 35317, 35323, 35327, 35339, 35353, 35363, 35381, 35393, 35401,\n 35407, 35419, 35423, 35437, 35447, 35449, 35461, 35491, 35507, 35509,\n 35521, 35527, 35531, 35533, 35537, 35543, 35569, 35573, 35591, 35593,\n 35597, 35603, 35617, 35671, 35677, 35729, 35731, 35747, 35753, 35759,\n 35771, 35797, 35801, 35803, 35809, 35831, 35837, 35839, 35851, 35863,\n 35869, 35879, 35897, 35899, 35911, 35923, 35933, 35951, 35963, 35969,\n 35977, 35983, 35993, 35999, 36007, 36011, 36013, 36017, 36037, 36061,\n 36067, 36073, 36083, 36097, 36107, 36109, 36131, 36137, 36151, 36161,\n 36187, 36191, 36209, 36217, 36229, 36241, 36251, 36263, 36269, 36277,\n 36293, 36299, 36307, 36313, 36319, 36341, 36343, 36353, 36373, 36383,\n 36389, 36433, 36451, 36457, 36467, 36469, 36473, 36479, 36493, 36497,\n 36523, 36527, 36529, 36541, 36551, 36559, 36563, 36571, 36583, 36587,\n 36599, 36607, 36629, 36637, 36643, 36653, 36671, 36677, 36683, 36691,\n 36697, 36709, 36713, 36721, 36739, 36749, 36761, 36767, 36779, 36781,\n 36787, 36791, 36793, 36809, 36821, 36833, 36847, 36857, 36871, 36877,\n 36887, 36899, 36901, 36913, 36919, 36923, 36929, 36931, 36943, 36947,\n 36973, 36979, 36997, 37003, 37013, 37019, 37021, 37039, 37049, 37057,\n 37061, 37087, 37097, 37117, 37123, 37139, 37159, 37171, 37181, 37189,\n 37199, 37201, 37217, 37223, 37243, 37253, 37273, 37277, 37307, 37309,\n 37313, 37321, 37337, 37339, 37357, 37361, 37363, 37369, 37379, 37397,\n 37409, 37423, 37441, 37447, 37463, 37483, 37489, 37493, 37501, 37507,\n 37511, 37517, 37529, 37537, 37547, 37549, 37561, 37567, 37571, 37573,\n 37579, 37589, 37591, 37607, 37619, 37633, 37643, 37649, 37657, 37663,\n 37691, 37693, 37699, 37717, 37747, 37781, 37783, 37799, 37811, 37813,\n 37831, 37847, 37853, 37861, 37871, 37879, 37889, 37897, 37907, 37951,\n 37957, 37963, 37967, 37987, 37991, 37993, 37997, 38011, 38039, 38047,\n 38053, 38069, 38083, 38113, 38119, 38149, 38153, 38167, 38177, 38183,\n 38189, 38197, 38201, 38219, 38231, 38237, 38239, 38261, 38273, 38281,\n 38287, 38299, 38303, 38317, 38321, 38327, 38329, 38333, 38351, 38371,\n 38377, 38393, 38431, 38447, 38449, 38453, 38459, 38461, 38501, 38543,\n 38557, 38561, 38567, 38569, 38593, 38603, 38609, 38611, 38629, 38639,\n 38651, 38653, 38669, 38671, 38677, 38693, 38699, 38707, 38711, 38713,\n 38723, 38729, 38737, 38747, 38749, 38767, 38783, 38791, 38803, 38821,\n 38833, 38839, 38851, 38861, 38867, 38873, 38891, 38903, 38917, 38921,\n 38923, 38933, 38953, 38959, 38971, 38977, 38993, 39019, 39023, 39041,\n 39043, 39047, 39079, 39089, 39097, 39103, 39107, 39113, 39119, 39133,\n 39139, 39157, 39161, 39163, 39181, 39191, 39199, 39209, 39217, 39227,\n 39229, 39233, 39239, 39241, 39251, 39293, 39301, 39313, 39317, 39323,\n 39341, 39343, 39359, 39367, 39371, 39373, 39383, 39397, 39409, 39419,\n 39439, 39443, 39451, 39461, 39499, 39503, 39509, 39511, 39521, 39541,\n 39551, 39563, 39569, 39581, 39607, 39619, 39623, 39631, 39659, 39667,\n 39671, 39679, 39703, 39709, 39719, 39727, 39733, 39749, 39761, 39769,\n 39779, 39791, 39799, 39821, 39827, 39829, 39839, 39841, 39847, 39857,\n 39863, 39869, 39877, 39883, 39887, 39901, 39929, 39937, 39953, 39971,\n 39979, 39983, 39989, 40009, 40013, 40031, 40037, 40039, 40063, 40087,\n 40093, 40099, 40111, 40123, 40127, 40129, 40151, 40153, 40163, 40169,\n 40177, 40189, 40193, 40213, 40231, 40237, 40241, 40253, 40277, 40283,\n 40289, 40343, 40351, 40357, 40361, 40387, 40423, 40427, 40429, 40433,\n 40459, 40471, 40483, 40487, 40493, 40499, 40507, 40519, 40529, 40531,\n 40543, 40559, 40577, 40583, 40591, 40597, 40609, 40627, 40637, 40639,\n 40693, 40697, 40699, 40709, 40739, 40751, 40759, 40763, 40771, 40787,\n 40801, 40813, 40819, 40823, 40829, 40841, 40847, 40849, 40853, 40867,\n 40879, 40883, 40897, 40903, 40927, 40933, 40939, 40949, 40961, 40973,\n 40993, 41011, 41017, 41023, 41039, 41047, 41051, 41057, 41077, 41081,\n 41113, 41117, 41131, 41141, 41143, 41149, 41161, 41177, 41179, 41183,\n 41189, 41201, 41203, 41213, 41221, 41227, 41231, 41233, 41243, 41257,\n 41263, 41269, 41281, 41299, 41333, 41341, 41351, 41357, 41381, 41387,\n 41389, 41399, 41411, 41413, 41443, 41453, 41467, 41479, 41491, 41507,\n 41513, 41519, 41521, 41539, 41543, 41549, 41579, 41593, 41597, 41603,\n 41609, 41611, 41617, 41621, 41627, 41641, 41647, 41651, 41659, 41669,\n 41681, 41687, 41719, 41729, 41737, 41759, 41761, 41771, 41777, 41801,\n 41809, 41813, 41843, 41849, 41851, 41863, 41879, 41887, 41893, 41897,\n 41903, 41911, 41927, 41941, 41947, 41953, 41957, 41959, 41969, 41981,\n 41983, 41999, 42013, 42017, 42019, 42023, 42043, 42061, 42071, 42073,\n 42083, 42089, 42101, 42131, 42139, 42157, 42169, 42179, 42181, 42187,\n 42193, 42197, 42209, 42221, 42223, 42227, 42239, 42257, 42281, 42283,\n 42293, 42299, 42307, 42323, 42331, 42337, 42349, 42359, 42373, 42379,\n 42391, 42397, 42403, 42407, 42409, 42433, 42437, 42443, 42451, 42457,\n 42461, 42463, 42467, 42473, 42487, 42491, 42499, 42509, 42533, 42557,\n 42569, 42571, 42577, 42589, 42611, 42641, 42643, 42649, 42667, 42677,\n 42683, 42689, 42697, 42701, 42703, 42709, 42719, 42727, 42737, 42743,\n 42751, 42767, 42773, 42787, 42793, 42797, 42821, 42829, 42839, 42841,\n 42853, 42859, 42863, 42899, 42901, 42923, 42929, 42937, 42943, 42953,\n 42961, 42967, 42979, 42989, 43003, 43013, 43019, 43037, 43049, 43051,\n 43063, 43067, 43093, 43103, 43117, 43133, 43151, 43159, 43177, 43189,\n 43201, 43207, 43223, 43237, 43261, 43271, 43283, 43291, 43313, 43319,\n 43321, 43331, 43391, 43397, 43399, 43403, 43411, 43427, 43441, 43451,\n 43457, 43481, 43487, 43499, 43517, 43541, 43543, 43573, 43577, 43579,\n 43591, 43597, 43607, 43609, 43613, 43627, 43633, 43649, 43651, 43661,\n 43669, 43691, 43711, 43717, 43721, 43753, 43759, 43777, 43781, 43783,\n 43787, 43789, 43793, 43801, 43853, 43867, 43889, 43891, 43913, 43933,\n 43943, 43951, 43961, 43963, 43969, 43973, 43987, 43991, 43997, 44017,\n 44021, 44027, 44029, 44041, 44053, 44059, 44071, 44087, 44089, 44101,\n 44111, 44119, 44123, 44129, 44131, 44159, 44171, 44179, 44189, 44201,\n 44203, 44207, 44221, 44249, 44257, 44263, 44267, 44269, 44273, 44279,\n 44281, 44293, 44351, 44357, 44371, 44381, 44383, 44389, 44417, 44449,\n 44453, 44483, 44491, 44497, 44501, 44507, 44519, 44531, 44533, 44537,\n 44543, 44549, 44563, 44579, 44587, 44617, 44621, 44623, 44633, 44641,\n 44647, 44651, 44657, 44683, 44687, 44699, 44701, 44711, 44729, 44741,\n ]\n\ndef find_prime_index(p):\n i = 0\n j = len(primes) - 1\n if primes[i] == p:\n return i\n if primes[j] == p:\n return j\n while j > i + 1:\n mid = (i + j) / 2\n if primes[mid] == p:\n return mid\n if primes[mid] < p:\n i = mid\n else:\n j = mid\n return j\n\ndef dp(n, p):\n if p > n:\n return 0\n if p * p > n:\n return 1\n np = n // p\n index = find_prime_index(p)\n result = np\n for i in range(index):\n result -= dp(np, primes[i])\n return result\n\ndef is_prime(p):\n if p <= primes[-1]:\n index = find_prime_index(p)\n return p == primes[index]\n for i in range(len(primes)):\n if p % primes[i] == 0:\n return False\n return True\n\na, b, k = map(lambda x: int(x), raw_input().split())\nif not is_prime(k):\n print 0\nelse:\n print dp(b, k) - dp(a-1, k)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6284fd38b9000fc4ea14d96245b10994", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import sys\nimport math\n\na, b, k = map(int, sys.stdin.readline().split())\n\n\ndef rho(n, primes, s=0):\n if s >= len(primes) or n < primes[s]:\n return 0\n\n ret = 0\n for i in xrange(s, len(primes)):\n next = n / primes[i]\n\n if next == 0:\n break\n\n ret += next\n ret -= rho(next, primes, i + 1)\n\n return ret\n\ndef answer(c):\n if c < k:\n return 0\n if k*k > c:\n return 1\n\n primes = [2] if k > 2 else []\n for d in xrange(3, k, 2):\n for p in primes:\n if d % p == 0:\n break\n else:\n primes.append(d)\n\n return c/k - rho(c/k, primes)\n\ndef is_prime(a):\n for d in xrange(2, int(math.sqrt(a)) + 1):\n if a % d == 0:\n return True\n return False\n\nif is_prime(k):\n print 0\nelse:\n print answer(b) - answer(a - 1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1ee7e445d47ac208b97fe68b1ad3bcc8", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\nimport math\n\nprimes = []\nMAXN = 50000\nhash = []\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 res = v / k\n for prime in primes:\n if prime >= k:\n break\n res -= calc(v/k, prime)\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": "711741d340e5d1cc799db9d31991e031", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.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[1]<5 and a[0]+a[1]<7 else \"Second\")\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c8adcd7f071f490571e7f7f97cc4ccf7", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.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[1]<5 and a[0]+a[1]<7 else \"Second\")\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "83baf107c4baa29a783afab7bfbdddc0", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.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[1]<5 and a[0]+a[1]<7 else \"Second\")\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3cd998819360ccf9a5a75573fbe583e5", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "n, m, i1, j1, i2, j2 = map(int, raw_input().split())\nx = [abs(i1 - i2), abs(j1 - j2)]\nx.sort()\nif x[1] >= 5:\n print \"Second\"\nelif x[0] <= 2:\n print \"First\"\nelse:\n if x[1] == 4:\n print \"Second\"\n else:\n print \"First\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba443d18cdba1c99c130082c6934298c", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "n,m,x1,y1,x2,y2 = map(int, input().split())\nn = abs(x1 - x2)\nm = abs(y1 - y2)\nif n > 2 or m > 2:\n print(\"Second\")\nelif n == 2 and m == 2:\n print(\"Second\")\nelse:\n print(\"First\")", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a2655a95e03c1bd1bd2d8434f40d4cf3", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "import re\nimport sys\n\nMOD = 2 ** 15\nMOD2 = 2 * MOD\n\nclass X:\n def __init__(self, x):\n if isinstance(x, X):\n self.x = x.x\n else:\n self.x = x\n def __add__(self, other):\n return X((self.x + other.x + MOD2) % MOD)\n def __sub__(self, other):\n return X((self.x - other.x + MOD2) % MOD)\n def __mul__(self, other):\n return X((self.x * other.x) % MOD)\n def __div__(self, other):\n return X((sefl.x // other.x) % MOD)\n def __eq__(self, other):\n return self.x == other.x\n def __lt__(self, other):\n return self.x < other.x\n def __gt__(self, other):\n return self.x > other.x\n \n\n#fin = open(\"input.txt\", 'r')\n#fout = open(\"output.txt\", 'w')\nfin = sys.stdin\nfout = sys.stdout\n\nfn = int(fin.readline())\ntext = \"\".join(fin.readlines())\n\ntext.replace(\";\", \"\\n\")\ntext = text[text.find(\"{\") + 1: text.find(\"}\")]\ntext = re.sub(r\"(\\d+)\", r\"X(\\1)\", text)\ntext = [\" \" + x.strip() for x in text.split(\"\\n\")]\ntext = \"\\n\".join(text)\ntext = re.sub(r\"(if.*?)(return.*)\", r\"\\1: \\2\", text)\ntext = \"def ff(n):\\n\" + text\n\nexec(compile(text.strip(), \"f**k\", 'exec')\n\ncache = {}\ndef f(n):\n return cache[n.x]\n \nans = -1\nfor i in range(0, MOD + 1):\n t = cache[i] = X(ff(X(i)))\n if t.x == fn:\n ans = i\n \nprint(ans)\n \n\n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "007e38e3417eeb9fcc7988e364d39a40", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import re\nimport sys\n\nsys.setrecursionlimit(5000)\n\nMOD = 2 ** 15\nMOD2 = 2 * MOD\n\nclass X:\n def __init__(self, x):\n if isinstance(x, X):\n self.x = x.x\n else:\n self.x = x\n def __add__(self, other):\n return X(((self.x + other.x) % MOD + MOD) % MOD)\n def __sub__(self, other):\n return X(((self.x - other.x) % MOD + MOD) % MOD)\n def __mul__(self, other):\n return X(((self.x * other.x) % MOD + MOD) % MOD)\n def __div__(self, other):\n return X(((sefl.x // other.x) % MOD + MOD) % MOD)\n def __eq__(self, other):\n return self.x == other.x\n def __lt__(self, other):\n return self.x < other.x\n def __gt__(self, other):\n return self.x > other.x\n \n#fin, fout = open(\"input.txt\", 'r'), open(\"output.txt\", 'w')\nfin, fout = sys.stdin, sys.stdout\n\n\nfn = int(fin.readline())\ntext = \"\".join(fin.readlines())\ntext = text.replace(\"\\n\", \"\")\n\ntext = text[text.find(\"{\") + 1: text.find(\"}\")]\ntext = re.sub(r\"(\\d+)\", r\"X(\\1)\", text)\ntext = re.sub(r\"(if.*?)return\", r\"\\1 : return\", text)\ntext = re.sub(r\"\\s*([\\(\\)])\\s*\", r\"\\1\", text)\ntext = \"\".join(text)\ntext = \"\".join(\" \" + x.strip() + \"\\n\" for x in text.split(\";\"))\ntext = \"def ff(n):\\n\" + text\n\nexec(compile(text.strip(), \"f**k\", 'exec'))\n\ncache = {}\ndef f(n):\n try:\n return cache[n.x]\n except KeyError:\n r = cache[n.x] = X(ff(n))\n return r\n \nans = -1\nfor i in range(0, MOD):\n t = cache[i] = X(ff(X(i))\n if t.x == fn:\n ans = i\n \nprint(ans)\n \n\n\n \n \n", "lang_cluster": "Python", "compilation_error": true, "code_uid": "9f7b1799af00ace299985affc7855746", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "import re,sys\nclass INT:\n def __init__(self,a):\n if isinstance(a,INT):\n self.v=a.v\n else:\n self.v=int(a)\n def __add__(self,a):\n return INT((self.v+a.v)&32767)\n def __sub__(self,a):\n return INT((self.v-a.v)&32767)\n def __mul__(self,a):\n return INT((self.v*a.v)&32767)\n def __div__(self,a):\n return INT((self.v/a.v)&32767)\n def __eq__(self,a):\n return self.v==a.v\n def __gt__(self,a):\n return self.v>a.v\n def __lt__(self,a):\n return self.v 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 = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i).val () & 32767\\n'\n#s += 'for i in range (32768):\\n'\n#s += '\\tprint \\'%d: %d\\' % (i, a[i])\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\n#s += 'print n\\n'\ns = s.replace ('\\t\\n', '\\n')\n#print s\nexec s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5b41058a434a3bc37ba9e4ed95a5ea6a", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\nn = int (sys.stdin.readline ())\ns = ''.join (sys.stdin.readlines ())\ns = s.replace ('\\n', '')\ns = s.replace ('{', '')\ns = s.replace ('}', '')\ns = s.replace ('int f(int n)', \\\n 'a = [-1] * 32768\\ndef f (n):\\n\\tglobal a;if (a[n] != -1) return a[n];')\ns = s.replace (';', '\\n\\t')\ns = s.replace ('return', ':return')\ns = s.replace ('\\t:', '\\t')\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i) & 32767\\n'\n#s += 'for i in range (32768):\\n'\n#s += '\\tprint \\'%d: %d\\' % (i, a[i])\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\n#s += 'print n\\n'\ns = s.replace ('\\t\\n', '\\n')\n#print s\nexec s\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cf9ffb0e989948a3d2abde4e32092c23", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.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# print(\"posibles {}\".format(posibles_jefes_filtrados))\n assert len(posibles_jefes_filtrados) == 1\n assert posibles_jefes_filtrados[0] == ops[0][1]\n posibles_jefes_mencionados.add(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": "c60cc90fae439d28d71acb845f17f954", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.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 if(posibles_jefes_filtrados):\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# print(\"posibles {}\".format(posibles_jefes_filtrados))\n assert len(posibles_jefes_filtrados) <= 1\n if(posibles_jefes_filtrados):\n assert posibles_jefes_filtrados[0] == ops[0][1]\n posibles_jefes_mencionados.add(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": "2b7d06dbaaf96d821569da7ac0a80d1e", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.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 if(posibles_jefes_filtrados):\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# print(\"posibles {}\".format(posibles_jefes_filtrados))\n assert len(posibles_jefes_filtrados) <= 1\n if(posibles_jefes_filtrados):\n assert posibles_jefes_filtrados[0] == ops[0][1]\n posibles_jefes_mencionados.add(ops[0][1])\n else:\n assert ultima_salida_inesperada is not None\n# print(\"continuos {}\".format(continuos))\n posibles_jefes_mencionados = set(filter(lambda x:ultimo_en_salir[x] and continuos[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": "a362eb852eb3310ce312d7492f2e035a", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0} {"lang": "Python 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": "4b32b99f5c82b42b6ea7e15a5d0079cf", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "Python 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()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eb5224e1f40237f16fe11ff58fd60e6f", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "Python 3", "source_code": "import sys\n\nOP_CW1 = 'A'\nOP_CW4 = 'B'\nOP_CW16 = 'C'\nOP_CCW = 'E'\nOP_L = 'U'\nOP_INV_L = 'V'\nOP_R = 'W'\nOP_INV_R = 'X'\nOP_S = 'S'\nOP_MOVE_LL1 = 'O'\nOP_MOVE_LL4 = 'P'\nOP_MOVE_LL16 = 'Q'\nOP_MOVE_L_THROW = 'R'\n\ndef GetK(board): return len(board) // 4\n\ndef Slot(board, slotval=-1): return board.index(slotval)\n\ndef KS(board, slotval=-1): return GetK(board), Slot(board, slotval)\n\ndef Width(K): return K * 2 + 1\n\ndef PrintPermumation(head, board, slotval=None):\n K = GetK(board)\n W = Width(K)\n if slotval is None: slotval = K\n slot = Slot(board, slotval)\n print(head, '===', file=sys.stderr)\n tostr = lambda x: 'EE' if x == slotval else '%2d' % x\n for row in [board[:W], board[W:]]:\n print(' '.join(tostr(x) for x in row), file=sys.stderr)\n\ndef ApplyOps(board, seq, ops=None, slotval=-1):\n K, slot = KS(board, slotval)\n W = Width(K)\n for c in seq:\n if c == 'l':\n assert slot % W > 0, slot\n s1 = slot - 1\n elif c == 'r':\n assert slot % W + 1 < W, slot\n s1 = slot + 1\n elif c == 'd':\n assert slot % W in [0, K, K * 2], slot\n assert slot // W == 0\n s1 = slot + W\n elif c == 'u':\n assert slot % W in [0, K, K * 2], slot\n assert slot // W == 1\n s1 = slot - W\n else:\n s1 = None\n if s1 is not None:\n board[s1], board[slot] = board[slot], board[s1]\n else:\n P = ops[c]\n tmp = board[:]\n for i in range(len(board)): board[i] = tmp[P[i]]\n slot = Slot(board, slotval)\n\ndef LoopedView(board):\n K, slot = KS(board)\n W = Width(slot)\n assert slot == K\n def translate(x):\n if x == -1: return x\n if x <= W: return x - 1\n # W+1 -> 2W-2\n return 3 * W - 1 - x\n r = []\n for rng in [range(slot + 1, W), reversed(range(W, W * 2)), range(0, slot)]:\n for i in rng:\n r.append(translate(board[i]))\n return r\n\ndef Mod(x, m):\n x %= m\n if x < 0: x += m\n return x\n\ndef CanonicalizeView(view):\n i = view.index(0)\n view[:] = view[i:] + view[:i]\n\ndef ToPermutation(K, ops, seq):\n board = list(range(K * 4 + 2))\n ApplyOps(board, seq, ops, slotval=K)\n return board\n\ndef InitOps(K, debug=False):\n W = Width(K)\n ops = {}\n ops_codes = {}\n def ToP(seq): return ToPermutation(K, ops, seq)\n def Assign(rep, seq):\n ops[rep] = ToP(seq)\n ops_codes[rep] = seq\n\n Assign(OP_CW1, 'l' * K + 'd' + 'r' * (K * 2) + 'u' + 'l' * K)\n if debug: PrintPermumation('CW1', ops[OP_CW1])\n Assign(OP_CW4, OP_CW1 * 4)\n if debug: PrintPermumation('CW4', ops[OP_CW4])\n Assign(OP_CW16, OP_CW4 * 4)\n Assign(OP_CCW, OP_CW1 * (W * 2 - 2))\n if debug: PrintPermumation('CCW', ops[OP_CCW])\n\n Assign(OP_L, 'l' * K + 'd' + 'r' * K + 'u')\n if debug: PrintPermumation('L', ops[OP_L])\n Assign(OP_INV_L, OP_L * (K * 2))\n if debug: PrintPermumation('INV_L', ops[OP_INV_L])\n Assign(OP_R, 'r' * K + 'd' + 'l' * K + 'u')\n if debug: PrintPermumation('R', ops[OP_R])\n Assign(OP_INV_R, OP_R * (K * 2))\n if debug: PrintPermumation('INV_R', ops[OP_INV_R])\n\n Assign(OP_S, OP_INV_R + OP_INV_L + OP_R + OP_L)\n if debug: PrintPermumation('S', ops[OP_S])\n\n Assign(OP_MOVE_LL1, OP_CW1 + OP_S + OP_CW1)\n Assign(OP_MOVE_LL4, OP_MOVE_LL1 * 4)\n Assign(OP_MOVE_LL16, OP_MOVE_LL4 * 4)\n Assign(OP_MOVE_L_THROW, OP_S * 2 + OP_CW1)\n if debug:\n PrintPermumation('MOVE_LL', ops[OP_MOVE_LL1])\n PrintPermumation('MOVE_L_THROW', ops[OP_MOVE_L_THROW])\n return ops, ops_codes\n\ndef Solve(board, debug=False):\n ans = []\n K, slot = KS(board)\n W = Width(K)\n\n if slot % W < K:\n t = 'r' * (K - slot % W)\n else:\n t = 'l' * (slot % W - K)\n if slot // W == 1:\n t = t + 'u'\n ans.append(t)\n ApplyOps(board, t)\n slot = Slot(board)\n assert slot == K\n\n ops, ops_codes = InitOps(K)\n\n def ApplyMultipleOp(num, items):\n for k, op in reversed(items):\n while num >= k:\n num -= k\n ApplyOps(board, op, ops)\n ans.append(op)\n\n for k in range(1, W * 2 - 1):\n view = LoopedView(board)\n if debug: print('=' * 20, k, '\\n', view, file=sys.stderr)\n num_cw = Mod(+(K * 2 - view.index(k)), len(view))\n CanonicalizeView(view)\n num_move = view.index(k) - k\n if debug: print(num_cw, num_move, file=sys.stderr)\n ApplyMultipleOp(num_cw, [(1, OP_CW1), (4, OP_CW4), (16, OP_CW16)])\n if debug: PrintPermumation('t', board, slotval=-1)\n ApplyMultipleOp(num_move // 2, [(1, OP_MOVE_LL1), (4, OP_MOVE_LL4), (16, OP_MOVE_LL16)])\n if debug: PrintPermumation('tt', board, slotval=-1)\n if num_move % 2 > 0:\n if k == W * 2 - 2: return False\n ApplyOps(board, OP_MOVE_L_THROW, ops)\n ans.append(OP_MOVE_L_THROW)\n view = LoopedView(board)\n num_cw = Mod(K * 3 + 1 - view.index(0), len(view))\n ApplyMultipleOp(num_cw, [(1, OP_CW1), (4, OP_CW4), (16, OP_CW16)])\n if debug: PrintPermumation('ttt', board, slotval=-1)\n f = 'r' * K + 'd'\n ApplyOps(board, f)\n ans.append(f)\n if debug: PrintPermumation('ttt', board, slotval=-1)\n \n print('SURGERY COMPLETE')\n print(''.join(ans))\n for k, v in ops_codes.items():\n print(k, v)\n print('DONE')\n return True\n\n#ops = InitOps(11, debug=True)\n\n#import random\n#board = list(range(10 * 4 + 2))\n#random.shuffle(board)\n#print(board)\n##board = [4, 35, 3, 15, 38, 1, 31, 7, 42, 26, 19, 27, 5, 11, 2, 33, 40, 16, 20, 12, 18, 24, 28, 6, 36, 22, 9, 29, 30, 43, 21, 10, 17, 0, 13, 8, 45, 25, 37, 32, 44, 14, 39, 34, 23, 41]\n#if True:\n# board[board.index(0)] = -1\n# a = Solve(board, debug=True)\n# print(a, file=sys.stderr)\nfor _ in range(int(sys.stdin.readline())):\n sys.stdin.readline()\n tr = lambda s: -1 if s == 'E' else int(s)\n row1 = list(map(tr, sys.stdin.readline().split()))\n row2 = list(map(tr, sys.stdin.readline().split()))\n if not Solve(row1 + row2): print('SURGERY FAILED')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dc11d3c05cab844c80b3d87c007fc832", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "Python 3", "source_code": "def flatten(grid):\n k = len(grid[0]) // 2\n seek = list(range(2*k + 2)) + list(range(2*k + 2, 4*k + 2))[::-1]\n return [seek[v] for v in grid[0] + grid[1][::-1] if v]\n\ndef solve(grid):\n grid = list(map(list, grid))\n k = len(grid[0]) // 2\n flat = flatten(grid)\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 k = int(input())\n grid = [get_line() for i in range(2)]\n assert all(len(row) == 2*k + 1 for row in grid)\n res = solve(grid)\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()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2ac906aa196bdeb64a52099f9e1ca327", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "Python 3", "source_code": "import sys\n\nOP_CW1 = 'A'\nOP_CW4 = 'B'\nOP_CW16 = 'C'\nOP_CCW = 'E'\nOP_L = 'U'\nOP_INV_L = 'V'\nOP_R = 'W'\nOP_INV_R = 'X'\nOP_S = 'S'\nOP_MOVE_LL1 = 'O'\nOP_MOVE_LL4 = 'P'\nOP_MOVE_LL16 = 'Q'\nOP_MOVE_L_THROW = 'R'\n\ndef GetK(board): return len(board) // 4\n\ndef Slot(board, slotval=-1): return board.index(slotval)\n\ndef KS(board, slotval=-1): return GetK(board), Slot(board, slotval)\n\ndef Width(K): return K * 2 + 1\n\ndef PrintPermumation(head, board, slotval=None):\n K = GetK(board)\n W = Width(K)\n if slotval is None: slotval = K\n slot = Slot(board, slotval)\n print(head, '===', file=sys.stderr)\n tostr = lambda x: 'EE' if x == slotval else '%2d' % x\n for row in [board[:W], board[W:]]:\n print(' '.join(tostr(x) for x in row), file=sys.stderr)\n\ndef ApplyOps(board, seq, ops=None, slotval=-1):\n K, slot = KS(board, slotval)\n W = Width(K)\n for c in seq:\n if c == 'l':\n assert slot % W > 0, slot\n s1 = slot - 1\n elif c == 'r':\n assert slot % W + 1 < W, slot\n s1 = slot + 1\n elif c == 'd':\n assert slot % W in [0, K, K * 2], slot\n assert slot // W == 0\n s1 = slot + W\n elif c == 'u':\n assert slot % W in [0, K, K * 2], slot\n assert slot // W == 1\n s1 = slot - W\n else:\n s1 = None\n if s1 is not None:\n board[s1], board[slot] = board[slot], board[s1]\n else:\n P = ops[c]\n tmp = board[:]\n for i in range(len(board)): board[i] = tmp[P[i]]\n slot = Slot(board, slotval)\n\ndef LoopedView(board):\n K, slot = KS(board)\n W = Width(slot)\n assert slot == K\n def translate(x):\n if x == -1: return x\n if x <= W: return x - 1\n # W+1 -> 2W-2\n return 3 * W - 1 - x\n r = []\n for rng in [range(slot + 1, W), reversed(range(W, W * 2)), range(0, slot)]:\n for i in rng:\n r.append(translate(board[i]))\n return r\n\ndef Mod(x, m):\n x %= m\n if x < 0: x += m\n return x\n\ndef CanonicalizeView(view):\n i = view.index(0)\n view[:] = view[i:] + view[:i]\n\ndef ToPermutation(K, ops, seq):\n board = list(range(K * 4 + 2))\n ApplyOps(board, seq, ops, slotval=K)\n return board\n\ndef InitOps(K, debug=False):\n W = Width(K)\n ops = {}\n ops_codes = {}\n def ToP(seq): return ToPermutation(K, ops, seq)\n def Assign(rep, seq):\n ops[rep] = ToP(seq)\n ops_codes[rep] = seq\n\n Assign(OP_CW1, 'l' * K + 'd' + 'r' * (K * 2) + 'u' + 'l' * K)\n if debug: PrintPermumation('CW1', ops[OP_CW1])\n Assign(OP_CW4, OP_CW1 * 4)\n if debug: PrintPermumation('CW4', ops[OP_CW4])\n Assign(OP_CW16, OP_CW4 * 4)\n Assign(OP_CCW, OP_CW1 * (W * 2 - 2))\n if debug: PrintPermumation('CCW', ops[OP_CCW])\n\n Assign(OP_L, 'l' * K + 'd' + 'r' * K + 'u')\n if debug: PrintPermumation('L', ops[OP_L])\n Assign(OP_INV_L, OP_L * (K * 2))\n if debug: PrintPermumation('INV_L', ops[OP_INV_L])\n Assign(OP_R, 'r' * K + 'd' + 'l' * K + 'u')\n if debug: PrintPermumation('R', ops[OP_R])\n Assign(OP_INV_R, OP_R * (K * 2))\n if debug: PrintPermumation('INV_R', ops[OP_INV_R])\n\n Assign(OP_S, OP_INV_R + OP_INV_L + OP_R + OP_L)\n if debug: PrintPermumation('S', ops[OP_S])\n\n Assign(OP_MOVE_LL1, OP_CW1 + OP_S + OP_CW1)\n Assign(OP_MOVE_LL4, OP_MOVE_LL1 * 4)\n Assign(OP_MOVE_LL16, OP_MOVE_LL4 * 4)\n Assign(OP_MOVE_L_THROW, OP_S * 2 + OP_CW1)\n if debug:\n PrintPermumation('MOVE_LL', ops[OP_MOVE_LL1])\n PrintPermumation('MOVE_L_THROW', ops[OP_MOVE_L_THROW])\n return ops, ops_codes\n\ndef Solve(board, debug=False):\n ans = []\n K, slot = KS(board)\n W = Width(K)\n\n if slot % W < K:\n t = 'r' * (K - slot % W)\n else:\n t = 'l' * (slot % W - K)\n if slot // W == 1:\n t = t + 'u'\n ans.append(t)\n ApplyOps(board, t)\n slot = Slot(board)\n assert slot == K\n\n ops, ops_codes = InitOps(K)\n\n def ApplyMultipleOp(num, items):\n for k, op in reversed(items):\n while num >= k:\n num -= k\n ApplyOps(board, op, ops)\n ans.append(op)\n\n for k in range(1, W * 2 - 1):\n view = LoopedView(board)\n if debug: print('=' * 20, k, '\\n', view, file=sys.stderr)\n num_cw = Mod(+(K * 2 - view.index(k)), len(view))\n CanonicalizeView(view)\n num_move = view.index(k) - k\n if debug: print(num_cw, num_move, file=sys.stderr)\n ApplyMultipleOp(num_cw, [(1, OP_CW1), (4, OP_CW4), (16, OP_CW16)])\n if debug: PrintPermumation('t', board, slotval=-1)\n ApplyMultipleOp(num_move // 2, [(1, OP_MOVE_LL1), (4, OP_MOVE_LL4), (16, OP_MOVE_LL16)])\n if debug: PrintPermumation('tt', board, slotval=-1)\n if num_move % 2 > 0:\n if k == W * 2 - 2: return False\n ApplyOps(board, OP_MOVE_L_THROW, ops)\n ans.append(OP_MOVE_L_THROW)\n view = LoopedView(board)\n num_cw = Mod(K * 3 + 1 - view.index(0), len(view))\n ApplyMultipleOp(num_cw, [(1, OP_CW1), (4, OP_CW4), (16, OP_CW16)])\n if debug: PrintPermumation('ttt', board, slotval=-1)\n f = 'r' * K + 'd'\n ApplyOps(board, f)\n ans.append(f)\n if debug: PrintPermumation('ttt', board, slotval=-1)\n \n print('SURGERY COMPLETE')\n print(''.join(ans))\n for k, v in ops_codes.items():\n print(k, v)\n return True\n\n#ops = InitOps(11, debug=True)\n\n#import random\n#board = list(range(10 * 4 + 2))\n#random.shuffle(board)\n#print(board)\n##board = [4, 35, 3, 15, 38, 1, 31, 7, 42, 26, 19, 27, 5, 11, 2, 33, 40, 16, 20, 12, 18, 24, 28, 6, 36, 22, 9, 29, 30, 43, 21, 10, 17, 0, 13, 8, 45, 25, 37, 32, 44, 14, 39, 34, 23, 41]\n#if True:\n# board[board.index(0)] = -1\n# a = Solve(board, debug=True)\n# print(a, file=sys.stderr)\nfor _ in range(int(sys.stdin.readline())):\n sys.stdin.readline()\n tr = lambda s: -1 if s == 'E' else int(s)\n row1 = list(map(tr, sys.stdin.readline().split()))\n row2 = list(map(tr, sys.stdin.readline().split()))\n if not Solve(row1 + row2): print('SURGERY FAILED')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "06890dfafdaba5b2ec9a11ee1aba424f", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "PyPy 3", "source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, m = map(int, input().split())\r\ndp = [0] * (n + 2)\r\ndp[n] = 1\r\nfor i in range(n - 1, 0, -1):\r\n dpi = dp[i + 1]\r\n j = 2\r\n while i * j < n + 2:\r\n dpi += dp[i * j] - dp[min(n + 1, (i + 1) * j)]\r\n dpi %= m\r\n j += 1\r\n dp[i] = dpi + dp[i + 1]\r\n dp[i] %= m\r\nans = (dp[1] - dp[2]) % m\r\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "533c6cddaeb042f08967f9560dfcb900", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.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\n\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 dp = [0 for _ in range(n+1)]\n dp[1] = 1\n h = [0 for _ in range(n+1)]\n cumul = 0\n prev = dp[1]\n h[2]-=1\n for u in range(1, len(dp)):\n if u > 1:\n dp[u] += prev + dp[1]\n dp[u] %= m\n\n cumul += h[u]\n cumul %= m\n \n dp[u] += cumul\n dp[u] %= m\n \n prev += dp[u]\n prev %= m\n '''u = 7\n 14 + 0, 14 + 1, 14 + 2\n 7 7 8\n '''\n j = 2\n while( j * u < len(dp)):\n h[j*u] += dp[u]\n h[j*u] %= m\n if j*u + j< len(dp):\n h[j*u + j] -= dp[u]\n h[j*u + j] %= m\n j+=1\n print (dp[-1])\n\n ######################################################################\nif __name__ == '__main__' :\n main()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "92828aa59474972d0f96d8f3e5df58e5", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "\r\ndef divisors(M):\r\n d=[]\r\n i=1\r\n while M>=i**2:\r\n if M%i==0:\r\n d.append(i)\r\n if i**2!=M:\r\n d.append(M//i)\r\n i=i+1\r\n return d\r\n\r\ndef popcount(x):\r\n x = x - ((x >> 1) & 0x55555555)\r\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333)\r\n x = (x + (x >> 4)) & 0x0f0f0f0f\r\n x = x + (x >> 8)\r\n x = x + (x >> 16)\r\n return x & 0x0000007f\r\n\r\ndef eratosthenes(n):\r\n res=[0 for i in range(n+1)]\r\n prime=set([])\r\n for i in range(2,n+1):\r\n if not res[i]:\r\n prime.add(i)\r\n for j in range(1,n//i+1):\r\n res[i*j]=1\r\n return prime\r\n\r\ndef factorization(n):\r\n res=[]\r\n for p in prime:\r\n if n%p==0:\r\n while n%p==0:\r\n n//=p\r\n res.append(p)\r\n if n!=1:\r\n res.append(n)\r\n return res\r\n\r\ndef euler_phi(n):\r\n res = n\r\n for x in range(2,n+1):\r\n if x ** 2 > n:\r\n break\r\n if n%x==0:\r\n res = res//x * (x-1)\r\n while n%x==0:\r\n n //= x\r\n if n!=1:\r\n res = res//n * (n-1)\r\n return res\r\n\r\ndef ind(b,n):\r\n res=0\r\n while n%b==0:\r\n res+=1\r\n n//=b\r\n return res\r\n\r\ndef isPrimeMR(n):\r\n d = n - 1\r\n d = d // (d & -d)\r\n L = [2, 3, 5, 7, 11, 13, 17]\r\n for a in L:\r\n t = d\r\n y = pow(a, t, n)\r\n if y == 1: continue\r\n while y != n - 1:\r\n y = (y * y) % n\r\n if y == 1 or t == n - 1: return 0\r\n t <<= 1\r\n return 1\r\ndef findFactorRho(n):\r\n from math import gcd\r\n m = 1 << n.bit_length() // 8\r\n for c in range(1, 99):\r\n f = lambda x: (x * x + c) % n\r\n y, r, q, g = 2, 1, 1, 1\r\n while g == 1:\r\n x = y\r\n for i in range(r):\r\n y = f(y)\r\n k = 0\r\n while k < r and g == 1:\r\n ys = y\r\n for i in range(min(m, r - k)):\r\n y = f(y)\r\n q = q * abs(x - y) % n\r\n g = gcd(q, n)\r\n k += m\r\n r <<= 1\r\n if g == n:\r\n g = 1\r\n while g == 1:\r\n ys = f(ys)\r\n g = gcd(abs(x - ys), n)\r\n if g < n:\r\n if isPrimeMR(g): return g\r\n elif isPrimeMR(n // g): return n // g\r\n return findFactorRho(g)\r\ndef primeFactor(n):\r\n i = 2\r\n ret = {}\r\n rhoFlg = 0\r\n while i*i <= n:\r\n k = 0\r\n while n % i == 0:\r\n n //= i\r\n k += 1\r\n if k: ret[i] = k\r\n i += 1 + i % 2\r\n if i == 101 and n >= 2 ** 20:\r\n while n > 1:\r\n if isPrimeMR(n):\r\n ret[n], n = 1, 1\r\n else:\r\n rhoFlg = 1\r\n j = findFactorRho(n)\r\n k = 0\r\n while n % j == 0:\r\n n //= j\r\n k += 1\r\n ret[j] = k\r\n\r\n if n > 1: ret[n] = 1\r\n if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}\r\n return ret\r\n\r\ndef divisors(n):\r\n res = [1]\r\n prime = primeFactor(n)\r\n for p in prime:\r\n newres = []\r\n for d in res:\r\n for j in range(prime[p]+1):\r\n newres.append(d*p**j)\r\n res = newres\r\n res.sort()\r\n return res\r\n\r\ndef xorfactorial(num):\r\n if num==0:\r\n return 0\r\n elif num==1:\r\n return 1\r\n elif num==2:\r\n return 3\r\n elif num==3:\r\n return 0\r\n else:\r\n x=baseorder(num)\r\n return (2**x)*((num-2**x+1)%2)+function(num-2**x)\r\n\r\ndef xorconv(n,X,Y):\r\n if n==0:\r\n res=[(X[0]*Y[0])%mod]\r\n return res\r\n x=[X[i]+X[i+2**(n-1)] for i in range(2**(n-1))]\r\n y=[Y[i]+Y[i+2**(n-1)] for i in range(2**(n-1))]\r\n z=[X[i]-X[i+2**(n-1)] for i in range(2**(n-1))]\r\n w=[Y[i]-Y[i+2**(n-1)] for i in range(2**(n-1))]\r\n res1=xorconv(n-1,x,y)\r\n res2=xorconv(n-1,z,w)\r\n former=[(res1[i]+res2[i])*inv for i in range(2**(n-1))]\r\n latter=[(res1[i]-res2[i])*inv for i in range(2**(n-1))]\r\n former=list(map(lambda x:x%mod,former))\r\n latter=list(map(lambda x:x%mod,latter))\r\n return former+latter\r\n\r\ndef merge_sort(A,B):\r\n pos_A,pos_B = 0,0\r\n n,m = len(A),len(B)\r\n res = []\r\n while pos_A < n and pos_B < m:\r\n a,b = A[pos_A],B[pos_B]\r\n if a < b:\r\n res.append(a)\r\n pos_A += 1\r\n else:\r\n res.append(b)\r\n pos_B += 1\r\n res += A[pos_A:]\r\n res += B[pos_B:]\r\n return res\r\n\r\nclass UnionFindVerSize():\r\n def __init__(self, N):\r\n self._parent = [n for n in range(0, N)]\r\n self._size = [1] * N\r\n self.group = N\r\n\r\n def find_root(self, x):\r\n if self._parent[x] == x: return x\r\n self._parent[x] = self.find_root(self._parent[x])\r\n stack = [x]\r\n while self._parent[stack[-1]]!=stack[-1]:\r\n stack.append(self._parent[stack[-1]])\r\n for v in stack:\r\n self._parent[v] = stack[-1]\r\n return self._parent[x]\r\n\r\n def unite(self, x, y):\r\n gx = self.find_root(x)\r\n gy = self.find_root(y)\r\n if gx == gy: return\r\n\r\n self.group -= 1\r\n\r\n if self._size[gx] < self._size[gy]:\r\n self._parent[gx] = gy\r\n self._size[gy] += self._size[gx]\r\n else:\r\n self._parent[gy] = gx\r\n self._size[gx] += self._size[gy]\r\n\r\n def get_size(self, x):\r\n return self._size[self.find_root(x)]\r\n\r\n def is_same_group(self, x, y):\r\n return self.find_root(x) == self.find_root(y)\r\n\r\nclass WeightedUnionFind():\r\n def __init__(self,N):\r\n self.parent = [i for i in range(N)]\r\n self.size = [1 for i in range(N)]\r\n self.val = [0 for i in range(N)]\r\n self.flag = True\r\n self.edge = [[] for i in range(N)]\r\n\r\n def dfs(self,v,pv):\r\n stack = [(v,pv)]\r\n new_parent = self.parent[pv]\r\n while stack:\r\n v,pv = stack.pop()\r\n self.parent[v] = new_parent\r\n for nv,w in self.edge[v]:\r\n if nv!=pv:\r\n self.val[nv] = self.val[v] + w\r\n stack.append((nv,v))\r\n\r\n def unite(self,x,y,w):\r\n if not self.flag:\r\n return\r\n if self.parent[x]==self.parent[y]:\r\n self.flag = (self.val[x] - self.val[y] == w)\r\n return\r\n\r\n if self.size[self.parent[x]]>self.size[self.parent[y]]:\r\n self.edge[x].append((y,-w))\r\n self.edge[y].append((x,w))\r\n self.size[x] += self.size[y]\r\n self.val[y] = self.val[x] - w\r\n self.dfs(y,x)\r\n else:\r\n self.edge[x].append((y,-w))\r\n self.edge[y].append((x,w))\r\n self.size[y] += self.size[x]\r\n self.val[x] = self.val[y] + w\r\n self.dfs(x,y)\r\n\r\nclass Dijkstra():\r\n class Edge():\r\n def __init__(self, _to, _cost):\r\n self.to = _to\r\n self.cost = _cost\r\n\r\n def __init__(self, V):\r\n self.G = [[] for i in range(V)]\r\n self._E = 0\r\n self._V = V\r\n\r\n @property\r\n def E(self):\r\n return self._E\r\n\r\n @property\r\n def V(self):\r\n return self._V\r\n\r\n def add_edge(self, _from, _to, _cost):\r\n self.G[_from].append(self.Edge(_to, _cost))\r\n self._E += 1\r\n\r\n def shortest_path(self, s):\r\n import heapq\r\n que = []\r\n d = [10**15] * self.V\r\n d[s] = 0\r\n heapq.heappush(que, (0, s))\r\n\r\n while len(que) != 0:\r\n cost, v = heapq.heappop(que)\r\n if d[v] < cost: continue\r\n\r\n for i in range(len(self.G[v])):\r\n e = self.G[v][i]\r\n if d[e.to] > d[v] + e.cost:\r\n d[e.to] = d[v] + e.cost\r\n heapq.heappush(que, (d[e.to], e.to))\r\n return d\r\n\r\n#Z[i]:length of the longest list starting from S[i] which is also a prefix of S\r\n#O(|S|)\r\ndef Z_algorithm(s):\r\n N = len(s)\r\n Z_alg = [0]*N\r\n\r\n Z_alg[0] = N\r\n i = 1\r\n j = 0\r\n while i < N:\r\n while i+j < N and s[j] == s[i+j]:\r\n j += 1\r\n Z_alg[i] = j\r\n if j == 0:\r\n i += 1\r\n continue\r\n k = 1\r\n while i+k < N and k + Z_alg[k] 0:\r\n res_sum += self.BIT[idx]\r\n if mod:\r\n res_sum %= mod\r\n idx -= idx&(-idx)\r\n return res_sum\r\n\r\n #Ai += x O(logN)\r\n def update(self,idx,x):\r\n mod = self.mod\r\n while idx <= self.num:\r\n self.BIT[idx] += x\r\n if mod:\r\n self.BIT[idx] %= mod\r\n idx += idx&(-idx)\r\n return\r\n\r\nclass dancinglink():\r\n def __init__(self,n,debug=False):\r\n self.n = n\r\n self.debug = debug\r\n self._left = [i-1 for i in range(n)]\r\n self._right = [i+1 for i in range(n)]\r\n self.exist = [True for i in range(n)]\r\n\r\n def pop(self,k):\r\n if self.debug:\r\n assert self.exist[k]\r\n L = self._left[k]\r\n R = self._right[k]\r\n if L!=-1:\r\n if R!=self.n:\r\n self._right[L],self._left[R] = R,L\r\n else:\r\n self._right[L] = self.n\r\n elif R!=self.n:\r\n self._left[R] = -1\r\n self.exist[k] = False\r\n\r\n def left(self,idx,k=1):\r\n if self.debug:\r\n assert self.exist[idx]\r\n res = idx\r\n while k:\r\n res = self._left[res]\r\n if res==-1:\r\n break\r\n k -= 1\r\n return res\r\n\r\n def right(self,idx,k=1):\r\n if self.debug:\r\n assert self.exist[idx]\r\n res = idx\r\n while k:\r\n res = self._right[res]\r\n if res==self.n:\r\n break\r\n k -= 1\r\n return res\r\n\r\nclass SparseTable():\r\n def __init__(self,A,merge_func,ide_ele):\r\n N=len(A)\r\n n=N.bit_length()\r\n self.table=[[ide_ele for i in range(n)] for i in range(N)]\r\n self.merge_func=merge_func\r\n\r\n for i in range(N):\r\n self.table[i][0]=A[i]\r\n\r\n for j in range(1,n):\r\n for i in range(0,N-2**j+1):\r\n f=self.table[i][j-1]\r\n s=self.table[i+2**(j-1)][j-1]\r\n self.table[i][j]=self.merge_func(f,s)\r\n\r\n def query(self,s,t):\r\n b=t-s+1\r\n m=b.bit_length()-1\r\n return self.merge_func(self.table[s][m],self.table[t-2**m+1][m])\r\n\r\nclass BinaryTrie:\r\n class node:\r\n def __init__(self,val):\r\n self.left = None\r\n self.right = None\r\n self.max = val\r\n\r\n def __init__(self):\r\n self.root = self.node(-10**15)\r\n\r\n def append(self,key,val):\r\n pos = self.root\r\n for i in range(29,-1,-1):\r\n pos.max = max(pos.max,val)\r\n if key>>i & 1:\r\n if pos.right is None:\r\n pos.right = self.node(val)\r\n pos = pos.right\r\n else:\r\n pos = pos.right\r\n else:\r\n if pos.left is None:\r\n pos.left = self.node(val)\r\n pos = pos.left\r\n else:\r\n pos = pos.left\r\n pos.max = max(pos.max,val)\r\n\r\n def search(self,M,xor):\r\n res = -10**15\r\n pos = self.root\r\n for i in range(29,-1,-1):\r\n if pos is None:\r\n break\r\n\r\n if M>>i & 1:\r\n if xor>>i & 1:\r\n if pos.right:\r\n res = max(res,pos.right.max)\r\n pos = pos.left\r\n else:\r\n if pos.left:\r\n res = max(res,pos.left.max)\r\n pos = pos.right\r\n else:\r\n if xor>>i & 1:\r\n pos = pos.right\r\n else:\r\n pos = pos.left\r\n\r\n if pos:\r\n res = max(res,pos.max)\r\n return res\r\n\r\ndef solveequation(edge,ans,n,m):\r\n #edge=[[to,dire,id]...]\r\n x=[0]*m\r\n used=[False]*n\r\n for v in range(n):\r\n if used[v]:\r\n continue\r\n y = dfs(v)\r\n if y!=0:\r\n return False\r\n return x\r\n\r\n def dfs(v):\r\n used[v]=True\r\n r=ans[v]\r\n for to,dire,id in edge[v]:\r\n if used[to]:\r\n continue\r\n y=dfs(to)\r\n if dire==-1:\r\n x[id]=y\r\n else:\r\n x[id]=-y\r\n r+=y\r\n return r\r\n\r\nclass SegmentTree:\r\n def __init__(self, init_val, segfunc, ide_ele):\r\n n = len(init_val)\r\n self.segfunc = segfunc\r\n self.ide_ele = ide_ele\r\n self.num = 1 << (n - 1).bit_length()\r\n self.tree = [ide_ele] * 2 * self.num\r\n self.size = n\r\n for i in range(n):\r\n self.tree[self.num + i] = init_val[i]\r\n for i in range(self.num - 1, 0, -1):\r\n self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])\r\n\r\n def update(self, k, x):\r\n k += self.num\r\n self.tree[k] = x\r\n while k > 1:\r\n self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])\r\n k >>= 1\r\n\r\n def query(self, l, r):\r\n if r==self.size:\r\n r = self.num\r\n\r\n res = self.ide_ele\r\n\r\n l += self.num\r\n r += self.num\r\n while l < r:\r\n if l & 1:\r\n res = self.segfunc(res, self.tree[l])\r\n l += 1\r\n if r & 1:\r\n res = self.segfunc(res, self.tree[r - 1])\r\n l >>= 1\r\n r >>= 1\r\n return res\r\n\r\n def bisect_l(self,l,r,x):\r\n l += self.num\r\n r += self.num\r\n Lmin = -1\r\n Rmin = -1\r\n while l>= 1\r\n r >>= 1\r\n\r\n if Lmin != -1:\r\n pos = Lmin\r\n while pos n:\r\n break\r\n\r\n imos[i*j] += dp[i]\r\n imos[i*j] %= mod\r\n if (i+1)*j <= n:\r\n imos[(i+1)*j] -= dp[i]\r\n imos[(i+1)*j] %= mod\r\n \r\n #print(dp)\r\n #print(imos)\r\n\r\n #debug = [dp[j] for j in range(n+1)]\r\n #S = imos[0]\r\n #for j in range(1,n+1):\r\n #S = (S + imos[j]) % mod\r\n #if ih)|(a>w):\n\tprint-1\nelse:\n\tk=gcd(h+a,w+a)\n\tc=k//a\n\tif c==0:\n\t\tprint-1\n\telse:\n\t\tprint float(k)/c-a", "lang_cluster": "Python", "compilation_error": false, "code_uid": "222b6d0ab0583db4d9f8c536e60e10f6", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "a,h,w=(int(x) for x in input().split())\nif h==w:\n if aw:\n w,h=h,w\n if w>h+a*2:\n w=w-h-a\n if h>w:\n w,h=h,w \n m=h//a\n s=(w-h)//a\n r=0\n if mw:\n w,h=h,w\n if w>h+a*2:\n w=w-h-a\nif h>w:\n w,h=h,w \nm=h//a\ns=(w-h)//a\nr=0\nif mw:\n w,h=h,w\n if w>h+a*2:\n w=w-h-a\nif h>w:\n w,h=h,w \nm=h//a\ns=(w-h)//a\nr=0\nif mh)|(a>w):\n\tprint-1\nelse:\n\tk=abs(h-w)\n\tif k==0:\n\t\tk=h\n\tif kn:\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)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cb8f4fd1a2c130f689f222e6197125f8", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.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": "d9595f699dc4e2f0c2d6c71761782517", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.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": "ccb3a3ea69a11061e7150e56d55107d4", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.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": "ed1cfc50fafd2a2918b74b01c798530e", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.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": "aaba01243253043fb714835c556d18f0", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.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 = [-1]*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] = v\n bfs.append(u)\n elif lvl[u]==lvl[v]+1:\n ans[u]=1\nansv = 0\nans1 = 0\nfor v in range(k-1):\n if ans[way[v]] or a[way[v]]!= way[v+1]:#\n ansv +=1\nfor v in range(k-1):\n if k-v-1!=lvl[way[v]]:\n ans1+=1\n else:\n break\nprint(ans1,ansv)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84bbf8a1e395359ce90856895c046990", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"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\n\nfor v in range(k-1):\n if ans[way[v]] or len(a[way[v]])>1:#\n ansv +=1\nfor v in range(k-1):\n if k-v-1!=lvl[way[v]] and way[v] 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": "412de02c6c7e8d4be07cc673a6ddc93a", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"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] 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": "7e5d9f283df1d027a7cb6cbf474e282d", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"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 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\nfor v in range(k-1):\n if ans[way[v]] or a[way[v]].pop()!=way[v+1]:#\n ansv +=1\n\nprint(ans1,ansv)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8b6eaa4422d2dfeb893a50a348baa3eb", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\nprev_points = [[] for _ in range(n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n prev_points[v].append(u)\nk = int(input())\np = [int(pi) - 1 for pi in input().split()]\nbest_ways_d = [-1] * n\nbest_ways_nm1 = [0] * n\nq = [(p[-1], 0)]\nfor u, d in q:\n if best_ways_d[u] < 0:\n best_ways_d[u] = d\n d += 1\n for v in prev_points[u]:\n q.append((v, d))\n elif best_ways_d[u] == d:\n best_ways_nm1[u] += 1\nans1 = ans2 = 0\nfor i in range(1, k):\n u, v = p[i - 1], p[i]\n if best_ways_d[u] <= best_ways_d[v]:\n ans1 += 1\n ans2 += 1\n elif best_ways_nm1[u]:\n ans2 += 1\nprint(ans1, ans2)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "93d8b55c056388057acb64dafb6872ef", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"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 v[j]:\n v[j+val]=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": "94e2057fd0617be1eeb24ce901f3bedf", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0} {"lang": "PyPy 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 v[j] :\n v[j+val]=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": "41684bbda021ab106d9ed020d25879ce", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.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 v[j-val] and not v[j]:\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": "da47bb13d01d1d903cd0b3578f4d577a", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.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={}\nfor i in range(2,n+1):\n p[i]=int(nums[i-2])\n if p[i] in mp:\n mp[p[i]].append(i)\n else:\n mp[p[i]]=[i]\ns=[0]*(n+1)\ndef sof(i):\n if s[i]!=0:\n return s[i]\n if i in mp:\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]==True:\n return True\n for j in range(des-val,-1,-1):\n if v[j]==True:\n v[j+val]=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": "6f5967439c070b9bed5d971ed68c3bd2", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.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 i in mp:\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 v[j]:\n v[j+val]=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": "a1dea508d0d0737b1a76a7269cd540a3", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "start = raw_input().strip()\nend = raw_input().strip()\nk = int(raw_input())\nif k == 0:\n if start == end:\n print 1\n else:\n print 0\n exit(0)\nL = len(start)\nans = tmp = 0\nmod = 10 ** 9 + 7\nfor i in xrange(1, L):\n if start[i:] + start[:i] == end:\n tmp += 1\nif start == end:\n p = [1, 0]\n for i in xrange(k):\n p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]\n ans += p[0]\nif tmp > 0:\n p = [0, 1]\n for i in xrange(k):\n p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]\n ans += p[0] * tmp % mod\nprint ans % mod\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "305c33c7f16f232074c6b05d60ad54e0", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "'''\nCreated on Apr 20, 2012\n\n@author: Tobias Flach\n'''\n\ndef solve():\n prime = 1000000007\n \n str_a = raw_input()\n str_b = raw_input()\n k = int(raw_input())\n \n good_shifts = 0\n bad_shifts = 0\n \n for i in range(0, len(str_a)):\n shifted = str_a[i:] + str_a[:i]\n if shifted == str_b:\n good_shifts += 1\n else:\n bad_shifts += 1\n \n good_sols = 0\n bad_sols = 0\n if str_a == str_b:\n good_sols = 1\n else:\n bad_sols = 1\n \n for i in range(0, k):\n t_good_sols = good_sols * (good_shifts - 1) + bad_sols * good_shifts\n t_bad_sols = good_sols * bad_shifts + bad_sols * (bad_shifts - 1)\n good_sols = t_good_sols % prime\n bad_sols = t_bad_sols % prime\n \n print \"%d\" % (good_sols)\n\nif __name__ == '__main__':\n solve()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a310c09c61fe950aae0764a8232086b1", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "import sys\n\nstart = raw_input()\nend = raw_input()\nk = int(raw_input())\n\ndpA = [-1 for i in xrange(k+1)]\ndpB = [-1 for i in xrange(k+1)]\n\ndef calculaA(n):\n global dpA, dpB\n if n == 0:\n return 0\n if dpA[n-1] == -1:\n calculaA(n-1)\n\n dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A\n dpB[n] = dpA[n-1]*B + dpB[n-1]*(B-1)\n\n return dpA[n]\n\nif start == end and k == 0:\n print 1\n exit(0)\n\nA = B = 0\n\nif start != end:\n dpA[0] = 0\n dpB[0] = 1\nelse:\n dpA[0] = 1\n dpB[0] = 0\n\n\nfor i in xrange(len(start)):\n now = start[i:]+start[:i]\n \n if now == end:\n A += 1\n else:\n B += 1\n\nprint calculaA(k)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "14a568839053fd66e94053a2ac23c21d", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "# Shayenne Moura\n\nn, m, l = map(int, raw_input().split())\n\nplanet = []\n\nfor i in xrange(n):\n nome = raw_input()\n op = []\n for j in xrange(m):\n \n a, b, c = map(int, raw_input().split())\n\n op.append([a, b, c])\n\n planet.append(op)\n\n\nmaximo = 0\n\nfor i in xrange(n):\n for j in xrange(n):\n if i != j:\n pft = []\n for k in xrange(m):\n luc = planet[j][k][1] - planet[i][k][0]\n pft.append([luc, planet[i][k][2]])\n \n pft.sort(reverse=True, key=lambda tup:tup[0])\n\n qtd = 0\n ganho = 0\n for r in xrange(len(pft)):\n if qtd + pft[r][1] <= l and pft[r][0] > 0:\n ganho += pft[r][0]*pft[r][1]\n qtd += pft[r][1]\n elif pft[r][0] > 0:\n ganho += pft[r][0]*(l-qtd)\n break\n \n \n\n if ganho > maximo:\n maximo = ganho\n\nprint maximo\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6227fdf46b669ec76ee40ee97b51050", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "Python 2", "source_code": "\n\nstart = raw_input()\nend = raw_input()\nk = int(raw_input())\n\ndpA = [-1 for i in xrange(k+1)]\ndpB = [-1 for i in xrange(k+1)]\n\ndef calculaA(n):\n global dpA, dpB\n if n == 0:\n return 0\n if dpA[n-1] == -1:\n calculaA(n-1)\n\n dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A\n dpB[n] = dpA[n-1]*B + dpB[n-1]*(B-1)\n\n return dpA[n]\n\n\nA = B = 0\n\nif start != end:\n dpA[0] = 0\n dpB[0] = 1\nelse:\n dpA[0] = 1\n dpB[0] = 0\n\n\nfor i in xrange(len(start)):\n now = start[i:]+start[:i]\n \n if now == end:\n A += 1\n else:\n B += 1\n\nprint calculaA(k)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28c8a0bf2090e185cc904a11de5a4b77", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "Python 3", "source_code": "n = int(input())\nf = list(map(int, input().split()))\nfor i in range(n):\n f[i] -= 1\n\ndef gcd(a, b):\n while (a != 0 and b != 0):\n a, b = b, a % b\n return a + b\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nans = 1\nminn = 0\n\nfor i in range(n):\n vis = [False] * n\n cur = i\n st, pr = 0, 0\n while not vis[cur]:\n vis[cur] = True\n cur = f[cur]\n st += 1\n fs = cur\n cur = i\n while cur != fs:\n pr += 1\n cur = f[cur]\n minn = max(minn, pr)\n ans = lcm(ans, st - pr)\n\nprint(((max(0, minn - 1))// ans + 1) * ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "260b47b3e59dbf529855cfb0b9921e95", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.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\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a % b)\n\nto_start = max(path_lens)\nlcm = 1\nfor i, v in enumerate(cycle_lens):\n\tlcm = lcm * v // gcd(lcm, v)\n\n# res = to_start\n# if lcm > 1:\n# \tres += lcm\n\nres = to_start\nif to_start % lcm > 0 or to_start == 0:\n\tres += lcm - to_start % lcm\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "164d9557e0908fe58e95ba1eeaa716c3", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "N = int(raw_input())\na = map(int, raw_input().split())\nfor i in xrange(N):\n a[i] -= 1\n\ndef pers(i):\n b = [-1] * N\n j = 0\n while b[i] == -1:\n b[i] = j\n i = a[i]\n j += 1\n return (b[i], j - b[i])\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\ndef lcm(a, b):\n return a / gcd(a, b) * b\n\nx = 1\nl = 1\nfor i in xrange(N):\n pred, per = pers(i)\n x = lcm(x, per)\n if pred > l:\n l = pred\ny = x\nwhile y < l:\n y += x\nprint y\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9fdac5f5540da2fae18ebc75f523372e", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "n=int(input())\na=list(map(int, input().split()))\n\nfor i in range(len(a)):\n a[i] = a[i]-1\n\ninstack=[False]*n\nprocessed=[False]*n\nloopl = []\ninloop = [False]*n\ndef dfs1(v):\n if (instack[v]):\n cl = 1\n t = a[v]\n inloop[v] = True\n while t != v:\n inloop[t] = True\n cl = cl+1\n t = a[t]\n loopl.append(cl)\n return\n if processed[v]:\n return\n\n processed[v] = True\n instack[v] = True\n dfs1(a[v])\n instack[v] = False\nfor i in range(n):\n dfs1(i)\nmaxdis = 0\nfor i in range(n):\n t = i\n cl = 0\n while not inloop[t]:\n cl += 1\n t = a[t]\n maxdis = max(maxdis, cl)\n\ndef gcd(a, b):\n if a == 0:\n return b\n return gcd(b%a, a)\ndef mkd(a, b):\n return (a*b)//gcd(a,b)\nmkl=1\nfor i in loopl:\n mkl = mkd(mkl, i)\nans = mkl\nwhile ans < maxdis:\n ans += mkl\nprint(ans)\n#print(inloop)\n#print(loopl)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5355c100006ce58b8f44d00edf73cdb0", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "PyPy 2", "source_code": "from fractions import gcd\n\nn = int(raw_input())\nf = [0] + map(int, raw_input().split())\n\nmax_prefix = 0\nperiod = 1\n\nvisited = set()\nfor i in xrange(1, n+1):\n\tif i not in visited:\n\t\tj, steps = i, 0\n\t\twhile j not in visited:\n\t\t\tvisited.add(j)\n\t\t\tj = f[j]\n\t\t\tsteps += 1\n\t\tk, prefix = i, 0\n\t\twhile k != j:\n\t\t\tk = f[k]\n\t\t\tprefix += 1\n\t\tmax_prefix = max(max_prefix, prefix)\n\t\tloop = steps - prefix\n\t\tif loop:\n\t\t\tperiod = period * loop / gcd(period, loop)\n\np = period\nwhile period < max_prefix:\n\tperiod += p\nprint period", "lang_cluster": "Python", "compilation_error": false, "code_uid": "28a0178260fba9da9ee029d340116e53", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "import sys,heapq\n\n#sys.stdin=open(\"data.txt\")\n\ninput=sys.stdin.readline\n\n\n\nn,a,b=map(int,input().split())\n\n\n\nif an: break\n\n pascal.append(newrow)\n\n def getcom(a,b):\n\n # return a+b choose b\n\n # if larger than n, return infinite\n\n if len(pascal[a])>b: return pascal[a][b]\n\n if b==0: return 1\n\n if b==1: return a\n\n return 100000005\n\n\n\n # start with the null node (prefix cost 0)\n\n # can split a node into two other nodes with added cost c+a+b\n\n # new nodes have prefix costs c+a, c+b\n\n # want n-1 splits in total\n\n remain=n-1\n\n ans=0\n\n possible=[[a+b,1]] # [c,count]\n\n while 1:\n\n # cost u, v leaves\n\n u,v=heapq.heappop(possible)\n\n while possible and possible[0][0]==u:\n\n v+=possible[0][1]\n\n heapq.heappop(possible)\n\n if remain<=v:\n\n ans+=u*remain\n\n break\n\n ans+=u*v\n\n remain-=v\n\n heapq.heappush(possible,[u+a,v])\n\n heapq.heappush(possible,[u+b,v])\n\n print(ans)\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fcea8983255b8bbf4d426d3b153ac4ca", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.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 an: break\n pascal.append(newrow)\n def getcom(a,b):\n # return a+b choose b\n # if larger than n, return infinite\n if len(pascal[a])>b: return pascal[a][b]\n if b==0: return 1\n if b==1: return a\n return 100000005\n\n # start with the null node (prefix cost 0)\n # can split a node into two other nodes with added cost c+a+b\n # new nodes have prefix costs c+a, c+b\n # want n-1 splits in total\n remain=n-1\n ans=0\n possible=[[a+b,1]] # [c,count]\n while 1:\n # cost u, v leaves\n u,v=heapq.heappop(possible)\n while possible and possible[0][0]==u:\n v+=possible[0][1]\n heapq.heappop(possible)\n if remain<=v:\n ans+=u*remain\n break\n ans+=u*v\n remain-=v\n heapq.heappush(possible,[u+a,v])\n heapq.heappush(possible,[u+b,v])\n print(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d56fc954a8df248d6c4ff7445bc871e", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "import sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif an: break\n pascal.append(newrow)\n def getcom(a,b):\n # return a+b choose b\n # if larger than n, return infinite\n if len(pascal[a])>b: return pascal[a][b]\n if b==0: return 1\n if b==1: return a\n return 100000005\n\n # start with the null node (prefix cost 0)\n # can split a node into two other nodes with added cost c+a+b\n # new nodes have prefix costs c+a, c+b\n # want n-1 splits in total\n n-=1 # now represents number of splits needed\n\n # binary search the last cost added\n lo=0\n hi=a*int((n**0.5)*2+5)\n\n while 1:\n mid=(lo+hi)//2\n # count stuff\n c0=0 # < mid\n c1=0 # = mid\n for i in range(mid//a+1):\n j=(mid-i*a)//b\n if (mid-i*a)%b!=0:\n # c0 += iC0 + (i+1)C1 + (i+2)C2 + ... + (i+j)Cj\n for k in range(j+1):\n #print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n else:\n for k in range(j):\n #print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n #print(mid,i,j,\"c1\")\n c1+=getcom(i,j)\n #print(mid,\"is\",c0,c1)\n if nn: break\n pascal.append(newrow)\n def getcom(a,b):\n # return a+b choose b\n # if larger than n, return infinite\n if len(pascal[a])>b: return pascal[a][b]\n if b==0: return 1\n if b==1: return a\n return 100000005\n\n # start with the null node (prefix cost 0)\n # can split a node into two other nodes with added cost c+a+b\n # new nodes have prefix costs c+a, c+b\n # want n-1 splits in total\n n-=1 # now represents number of splits needed\n\n # binary search the last cost added\n lo=0\n hi=a*int((n**0.5)*3+3)\n\n while 1:\n mid=(lo+hi)//2\n mid=11\n # count stuff\n c0=0 # < mid\n c1=0 # = mid\n for i in range(mid//a+1):\n j=(mid-i*a)//b\n if (mid-i*a)%b!=0:\n # c0 += iC0 + (i+1)C1 + (i+2)C2 + ... + (i+j)Cj\n for k in range(j+1):\n print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n else:\n for k in range(j):\n print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n print(mid,i,j,\"c1\")\n c1+=getcom(i,j)\n print(mid,\"is\",c0,c1)\n if n r: return 1\n\tkey = l, eq, eq_i\n\tif key in f: return f[key]\n\n\tt = 0\n\tfor x in (['0', '1'] if s[l] == '?' else [s[l]]):\n\t\tif l == r: a = [x]\n\t\telse: a = ['0', '1'] if s[r] == '?' else [s[r]]\n\t\tfor y in a:\n\t\t\tif not((eq and x > y) or (eq_i and x == y == '1')): t += calc(l + 1, r - 1, eq and x == y, eq_i and x != y)\n\tf[key] = t\n\treturn t\n\ns = ['?'] * n\nfor i in xrange(n):\n\ts[i] = '0'\n\tf = {}\n\tp = calc(0, n - 1, True, True)\n\tif m > p:\n\t\tm -= p\n\t\ts[i] = '1'\n\nprint ''.join(s) if s[0] == '0' else -1", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8fe01752294b079ae3e4006522437259", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "from itertools import *\n\ndef foo(i, rev, inv):\n j = n - 1 - i\n if i > j: return 1\n if (i, rev, inv) in cache: return cache[i, rev, inv]\n ret = 0\n for a, b in product((0, 1), repeat = 2):\n if (i < j or a == b) and s[i] in (None, a) and s[j] in (None, b) and (a <= b or rev) and (a <= (b ^ 1) or inv):\n ret += foo(i + 1, rev or a < b, inv or a < (b ^ 1))\n cache[i, rev, inv] = ret\n return ret\n\nn, k = map(int, raw_input().split())\nk += 1\ns = [None] * n\nfor i in xrange(n):\n cache = {}\n s[i] = 0\n t = foo(0, False, False)\n if k > t:\n k -= t\n s[i] = 1\nprint ''.join(map(str, s)) if s[0] == 0 else -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "129b9acd7f591c46c1a9b9478c982eec", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nm += 1\n\n\ndef calc(l, r, eq, eq_i):\n if l > r:\n return 1\n key = l, eq, eq_i\n if key in f:\n return f[key]\n\n t = 0\n for x in (['0', '1'] if s[l] == '?' else [s[l]]):\n if l == r:\n a = [x]\n else:\n a = ['0', '1'] if s[r] == '?' else [s[r]]\n for y in a:\n if not((eq and x > y) or (eq_i and x == y == '1')):\n t += calc(l + 1, r - 1, eq and x == y, eq_i and x != y)\n f[key] = t\n return t\n\n\ns = ['?'] * n\nfor i in range(n):\n s[i] = '0'\n f = {}\n p = calc(0, n - 1, True, True)\n if m > p:\n m -= p\n s[i] = '1'\n\nif s[0] == '0':\n print(''.join(s))\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d7f798ecb90a698a3f91e51550f304f5", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "def raschot(d, e, g, h):\n if d > e:\n return 1\n key = d, g, h\n if key in b:\n return b[key]\n f = 0\n for x in (['0', '1'] if a0[d] == '?' else [a0[d]]):\n if d == e:\n a = [x]\n else:\n a = ['0', '1'] if a0[e] == '?' else [a0[e]]\n for y in a:\n if not ((g and x > y) or (h and x == y == '1')):\n f += raschot(d + 1, e - 1, g and x == y, h and x != y)\n b[key] = f\n return f\n\n\nn, m = map(int, input().split())\nm += 1\na0 = ['?'] * n\nfor i in range(n):\n a0[i] = '0'\n b = {}\n c = raschot(0, n - 1, True, True)\n if m > c:\n m -= c\n a0[i] = '1'\nif a0[0] == '0':\n print(''.join(a0))\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6cfad4d9038eaad04c1763f1dea19804", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "from itertools import *\n\ndef foo(i, rev, inv):\n j = n - 1 - i\n if i >= j: return 1\n if (i, rev, inv) in cache: return cache[i, rev, inv]\n ret = 0\n for a, b in product((0, 1), repeat = 2):\n if s[i] in (None, a) and s[j] in (None, b) and (a <= b or rev) and (a <= (b ^ 1) or inv):\n ret += foo(i + 1, rev or a < b, inv or a < (b ^ 1))\n cache[i, rev, inv] = ret\n return ret\n\nn, k = map(int, raw_input().split())\nk += 1\ns = [None] * n\nfor i in xrange(n):\n cache = {}\n s[i] = 0\n t = foo(0, False, False)\n if k > t:\n k -= t\n s[i] = 1\nprint ''.join(map(str, s)) if s[0] == 0 else -1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "373442e09db43aa60a1103c089847144", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.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(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": "87ac5dedc70e4f3fcf599e9f56cab0d8", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "N,M = map(int,raw_input().split())\n\nP = {}\nQ = {}\nfor i in range(10001):\n for j in range(1,5):\n P[(i,j)] = set()\n Q[(i,j)] = set()\n\nfor i in range(10):\n P[(i,1)].add(i)\n Q[(i,1)].add(i)\nfor i in range(100):\n P[(i,2)].add(i)\n Q[(i,2)].add(i)\n a,b = i/10,i%10\n next = [a+b,abs(a-b),a*b]\n for j in next:\n P[(j,2)].add(i)\n Q[(i,2)].add(j)\nfor i in range(1000):\n P[(i,3)].add(i)\n Q[(i,3)].add(i)\n candidate = [((i/100,1),(i%100,2)),((i/10,2),(i%10,1))]\n next = []\n for p,q in candidate:\n for a in Q[p]:\n for b in Q[q]:\n next.append(a+b)\n next.append(abs(a-b))\n next.append(a*b)\n next = set(next)\n for j in next:\n P[(j,3)].add(i)\n Q[(i,3)].add(j)\nfor i in range(10000):\n P[(i,4)].add(i)\n Q[(i,4)].add(i)\n candidate = [((i/1000,1),(i%1000,3)),((i/100,2),(i%100,2)),((i/10,3),(i%10,1))]\n next = []\n for p,q in candidate:\n for a in Q[p]:\n for b in Q[q]:\n next.append(a+b)\n next.append(abs(a-b))\n next.append(a*b)\n next = set(next)\n for j in next:\n P[(j,4)].add(i)\n Q[(i,4)].add(j)\n\ndef f(n,m,p):\n for i in range(10000):\n for j in p[(abs(n-i),4)]:\n print '%04d%04d'%(i,j)\n m -= 1\n if m == 0:\n return\n\nf(N,M,P)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "352194f4f46922b2d48394684aaa9d38", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\nimport sys\n\na = []\n\ndef gen (n, d):\n\tglobal a\n\tif n > 0:\n\t\ta += [n]\n\tif d > 0:\n\t\tgen (n * 10 + 4, d - 1)\n\t\tgen (n * 10 + 7, d - 1)\n\ndef go (l, r, pos, c):\n\tl = max (l, pos)\n\tr = min (r, c)\n#\tprint l, r, c\n\treturn max (r - l + 1, 0) * c\n\ndef fact (n):\n\tif n > 12:\n\t\treturn 10 ** 9 + 1\n\tif n == 0:\n\t\treturn 1\n\treturn n * fact (n - 1)\n\ngen (0, 9)\na.sort ()\n\nwhile True:\n\ts = sys.stdin.readline ().strip ()\n\tif s == '':\n\t\ts = sys.stdin.readline ().strip ()\n\t\tif s == '':\n\t\t\tbreak\n\tn, k = [int (x) for x in s.split ()]\n\tif n <= 12:\n\t\tif k > fact (n):\n\t\t\tprint -1\n\t\t\tcontinue\n\tm = max (n - 13, 0)\n\td = n - m\n\tres = 0\n\tfor c in a:\n\t\tif c <= m:\n\t\t\tres = res + 1\n\tb = range (n - d + 1, n + 1)\n\tp = range (n - d + 1, n + 1)\n\tq = []\n\tk -= 1\n\tfor i in range (d)[::-1]:\n\t\tj = k / fact (i)\n#\t\tprint k, fact (i), j\n\t\tk %= fact (i)\n\t\tq += [b[j]]\n\t\tb = b[:j] + b[j + 1:]\n#\t\tprint p, q, b\n\tfor i in range (d):\n\t\tif p[i] in a and q[i] in a:\n\t\t\tres += 1\n\tprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a136f8830ef0e258f3104eb20b6b4893", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\ndef isLucky(num):\n\ts = str(num)\n\tfor i in s:\n\t\tif i != '4' and i != '7':\n\t\t\treturn False\n\treturn True\n\ndef getLucky(d):\n\tif d == 1:\n\t\tfor i in [4, 7]:\n\t\t\tyield str(i)\n\telse:\n\t\tl = [i for i in getLucky(d-1)]\n\t\tfor j in l:\n\t\t\tyield '4'+j\n\t\tfor j in l:\n\t\t\tyield '7'+j\n\nluckies = []\nfor d in range(1,11):\n\tfor i in getLucky(d):\n\t\tluckies.append(int(i))\n\ndef canto(l, k):\n\t# find the k(th) permutation of list l, k counts from 1\n\tn = len(l)\n\tp = k - 1\n\ta = []\n\ti = n - 1\n\tmark = [False]*(n+1)\n\twhile len(a) < n:\n\t\tfac = math.factorial(i)\n\n\t\ta.append(p/fac)\n\t\tp %= fac\n\t\ti -= 1\n\t\tj = 1\n\t\tcnt = 0\n\t\twhile cnt < a[-1]+1:\n\t\t\tif not mark[j]:\n\t\t\t\tcnt += 1\n\t\t\tj += 1\n\t\ta[-1] = j-1\n\t\tmark[a[-1]] = True\n\treturn [l[i-1] for i in a]\n\nn, k = map(int, raw_input().split())\nif n < 20 and k > math.factorial(n):\n\tprint -1\nelse:\n\tfor tail in xrange(1, 31):\n\t\tfac = math.factorial(tail)\n\t\tif fac >= k:\n\t\t\tbreak\n\tl = [i for i in xrange(n+1-tail, n+1)]\n\tp_tail = canto(l, k)\n\t# print 'tail',tail\n\t# print p_tail\n\n\tans = 0\n\tfor lucky in luckies:\n\t\tif lucky > n: break\n\t\t# print 'lucky is',lucky\n\t\tif lucky <= n-tail:\n\t\t\tans += 1\n\t\t\t# print lucky\n\t\telse:\n\t\t\ti = p_tail.index(lucky)\n\t\t\tif isLucky(n-tail+1+i):\n\t\t\t\tans += 1\n\t\t\t\t# print lucky\n\tprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c779a011a26a440daab5f976c438b533", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "import math\n\ndef good(x):\n while x > 0:\n if x % 10 != 4 and x % 10 != 7:\n return False\n x //=10\n return True\n\nn, k = map(int, input().split())\n\nl = 1\nr = n\nif n >= 11:\n l = n-10\nif n <= 10 and math.factorial(n) < k:\n print(-1)\nelse:\n L = r - l + 1\n a = []\n for i in range(L):\n a.append(i)\n b = []\n k -= 1\n for i in range(L):\n x = k//math.factorial(L-i-1)\n y = a[x]\n b.append(y+l)\n a.remove(y)\n k -= x * math.factorial(L-i-1)\n c = []\n if 4 < l:\n c.append(4)\n if 7 < l:\n c.append(7)\n ans = 0\n while len(c) > 0:\n ans += len(c)\n cc = []\n for x in c:\n if x * 10 + 4 < l:\n cc.append(x * 10 + 4)\n if x * 10 + 7 < l:\n cc.append(x * 10 + 7)\n c = cc\n for i in range(L):\n if good(i+l) and good(b[i]):\n ans += 1\n print(ans)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e4943a923b67564f105b2d104c3b141", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "Python 3", "source_code": "def lucky(x):\n s=str(x)\n return s.count('4')+s.count('7')==len(s)\n\ndef Gen_lucky(n):\n s=str(n)\n if(len(s)==1):\n if(s[0]=='4' or s[0]=='7'):\n return 1\n return 0\n x=0\n for i in range(1,len(s)):\n x+=2**i\n if(s[0]<'4'):\n return x\n if(s[0]>'7'):\n return x+2**len(s)\n if(s[0]=='5' or s[0]=='6'):\n return x+(2**(len(s)-1))\n if(s[0]=='7'):\n x+=2**(len(s)-1)\n x+=Getlucky(s[1:])\n return x\n \n\ndef Form(X,k):\n if(k==0):\n return X\n for i in range(len(X)):\n if(k>=F[len(X)-i-1]):\n h=k//F[len(X)-i-1]\n r=k%F[len(X)-i-1]\n G=list(X[i+1:])\n G.remove(X[i+h])\n G=[X[i]]+G\n return Form(X[:i]+[X[i+h]]+G,r)\n\np=1\n\nF=[1]\ni=1\nwhile(p<=10**10):\n p*=i\n F.append(p)\n i+=1\n\nn,k=map(int,input().split())\n\n\n \nif(n<=15):\n L=Form(list(range(1,n+1)),k-1)\n x=0\n for i in range(n):\n if(lucky(i+1) and lucky(L[i])):\n x+=1\n print(x)\nelse:\n L=Form(list(range(n-13,n+1)),k-1)\n x=Gen_lucky(n-14)\n for i in range(n-13,n+1):\n if(lucky(L[i-n+13]) and lucky(i)):\n x+=1\n print(x)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ae6492ac25186d1fe7f813fe4faaaed3", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "Python 2", "source_code": "import math\ndef isLucky(num):\n\ts = str(num)\n\tfor i in s:\n\t\tif i != '4' and i != '7':\n\t\t\treturn False\n\treturn True\n\ndef getLucky(d):\n\tif d == 1:\n\t\tfor i in [4, 7]:\n\t\t\tyield str(i)\n\telse:\n\t\tl = [i for i in getLucky(d-1)]\n\t\tfor j in l:\n\t\t\tyield '4'+j\n\t\tfor j in l:\n\t\t\tyield '7'+j\n\nluckies = []\nfor d in range(1,11):\n\tfor i in getLucky(d):\n\t\tluckies.append(int(i))\n\ndef canto(l, k):\n\t# find the k(th) permutation of list l, k counts from 1\n\tn = len(l)\n\tp = k - 1\n\ta = []\n\ti = n - 1\n\tmark = [False]*(n+1)\n\twhile len(a) < n:\n\t\tfac = math.factorial(i)\n\n\t\ta.append(p/fac)\n\t\tp %= fac\n\t\ti -= 1\n\t\tj = 1\n\t\tcnt = 0\n\t\twhile cnt < a[-1]+1:\n\t\t\tif not mark[j]:\n\t\t\t\tcnt += 1\n\t\t\tj += 1\n\t\ta[-1] = j-1\n\t\tmark[a[-1]] = True\n\treturn [l[i-1] for i in a]\n\nn, k = map(int, raw_input().split())\n\nfor tail in range(1, n+1):\n\tfac = math.factorial(tail)\n\tif fac >= k:\n\t\tbreak\nl = [i for i in range(n+1-tail, n+1)]\np_tail = canto(l, k)\n# print 'tail',tail\n# print p_tail\n\nans = 0\nfor lucky in luckies:\n\tif lucky > n: break\n\t# print 'lucky is',lucky\n\tif lucky <= n-tail:\n\t\tans += 1\n\t\t# print lucky\n\telse:\n\t\ti = p_tail.index(lucky)\n\t\tif isLucky(n-tail+1+i):\n\t\t\tans += 1\n\t\t\t# print lucky\nprint ans\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8ec9fb175c8ed502e17949fd059da88", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "PyPy 3", "source_code": "MOD = 998244353;import __pypy__;int_add = __pypy__.intop.int_add;int_sub = __pypy__.intop.int_sub;int_mul = __pypy__.intop.int_mul\r\ndef make_mod_mul(mod=MOD):\r\n fmod_inv = 1.0 / mod\r\n def mod_mul(a, b, c=0):\r\n res = int_sub(int_add(int_mul(a, b), c), int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)))\r\n if res >= mod: return res - mod\r\n elif res < 0: return res + mod\r\n else: return res\r\n return mod_mul\r\nmod_mul = make_mod_mul()\r\ndef mod_pow(x, y):\r\n if y == 0: return 1\r\n res = 1\r\n while y > 1:\r\n if y & 1 == 1: res = mod_mul(res, x)\r\n x = mod_mul(x, x); y >>= 1\r\n return mod_mul(res, x)\r\nn, m = map(int, input().split());pascal = [[1]]\r\nfor _ in range(n + m + 5):\r\n nl = [1]\r\n for i in range(_): nl.append((pascal[-1][i] + pascal[-1][i+1]) % MOD)\r\n nl.append(1); pascal.append(nl)\r\ndef s1(n,m):\r\n out = 0\r\n for row in range(1, n):\r\n above = row\r\n below = n - row\r\n\r\n bottom = []\r\n for i in range(m):\r\n a = below - 1\r\n b = i\r\n a2 = below\r\n b2 = m-i-1\r\n bottom.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n\r\n top = []\r\n for i in range(m):\r\n a = above - 1\r\n b = i\r\n a2 = above\r\n b2 = m-i-1\r\n top.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n top.reverse()\r\n\r\n curr = 0\r\n for i in range(m):\r\n out += mod_mul(curr,bottom[i])\r\n curr += top[i]\r\n curr %= MOD\r\n out %= MOD\r\n return out * 2\r\n\r\ndef s2(n,m):\r\n o = 0\r\n for i in range(1,n):\r\n for j in range(1,m):\r\n a = pascal[i+j-1][i-1]\r\n b = pascal[n-i+j-1][n-i]\r\n c = pascal[n-i-1+m-j][m-j]\r\n d = pascal[i+m-j-1][i]\r\n #print(a,b,c,d)\r\n o += mod_mul(mod_mul(a,b),mod_mul(c,d))\r\n return o\r\n\r\n\r\nc1 = s1(n,m)\r\nc2 = s1(m,n)\r\nc3 = s2(n,m)\r\n\r\nout = (c1 + c2 - 2*c3) % MOD\r\nprint(out)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2198ecc557d36049c3ab5f4d0ca2d5d", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0} {"lang": "PyPy 3", "source_code": "MOD = 998244353;import __pypy__;int_add = __pypy__.intop.int_add;int_sub = __pypy__.intop.int_sub;int_mul = __pypy__.intop.int_mul\r\ndef make_mod_mul(mod=MOD):\r\n fmod_inv = 1.0 / mod\r\n def mod_mul(a, b, c=0):\r\n res = int_sub(int_add(int_mul(a, b), c), int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)))\r\n if res >= mod: return res - mod\r\n elif res < 0: return res + mod\r\n else: return res\r\n return mod_mul\r\nmod_mul = make_mod_mul()\r\ndef mod_pow(x, y):\r\n if y == 0: return 1\r\n res = 1\r\n while y > 1:\r\n if y & 1 == 1: res = mod_mul(res, x)\r\n x = mod_mul(x, x); y >>= 1\r\n return mod_mul(res, x)\r\nn, m = map(int, input().split());pascal = [[1]]\r\nfor _ in range(n + m + 5):\r\n nl = [1]\r\n for i in range(_): nl.append((pascal[-1][i] + pascal[-1][i+1]) % MOD)\r\n nl.append(1); pascal.append(nl)\r\ndef s1(n,m):\r\n out = 0\r\n for row in range(1, n):\r\n above = row; below = n - row; bottom = [];top = []\r\n for i in range(m): a = below - 1; b = i; a2 = below; b2 = m-i-1; bottom.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n for i in range(m): a = above - 1; b = i; a2 = above; b2 = m-i-1; top.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n top.reverse(); curr = 0\r\n for i in range(m): out += mod_mul(curr,bottom[i]); curr += top[i]; curr %= MOD; out %= MOD\r\n return out * 2\r\ndef s2(n,m):\r\n o = 0\r\n for i in range(1,n):\r\n for j in range(1,m): a = pascal[i+j-1][i-1]; b = pascal[n-i+j-1][n-i]; c = pascal[n-i-1+m-j][m-j]; d = pascal[i+m-j-1][i]; o += mod_mul(mod_mul(a,b),mod_mul(c,d))\r\n return o\r\nc1 = s1(n,m);c2 = s1(m,n);c3 = s2(n,m);out = (c1 + c2 - 2*c3) % MOD;print(out)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8939c5c6f164c55955a4a6cfbfef0d0c", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0} {"lang": "PyPy 3", "source_code": "MOD = 998244353;import __pypy__;int_add = __pypy__.intop.int_add;int_sub = __pypy__.intop.int_sub;int_mul = __pypy__.intop.int_mul\r\ndef make_mod_mul(mod=MOD):\r\n fmod_inv = 1.0 / mod\r\n def mod_mul(a, b, c=0):\r\n res = int_sub(int_add(int_mul(a, b), c), int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)))\r\n if res >= mod: return res - mod\r\n elif res < 0: return res + mod\r\n else: return res\r\n return mod_mul\r\nmod_mul = make_mod_mul()\r\ndef mod_pow(x, y):\r\n if y == 0: return 1\r\n res = 1\r\n while y > 1:\r\n if y & 1 == 1: res = mod_mul(res, x)\r\n x = mod_mul(x, x); y >>= 1\r\n return mod_mul(res, x)\r\nn, m = map(int, input().split());pascal = [[1]]\r\nfor _ in range(n + m + 5):\r\n nl = [1]\r\n for i in range(_): nl.append((pascal[-1][i] + pascal[-1][i+1]) % MOD)\r\n nl.append(1); pascal.append(nl)\r\ndef s1(n,m):\r\n out = 0\r\n for row in range(1, n):\r\n above = row; below = n - row; bottom = [];top = []\r\n for i in range(m): a = below - 1; b = i; a2 = below; b2 = m-i-1; bottom.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n for i in range(m): a = above - 1; b = i; a2 = above; b2 = m-i-1; top.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n top.reverse(); curr = 0\r\n for i in range(m): out += mod_mul(curr,bottom[i]); curr += top[i]; curr %= MOD; out %= MOD\r\n return out * 2\r\ndef s2(n,m):\r\n o = 0\r\n for i in range(1,n):\r\n for j in range(1,m): a = pascal[i+j-1][i-1]; b = pascal[n-i+j-1][n-i]; c = pascal[n-i-1+m-j][m-j]; d = pascal[i+m-j-1][i]; o += mod_mul(mod_mul(a,b),mod_mul(c,d))\r\n return o\r\nc1 = s1(n,m);c2 = s1(m,n);c3 = s2(n,m);out = (c1 + c2 - 2*c3) % MOD;print(out)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "026ca48c929cecaeb049d342c82bd8af", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0} {"lang": "PyPy 3", "source_code": "M=998244353;N=4042\r\ntry:\r\n import __pypy__\r\n int_add=__pypy__.intop.int_add\r\n int_sub=__pypy__.intop.int_sub\r\n int_mul=__pypy__.intop.int_mul\r\n def make_mod_mul(mod=M):\r\n fmod_inv=1.0/mod\r\n def mod_mul(a,b,c=0):\r\n res=int_sub(\r\n int_add(int_mul(a,b),c),\r\n int_mul(mod,int(fmod_inv*a*b+fmod_inv*c)),\r\n )\r\n if res>=mod:return res-mod\r\n elif res<0:return res+mod\r\n else:return res\r\n return mod_mul\r\n mod_mul=make_mod_mul()\r\nexcept:\r\n def mod_mul(a,b):return(a*b)%M\r\ndef mod_add(a,b):\r\n v=a+b\r\n if v>=M:v-=M\r\n if v<0:v+=M\r\n return v\r\ndef mod_sum(a):\r\n v=0\r\n for i in a:v=mod_add(v,i)\r\n return v\r\nf1=[1]\r\nfor i in range(N):f1.append(mod_mul(f1[-1],i+1))\r\nf2=[pow(f1[-1],M-2,M)]\r\nfor i in range(N):f2.append(mod_mul(f2[-1],N-i))\r\nf2=f2[::-1]\r\nC=lambda a,b:mod_mul(mod_mul(f1[a],f2[b]),f2[a-b])\r\nA=lambda a,b,w:mod_mul(C(a+b,a),C(w+b-a-2,b-1))\r\ndef V(h,W,H):\r\n s=p=0\r\n for i in range(W-1):\r\n p=mod_add(p,A(i,H-h,W));s=mod_add(s,mod_mul(p,A(W-2-i,h,W)))\r\n return s\r\nH,W=map(int,input().split())\r\nY=mod_sum(mod_mul(A(s,h,W),A(W-2-s,H-h,W))for s in range(W-1)for h in range(1,H))\r\nX=mod_add(mod_sum(V(h,W,H)for h in range(1,H)),mod_sum(V(w,H,W)for w in range(1,W)))\r\nprint((X+X-Y-Y)%M)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "23c459d24fc17faac464e2167225faf0", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0} {"lang": "PyPy 3", "source_code": "MOD = 998244353;import __pypy__;int_add = __pypy__.intop.int_add;int_sub = __pypy__.intop.int_sub;int_mul = __pypy__.intop.int_mul\r\ndef make_mod_mul(mod=MOD):\r\n fmod_inv = 1.0 / mod\r\n\r\n def mod_mul(a, b, c=0):\r\n res = int_sub(int_add(int_mul(a, b), c), int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)))\r\n if res >= mod:\r\n return res - mod\r\n elif res < 0:\r\n return res + mod\r\n else:\r\n return res\r\n\r\n return mod_mul\r\n\r\n\r\nmod_mul = make_mod_mul()\r\n\r\n\r\ndef mod_pow(x, y):\r\n if y == 0:\r\n return 1\r\n res = 1\r\n while y > 1:\r\n if y & 1 == 1:\r\n res = mod_mul(res, x)\r\n x = mod_mul(x, x)\r\n y >>= 1\r\n return mod_mul(res, x)\r\n\r\nn, m = map(int, input().split())\r\n\r\npascal = [[1]]\r\nfor _ in range(n + m + 5):\r\n nl = [1]\r\n for i in range(_):\r\n nl.append((pascal[-1][i] + pascal[-1][i+1]) % MOD)\r\n nl.append(1)\r\n pascal.append(nl)\r\n\r\ndef s1(n,m):\r\n out = 0\r\n for row in range(1, n):\r\n above = row\r\n below = n - row\r\n\r\n bottom = []\r\n for i in range(m):\r\n a = below - 1\r\n b = i\r\n a2 = below\r\n b2 = m-i-1\r\n bottom.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n\r\n top = []\r\n for i in range(m):\r\n a = above - 1\r\n b = i\r\n a2 = above\r\n b2 = m-i-1\r\n top.append(mod_mul(pascal[a+b][a] , pascal[a2+b2][a2]))\r\n top.reverse()\r\n\r\n curr = 0\r\n for i in range(m):\r\n out += mod_mul(curr,bottom[i])\r\n curr += top[i]\r\n curr %= MOD\r\n out %= MOD\r\n return out * 2\r\n\r\ndef s2(n,m):\r\n o = 0\r\n for i in range(1,n):\r\n for j in range(1,m):\r\n a = pascal[i+j-1][i-1]\r\n b = pascal[n-i+j-1][n-i]\r\n c = pascal[n-i-1+m-j][m-j]\r\n d = pascal[i+m-j-1][i]\r\n #print(a,b,c,d)\r\n o += mod_mul(mod_mul(a,b),mod_mul(c,d))\r\n return o\r\n\r\n\r\nc1 = s1(n,m)\r\nc2 = s1(m,n)\r\nc3 = s2(n,m)\r\n\r\nout = (c1 + c2 - 2*c3) % MOD\r\nprint(out)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a1c0e5f4cb2915748818c2c106fc89c9", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0} {"lang": "Python 3", "source_code": "mod, sx, sy, dx, dy, t = map(int, input().split())\nclass Matrix():\n def __init__(self, n):\n self.n = n\n self.a = [[0] * n for _ in range(n)]\n\n def __mul__(self, b):\n res = Matrix(self.n)\n for i in range(self.n):\n for j in range(self.n):\n for k in range(self.n):\n res.a[i][j] += self.a[i][k] * b.a[k][j] % mod\n res.a[i][j] %= mod\n return res\n\n def __pow__(self, e):\n res = Matrix(self.n)\n for i in range(self.n):\n res.a[i][i] = 1\n tmp = self\n while e:\n if e & 1:\n res = res * tmp\n e >>= 1\n tmp = tmp * tmp\n return res\nM = Matrix(6)\nM.a = [[2, 1, 1, 0, 1, 2],\n [1, 2, 0, 1, 1, 2],\n [1, 1, 1, 0, 1, 2],\n [1, 1, 0, 1, 1, 2],\n [0, 0, 0, 0, 1, 1],\n [0, 0, 0, 0, 0, 1]]\nsx -= 1\nsy -= 1\nr = M ** t\nf = lambda i: (r.a[i][0] * sx + r.a[i][1] * sy + r.a[i][2] * dx + r.a[i][3] * dy + r.a[i][5]) % mod + 1\nprint(f(0), f(1))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "605e4b8999f3e5d7a00eb8b0883fff1f", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "53b483ed21b8aaaf800e604973594451", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "od, 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)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ce116966546afec39f983b2d322e7c80", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "od, 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", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a892565e335950178b4d5b13ec38898c", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "mod, sx, sy, dx, dy, t = map(int,raw_input().split())\nclass Matrix():\n def __init__(self, n):\n self.n = n\n self.a = [[0] * n for _ in range(n)]\n\n def __mul__(self, b):\n res = Matrix(self.n)\n for i in range(self.n):\n for j in range(self.n):\n for k in range(self.n):\n res.a[i][j] += self.a[i][k] * b.a[k][j] % mod\n res.a[i][j] %= mod\n return res\n\n def __pow__(self, e):\n res = Matrix(self.n)\n for i in range(self.n):\n res.a[i][i] = 1\n tmp = self\n while e:\n if e & 1:\n res = res * tmp\n e >>= 1\n tmp = tmp * tmp\n return res\nM = Matrix(6)\nM.a = [[2, 1, 1, 0, 1, 2],\n [1, 2, 0, 1, 1, 2],\n [1, 1, 1, 0, 1, 2],\n [1, 1, 0, 1, 1, 2],\n [0, 0, 0, 0, 1, 1],\n [0, 0, 0, 0, 0, 1]]\nsx -= 1\nsy -= 1\nr = M ** t\nf = lambda i: (r.a[i][0] * sx + r.a[i][1] * sy + r.a[i][2] * dx + r.a[i][3] * dy + r.a[i][5]) % mod + 1\nprint(f(0), f(1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bd1ce16108e7c3859d6938ec7c438e0a", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import math\na,b= map(int,input().split())\nn=a+b\nans,l=0,1\nwhile l<=n:\n g= n//l\n if a= arem and bPeriod >= brem:\n \tvalidK = aPeriod + bPeriod - aLeft - bLeft + 1\n \tif (t + 1) * (aLeft + bLeft) == ab:\n \t\tvalidK -= 1\n \tif validK > 0:\n \t\tcnt += validK\n k = ab // t + 1\nprint(cnt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5822ac270b3110b0402796643573b36d", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "import math\n\na, b = [int(x) for x in input().split()]\ncnt = 0\nab = a + b\nk = 2\nwhile k <= ab:\n t = ab // k\n aPeriod = a // t\n bPeriod = b // t\n aLeft = (a + t) // (t + 1)\n bLeft = (b + t) // (t + 1)\n arem = a - t * aPeriod\n brem = b - t * bPeriod\n if aPeriod >= arem and bPeriod >= brem:\n \tvalidK = aPeriod + bPeriod - aLeft - bLeft + 1\n \tif validK > 0:\n \t\tcnt += validK\n k = ab // t + 1\nprint(cnt)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5e6a3b404bdf91a48cd177e14819f488", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.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": "bd82c5c7ae58443f269e0eec332ffade", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "\n\nn, m, l = map(int, raw_input().split())\n\nplanet = []\n\nfor i in xrange(n):\n nome = raw_input()\n op = []\n for j in xrange(m):\n \n a, b, c = map(int, raw_input().split())\n\n op.append([a, b, c])\n\n planet.append(op)\n\n\nmaximo = 0\n\nfor i in xrange(n):\n for j in xrange(n):\n if i != j:\n pft = []\n for k in xrange(m):\n luc = planet[j][k][1] - planet[i][k][0]\n pft.append([luc, planet[i][k][2]])\n \n pft.sort(reverse=True, key=lambda tup:tup[0])\n\n qtd = 0\n ganho = 0\n for r in xrange(len(pft)):\n if qtd + pft[r][1] <= l and pft[r][0] > 0:\n ganho += pft[r][0]*pft[r][1]\n qtd += pft[r][1]\n elif pft[r][0] > 0:\n ganho += pft[r][0]*(l-qtd)\n break\n \n \n\n if ganho > maximo:\n maximo = ganho\n\nprint maximo\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "5bd1019678edd7a6d40c0d99bdd022c7", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n, m, l = map(int, raw_input().split())\n\nplanet = []\n\nfor i in xrange(n):\n nome = raw_input()\n op = []\n for j in xrange(m):\n \n a, b, c = map(int, raw_input().split())\n\n op.append([a, b, c])\n\n planet.append(op)\n\n\nmaximo = 0\n\nfor i in xrange(n):\n for j in xrange(n):\n if i != j:\n pft = []\n for k in xrange(m):\n luc = planet[j][k][1] - planet[i][k][0]\n pft.append([luc, planet[i][k][2]])\n \n pft.sort(reverse=True, key=lambda tup:tup[0])\n\n qtd = 0\n ganho = 0\n for r in xrange(len(pft)):\n if qtd + pft[r][1] <= l and pft[r][0] > 0:\n ganho += pft[r][0]*pft[r][1]\n qtd += pft[r][1]\n elif pft[r][0] > 0:\n ganho += pft[r][0]*(l-qtd)\n break\n \n \n\n if ganho > maximo:\n maximo = ganho\n\nprint maximo\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ec3bb93f2ea34fe8e85b0937ca82b521", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n, m, l = map(int, raw_input().split())\n\nplanet = []\n\nfor i in xrange(n):\n nome = raw_input()\n op = []\n for j in xrange(m):\n \n a, b, c = map(int, raw_input().split())\n\n op.append([a, b, c])\n\n planet.append(op)\n\n\nmaximo = 0\n\nfor i in xrange(n):\n for j in xrange(n):\n if i != j:\n pft = []\n for k in xrange(m):\n luc = (planet[j][k][1] - planet[i][k][0])*planet[i][k][2]\n pft.append([luc, planet[i][k][2]])\n \n pft.sort(reverse=True, key=lambda tup:tup[0])\n\n qtd = 0\n ganho = 0\n for r in xrange(len(pft)):\n if qtd + pft[r][1] < l and pft[r][0] > 0:\n ganho += pft[r][0]\n qtd += pft[r][1]\n elif pft[r][0] > 0:\n ganho += (pft[r][0]/pft[r][1])*(l-qtd)\n break\n else:\n break\n \n\n if ganho > maximo:\n maximo = ganho\n\nprint maximo\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2be2e0166ca507a0c56d0de279f601b9", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n, m, l = map(int, raw_input().split())\n\nplanet = []\n\nfor i in xrange(n):\n nome = raw_input()\n op = []\n for j in xrange(m):\n \n a, b, c = map(int, raw_input().split())\n\n op.append([a, b, c])\n\n planet.append(op)\n\n\nmaximo = 0\n\nfor i in xrange(n):\n for j in xrange(n):\n if i != j:\n pft = []\n for k in xrange(m):\n luc = planet[j][k][1] - planet[i][k][0]\n pft.append([luc, planet[i][k][2]])\n \n pft.sort(reverse=True, key=lambda tup:tup[0])\n\n qtd = 0\n ganho = 0\n for r in xrange(len(pft)):\n if qtd + pft[r][1] < l:\n ganho += pft[r][0]*pft[r][1]\n qtd += pft[r][1]\n else:\n ganho += pft[r][0]*(l-qtd)\n break\n \n if ganho > maximo:\n maximo = ganho\n\nprint maximo\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "cc88d5140a8daf635eefcc4a9888354b", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "Python 2", "source_code": "n,m,capacity = [int(x) for x in raw_input().split()]\n\nclass Planet:\n def __init__(self):\n self.a = []\n self.b = []\n self.c = []\n self.n = \"\"\n def __repr__(self):\n return \"%s: a:%r, b:%r, c:%r\" % (self.n, self.a, self.b,self.c)\n\ndef calc_profit(p1, p2):\n #print \"%s -> %s\" % (p1.n, p2.n)\n profits = []\n for j in range(m):\n if p1.c[j] == 0:\n continue\n profit = p2.b[j] - p1.a[j]\n if profit > 0:\n profits.append((profit, p1.c[j]))\n profits.sort(reverse=True)\n load = 0\n total_profit = 0\n for p in profits:\n if load + p[1] > capacity:\n c = capacity - load\n else: \n c = p[1]\n total_profit += p[0]*c\n load += c\n if c != p[1]:\n break\n #print \"profit: %d\" % total_profit\n return total_profit \n\nps = []\n\nfor i in range(n):\n p = Planet()\n p.n = raw_input()\n for j in range(n):\n a,b,c = [int(x) for x in raw_input().split()]\n p.a.append(a)\n p.b.append(b)\n p.c.append(c)\n ps.append(p) \n \nmax_profit = -1\n\nfor n1 in range(n):\n for n2 in range(n):\n if n1 != n2:\n profit = calc_profit(ps[n1], ps[n2])\n max_profit = max(max_profit, profit)\n\nprint max_profit \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ba795c7549aed3d3d7055ffc7a4852e9", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "Python 3", "source_code": "a = list(map(int,input().split()))\ndef calc(a):\n return int((((a[1]-a[0])+(a[1]+a[0]))/2))\na.sort()\nif a[1] % 2 == 0 and a[0] % 2 == 0:\n print(calc(a))\nelif a[1] % 2 == 0 or a[0] % 2 == 0:\n print(a[2])\nelse:\n print(calc(a))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3c9bf37b127ad6cbc4bdbc6e929a8bc1", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "a, b, c = map(int, raw_input().split(' '))\nl = [a, b, c]\nl.sort()\n[a, b, c] = l\nif a % 2 == b % 2 == c % 2:\n\tprint b\nelse:\n\tif a % 2 == b % 2:\n\t\tprint b\n\telif a % 2 == c % 2:\n\t\tprint c\n\telse:\n\t\tprint c\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "798801d7c571a51504f8efd6099e212d", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def pixel(input):\n red, green, blue = input.split()\n red = int(red)\n green = int(green)\n blue = int(blue)\n\n plist = [red,green,blue]\n plist.sort()\n\n lowestChet = is_chet(plist[0])\n midChet = is_chet(plist[1])\n\n if ((midChet + lowestChet) == 2) or ((midChet + lowestChet) == 0):\n return plist[1]\n else:\n return plist[2]\n\n\ndef is_chet(n):\n return 1 if n % 2 == 0 else 0\n \nprint(pixel(input()))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1258bc93954d9fbbe4943075688842a", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def cal(ar,cnt):\n if ar[0]==ar[1]:\n return cnt+ar[0]\n elif ar[0]==ar[2]:\n return cnt+ar[0]\n elif ar[1]==ar[2]:\n return cnt+ar[1]\n else:\n ar.sort()\n ar[2]-=1\n ar[1]-=1\n ar[0]+=1\n cnt+=1\n return cal(ar,cnt)\n\na = list(map(int,input().split()))\nprint(cal(a,0))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "066349184b972979fa5c92bbedba8be1", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "def pixel(input):\n red, green, blue = input.split()\n pixels = [int(red), int(green), int(blue)]\n\n red = 0\n green = 1\n blue = 2\n\n battles = 0\n\n f1 = None\n f2 = None\n w = None\n\n\n while True:\n if pixels[red] == pixels[green]:\n break\n if pixels[red] == pixels[blue]:\n break\n if pixels[green] == pixels[red]:\n break\n if pixels[green] == pixels[blue]:\n break\n if pixels[blue] == pixels[red]:\n break\n if pixels[blue] == pixels[green]:\n break\n\n\n lowest = get_min_key(pixels)\n if lowest == red:\n f1 = green\n f2 = blue\n w = red\n elif lowest == green:\n f1 = red\n f2 = blue\n w = green\n elif lowest == blue:\n f1 = red\n f2 = green\n w = blue\n\n pixels[f1] -= 1\n pixels[f2] -= 1\n pixels[w] += 1\n battles += 1\n\n minBattles = 0\n maxBattles = 0\n minPixels = pixels.copy()\n maxPixels = pixels.copy()\n\n\n lowest = get_min_key(pixels)\n\n if lowest == red:\n f1 = green\n f2 = blue\n w = red\n elif lowest == green:\n f1 = red\n f2 = blue\n w = green\n elif lowest == blue:\n f1 = red\n f2 = green\n w = blue\n\n while True:\n is_mir = len([x for x in maxPixels if x <= 0]) > 1\n if is_mir:\n break\n\n if maxPixels[f1] == 0:\n tmp = w\n w = f1\n f1 = tmp\n\n if maxPixels[f2] == 0:\n tmp = w\n w = f2\n f2 = tmp\n\n maxPixels[f1] -= 1\n maxPixels[f2] -= 1\n maxPixels[w] += 1\n\n minBattles += 1\n\n highest = get_max_key(pixels)\n if highest == red:\n f1 = green\n f2 = blue\n w = red\n elif highest == green:\n f1 = red\n f2 = blue\n w = green\n elif highest == blue:\n f1 = red\n f2 = green\n w = blue\n\n while True:\n is_mir = len([x for x in minPixels if x <= 0]) > 1\n if is_mir:\n break\n\n if minPixels[f1] == 0:\n tmp = w\n w = f1\n f1 = tmp\n\n if minPixels[f2] == 0:\n tmp = w\n w = f2\n f2 = tmp\n\n minPixels[f1] -= 1\n minPixels[f2] -= 1\n minPixels[w] += 1\n\n maxBattles += 1\n\n return battles + minBattles if battles + minBattles < battles + maxBattles else battles + maxBattles\n\ndef get_max_key(pixels):\n maxKey = 0\n max = pixels[maxKey]\n for key, pixel in enumerate(pixels):\n if pixel > max:\n max = pixel\n maxKey = key\n\n return maxKey\n\n\ndef get_min_key(pixels):\n minKey = 0\n min = pixels[minKey]\n for key, pixel in enumerate(pixels):\n if pixel < min:\n min = pixel\n minKey = key\n\n return minKey\n \nprint(pixel(input()))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "682f99053a1058724964ee01aede4c27", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "# Read input\nn,m,k = map(int,raw_input().split())\na = [map(int,raw_input().split())+[i+1] for i in range(m)]\n\ndef reduce (e,x,y,d,cst):\n return [cst-((cst-max(e[0],x))/(k**d))*k**d,\n cst+((min(e[1],y)-cst)/(k**d))*k**d]\n\n# Recursive approach\ndef next (s1,s2,cst,d,mi,ma,l,r):\n ll = [reduce(e,mi,ma,d,cst)+[e[2],e[3]] for e in l if ma>=e[0] and mi<=e[1]]\n if len(ll)x[2]], r-1),\n [x[3],1]] for x in ll if x[1]>=x[0]]\n \n # Case adds k\n res += [[next (s1+cst+k,s2+k**d,cst+k,d,x[0]+k,x[1]+k,\n [e for e in l if e[2]>x[2]], r-1),\n [x[3],0]] for x in ll if x[1]>=x[0]]\n\n ll = [e for e in res if e[0]!=False]\n if len(ll)==0: return False\n M = max (ll)\n return [M[0][0], [M[1]]+M[0][1]]\n\nl = next (0,1,0,0,0,10**16,a,n)\nif l==False:\n print \"NO\"\nelse: \n print \"YES\"\n c = l[0][1]\n for e in l[1]:\n print e[0], c\n if e[1]: c*=k\n else: c+=k\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7271ff3698310a88f0194b2786881370", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.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\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\nbest_link = None\n\nfor pos, group in enumerate(groups):\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 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\nif best_link:\n print('YES')\n schedule = need_days * [ None ]\n link = best_link\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()\nelse:\n print('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "80a72b13fe35711b64872d363f8ae5d2", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.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\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de73a25b8b8b2394823cdacfdb5d1611", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "Python 2", "source_code": "# Read input\nn,m,k = map(int,raw_input().split())\na = [map(int,raw_input().split())+[i+1] for i in range(m)]\n\n# Format datastructure\na.sort(key=lambda x:x[2])\nM = a[-1][2]\nP = dict()\nind = dict()\n\n# Select the first valid interval after p\ndef valid (val,p,i):\n return [q for q in range (p+1,m-i+1) if a[q][0]<=val and val<=a[q][1]\n and a[p][2]0 else None\n \n val = v*k\n lprod = valid (val,p,i-1)\n mprod = path (i-1,lprod[0],val) if len(lprod)>0 else None\n\n if madd>mprod: P[i,p,v] = (madd[0] +v, ladd[0], v+k)\n elif mprod>madd: P[i,p,v] = (mprod[0]+v, lprod[0], v*k)\n else: P[i,p,v] = None\n return P[i,p,v]\n\n#\nvals = set (sum ((range(a[i][0],a[i][1]+1) for i in range (m)), []))\nfor p in range(m):\n for v in range(a[p][0],a[p][1]+1):\n ind[v] = p if not ind.has_key(v) or p= need_days:\n for subject in group.subjects:\n for weight in range(subject.low, subject.high + 1):\n subject.add_link(weight, Link(subject, weight, 1, None))\n #print(pos, weight, 1)\n for subject in group.subjects:\n for i, link in enumerate(subject.links):\n if link == None:\n continue\n if link.days == need_days:\n win(link)\n weight = subject.low + i\n for next_weight in [ weight + more, weight * more ]:\n max_pos = num_groups + link.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(next_weight, Link(\n next_subject, next_weight, link.days + 1, link))\n #print(next_pos, next_weight, link.days + 1)\n\nprint('NO')\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b72f38eca999ed6ad7554093bbdc2553", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "Python 3", "source_code": "vals = [0, 2, 4, 11, 32, 97, 295, 940, 3148, 10901, 38324, 135313, 478989, 1704939, 6120951, 22187311, 81129556, 298715961, 1105546606, 4107686743, 15311861251, 57245614745, 214625591690, 806848059041, 3040880190559, 11487184020677, 43485050394205, 164927004274136, 626608618666934, 2384493434591620, 9087529927375918, 34682392280950974, 132542351686437644, 507171591796393381, 1943050156148444582, 7452770379302126187, 28617610413867287010, 110004285524692169216, 423278853888970409883, 1630293028998903898224, 6285059739994372175113, 24251646015941054123514, 93658090212564057369267, 361998255935404053662628, 1400264769080901203586626, 5420536513622893899223411, 20998547288236908910221869, 81402555582647387745072353, 315773811781519195206203743, 1225720522015608235445806021, 4760719694151787159929017594, 18501572033220094871426132593, 71943092199993678724857210801, 279900787023066422206380766515, 1089542787771588881232684451558, 4243270322763252541573736843398, 16533504004199807912573377049815, 64450888875566769728212852796272, 251353626653428916209479575238346, 980678120264352074967128926804970, 3827772695602948667320461087747608, 14946438805836705201610573978579332, 58384183641939996074486313064537042, 228146013979094959932481402500104857, 891836734216487281263993819053310580, 3487446305259076789631430819941164781, 13641891354433181356051446335973874898, 53380418002140832442127026242477826983, 208941818119368213463213106465436894420, 818089279597127665466775004269944627746, 3204085518917391642418980497822707368946, 12552548116979151772259349500529912185843, 49190428824796945806814476487174834833637, 192817716405499011473650043729840753603575, 756010333197049943262587147038690044323990, 2964967973738716215665619390729889117524126, 11631103235901605746966358476195230631624401, 45638117709881716820884625066346212193997756, 179117430766782718986585277827256933832578361, 703151339946287405256622851905491035823870364, 2760947953575465122602355158892640666820856655, 10843358244638208764264135386695995237230629260, 42595466751701481649228987244607986409898023182, 167361224438360440216773707743558900398932244382, 657712618935505465438291334703722328200913085438, 2585267129244075193809802877463649441653730126578, 10163907817638626817716918583895182831004513613123, 39966879600102108651549930111231157595519353367123, 157189034927496653479371759900026083719376366733614, 618336723242289821990531677547460787238476902915199, 2432803210487705745299587099505477676690341445712692, 9573406030090228456311712528276315005390377833848765, 37679227834331314384610566709094016942462047210730106, 148324205307544414472966671933319118336620842676034017, 583976180035270137125482861057965298570997748434633384, 2299587233992938795306777931535364083324792816656702562, 9056803044160163377763486214083966370497445758220238091, 35675403784053203605687069929418410353969228253977145175, 140549888973728380230585821156179869098315235374112780826, 553807051777443444619226740438552112146914572740818813349, 2182486580317155631599040361201576579661428502121123653136, 8602181468318536143561958614628117733446887135993193611259, 33910044229098624305263229397172982034616011218746549038961, 133693317292732811080040087400152346242814293126404041861193, 527170992897482625043862793628047993596077613055004462678358, 2078991323053339085220679240645759577116281504673965228281165, 8199967674079627513978859635806997637089923310593314990686802, 32346615646788397692645101000786880447192779976021484665026491, 127615014986565116912823011055488469695887719846538447148962878, 503535300132270633737648282143125136291637827235646987383725796, 1987066070190752220539052383119214966394869616456484179319219065, 7842381691354570986450767323914631805571692713415931280867539121, 30955369342236909413806190480686935113629828042777927462299708227, 122201190138992862183156046825436224148821835549252243468507301695, 482464559698258280614105143074906719974084230825244765227211470338, 1905044210329310933012883474559145946790917492784787928227261446437, 7523042318799748660208705403536100792111075885171898541934731742390, 29711865307743859983774105830474814695120217213404274613967605343142, 117358210334644832241289809026318941566777541081906921752718004064223, 463599954895501530333274519944443410381288269629861291846027518952547, 1831550319939959155587395984307016482400316562294418569080566939394373, 7236675876342106283578534336330743048842197598376804592542495717488169, 28595877959236188869992380241499418925461422245402511601972127083938809, 113008487488979608728537052095796235153826972386884347812349453027284777, 446643776276434337481901364650647855177976433243812620954649695122316826, 1765441807395465620252685967072498086035986271227159688590935355004060027, 6978896171078699499744178015254900571985547608845028328618588278612230285, 27590565813291130651676295962305434607391880724234668660140969043129437306, 109087342089418473054846937271841020723765346564892390158006517105586188244, 431347570427895275684887399889776157420375297525437055850000845301829933805, 1705764090654176600783120803651477353278324598907144288980953523257690938954, 6746034859339085323037813551799895795035073688161810095995890114587607307967, 26681829042596408508727803106987892830022155937080103881413184938373444601780, 105540568643047320085637757372875138941484282898455734499378871247031545034426, 417502908721193606389605307438517612545962933342696670188454638798883820258264, 1651715574747214150853710839970797716108744553638299319610439913405742985968373, 6535008503124889007856937275951632354585153583690531839980836461545232215824404, 25857804572051561459180314229189646010564292988633513533872884661419076724098956, 102322517183818948564124541851280345149045011490572076449791435684627433270629411, 404934094236883704120894459814765768721634186306504238924488061567317975693145340, 1602619915399511600553438890014229979328824144334807821204535561824879143206962453, 6343213042207650159611655077596947878673846137393784013748813764014784872364716886, 25108464423291463997404385112070199473744447497076474425682598855413110035742418914, 99394563947684374904758920726914308485128620392393490084506181225843747588475207197, 393492336753755531692026489972641598688144826660754601765695380807032546907543503921, 1557903824987562696463244084053237928311159497375106563075214332506952142892403104132, 6168439205715589425691171307912496909504919319342781227412278678910873593341882573211, 24425293227292450643484793977655277617059585096421595028507694237157052955457119327788, 96723881571135418665545369057123041094621729891750877288042985634178222443867299246418, 383051061687942536045084445172520830808282863996319158056819349124211693991398816327207, 1517079174117195579690955122633080343549424859594834854448758112231369900479121012142113, 6008804205917549913707301141913450089100988933558420551241354568832564553473079190572278, 23801027487732914406483006100676356957141654837362665600929752551423761670767951464675913, 94282443605173282918820528593155670207503470313471709302507741333407860445366620005663942, 373502108594609108040503037731586547276548840138645909419252430705207407681196709803983480, 1479728471960463699182943027707841420937310959692022055363898209234875053818609663966205866, 5862696271018571500089423595308441031224631020361921119823688743286535539779290630567630424, 23229443652081270733980663131770350007457433326179896912355233731751050724947198946004003975, 92046214646244587690706228458864173904798062070835842020367088988974705829518078204001021363, 364752635838858477460715070856088351075708777551436448235555244229366219828253326349002137500, 1445493034116344468923655951043320186128439597523080639496656917977382053690974380985547117707, 5728729409451696444372051461356534264846576646485085732046890058188716009614118855674637377976, 22705185146420504401997097103314578637547420523062806257838636533087251029395653129572040040074, 89994488892654396058856217300404040365891816827131704366554032344385475130012751055422998088811, 356722590821763183370769773946287974891959302880630650897935809030336785839603723618464030276788, 1414063305994736576027292395949115069687019850459912237903595491623285483544543552340164385746823, 5605706391578319849214622281168740607481793100182010208297580436542090440514111407701729518697618, 22223620744205360017667654052757026972000168259047208882853304998777155752466388108220124201070651, 88109348206147011746068556866098564625699209460062623605419377857389060105300638390094653102087665, 349342636080041683221934374226900622820872946841401311867352745078418891476797889097584439698488510, 1385170925534265899519131581097494785149908651513473500940930511309994846416946247702384780811305993, 5492588368773762187176960346750382398248979869518043882552293646465784762754580760180824188726279279, 21780728267753329002789566624916226339853435239931399185927732684141543568339811214313133006185789862, 86375216875091724004892983761031261568077226356560376884219660239075463095982915374142957348433560808, 342552444573954421439069379710177772069561072341619580877761685530229948518863741413885365554900097068, 1358582195600779764137599964716337955978399926986276091819585687264212241288091184793396726965847374717, 5388469875817259323304509591448381084385961063465665255658239637278204961430203993624180560639796747605, 21372998850022699161426070331663358980991055327568017672150484504323229468157683662487272446683394953616, 84778494911805672551905487568003378988055807689922250276608386182662094701118796017840631111511241539380, 336299294984076094211910140735246876668599223869497646602011823658647050190386550822954545260278612631544, 1334092702567721627301741363861098515979926575994751181111582340637309219232241033600092838437900802205038, 5292558212680523400742812226353811345695668866524041146689910628871196088819553304554474876050018124114153, 20997357930969861565036947992351357737332219482074988303743785974044064606333782872828128356414654770048429, 83307255301650683813771759430113027376624989750108038627604618437376758764431340497982895988412865509848646, 330536911422094638826855051199545833594432618486709155341244741865583122131341876999368620130514508527934886, 1311522869083496832871707350626892106751939874234564517468101657197217628921812764530031965246754289948832905, 5204156397188024528172208860333403395144057036547715697743789160749123289693413744575143624612520273136245942, 20651099904331266347452312738842587016214690030449557930458679449892111940939905103364939451289307748992021705, 81950993437459573466341756935194915370706037015935432733554932948181854760107481589302122500483380360974120698, 325224502658680918621143766183198696515890363756397080976420998474791236483195824901624062741635519646490626407, 1290714269690655531306881841380634199972701772564446091319466174738466016505934864779800047925147878259285097303, 5122649034621028257092921727961683522826738055239047518130182514401914195565325824742487436606026182522647156675, 20331833918723604572328478218344871921785349256218990332867325768701950803782350327182973980977910184990231738767, 80700419210399288565532992313764196322776455936388215324863888557166663083824127963351927392338983532130677066691, 320325964488275811162806976162403939204447615115097764645943597768559937809078043653016835390579784416806189815956, 1271526570389220738417720962998566369113558429608467759079824319778588199759814382086958737211830037441352944048167, 5047490573839566652123419730499281587581764724700676283660476791813590196494125779764142565481025618321161423806066, 20037438807446179847249688629193061142526113477517522632902620906339929842504046050208876416491892141201070822230131, 79547284021186879599064590255903862162736176763577694086452574483959105669722214770109007085871325696665049873073536, 315809215683715856623773540595819635047566056859602300667262187593705408991392910317051208881558444097467184884431157, 1253834979285426570031233194424112121276155771396268926629394300954835640295429800316432432553283540199303378978033661]\r\nn, m = map(int, input().split())\r\nprint(vals[n] % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "db8e5613f6c62086b6071a45128a024d", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "PyPy 3-64", "source_code": "vals = [0, 2, 4, 11, 32, 97, 295, 940, 3148, 10901, 38324, 135313, 478989, 1704939, 6120951, 22187311, 81129556, 298715961, 1105546606, 4107686743, 15311861251, 57245614745, 214625591690, 806848059041, 3040880190559, 11487184020677, 43485050394205, 164927004274136, 626608618666934, 2384493434591620, 9087529927375918, 34682392280950974, 132542351686437644, 507171591796393381, 1943050156148444582, 7452770379302126187, 28617610413867287010, 110004285524692169216, 423278853888970409883, 1630293028998903898224, 6285059739994372175113, 24251646015941054123514, 93658090212564057369267, 361998255935404053662628, 1400264769080901203586626, 5420536513622893899223411, 20998547288236908910221869, 81402555582647387745072353, 315773811781519195206203743, 1225720522015608235445806021, 4760719694151787159929017594, 18501572033220094871426132593, 71943092199993678724857210801, 279900787023066422206380766515, 1089542787771588881232684451558, 4243270322763252541573736843398, 16533504004199807912573377049815, 64450888875566769728212852796272, 251353626653428916209479575238346, 980678120264352074967128926804970, 3827772695602948667320461087747608, 14946438805836705201610573978579332, 58384183641939996074486313064537042, 228146013979094959932481402500104857, 891836734216487281263993819053310580, 3487446305259076789631430819941164781, 13641891354433181356051446335973874898, 53380418002140832442127026242477826983, 208941818119368213463213106465436894420, 818089279597127665466775004269944627746, 3204085518917391642418980497822707368946, 12552548116979151772259349500529912185843, 49190428824796945806814476487174834833637, 192817716405499011473650043729840753603575, 756010333197049943262587147038690044323990, 2964967973738716215665619390729889117524126, 11631103235901605746966358476195230631624401, 45638117709881716820884625066346212193997756, 179117430766782718986585277827256933832578361, 703151339946287405256622851905491035823870364, 2760947953575465122602355158892640666820856655, 10843358244638208764264135386695995237230629260, 42595466751701481649228987244607986409898023182, 167361224438360440216773707743558900398932244382, 657712618935505465438291334703722328200913085438, 2585267129244075193809802877463649441653730126578, 10163907817638626817716918583895182831004513613123, 39966879600102108651549930111231157595519353367123, 157189034927496653479371759900026083719376366733614, 618336723242289821990531677547460787238476902915199, 2432803210487705745299587099505477676690341445712692, 9573406030090228456311712528276315005390377833848765, 37679227834331314384610566709094016942462047210730106, 148324205307544414472966671933319118336620842676034017, 583976180035270137125482861057965298570997748434633384, 2299587233992938795306777931535364083324792816656702562, 9056803044160163377763486214083966370497445758220238091, 35675403784053203605687069929418410353969228253977145175, 140549888973728380230585821156179869098315235374112780826, 553807051777443444619226740438552112146914572740818813349, 2182486580317155631599040361201576579661428502121123653136, 8602181468318536143561958614628117733446887135993193611259, 33910044229098624305263229397172982034616011218746549038961, 133693317292732811080040087400152346242814293126404041861193, 527170992897482625043862793628047993596077613055004462678358, 2078991323053339085220679240645759577116281504673965228281165, 8199967674079627513978859635806997637089923310593314990686802, 32346615646788397692645101000786880447192779976021484665026491, 127615014986565116912823011055488469695887719846538447148962878, 503535300132270633737648282143125136291637827235646987383725796, 1987066070190752220539052383119214966394869616456484179319219065, 7842381691354570986450767323914631805571692713415931280867539121, 30955369342236909413806190480686935113629828042777927462299708227, 122201190138992862183156046825436224148821835549252243468507301695, 482464559698258280614105143074906719974084230825244765227211470338, 1905044210329310933012883474559145946790917492784787928227261446437, 7523042318799748660208705403536100792111075885171898541934731742390, 29711865307743859983774105830474814695120217213404274613967605343142, 117358210334644832241289809026318941566777541081906921752718004064223, 463599954895501530333274519944443410381288269629861291846027518952547, 1831550319939959155587395984307016482400316562294418569080566939394373, 7236675876342106283578534336330743048842197598376804592542495717488169, 28595877959236188869992380241499418925461422245402511601972127083938809, 113008487488979608728537052095796235153826972386884347812349453027284777, 446643776276434337481901364650647855177976433243812620954649695122316826, 1765441807395465620252685967072498086035986271227159688590935355004060027, 6978896171078699499744178015254900571985547608845028328618588278612230285, 27590565813291130651676295962305434607391880724234668660140969043129437306, 109087342089418473054846937271841020723765346564892390158006517105586188244, 431347570427895275684887399889776157420375297525437055850000845301829933805, 1705764090654176600783120803651477353278324598907144288980953523257690938954, 6746034859339085323037813551799895795035073688161810095995890114587607307967, 26681829042596408508727803106987892830022155937080103881413184938373444601780, 105540568643047320085637757372875138941484282898455734499378871247031545034426, 417502908721193606389605307438517612545962933342696670188454638798883820258264, 1651715574747214150853710839970797716108744553638299319610439913405742985968373, 6535008503124889007856937275951632354585153583690531839980836461545232215824404, 25857804572051561459180314229189646010564292988633513533872884661419076724098956, 102322517183818948564124541851280345149045011490572076449791435684627433270629411, 404934094236883704120894459814765768721634186306504238924488061567317975693145340, 1602619915399511600553438890014229979328824144334807821204535561824879143206962453, 6343213042207650159611655077596947878673846137393784013748813764014784872364716886, 25108464423291463997404385112070199473744447497076474425682598855413110035742418914, 99394563947684374904758920726914308485128620392393490084506181225843747588475207197, 393492336753755531692026489972641598688144826660754601765695380807032546907543503921, 1557903824987562696463244084053237928311159497375106563075214332506952142892403104132, 6168439205715589425691171307912496909504919319342781227412278678910873593341882573211, 24425293227292450643484793977655277617059585096421595028507694237157052955457119327788, 96723881571135418665545369057123041094621729891750877288042985634178222443867299246418, 383051061687942536045084445172520830808282863996319158056819349124211693991398816327207, 1517079174117195579690955122633080343549424859594834854448758112231369900479121012142113, 6008804205917549913707301141913450089100988933558420551241354568832564553473079190572278, 23801027487732914406483006100676356957141654837362665600929752551423761670767951464675913, 94282443605173282918820528593155670207503470313471709302507741333407860445366620005663942, 373502108594609108040503037731586547276548840138645909419252430705207407681196709803983480, 1479728471960463699182943027707841420937310959692022055363898209234875053818609663966205866, 5862696271018571500089423595308441031224631020361921119823688743286535539779290630567630424, 23229443652081270733980663131770350007457433326179896912355233731751050724947198946004003975, 92046214646244587690706228458864173904798062070835842020367088988974705829518078204001021363, 364752635838858477460715070856088351075708777551436448235555244229366219828253326349002137500, 1445493034116344468923655951043320186128439597523080639496656917977382053690974380985547117707, 5728729409451696444372051461356534264846576646485085732046890058188716009614118855674637377976, 22705185146420504401997097103314578637547420523062806257838636533087251029395653129572040040074, 89994488892654396058856217300404040365891816827131704366554032344385475130012751055422998088811, 356722590821763183370769773946287974891959302880630650897935809030336785839603723618464030276788, 1414063305994736576027292395949115069687019850459912237903595491623285483544543552340164385746823, 5605706391578319849214622281168740607481793100182010208297580436542090440514111407701729518697618, 22223620744205360017667654052757026972000168259047208882853304998777155752466388108220124201070651, 88109348206147011746068556866098564625699209460062623605419377857389060105300638390094653102087665, 349342636080041683221934374226900622820872946841401311867352745078418891476797889097584439698488510, 1385170925534265899519131581097494785149908651513473500940930511309994846416946247702384780811305993, 5492588368773762187176960346750382398248979869518043882552293646465784762754580760180824188726279279, 21780728267753329002789566624916226339853435239931399185927732684141543568339811214313133006185789862, 86375216875091724004892983761031261568077226356560376884219660239075463095982915374142957348433560808, 342552444573954421439069379710177772069561072341619580877761685530229948518863741413885365554900097068, 1358582195600779764137599964716337955978399926986276091819585687264212241288091184793396726965847374717, 5388469875817259323304509591448381084385961063465665255658239637278204961430203993624180560639796747605, 21372998850022699161426070331663358980991055327568017672150484504323229468157683662487272446683394953616, 84778494911805672551905487568003378988055807689922250276608386182662094701118796017840631111511241539380, 336299294984076094211910140735246876668599223869497646602011823658647050190386550822954545260278612631544, 1334092702567721627301741363861098515979926575994751181111582340637309219232241033600092838437900802205038, 5292558212680523400742812226353811345695668866524041146689910628871196088819553304554474876050018124114153, 20997357930969861565036947992351357737332219482074988303743785974044064606333782872828128356414654770048429, 83307255301650683813771759430113027376624989750108038627604618437376758764431340497982895988412865509848646, 330536911422094638826855051199545833594432618486709155341244741865583122131341876999368620130514508527934886, 1311522869083496832871707350626892106751939874234564517468101657197217628921812764530031965246754289948832905, 5204156397188024528172208860333403395144057036547715697743789160749123289693413744575143624612520273136245942, 20651099904331266347452312738842587016214690030449557930458679449892111940939905103364939451289307748992021705, 81950993437459573466341756935194915370706037015935432733554932948181854760107481589302122500483380360974120698, 325224502658680918621143766183198696515890363756397080976420998474791236483195824901624062741635519646490626407, 1290714269690655531306881841380634199972701772564446091319466174738466016505934864779800047925147878259285097303, 5122649034621028257092921727961683522826738055239047518130182514401914195565325824742487436606026182522647156675, 20331833918723604572328478218344871921785349256218990332867325768701950803782350327182973980977910184990231738767, 80700419210399288565532992313764196322776455936388215324863888557166663083824127963351927392338983532130677066691, 320325964488275811162806976162403939204447615115097764645943597768559937809078043653016835390579784416806189815956, 1271526570389220738417720962998566369113558429608467759079824319778588199759814382086958737211830037441352944048167, 5047490573839566652123419730499281587581764724700676283660476791813590196494125779764142565481025618321161423806066, 20037438807446179847249688629193061142526113477517522632902620906339929842504046050208876416491892141201070822230131, 79547284021186879599064590255903862162736176763577694086452574483959105669722214770109007085871325696665049873073536, 315809215683715856623773540595819635047566056859602300667262187593705408991392910317051208881558444097467184884431157, 1253834979285426570031233194424112121276155771396268926629394300954835640295429800316432432553283540199303378978033661]\r\nn, m = map(int, input().split())\r\nprint(vals[n] % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d17880cee7d9ed652b2fd64acd75760f", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "PyPy 2", "source_code": "vals = [0, 2, 4, 11, 32, 97, 295, 940, 3148, 10901, 38324, 135313, 478989, 1704939, 6120951, 22187311, 81129556, 298715961, 1105546606, 4107686743, 15311861251, 57245614745, 214625591690, 806848059041, 3040880190559, 11487184020677, 43485050394205, 164927004274136, 626608618666934, 2384493434591620, 9087529927375918, 34682392280950974, 132542351686437644, 507171591796393381, 1943050156148444582, 7452770379302126187, 28617610413867287010, 110004285524692169216, 423278853888970409883, 1630293028998903898224, 6285059739994372175113, 24251646015941054123514, 93658090212564057369267, 361998255935404053662628, 1400264769080901203586626, 5420536513622893899223411, 20998547288236908910221869, 81402555582647387745072353, 315773811781519195206203743, 1225720522015608235445806021, 4760719694151787159929017594, 18501572033220094871426132593, 71943092199993678724857210801, 279900787023066422206380766515, 1089542787771588881232684451558, 4243270322763252541573736843398, 16533504004199807912573377049815, 64450888875566769728212852796272, 251353626653428916209479575238346, 980678120264352074967128926804970, 3827772695602948667320461087747608, 14946438805836705201610573978579332, 58384183641939996074486313064537042, 228146013979094959932481402500104857, 891836734216487281263993819053310580, 3487446305259076789631430819941164781, 13641891354433181356051446335973874898, 53380418002140832442127026242477826983, 208941818119368213463213106465436894420, 818089279597127665466775004269944627746, 3204085518917391642418980497822707368946, 12552548116979151772259349500529912185843, 49190428824796945806814476487174834833637, 192817716405499011473650043729840753603575, 756010333197049943262587147038690044323990, 2964967973738716215665619390729889117524126, 11631103235901605746966358476195230631624401, 45638117709881716820884625066346212193997756, 179117430766782718986585277827256933832578361, 703151339946287405256622851905491035823870364, 2760947953575465122602355158892640666820856655, 10843358244638208764264135386695995237230629260, 42595466751701481649228987244607986409898023182, 167361224438360440216773707743558900398932244382, 657712618935505465438291334703722328200913085438, 2585267129244075193809802877463649441653730126578, 10163907817638626817716918583895182831004513613123, 39966879600102108651549930111231157595519353367123, 157189034927496653479371759900026083719376366733614, 618336723242289821990531677547460787238476902915199, 2432803210487705745299587099505477676690341445712692, 9573406030090228456311712528276315005390377833848765, 37679227834331314384610566709094016942462047210730106, 148324205307544414472966671933319118336620842676034017, 583976180035270137125482861057965298570997748434633384, 2299587233992938795306777931535364083324792816656702562, 9056803044160163377763486214083966370497445758220238091, 35675403784053203605687069929418410353969228253977145175, 140549888973728380230585821156179869098315235374112780826, 553807051777443444619226740438552112146914572740818813349, 2182486580317155631599040361201576579661428502121123653136, 8602181468318536143561958614628117733446887135993193611259, 33910044229098624305263229397172982034616011218746549038961, 133693317292732811080040087400152346242814293126404041861193, 527170992897482625043862793628047993596077613055004462678358, 2078991323053339085220679240645759577116281504673965228281165, 8199967674079627513978859635806997637089923310593314990686802, 32346615646788397692645101000786880447192779976021484665026491, 127615014986565116912823011055488469695887719846538447148962878, 503535300132270633737648282143125136291637827235646987383725796, 1987066070190752220539052383119214966394869616456484179319219065, 7842381691354570986450767323914631805571692713415931280867539121, 30955369342236909413806190480686935113629828042777927462299708227, 122201190138992862183156046825436224148821835549252243468507301695, 482464559698258280614105143074906719974084230825244765227211470338, 1905044210329310933012883474559145946790917492784787928227261446437, 7523042318799748660208705403536100792111075885171898541934731742390, 29711865307743859983774105830474814695120217213404274613967605343142, 117358210334644832241289809026318941566777541081906921752718004064223, 463599954895501530333274519944443410381288269629861291846027518952547, 1831550319939959155587395984307016482400316562294418569080566939394373, 7236675876342106283578534336330743048842197598376804592542495717488169, 28595877959236188869992380241499418925461422245402511601972127083938809, 113008487488979608728537052095796235153826972386884347812349453027284777, 446643776276434337481901364650647855177976433243812620954649695122316826, 1765441807395465620252685967072498086035986271227159688590935355004060027, 6978896171078699499744178015254900571985547608845028328618588278612230285, 27590565813291130651676295962305434607391880724234668660140969043129437306, 109087342089418473054846937271841020723765346564892390158006517105586188244, 431347570427895275684887399889776157420375297525437055850000845301829933805, 1705764090654176600783120803651477353278324598907144288980953523257690938954, 6746034859339085323037813551799895795035073688161810095995890114587607307967, 26681829042596408508727803106987892830022155937080103881413184938373444601780, 105540568643047320085637757372875138941484282898455734499378871247031545034426, 417502908721193606389605307438517612545962933342696670188454638798883820258264, 1651715574747214150853710839970797716108744553638299319610439913405742985968373, 6535008503124889007856937275951632354585153583690531839980836461545232215824404, 25857804572051561459180314229189646010564292988633513533872884661419076724098956, 102322517183818948564124541851280345149045011490572076449791435684627433270629411, 404934094236883704120894459814765768721634186306504238924488061567317975693145340, 1602619915399511600553438890014229979328824144334807821204535561824879143206962453, 6343213042207650159611655077596947878673846137393784013748813764014784872364716886, 25108464423291463997404385112070199473744447497076474425682598855413110035742418914, 99394563947684374904758920726914308485128620392393490084506181225843747588475207197, 393492336753755531692026489972641598688144826660754601765695380807032546907543503921, 1557903824987562696463244084053237928311159497375106563075214332506952142892403104132, 6168439205715589425691171307912496909504919319342781227412278678910873593341882573211, 24425293227292450643484793977655277617059585096421595028507694237157052955457119327788, 96723881571135418665545369057123041094621729891750877288042985634178222443867299246418, 383051061687942536045084445172520830808282863996319158056819349124211693991398816327207, 1517079174117195579690955122633080343549424859594834854448758112231369900479121012142113, 6008804205917549913707301141913450089100988933558420551241354568832564553473079190572278, 23801027487732914406483006100676356957141654837362665600929752551423761670767951464675913, 94282443605173282918820528593155670207503470313471709302507741333407860445366620005663942, 373502108594609108040503037731586547276548840138645909419252430705207407681196709803983480, 1479728471960463699182943027707841420937310959692022055363898209234875053818609663966205866, 5862696271018571500089423595308441031224631020361921119823688743286535539779290630567630424, 23229443652081270733980663131770350007457433326179896912355233731751050724947198946004003975, 92046214646244587690706228458864173904798062070835842020367088988974705829518078204001021363, 364752635838858477460715070856088351075708777551436448235555244229366219828253326349002137500, 1445493034116344468923655951043320186128439597523080639496656917977382053690974380985547117707, 5728729409451696444372051461356534264846576646485085732046890058188716009614118855674637377976, 22705185146420504401997097103314578637547420523062806257838636533087251029395653129572040040074, 89994488892654396058856217300404040365891816827131704366554032344385475130012751055422998088811, 356722590821763183370769773946287974891959302880630650897935809030336785839603723618464030276788, 1414063305994736576027292395949115069687019850459912237903595491623285483544543552340164385746823, 5605706391578319849214622281168740607481793100182010208297580436542090440514111407701729518697618, 22223620744205360017667654052757026972000168259047208882853304998777155752466388108220124201070651, 88109348206147011746068556866098564625699209460062623605419377857389060105300638390094653102087665, 349342636080041683221934374226900622820872946841401311867352745078418891476797889097584439698488510, 1385170925534265899519131581097494785149908651513473500940930511309994846416946247702384780811305993, 5492588368773762187176960346750382398248979869518043882552293646465784762754580760180824188726279279, 21780728267753329002789566624916226339853435239931399185927732684141543568339811214313133006185789862, 86375216875091724004892983761031261568077226356560376884219660239075463095982915374142957348433560808, 342552444573954421439069379710177772069561072341619580877761685530229948518863741413885365554900097068, 1358582195600779764137599964716337955978399926986276091819585687264212241288091184793396726965847374717, 5388469875817259323304509591448381084385961063465665255658239637278204961430203993624180560639796747605, 21372998850022699161426070331663358980991055327568017672150484504323229468157683662487272446683394953616, 84778494911805672551905487568003378988055807689922250276608386182662094701118796017840631111511241539380, 336299294984076094211910140735246876668599223869497646602011823658647050190386550822954545260278612631544, 1334092702567721627301741363861098515979926575994751181111582340637309219232241033600092838437900802205038, 5292558212680523400742812226353811345695668866524041146689910628871196088819553304554474876050018124114153, 20997357930969861565036947992351357737332219482074988303743785974044064606333782872828128356414654770048429, 83307255301650683813771759430113027376624989750108038627604618437376758764431340497982895988412865509848646, 330536911422094638826855051199545833594432618486709155341244741865583122131341876999368620130514508527934886, 1311522869083496832871707350626892106751939874234564517468101657197217628921812764530031965246754289948832905, 5204156397188024528172208860333403395144057036547715697743789160749123289693413744575143624612520273136245942, 20651099904331266347452312738842587016214690030449557930458679449892111940939905103364939451289307748992021705, 81950993437459573466341756935194915370706037015935432733554932948181854760107481589302122500483380360974120698, 325224502658680918621143766183198696515890363756397080976420998474791236483195824901624062741635519646490626407, 1290714269690655531306881841380634199972701772564446091319466174738466016505934864779800047925147878259285097303, 5122649034621028257092921727961683522826738055239047518130182514401914195565325824742487436606026182522647156675, 20331833918723604572328478218344871921785349256218990332867325768701950803782350327182973980977910184990231738767, 80700419210399288565532992313764196322776455936388215324863888557166663083824127963351927392338983532130677066691, 320325964488275811162806976162403939204447615115097764645943597768559937809078043653016835390579784416806189815956, 1271526570389220738417720962998566369113558429608467759079824319778588199759814382086958737211830037441352944048167, 5047490573839566652123419730499281587581764724700676283660476791813590196494125779764142565481025618321161423806066, 20037438807446179847249688629193061142526113477517522632902620906339929842504046050208876416491892141201070822230131, 79547284021186879599064590255903862162736176763577694086452574483959105669722214770109007085871325696665049873073536, 315809215683715856623773540595819635047566056859602300667262187593705408991392910317051208881558444097467184884431157, 1253834979285426570031233194424112121276155771396268926629394300954835640295429800316432432553283540199303378978033661]\r\nn, m = map(int, raw_input().split())\r\nprint vals[n] % m\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "26cd94305ae862243ee4491a27cea502", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "vals = [0, 2, 4, 11, 32, 97, 295, 940, 3148, 10901, 38324, 135313, 478989, 1704939, 6120951, 22187311, 81129556, 298715961, 1105546606, 4107686743, 15311861251, 57245614745, 214625591690, 806848059041, 3040880190559, 11487184020677, 43485050394205, 164927004274136, 626608618666934, 2384493434591620, 9087529927375918, 34682392280950974, 132542351686437644, 507171591796393381, 1943050156148444582, 7452770379302126187, 28617610413867287010, 110004285524692169216, 423278853888970409883, 1630293028998903898224, 6285059739994372175113, 24251646015941054123514, 93658090212564057369267, 361998255935404053662628, 1400264769080901203586626, 5420536513622893899223411, 20998547288236908910221869, 81402555582647387745072353, 315773811781519195206203743, 1225720522015608235445806021, 4760719694151787159929017594, 18501572033220094871426132593, 71943092199993678724857210801, 279900787023066422206380766515, 1089542787771588881232684451558, 4243270322763252541573736843398, 16533504004199807912573377049815, 64450888875566769728212852796272, 251353626653428916209479575238346, 980678120264352074967128926804970, 3827772695602948667320461087747608, 14946438805836705201610573978579332, 58384183641939996074486313064537042, 228146013979094959932481402500104857, 891836734216487281263993819053310580, 3487446305259076789631430819941164781, 13641891354433181356051446335973874898, 53380418002140832442127026242477826983, 208941818119368213463213106465436894420, 818089279597127665466775004269944627746, 3204085518917391642418980497822707368946, 12552548116979151772259349500529912185843, 49190428824796945806814476487174834833637, 192817716405499011473650043729840753603575, 756010333197049943262587147038690044323990, 2964967973738716215665619390729889117524126, 11631103235901605746966358476195230631624401, 45638117709881716820884625066346212193997756, 179117430766782718986585277827256933832578361, 703151339946287405256622851905491035823870364, 2760947953575465122602355158892640666820856655, 10843358244638208764264135386695995237230629260, 42595466751701481649228987244607986409898023182, 167361224438360440216773707743558900398932244382, 657712618935505465438291334703722328200913085438, 2585267129244075193809802877463649441653730126578, 10163907817638626817716918583895182831004513613123, 39966879600102108651549930111231157595519353367123, 157189034927496653479371759900026083719376366733614, 618336723242289821990531677547460787238476902915199, 2432803210487705745299587099505477676690341445712692, 9573406030090228456311712528276315005390377833848765, 37679227834331314384610566709094016942462047210730106, 148324205307544414472966671933319118336620842676034017, 583976180035270137125482861057965298570997748434633384, 2299587233992938795306777931535364083324792816656702562, 9056803044160163377763486214083966370497445758220238091, 35675403784053203605687069929418410353969228253977145175, 140549888973728380230585821156179869098315235374112780826, 553807051777443444619226740438552112146914572740818813349, 2182486580317155631599040361201576579661428502121123653136, 8602181468318536143561958614628117733446887135993193611259, 33910044229098624305263229397172982034616011218746549038961, 133693317292732811080040087400152346242814293126404041861193, 527170992897482625043862793628047993596077613055004462678358, 2078991323053339085220679240645759577116281504673965228281165, 8199967674079627513978859635806997637089923310593314990686802, 32346615646788397692645101000786880447192779976021484665026491, 127615014986565116912823011055488469695887719846538447148962878, 503535300132270633737648282143125136291637827235646987383725796, 1987066070190752220539052383119214966394869616456484179319219065, 7842381691354570986450767323914631805571692713415931280867539121, 30955369342236909413806190480686935113629828042777927462299708227, 122201190138992862183156046825436224148821835549252243468507301695, 482464559698258280614105143074906719974084230825244765227211470338, 1905044210329310933012883474559145946790917492784787928227261446437, 7523042318799748660208705403536100792111075885171898541934731742390, 29711865307743859983774105830474814695120217213404274613967605343142, 117358210334644832241289809026318941566777541081906921752718004064223, 463599954895501530333274519944443410381288269629861291846027518952547, 1831550319939959155587395984307016482400316562294418569080566939394373, 7236675876342106283578534336330743048842197598376804592542495717488169, 28595877959236188869992380241499418925461422245402511601972127083938809, 113008487488979608728537052095796235153826972386884347812349453027284777, 446643776276434337481901364650647855177976433243812620954649695122316826, 1765441807395465620252685967072498086035986271227159688590935355004060027, 6978896171078699499744178015254900571985547608845028328618588278612230285, 27590565813291130651676295962305434607391880724234668660140969043129437306, 109087342089418473054846937271841020723765346564892390158006517105586188244, 431347570427895275684887399889776157420375297525437055850000845301829933805, 1705764090654176600783120803651477353278324598907144288980953523257690938954, 6746034859339085323037813551799895795035073688161810095995890114587607307967, 26681829042596408508727803106987892830022155937080103881413184938373444601780, 105540568643047320085637757372875138941484282898455734499378871247031545034426, 417502908721193606389605307438517612545962933342696670188454638798883820258264, 1651715574747214150853710839970797716108744553638299319610439913405742985968373, 6535008503124889007856937275951632354585153583690531839980836461545232215824404, 25857804572051561459180314229189646010564292988633513533872884661419076724098956, 102322517183818948564124541851280345149045011490572076449791435684627433270629411, 404934094236883704120894459814765768721634186306504238924488061567317975693145340, 1602619915399511600553438890014229979328824144334807821204535561824879143206962453, 6343213042207650159611655077596947878673846137393784013748813764014784872364716886, 25108464423291463997404385112070199473744447497076474425682598855413110035742418914, 99394563947684374904758920726914308485128620392393490084506181225843747588475207197, 393492336753755531692026489972641598688144826660754601765695380807032546907543503921, 1557903824987562696463244084053237928311159497375106563075214332506952142892403104132, 6168439205715589425691171307912496909504919319342781227412278678910873593341882573211, 24425293227292450643484793977655277617059585096421595028507694237157052955457119327788, 96723881571135418665545369057123041094621729891750877288042985634178222443867299246418, 383051061687942536045084445172520830808282863996319158056819349124211693991398816327207, 1517079174117195579690955122633080343549424859594834854448758112231369900479121012142113, 6008804205917549913707301141913450089100988933558420551241354568832564553473079190572278, 23801027487732914406483006100676356957141654837362665600929752551423761670767951464675913, 94282443605173282918820528593155670207503470313471709302507741333407860445366620005663942, 373502108594609108040503037731586547276548840138645909419252430705207407681196709803983480, 1479728471960463699182943027707841420937310959692022055363898209234875053818609663966205866, 5862696271018571500089423595308441031224631020361921119823688743286535539779290630567630424, 23229443652081270733980663131770350007457433326179896912355233731751050724947198946004003975, 92046214646244587690706228458864173904798062070835842020367088988974705829518078204001021363, 364752635838858477460715070856088351075708777551436448235555244229366219828253326349002137500, 1445493034116344468923655951043320186128439597523080639496656917977382053690974380985547117707, 5728729409451696444372051461356534264846576646485085732046890058188716009614118855674637377976, 22705185146420504401997097103314578637547420523062806257838636533087251029395653129572040040074, 89994488892654396058856217300404040365891816827131704366554032344385475130012751055422998088811, 356722590821763183370769773946287974891959302880630650897935809030336785839603723618464030276788, 1414063305994736576027292395949115069687019850459912237903595491623285483544543552340164385746823, 5605706391578319849214622281168740607481793100182010208297580436542090440514111407701729518697618, 22223620744205360017667654052757026972000168259047208882853304998777155752466388108220124201070651, 88109348206147011746068556866098564625699209460062623605419377857389060105300638390094653102087665, 349342636080041683221934374226900622820872946841401311867352745078418891476797889097584439698488510, 1385170925534265899519131581097494785149908651513473500940930511309994846416946247702384780811305993, 5492588368773762187176960346750382398248979869518043882552293646465784762754580760180824188726279279, 21780728267753329002789566624916226339853435239931399185927732684141543568339811214313133006185789862, 86375216875091724004892983761031261568077226356560376884219660239075463095982915374142957348433560808, 342552444573954421439069379710177772069561072341619580877761685530229948518863741413885365554900097068, 1358582195600779764137599964716337955978399926986276091819585687264212241288091184793396726965847374717, 5388469875817259323304509591448381084385961063465665255658239637278204961430203993624180560639796747605, 21372998850022699161426070331663358980991055327568017672150484504323229468157683662487272446683394953616, 84778494911805672551905487568003378988055807689922250276608386182662094701118796017840631111511241539380, 336299294984076094211910140735246876668599223869497646602011823658647050190386550822954545260278612631544, 1334092702567721627301741363861098515979926575994751181111582340637309219232241033600092838437900802205038, 5292558212680523400742812226353811345695668866524041146689910628871196088819553304554474876050018124114153, 20997357930969861565036947992351357737332219482074988303743785974044064606333782872828128356414654770048429, 83307255301650683813771759430113027376624989750108038627604618437376758764431340497982895988412865509848646, 330536911422094638826855051199545833594432618486709155341244741865583122131341876999368620130514508527934886, 1311522869083496832871707350626892106751939874234564517468101657197217628921812764530031965246754289948832905, 5204156397188024528172208860333403395144057036547715697743789160749123289693413744575143624612520273136245942, 20651099904331266347452312738842587016214690030449557930458679449892111940939905103364939451289307748992021705, 81950993437459573466341756935194915370706037015935432733554932948181854760107481589302122500483380360974120698, 325224502658680918621143766183198696515890363756397080976420998474791236483195824901624062741635519646490626407, 1290714269690655531306881841380634199972701772564446091319466174738466016505934864779800047925147878259285097303, 5122649034621028257092921727961683522826738055239047518130182514401914195565325824742487436606026182522647156675, 20331833918723604572328478218344871921785349256218990332867325768701950803782350327182973980977910184990231738767, 80700419210399288565532992313764196322776455936388215324863888557166663083824127963351927392338983532130677066691, 320325964488275811162806976162403939204447615115097764645943597768559937809078043653016835390579784416806189815956, 1271526570389220738417720962998566369113558429608467759079824319778588199759814382086958737211830037441352944048167, 5047490573839566652123419730499281587581764724700676283660476791813590196494125779764142565481025618321161423806066, 20037438807446179847249688629193061142526113477517522632902620906339929842504046050208876416491892141201070822230131, 79547284021186879599064590255903862162736176763577694086452574483959105669722214770109007085871325696665049873073536, 315809215683715856623773540595819635047566056859602300667262187593705408991392910317051208881558444097467184884431157, 1253834979285426570031233194424112121276155771396268926629394300954835640295429800316432432553283540199303378978033661]\r\nn, m = map(int, input().split())\r\nprint(vals[n] % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6b32615e854d10342b4ae4f56f59a8bd", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "Python 2", "source_code": "vals = [0, 2, 4, 11, 32, 97, 295, 940, 3148, 10901, 38324, 135313, 478989, 1704939, 6120951, 22187311, 81129556, 298715961, 1105546606, 4107686743, 15311861251, 57245614745, 214625591690, 806848059041, 3040880190559, 11487184020677, 43485050394205, 164927004274136, 626608618666934, 2384493434591620, 9087529927375918, 34682392280950974, 132542351686437644, 507171591796393381, 1943050156148444582, 7452770379302126187, 28617610413867287010, 110004285524692169216, 423278853888970409883, 1630293028998903898224, 6285059739994372175113, 24251646015941054123514, 93658090212564057369267, 361998255935404053662628, 1400264769080901203586626, 5420536513622893899223411, 20998547288236908910221869, 81402555582647387745072353, 315773811781519195206203743, 1225720522015608235445806021, 4760719694151787159929017594, 18501572033220094871426132593, 71943092199993678724857210801, 279900787023066422206380766515, 1089542787771588881232684451558, 4243270322763252541573736843398, 16533504004199807912573377049815, 64450888875566769728212852796272, 251353626653428916209479575238346, 980678120264352074967128926804970, 3827772695602948667320461087747608, 14946438805836705201610573978579332, 58384183641939996074486313064537042, 228146013979094959932481402500104857, 891836734216487281263993819053310580, 3487446305259076789631430819941164781, 13641891354433181356051446335973874898, 53380418002140832442127026242477826983, 208941818119368213463213106465436894420, 818089279597127665466775004269944627746, 3204085518917391642418980497822707368946, 12552548116979151772259349500529912185843, 49190428824796945806814476487174834833637, 192817716405499011473650043729840753603575, 756010333197049943262587147038690044323990, 2964967973738716215665619390729889117524126, 11631103235901605746966358476195230631624401, 45638117709881716820884625066346212193997756, 179117430766782718986585277827256933832578361, 703151339946287405256622851905491035823870364, 2760947953575465122602355158892640666820856655, 10843358244638208764264135386695995237230629260, 42595466751701481649228987244607986409898023182, 167361224438360440216773707743558900398932244382, 657712618935505465438291334703722328200913085438, 2585267129244075193809802877463649441653730126578, 10163907817638626817716918583895182831004513613123, 39966879600102108651549930111231157595519353367123, 157189034927496653479371759900026083719376366733614, 618336723242289821990531677547460787238476902915199, 2432803210487705745299587099505477676690341445712692, 9573406030090228456311712528276315005390377833848765, 37679227834331314384610566709094016942462047210730106, 148324205307544414472966671933319118336620842676034017, 583976180035270137125482861057965298570997748434633384, 2299587233992938795306777931535364083324792816656702562, 9056803044160163377763486214083966370497445758220238091, 35675403784053203605687069929418410353969228253977145175, 140549888973728380230585821156179869098315235374112780826, 553807051777443444619226740438552112146914572740818813349, 2182486580317155631599040361201576579661428502121123653136, 8602181468318536143561958614628117733446887135993193611259, 33910044229098624305263229397172982034616011218746549038961, 133693317292732811080040087400152346242814293126404041861193, 527170992897482625043862793628047993596077613055004462678358, 2078991323053339085220679240645759577116281504673965228281165, 8199967674079627513978859635806997637089923310593314990686802, 32346615646788397692645101000786880447192779976021484665026491, 127615014986565116912823011055488469695887719846538447148962878, 503535300132270633737648282143125136291637827235646987383725796, 1987066070190752220539052383119214966394869616456484179319219065, 7842381691354570986450767323914631805571692713415931280867539121, 30955369342236909413806190480686935113629828042777927462299708227, 122201190138992862183156046825436224148821835549252243468507301695, 482464559698258280614105143074906719974084230825244765227211470338, 1905044210329310933012883474559145946790917492784787928227261446437, 7523042318799748660208705403536100792111075885171898541934731742390, 29711865307743859983774105830474814695120217213404274613967605343142, 117358210334644832241289809026318941566777541081906921752718004064223, 463599954895501530333274519944443410381288269629861291846027518952547, 1831550319939959155587395984307016482400316562294418569080566939394373, 7236675876342106283578534336330743048842197598376804592542495717488169, 28595877959236188869992380241499418925461422245402511601972127083938809, 113008487488979608728537052095796235153826972386884347812349453027284777, 446643776276434337481901364650647855177976433243812620954649695122316826, 1765441807395465620252685967072498086035986271227159688590935355004060027, 6978896171078699499744178015254900571985547608845028328618588278612230285, 27590565813291130651676295962305434607391880724234668660140969043129437306, 109087342089418473054846937271841020723765346564892390158006517105586188244, 431347570427895275684887399889776157420375297525437055850000845301829933805, 1705764090654176600783120803651477353278324598907144288980953523257690938954, 6746034859339085323037813551799895795035073688161810095995890114587607307967, 26681829042596408508727803106987892830022155937080103881413184938373444601780, 105540568643047320085637757372875138941484282898455734499378871247031545034426, 417502908721193606389605307438517612545962933342696670188454638798883820258264, 1651715574747214150853710839970797716108744553638299319610439913405742985968373, 6535008503124889007856937275951632354585153583690531839980836461545232215824404, 25857804572051561459180314229189646010564292988633513533872884661419076724098956, 102322517183818948564124541851280345149045011490572076449791435684627433270629411, 404934094236883704120894459814765768721634186306504238924488061567317975693145340, 1602619915399511600553438890014229979328824144334807821204535561824879143206962453, 6343213042207650159611655077596947878673846137393784013748813764014784872364716886, 25108464423291463997404385112070199473744447497076474425682598855413110035742418914, 99394563947684374904758920726914308485128620392393490084506181225843747588475207197, 393492336753755531692026489972641598688144826660754601765695380807032546907543503921, 1557903824987562696463244084053237928311159497375106563075214332506952142892403104132, 6168439205715589425691171307912496909504919319342781227412278678910873593341882573211, 24425293227292450643484793977655277617059585096421595028507694237157052955457119327788, 96723881571135418665545369057123041094621729891750877288042985634178222443867299246418, 383051061687942536045084445172520830808282863996319158056819349124211693991398816327207, 1517079174117195579690955122633080343549424859594834854448758112231369900479121012142113, 6008804205917549913707301141913450089100988933558420551241354568832564553473079190572278, 23801027487732914406483006100676356957141654837362665600929752551423761670767951464675913, 94282443605173282918820528593155670207503470313471709302507741333407860445366620005663942, 373502108594609108040503037731586547276548840138645909419252430705207407681196709803983480, 1479728471960463699182943027707841420937310959692022055363898209234875053818609663966205866, 5862696271018571500089423595308441031224631020361921119823688743286535539779290630567630424, 23229443652081270733980663131770350007457433326179896912355233731751050724947198946004003975, 92046214646244587690706228458864173904798062070835842020367088988974705829518078204001021363, 364752635838858477460715070856088351075708777551436448235555244229366219828253326349002137500, 1445493034116344468923655951043320186128439597523080639496656917977382053690974380985547117707, 5728729409451696444372051461356534264846576646485085732046890058188716009614118855674637377976, 22705185146420504401997097103314578637547420523062806257838636533087251029395653129572040040074, 89994488892654396058856217300404040365891816827131704366554032344385475130012751055422998088811, 356722590821763183370769773946287974891959302880630650897935809030336785839603723618464030276788, 1414063305994736576027292395949115069687019850459912237903595491623285483544543552340164385746823, 5605706391578319849214622281168740607481793100182010208297580436542090440514111407701729518697618, 22223620744205360017667654052757026972000168259047208882853304998777155752466388108220124201070651, 88109348206147011746068556866098564625699209460062623605419377857389060105300638390094653102087665, 349342636080041683221934374226900622820872946841401311867352745078418891476797889097584439698488510, 1385170925534265899519131581097494785149908651513473500940930511309994846416946247702384780811305993, 5492588368773762187176960346750382398248979869518043882552293646465784762754580760180824188726279279, 21780728267753329002789566624916226339853435239931399185927732684141543568339811214313133006185789862, 86375216875091724004892983761031261568077226356560376884219660239075463095982915374142957348433560808, 342552444573954421439069379710177772069561072341619580877761685530229948518863741413885365554900097068, 1358582195600779764137599964716337955978399926986276091819585687264212241288091184793396726965847374717, 5388469875817259323304509591448381084385961063465665255658239637278204961430203993624180560639796747605, 21372998850022699161426070331663358980991055327568017672150484504323229468157683662487272446683394953616, 84778494911805672551905487568003378988055807689922250276608386182662094701118796017840631111511241539380, 336299294984076094211910140735246876668599223869497646602011823658647050190386550822954545260278612631544, 1334092702567721627301741363861098515979926575994751181111582340637309219232241033600092838437900802205038, 5292558212680523400742812226353811345695668866524041146689910628871196088819553304554474876050018124114153, 20997357930969861565036947992351357737332219482074988303743785974044064606333782872828128356414654770048429, 83307255301650683813771759430113027376624989750108038627604618437376758764431340497982895988412865509848646, 330536911422094638826855051199545833594432618486709155341244741865583122131341876999368620130514508527934886, 1311522869083496832871707350626892106751939874234564517468101657197217628921812764530031965246754289948832905, 5204156397188024528172208860333403395144057036547715697743789160749123289693413744575143624612520273136245942, 20651099904331266347452312738842587016214690030449557930458679449892111940939905103364939451289307748992021705, 81950993437459573466341756935194915370706037015935432733554932948181854760107481589302122500483380360974120698, 325224502658680918621143766183198696515890363756397080976420998474791236483195824901624062741635519646490626407, 1290714269690655531306881841380634199972701772564446091319466174738466016505934864779800047925147878259285097303, 5122649034621028257092921727961683522826738055239047518130182514401914195565325824742487436606026182522647156675, 20331833918723604572328478218344871921785349256218990332867325768701950803782350327182973980977910184990231738767, 80700419210399288565532992313764196322776455936388215324863888557166663083824127963351927392338983532130677066691, 320325964488275811162806976162403939204447615115097764645943597768559937809078043653016835390579784416806189815956, 1271526570389220738417720962998566369113558429608467759079824319778588199759814382086958737211830037441352944048167, 5047490573839566652123419730499281587581764724700676283660476791813590196494125779764142565481025618321161423806066, 20037438807446179847249688629193061142526113477517522632902620906339929842504046050208876416491892141201070822230131, 79547284021186879599064590255903862162736176763577694086452574483959105669722214770109007085871325696665049873073536, 315809215683715856623773540595819635047566056859602300667262187593705408991392910317051208881558444097467184884431157, 1253834979285426570031233194424112121276155771396268926629394300954835640295429800316432432553283540199303378978033661]\r\nn, m = map(int, input().split())\r\nprint(vals[n] % m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a209fd22083c43336fe1cb0fc5a4f213", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "read = lambda: map(int, input().split())\nn = int(input())\na = list(read())\nb = [0] * n\nj = 0\nfor i in a:\n if i:\n b[j] = i\n j += 1\ncnt = sum(i != 0 for i in b)\nfor i in range(n):\n if b[i] == 0: break\n if b[i] == a[i]:\n cnt -= 1\nprint(cnt)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e98a9aad4b3457b42fd546c002ca296e", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "input()\nmemory = list(map(int, input().split()))\n\nproc_data = {p: (-1, -1) for p in memory}\n\nfor i, c in enumerate(memory):\n d1, d2 = proc_data[c]\n if d1 == -1: d1 = i\n d2 = i\n proc_data[c] = (d1, d2)\n\ntry: del proc_data[0]\nexcept KeyError:\n print(\"0\")\n exit()\n\ndata = list(proc_data.values())\ndata.sort()\n\nans = 0\n\nfirst_free = 0\n\nfor a, b in data:\n c = a - first_free\n ans += min(c, b-a+1)\n b -= c\n first_free = b + 1\n\nprint(ans)\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3576b03b08c9cfbf69c8a1386f6b4094", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\nk = [[0, 0, -1]]\ncnt = 0\nfor i in map(int, input().split()):\n if i:\n if k[-1][0] == i:\n k[-1][1] += 1\n else:\n k.append([i, 1, cnt])\n cnt += 1\ncnt = 0\nans = 0\nfor i in k[1:]:\n ans += min(i[1], i[2] - cnt)\n cnt += i[1]\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2138bc3192448ae2a4eb7e2242beb938", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "Python 3", "source_code": "n = int(input())\nl = list(map(int, input().split()))\nans = 0\ncount = 0\nd = dict()\ns = set()\ns1 = set()\nfor i in l:\n if i in s:\n d[i] += 1\n else:\n d[i] = 1\n s.add(i)\nfor i in range(n):\n if l[i] == 0:\n count += 1\n else:\n if l[i] not in s1:\n ans += min(d[l[i]], count)\n s1.add(l[i])\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "12b848f49b82effa4c06e1c1b19b31da", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "PyPy 3", "source_code": "p = 1000000007\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nm = int(input())\n\nd = [1] * 300001\ntd = [0] * 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[j * a[i - 1] + t]\n\t\tL = (L - t) // a[i - 1]\n\tk = 0\n\tfor j in range(L + b[i] + 1):\n\t\tif j <= L:\n\t\t\tk = (k + d[j]) % p\n\t\ttd[j] = k\n\t\tif j >= b[i]:\n\t\t\tk = (k - d[j - b[i]] + p) % p\n\tL += b[i]\n\tfor j in range(L + 1):\n\t\td[j] = td[j]\nprint(d[m] if m <= L else 0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "54c6b7851d8e9d5729c1385ca17f2188", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "import array\n\np = 1000000007\n\nn = int(input())\na = array.array('i', map(int, input().split()))\nb = array.array('i', 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": false, "code_uid": "2925c523c7a5127b73f0c92a47289cf7", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.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": false, "code_uid": "7ca68e5d5c06bbcdd6964ca44be1b8f8", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "p = 1000000007\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nm = int(input())\n\nd = [1] * 300001\ntd = [0] * 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\tfor j in range(L + 1):\n\t\td[j] = td[j]\nprint(d[m] if m <= L else 0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b63514f3b8b02e8b893f34d3b2091250", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "PyPy 3", "source_code": "p = 1000000007\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nm = int(input())\n\nd = [1 for _ in range(b[0] + 1)]\nfor i in range(1, n):\n\tif a[i - 1] != 1:\n\t\tt = m % a[i - 1]\n\t\tm //= a[i - 1]\n\t\td = [d[j * a[i - 1] + t] for j in range((len(d) - t - 1) // a[i - 1] + 1)]\n\ttd = [0 for _ in range(len(d) + b[i])]\n\tk = 0\n\tfor j in range(len(d) + b[i]):\n\t\tif j < len(d):\n\t\t\tk = (k + d[j]) % p\n\t\tif j > b[i]:\n\t\t\tk = (k - d[j - b[i] - 1] + p) % p\n\t\ttd[j] = k\n\td = td\nprint(d[m] if m < len(d) else 0)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0063709becec4d4ec3f94d1d019344a2", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "Python 2", "source_code": "r=[0,2,1,32,30,80,109,6824,59808,147224,415870,1757896,1897056,4898872,7593125,776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593,261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440,240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827,482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650,412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421]\nprint r[sum(map(int, raw_input().split())) - 2]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d267419ebe1b7be35df80d40242604aa", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "from math import log\na = {}\na[0]=[0,0]\na[1]=[0,2,1]\na[2]=[0,32,30,80,109]\na[3]=[0,6824,59808,147224,415870,1757896,1897056,4898872,7593125]\na[4]=[0,776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593]\na[5]=[0,261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440]\na[6]=[0,240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827]\na[7]=[0,482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650]\na[8]=[0,412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421]\nx,y = map(int,raw_input().split())\nx = log(x,2)\nprint a[x][y]\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a525d9e8818b50c7063457c06b43bf68", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "a=[[0],[2,1],[32,30,80,109],[6824,59808,147224,415870,1757896,1897056,4898872,7593125],[776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593],[261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440],[240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827],[482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650],[412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421]]\nn,k=map(int,raw_input().split())\ni=0\nwhile 1<>=1\n return r\n\ndef f(n):\n r=[]\n if (n&1)==0:\n e=0\n while (n&1)==0:n>>=1;e+=1\n yield (2,e)\n p=3\n while n>1:\n if p*p>n:p=n\n if n%p:\n p+=2\n continue\n e=1;n//=p\n while n%p==0:n//=p;e+=1\n yield (p,e)\n p+=2\n return r\nm,x=map(int,input().split())\np=2\nr=[(1,1)]\nfor p,e in f(m):\n assert e>=1\n ord=p-1\n assert powmod(x,ord,p)==1\n for pi,ei in f(p-1):\n while ord % pi == 0 and powmod(x,ord//pi,p)==1: ord//=pi\n ords=[(1,1),(ord,p-1)]\n q=p\n for v in range(2,e+1):\n q*=p\n if powmod(x,ord,q)!=1:ord*=p\n assert powmod(x,ord,q)==1\n ords.append((ord,q//p*(p-1)))\n r=[(a//gcd(a,c)*c,b*d) for a,b in r for c,d in ords]\nprint(sum(y//x for x,y in r))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a5cd1e0c4dbf1624af236ddd074bd47f", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "def p(a,b,m):\n a%=m\n r=1\n while b:\n if b&1:r=r*a%m\n a=a*a%m\n b>>=1\n return r\n\ndef f(n):\n r=[]\n if (n&1)==0:\n e=0\n while (n&1)==0:n>>=1;e+=1\n yield (2,e)\n p=3\n while n>1:\n if p*p>n:p=n\n if n%p:\n p+=2\n continue\n e=1;n//=p\n while n%p==0:n//=p;e+=1\n yield (p,e)\n p+=2\n return r\nm,x=map(int,input().split())\np=2\nr=[(1,1)]\nfor p,e in f(m):\n assert e>=1\n ord=p-1\n assert p(x,ord,p)==1\n for pi,ei in f(p-1):\n while ord % pi == 0 and p(x,ord//pi,p)==1: ord//=pi\n ords=[(1,1),(ord,p-1)]\n q=p\n for v in range(2,e+1):\n q*=p\n if p(x,ord,q)!=1:ord*=p\n assert p(x,ord,q)==1\n ords.append((ord,q//p*(p-1)))\n r=[(a//gcd(a,c)*c,b*d) for a,b in r for c,d in ords]\nprint(sum(y//x for x,y in r))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "63b482ac72bdf45937a1af9cf3d475e3", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "from math import gcd\ndef powmod(a,b,m):\n a%=m\n r=1\n while b:\n if b&1:r=r*a%m\n a=a*a%m\n b>>=1\n return r\n\ndef f(n):\n r=[]\n if (n&1)==0:\n e=0\n while (n&1)==0:n>>=1;e+=1\n yield (2,e)\n p=3\n while n>1:\n if p*p>n:p=n\n if n%p:\n p+=2\n continue\n e=1;n//=p\n while n%p==0:n//=p;e+=1\n yield (p,e)\n p+=2\n return r\nm,x=map(int,input().split())\np=2\nr=[(1,1)]\nfor p,e in f(m):\n assert e>=1\n ord=p-1\n assert powmod(x,ord,p)==1\n for pi,ei in f(p-1):\n while ord % pi == 0 and powmod(x,ord//pi,p)==1: ord//=pi\n ords=[(1,1),(ord,p-1)]\n q=p\n for v in range(2,e+1):\n q*=p\n if powmod(x,ord,q)!=1:ord*=p\n assert powmod(x,ord,q)==1\n ords.append((ord,q//p*(p-1)))\n r=[(a//gcd(a,c)*c,b*d) for a,b in r for c,d in ords]\nprint(sum(y//x for x,y in r))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "96effb2c21267ec7c2f69cdb391afcf8", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0} {"lang": "Python 3", "source_code": "import sys\n\ndef main():\n n, k = map(int, input().split())\n b = list(map(int, input().split()))\n bs = [[], [], []]\n s = input()\n for i in range(n):\n ind = -1\n if s[i] == 'O':\n ind = 0\n elif s[i] == 'R':\n ind = 1\n else:\n ind = 2\n bs[ind].append(b[i])\n bs[0].sort()\n bs[1].sort()\n bs[2].sort()\n if len(bs[0]) == 0 or len(bs[1]) + len(bs[2]) == 0 or len(bs[0]) + max(len(bs[1]), len(bs[2])) < k:\n print(-1)\n sys.exit(0)\n\n sufs = [0]\n for i in range(len(bs[0]) - 1, -1, -1):\n sufs.append(sufs[-1] + bs[0][i])\n\n ans = -1\n for i in (1, 2):\n x, y = bs[0], bs[i]\n if len(x) + len(y) < k:\n continue\n cursum = 0\n for cny in range(1, len(y) + 1):\n if cny > 0:\n cursum += y[-cny]\n cnx = k - cny\n if cnx > 0 and cnx <= len(x):\n ans = max(ans, cursum + sufs[cnx])\n\n print(ans)\n\nif __name__ == '__main__':\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0caa32186f1dd80dfbc01159dc0b503f", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "\nn,k=map(int,raw_input().split())\nv=map(int,raw_input().split())\ns=raw_input()\nr=[]\nw=[]\no=[]\n\nfor i in range(0,len(s)):\n\tif s[i]=='R':\n\t\tr.append(v[i])\n\tif s[i]=='W':\n\t\tw.append(v[i])\n\tif s[i]=='O':\n\t\to.append(v[i])\n\nr.sort(),w.sort(),o.sort()\nr.append(0),w.append(0),o.append(0)\nr.reverse(),w.reverse(),o.reverse()\n\nfor i in range(1,len(r)):\n\tr[i]+=r[i-1]\n\nfor i in range(1,len(w)):\n\tw[i]+=w[i-1]\n\nfor i in range(1,len(o)):\n\to[i]+=o[i-1]\n\nans=-1\n\nfor i in range(1,len(o)):\n\tif i>=k :\n\t\tbreak\n\tif k-i 0:\n ans = max(ans, A[i] + B[k-i])\n return ans\n\n\ndef testCase():\n n, k = [int(x) for x in input().split()]\n nums = [int(x) for x in input().split()]\n ros = input()\n n = len(nums)\n A = []\n B = []\n C = []\n for i in range(n):\n if ros[i] == 'R':\n A.append(nums[i])\n elif ros[i] == 'O':\n B.append(nums[i])\n else:\n C.append(nums[i])\n A.sort()\n A.append(0)\n A.reverse()\n B.sort()\n B.append(0)\n B.reverse()\n C.sort()\n C.append(0)\n C.reverse()\n ans = max(calca(A, B, k), calca(B, C, k))\n print(-1 if ans == -int(1e9) else ans)\n\n\ntestCase()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d686b65c1af6e1aa5c5895d5a3894aa8", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "rd = lambda: map(int, input().split())\nn, k = rd()\nb, c = list(rd()), input()\na, d = [[], [], []], {'R': 0, 'W': 1, 'O': 2}\nfor i in range(n):\n a[d[c[i]]].append(b[i])\nfor x in a:\n x.sort()\nf = lambda x: a[x][-1] + a[2][-1] + sum(sorted(a[x][:-1] + a[2][:-1])[::-1][:k - 2]) if len(a[x]) and len(a[x]) + len(a[2]) >= k else -1\nif len(a[2]) and k > 1:\n print(max(f(0), f(1)))\nelse:\n print(-1)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e0a325eb7e3eed380202dbe8aa267a06", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n,k = map(int, input().split())\nb = list(map(int,input().split()))\n\ns = input()\n\n# print(n,k)\n# print(b)\n# print(s)\n\nINF = 1000*1000*1000+123\nR = [];\nW = [];\nO = [];\n\nfor i in range(n):\n if s[i] == 'R':\n R.append(b[i])\n elif s[i] == 'W':\n W.append(b[i])\n else:\n O.append(b[i])\n\n\nR.sort()\nR.reverse()\n\nW.sort()\nW.reverse()\n\nO.sort()\nO.reverse()\n\n# print('--------')\n\n# print(\"-\",)\n\nif k == 1:\n print(-1)\n exit(0)\n\n\ndef solve(A,B):\n # print(\"\\nsolve\");\n # print(A);\n # print(B);\n nA = len(A);\n nB = len(B);\n\n pA = [0 for i in range(nA)]\n pB = [0 for i in range(nB)]\n\n pA[0] = A[0]\n pB[0] = B[0]\n\n for i in range(1,nA):\n pA[i] = pA[i-1] + A[i];\n for i in range(1,nB):\n pB[i] = pB[i-1] + B[i];\n\n # print(\"pA\",pA)\n # print(\"pB\",pB)\n\n res = -1\n\n for i in range(1,min(nA+1,k)):\n\n costA = pA[i-1]\n bNeed = k-i\n if bNeed <= 0 or bNeed > nB: continue\n costB = pB[bNeed-1]\n res = max(res,costA+costB)\n return res\n\n\nres = -1\nif len(R) > 0 and len(O)> 0:\n res = max(res,solve(R,O))\n\nif len(W) > 0 and len(O)> 0:\n res = max(res,solve(W,O))\n\nprint(res)\n\n#\n# a = [\n# 6,5,37,10,22,9,2,16,3,3,11,9,5,14,11,3,1,4,6,2,7,\n# 3,7,5,4,8,2,7,13,16,15,9,4,4,2,3,9,5,11,3,7,5,9,\n# 3,8,9,4,10,3,2,7,6,9,3,5,4,6,4,14,3,12,6,8,12,7\n# ]\n#\n# print(a)\n#\n# cnt = [0] * 1000\n#\n# for e in a:\n# cnt[e] += 1\n#\n# a = set(a)\n# a = sorted(a)\n#\n#\n# for e in a:\n# print(\"%d %d\"%(e,cnt[e]));\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "56069b2649e5421ae591c34f6201ddc1", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.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": "c5f4b807516d260cee1c47d0296af536", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "def inv(a):\n\treturn pow(a, MOD-2, MOD) %MOD\n\ndef fat(a):\n\tans = 1\n\tfor i in range(1, a+1):\n\t\tans = (ans*i)%MOD\n\treturn ans\n\nMOD = 998244353\nn, m, k = map(int, input().split())\np = inv(m)\n\n# O(Burro) O(n2)-> F\u00f3rmula da experan\u00e7a = sum(x^k * C(n, x) * p^x * q^(n-x))\n'''\nresp = 0\nq = (1 - p + MOD) % MOD\nfor x in range(1, n+1):\n\tresp += pow(x, k, MOD) %MOD * fat(n) %MOD * invfat(n-x) %MOD * invfat(x) %MOD *pow(p, x, MOD) %MOD * pow(q, n-x, MOD) %MOD\n'''\n# O(menos burro) O(nlog(k)) -> atualiza somat\u00f3rio usando valores ja calculados\nif n<=k:\n\tq = (1 - p + MOD) % MOD\n\tinv_q = inv(q)\n\tp_aux = p\n\tq_aux = pow(q, n-1, MOD)\n\tfn = n\n\tresp = n * p%MOD * q_aux%MOD\n\tresp = resp%MOD\n\n\tfor i in range(2, n+1):\n\t\tx = pow(i, k, MOD)\n\t\tp_aux = p_aux * p %MOD\n\t\tq_aux = q_aux * inv_q\t\n\t\tfn = fn*(n-i+1)%MOD*inv(i)%MOD\n\t\t\n\t\tresp = resp + x * fn %MOD * p_aux %MOD * q_aux %MOD\n\t\tresp = resp%MOD\n\tprint(resp)\n\n# O(inteligente) O(k2) -> A partir da FGM M(X), identifica padr\u00e3o das derivadas\n# k-\u00e9sima derivada de M(X) = E(x^k)\n# E(x^k) = n!/(n-k)! * p^k + k*(deriv[k-1] - sum(ind[i]*deriv[i])) + sum(ind[i]*deriv[i+1])\nelse:\n\tderiv = [(n*p)%MOD] #E(x) = np\n\tresp = n*n%MOD*p%MOD*p%MOD - n*p%MOD*p%MOD + n*p%MOD #E(x^2) = n^2p^2 - np^2 + np\n\tderiv.append(resp%MOD)\n\tfn = (n*(n-1))%MOD\n\tv=[1];\n\t\n\tfor i in range(3, k+1):\n\t\tfn = (fn * (n-i+1) %MOD)%MOD\n\t\tw = [(-(i-1)*v[0])%MOD]\t\n\t\tfor j in range(len(v)-1):\n\t\t\tw.append((v[j] - (i-1)*v[j+1]%MOD)%MOD) \n\t\tw.append((v[-1] + i-1)%MOD)\n\t\tv = tuple(w)\n\n\t\tresp = (fn * pow(p, i, MOD))%MOD\n\t\tfor j in range(len(v)):\n\t\t\tresp = (resp + v[j]*deriv[j]%MOD)%MOD\t\n\t\t\tresp = resp%MOD\n\t\tresp %= MOD\n\t\tderiv.append(resp)\n\n\tprint(deriv[k-1])\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ea1b856d59e1128332490c2701fe0b51", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353 \n\nn, m, k = [int(x) for x in input().split()]\n\nif m == 1:\n print pow(n, k, MOD)\n sys.exit()\n\np = pow(m, MOD - 2, MOD)\n\nvec = [0]*(k + 1)\nvec[0] = 1\nfor i in range(k):\n for m in reversed(range(i + 1)):\n vec[m + 1] = int( (vec[m + 1] + (n - m) * vec[m]) % MOD )\n vec[m] = int(vec[m] * m % MOD)\n\nx = p * pow(1 - p, MOD - 2, MOD)\n\nsumma = 0\nfor m in range(k + 1):\n summa += vec[m] * pow(1 + x, n - m, MOD) * pow(x, m, MOD) % MOD\n\nsumma *= pow(1 - p, n, MOD)\n\nprint summa % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "931f56da86e88c87e197599430f63349", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "Python 2", "source_code": "__author__ = 'sergio'\n\n\ndef sg(p):\n if p == 0:\n return -1\n else:\n return 1\n\n\ndef minim(w,h):\n if w < h:\n return (w,0)\n else:\n return (h,1)\n\n\ndef find_path(x, y, down, right):\n global size_n\n global size_m\n if down == 1:\n h = size_n - x\n else:\n h = x - 1\n if right == 1:\n w = size_m - y\n else:\n w = y - 1\n minimum = minim(w,h)\n p = minimum[0]\n ansX = x + p * sg(down)\n ansY = y + p * sg(right)\n if ansX == 1:\n down = 1\n if ansY == 1:\n right = 1\n if ansX == size_n:\n down = 0\n if ansY == size_m:\n right = 0\n return (ansX, ansY, down, right)\n\n\ndef total_black_bound_cells(n, m):\n return n + m - 2\n\n\ndef moves_count(x, y, xn, yn):\n return abs(x - xn)\n\n\ndef get_direction(direction):\n if direction == 'UL':\n return 0, 0\n elif direction == 'UR':\n return 0, 1\n elif direction == 'DL':\n return 1, 0\n elif direction == 'DR':\n return 1, 1\n\n\ndef turn_inside(n, m, xs, ys, down, right):\n if xs == 1:\n down = 1\n if ys == 1:\n right = 1\n if xs == n:\n down = 0\n if ys == m:\n right = 0\n return (down, right)\n\nsize_n = 0\nsize_m = 0\n\nif __name__ == '__main__':\n\n n, m = [int(x) for x in raw_input().strip().split(' ')]\n xs, ys, direction = raw_input().strip().split(' ')\n xs = int(xs)\n ys = int(ys)\n\n size_n = n\n size_m = m\n down, right = get_direction(direction)\n down, right = turn_inside(n, m, xs, ys, down, right)\n\n # print n, m, xs, ys, down, right\n\n # make visited_points with bound cells\n visited_points = {}\n total_to_check = total_black_bound_cells(n, m) # calculate\n # print 'total_to_check', total_to_check\n visited_points[(xs, ys)] = 1\n total_to_check -= 1\n x = xs\n y = ys\n dye = 1\n while (total_to_check > 0):\n xn, yn, down, right = find_path(x, y, down, right)\n dye += moves_count(x, y, xn, yn)\n # print 'moves_count', moves_count(x, y, xn, yn)\n x = xn\n y = yn\n if (x, y) not in visited_points:\n visited_points[(x, y)] = 1\n total_to_check -= 1\n elif visited_points[(x,y)] == 1:\n visited_points[(x,y)] += 1\n else:\n print -1\n exit()\n print dye\n\n\n# visited_points[(n, i)] = 0\n# if xs % 2 == 0:\n# for i in range (2, n + 1, 2):\n# visited_points[(i,1)] = 0\n# visited_points[(i,m)] = 0\n# else:\n# for i in range (1, n + 1, 2):\n# visited_points[(i,1)] = 0\n# visited_points[(i,m)] = 0\n#\n# if ys % 2 == 0:\n# for i in range (2, m + 1, 2):\n# visited_points[(1, i)] = 0\n# visited_points[(n, i)] = 0\n# else:\n# for i in range (1, m + 1, 2):\n# visited_points[(1, i)] = 0\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2e1150dc0438e5727759de92befa2796", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "__author__ = 'sergio'\n\n\ndef sg(p):\n if p == 0:\n return -1\n else:\n return 1\n\n\ndef minim(w,h):\n if w < h:\n return (w,0)\n else:\n return (h,1)\n\n\ndef find_path(x, y, down, right):\n global size_n\n global size_m\n if down == 1:\n h = size_n - x\n else:\n h = x - 1\n if right == 1:\n w = size_m - y\n else:\n w = y - 1\n minimum = minim(w,h)\n p = minimum[0]\n ansX = x + p * sg(down)\n ansY = y + p * sg(right)\n if ansX == 1:\n down = 1\n if ansY == 1:\n right = 1\n if ansX == size_n:\n down = 0\n if ansY == size_m:\n right = 0\n return (ansX, ansY, down, right)\n\n\ndef total_black_bound_cells(n, m):\n return n + m - 2\n\n\ndef moves_count(x, y, xn, yn):\n return abs(x - xn)\n\n\ndef get_direction(direction):\n if direction == 'UL':\n return 0, 0\n elif direction == 'UR':\n return 0, 1\n elif direction == 'DL':\n return 1, 0\n elif direction == 'DR':\n return 1, 1\n\n\ndef turn_inside(n, m, xs, ys, down, right):\n if xs == 1:\n down = 1\n if ys == 1:\n right = 1\n if xs == n:\n down = 0\n if ys == m:\n right = 0\n return (down, right)\n\nsize_n = 0\nsize_m = 0\n\nif __name__ == '__main__':\n\n n, m = [int(x) for x in raw_input().strip().split(' ')]\n xs, ys, direction = raw_input().strip().split(' ')\n xs = int(xs)\n ys = int(ys)\n\n size_n = n\n size_m = m\n down, right = get_direction(direction)\n down, right = turn_inside(n, m, xs, ys, down, right)\n\n # print n, m, xs, ys, down, right\n\n # make visited_points with bound cells\n visited_points = {}\n total_to_check = total_black_bound_cells(n, m) # calculate\n # print 'total_to_check', total_to_check\n visited_points[(xs, ys)] = 1\n total_to_check -= 1\n x = xs\n y = ys\n dye = 1\n while (total_to_check > 0):\n xn, yn, down, right = find_path(x, y, down, right)\n dye += moves_count(x, y, xn, yn)\n # print 'moves_count', moves_count(x, y, xn, yn)\n x = xn\n y = yn\n if (x, y) not in visited_points:\n visited_points[(x, y)] = 1\n total_to_check -= 1\n elif visited_points[(x,y)] == 1:\n visited_points[(x,y)] += 1\n else:\n print -1\n exit()\n print dye", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b01479ebcc562781f990335645469d1b", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "s=raw_input()\nn=len(s)\nf=[0]*n\ng=[0]*n\n'''\nAB->BA\nNo Other AB\n'''\n# 0=A\nf[0]=1\nfor i in xrange(0,n-1):\n if (s[i]=='A') and (s[i+1]=='A'):\n f[i+1]+=g[i]\n f[i+1]+=f[i]\n if (s[i]=='A') and (s[i+1]=='B'):\n f[i+1]+=f[i]\n f[i+1]+=g[i]\n g[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='A'):\n g[i+1]+=f[i]\n f[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='B'):\n f[i+1]+=g[i]\n g[i+1]+=g[i]\nans=0\nif s[n-1]=='B':\n ans+=g[n-1]\nelse:\n ans=f[n-1]+g[n-1]\nf=[0]*n\ng=[0]*n\n# 0=B\ng[0]=1\nfor i in xrange(0,n-1):\n if (s[i]=='A') and (s[i+1]=='A'):\n f[i+1]+=g[i]\n f[i+1]+=f[i]\n if (s[i]=='A') and (s[i+1]=='B'):\n f[i+1]+=f[i]\n f[i+1]+=g[i]\n g[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='A'):\n g[i+1]+=f[i]\n f[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='B'):\n f[i+1]+=g[i]\n g[i+1]+=g[i]\nif s[0]=='A':\n ans+=f[n-1]\nelse:\n ans+=g[n-1]\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b15c71767e809a3ac9dcff25dff60784", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "s = raw_input()\nn = len(s)\npb = -1\nfor i in xrange(n):\n\tif s[i] == 'B':\n\t\tpb = i\n\nif pb != -1:\n\ts = s[pb:] + s[:pb]\n\ns = s[-1] + s + s[0]\n\nres = 1\n\ndp = []\n\nfor i in xrange(n + 2):\n\tdp.append([[[0, 0], [0, 0]], [[0, 0], [0, 0]]])\n\nfor i in xrange(2, n + 1):\n\tfor first in xrange(2):\n\t\tfor prev in xrange(2):\n\t\t\tfor last in xrange(2):\n\t\t\t\tfor cur in xrange(2):\n\t\t\t\t\tif s[i - 1:i + 1] != 'BA' and cur == 1:\n\t\t\t\t\t\tcontinue\n\t\t\t\t\tif i == 2:\n\t\t\t\t\t\tif first != cur or prev != 0 or last != 0:\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tdp[i][first][last][cur] = 1\n\t\t\t\t\telif i > 2:\n\t\t\t\t\t\tif s[i - 2:i] == 'AB' and prev == 0 and cur == 0:\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tif i == n and s[n] + s[1] == 'AB' and cur == 0 and first == 0:\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tif i == n and s[n - 1:n + 1] == 'AB' and cur == 0 and last == 0:\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tdp[i][first][last][cur] += dp[i - 1][first][prev][last]\n\nres = 0\nfor i in xrange(2):\n\tfor j in xrange(2):\n\t\tfor k in xrange(2):\n\t\t\tres += dp[n][i][j][k]\n\nprint res\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "673ce135a3be34731e86fb6e330c169a", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "s=raw_input()\nn=len(s)\nf=[0]*n\ng=[0]*n\n'''\nAB->BA\nNo Other AB\n'''\n# 0=A\nf[0]=1\nfor i in xrange(0,n-1):\n if (s[i]=='A') and (s[i+1]=='A'):\n f[i+1]+=g[i]\n f[i+1]+=f[i]\n if (s[i]=='A') and (s[i+1]=='B'):\n f[i+1]+=f[i]\n f[i+1]+=g[i]\n g[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='A'):\n g[i+1]+=f[i]\n f[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='B'):\n f[i+1]+=g[i]\n g[i+1]+=g[i]\nans=0\nif s[n-1]=='B':\n ans+=g[n-1]\nelse:\n ans=f[n-1]+g[n-1]\nf=[0]*n\ng=[0]*n\n# 0=B\ng[0]=1\nfor i in xrange(0,n-1):\n if (s[i]=='A') and (s[i+1]=='A'):\n f[i+1]+=g[i]\n f[i+1]+=f[i]\n if (s[i]=='A') and (s[i+1]=='B'):\n f[i+1]+=f[i]\n f[i+1]+=g[i]\n g[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='A'):\n g[i+1]+=f[i]\n f[i+1]+=g[i]\n if (s[i]=='B') and (s[i+1]=='B'):\n f[i+1]+=g[i]\n g[i+1]+=g[i]\nif (s[0]=='A') and (s[n-1]=='B'):\n ans+=f[n-1]\nelif (s[0]=='B'):\n ans+=g[n-1]\nprint ans", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1e1bff4b366229710ba330ee433d25d1", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "n=int(input())\ns=[c=='1' for c in input()]\nm=len(s)\nz=[[0,0]]\nfor c in s:\n ind = z[-1][c]\n z[-1][c] = len(z)\n z.append(z[ind][:])\nassert(len(z) == m+1)\nz[m][0] = z[m][1] = m # make it sticky\n\n# how many things match directly\ndp = [0 for _ in range(m+1)]\ndp[0] = 1\nfor i in range(n):\n ndp = [0 for _ in range(m+1)]\n for i in range(m+1):\n ndp[z[i][0]] += dp[i]\n ndp[z[i][1]] += dp[i]\n dp = ndp\nres = dp[m]\n\nfor k in range(1, m):\n s0 = 0\n for c in s[-k:]:\n s0 = z[s0][c]\n dp = [0 for _ in range(m+1)]\n dp[s0] = 1\n for i in range(n - k):\n ndp = [0 for _ in range(m+1)]\n for i in range(m+1):\n ndp[z[i][0]] += dp[i]\n ndp[z[i][1]] += dp[i]\n dp = ndp\n for s1 in range(m): # skip m\n v = dp[s1]\n for c in s[-k:]:\n if s1 == m: v = 0\n s1 = z[s1][c]\n if s1 == m: res += v\nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c53930c74acd2c71f5dfbece9e627282", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900.0} {"lang": "PyPy 3", "source_code": "from bisect import *\nfrom collections import *\nfrom math import gcd,ceil,sqrt,floor,inf\nfrom heapq import *\nfrom itertools import *\nfrom operator import add,mul,sub,xor,truediv,floordiv\nfrom functools import *\n\n#------------------------------------------------------------------------\nimport 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#------------------------------------------------------------------------\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())\n#------------------------------------------------------------------------\n\n\nfarr=[1]\nifa=[]\n\ndef fact(x,mod=0):\n if mod:\n while x>=len(farr):\n farr.append(farr[-1]*len(farr)%mod)\n else:\n while x>=len(farr):\n farr.append(farr[-1]*len(farr))\n return farr[x]\n\ndef ifact(x,mod):\n global ifa\n ifa.append(pow(farr[-1],mod-2,mod))\n for i in range(x,0,-1):\n ifa.append(ifa[-1]*i%mod)\n ifa=ifa[::-1]\n\ndef per(i,j,mod=0):\n if if(mid):\n l=mid+1\n else:\n r=mid\n return l\n\ndef rinc(f,t,l,r):\n while lf(mid):\n r=mid-1\n else:\n l=mid\n return l\n\ndef isprime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\ndef binfun(x):\n c=0\n for w in arr:\n c+=ceil(w/x)\n return c\n\ndef lowbit(n):\n return n&-n\n\ndef inverse(a,m):\n a%=m\n if a<=1: return a\n return ((1-inverse(m,a)*m)//a)%m\n\nclass BIT:\n def __init__(self,arr):\n self.arr=arr\n self.n=len(arr)-1\n \n def update(self,x,v):\n while x<=self.n:\n self.arr[x]+=v\n x+=x&-x\n\n def query(self,x):\n ans=0\n while x:\n ans+=self.arr[x]\n x&=x-1\n return ans\n\nclass smt:\n def __init__(self,l,r,arr):\n self.l=l\n self.r=r\n self.value=(1<<31)-1 if l=self.r):\n return self.value\n val=(1<<31)-1\n mid=(self.l+self.r)//2\n if(l<=mid):\n val&=self.left.ask(l,r)\n if(r>mid):\n val&=self.right.ask(l,r)\n return val\n\nclass DSU:#\u5bb9\u91cf+\u8def\u5f84\u538b\u7f29\n def __init__(self,n):\n self.c=[-1]*n\n\n def same(self,x,y):\n return self.find(x)==self.find(y)\n\n def find(self,x):\n if self.c[x]<0:\n return x\n self.c[x]=self.find(self.c[x])\n return self.c[x]\n\n def union(self,u,v):\n u,v=self.find(u),self.find(v)\n if u==v:\n return False\n if self.c[u]=self.ranks[pv]:\n self.parent[pv]=pu\n if self.ranks[pv]==self.ranks[pu]:\n self.ranks[pu]+=1\n else:\n self.parent[pu]=pv\n\ndef Prime(n):\n c=0\n prime=[]\n flag=[0]*(n+1)\n for i in range(2,n+1):\n if not flag[i]:\n prime.append(i)\n c+=1\n for j in range(c):\n if i*prime[j]>n: break\n flag[i*prime[j]]=prime[j]\n if i%prime[j]==0: break\n return prime\n\ndef dij(s,graph):\n d={}\n d[s]=0\n heap=[(0,s)]\n seen=set()\n while heap:\n dis,u=heappop(heap)\n if u in seen:\n continue\n for v in graph[u]:\n if v not in d or d[v]>d[u]+graph[u][v]:\n d[v]=d[u]+graph[u][v]\n heappush(heap,(d[v],v))\n return d\n\ndef GP(it): return [(ch,len(list(g))) for ch,g in groupby(it)]\n\nclass DLN:\n def __init__(self,val):\n self.val=val\n self.pre=None\n self.next=None\n\n\n \n\nt=1\nfor i in range(t):\n mod=998244353\n n,k=RL()\n h=RLL()\n res=GP(h)\n c=0\n for ch,cnt in res:\n c+=cnt-1\n n=len(res)\n if res[-1][0]==res[0][0]:\n c+=1\n n-=1\n ans=pow(k,c,mod)\n tmp=pow(k,n,mod)\n fact(n,mod)\n ifact(n,mod)\n p=[1]\n for i in range(n):\n p.append(p[-1]*(k-2)%mod)\n for x in range(n//2+1):\n tmp=(tmp-p[n-2*x]*fact(n,mod)%mod*ifa[x]%mod*ifa[x]%mod*ifa[n-2*x]%mod)%mod\n ans=ans*tmp%mod*pow(2,mod-2,mod)%mod\n print(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9ed2c1a2cef166abab20f9af16493ec7", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "def main():\n M=998244353\n n,k,*h=map(int,open(0).read().split())\n m=sum(i!=j for i,j in zip(h,h[1:]+h[:1]))\n f=[0]*(m+1)\n f[0]=b=1\n for i in range(1,m+1):f[i]=b=b*i%M\n inv=[0]*(m+1)\n inv[m]=b=pow(f[m],M-2,M)\n for i in range(m,0,-1):inv[i-1]=b=b*i%M\n comb=lambda n,k:f[n]*inv[n-k]*inv[k]%M\n print((pow(k,m,M)-sum(comb(m,i)*comb(m-i,i)*pow(k-2,m-i-i,M)for i in range(m//2+1)))*pow(k,n-m,M)*pow(2,M-2,M)%M)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d7106ad522d9a6d8a7c757b15674417c", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "from bisect import *\nfrom collections import *\nfrom math import gcd,ceil,sqrt,floor,inf\nfrom heapq import *\nfrom itertools import *\nfrom operator import add,mul,sub,xor,truediv,floordiv\nfrom functools import *\n\n#------------------------------------------------------------------------\nimport 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#------------------------------------------------------------------------\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())\n#------------------------------------------------------------------------\n\n\nfarr=[1]\nifa=[]\n\ndef fact(x,mod=0):\n if mod:\n while x>=len(farr):\n farr.append(farr[-1]*len(farr)%mod)\n else:\n while x>=len(farr):\n farr.append(farr[-1]*len(farr))\n return farr[x]\n\ndef ifact(x,mod):\n global ifa\n ifa.append(pow(farr[-1],mod-2,mod))\n for i in range(x,0,-1):\n ifa.append(ifa[-1]*i%mod)\n ifa=ifa[::-1]\n\ndef per(i,j,mod=0):\n if if(mid):\n l=mid+1\n else:\n r=mid\n return l\n\ndef rinc(f,t,l,r):\n while lf(mid):\n r=mid-1\n else:\n l=mid\n return l\n\ndef isprime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\ndef binfun(x):\n c=0\n for w in arr:\n c+=ceil(w/x)\n return c\n\ndef lowbit(n):\n return n&-n\n\ndef inverse(a,m):\n a%=m\n if a<=1: return a\n return ((1-inverse(m,a)*m)//a)%m\n\nclass BIT:\n def __init__(self,arr):\n self.arr=arr\n self.n=len(arr)-1\n \n def update(self,x,v):\n while x<=self.n:\n self.arr[x]+=v\n x+=x&-x\n\n def query(self,x):\n ans=0\n while x:\n ans+=self.arr[x]\n x&=x-1\n return ans\n\nclass smt:\n def __init__(self,l,r,arr):\n self.l=l\n self.r=r\n self.value=(1<<31)-1 if l=self.r):\n return self.value\n val=(1<<31)-1\n mid=(self.l+self.r)//2\n if(l<=mid):\n val&=self.left.ask(l,r)\n if(r>mid):\n val&=self.right.ask(l,r)\n return val\n\nclass DSU:#\u5bb9\u91cf+\u8def\u5f84\u538b\u7f29\n def __init__(self,n):\n self.c=[-1]*n\n\n def same(self,x,y):\n return self.find(x)==self.find(y)\n\n def find(self,x):\n if self.c[x]<0:\n return x\n self.c[x]=self.find(self.c[x])\n return self.c[x]\n\n def union(self,u,v):\n u,v=self.find(u),self.find(v)\n if u==v:\n return False\n if self.c[u]=self.ranks[pv]:\n self.parent[pv]=pu\n if self.ranks[pv]==self.ranks[pu]:\n self.ranks[pu]+=1\n else:\n self.parent[pu]=pv\n\ndef Prime(n):\n c=0\n prime=[]\n flag=[0]*(n+1)\n for i in range(2,n+1):\n if not flag[i]:\n prime.append(i)\n c+=1\n for j in range(c):\n if i*prime[j]>n: break\n flag[i*prime[j]]=prime[j]\n if i%prime[j]==0: break\n return prime\n\ndef dij(s,graph):\n d={}\n d[s]=0\n heap=[(0,s)]\n seen=set()\n while heap:\n dis,u=heappop(heap)\n if u in seen:\n continue\n for v in graph[u]:\n if v not in d or d[v]>d[u]+graph[u][v]:\n d[v]=d[u]+graph[u][v]\n heappush(heap,(d[v],v))\n return d\n\ndef GP(it): return [(ch,len(list(g))) for ch,g in groupby(it)]\n\nclass DLN:\n def __init__(self,val):\n self.val=val\n self.pre=None\n self.next=None\n\n\n \n\nt=1\nfor i in range(t):\n mod=998244353\n n,k=RL()\n h=RLL()\n res=GP(h)\n c=0\n for ch,cnt in res:\n c+=cnt-1\n n=len(res)\n if n>1 and res[-1][0]==res[0][0]:\n c+=1\n n-=1\n ans=pow(k,c,mod)\n tmp=pow(k,n,mod)\n fact(n,mod)\n ifact(n,mod)\n p=[1]\n for i in range(n):\n p.append(p[-1]*(k-2)%mod)\n for x in range(n//2+1):\n tmp=(tmp-p[n-2*x]*fact(n,mod)%mod*ifa[x]%mod*ifa[x]%mod*ifa[n-2*x]%mod)%mod\n ans=ans*tmp%mod*pow(2,mod-2,mod)%mod\n print(ans)\n \n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a8a46d374a9972914df0bfd0c65a67b4", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "def main():\n M=998244353\n n,k,*h=map(int,open(0).read().split())\n m=sum(i!=j for i,j in zip(h,h[1:]+h[:1]))\n f=[0]*(m+1)\n f[0]=b=1\n for i in range(1,m+1):f[i]=b=b*i%M\n inv=[0]*(m+1)\n inv[m]=b=pow(f[m],M-2,M)\n for i in range(m,0,-1):inv[i-1]=b=b*i%M\n comb=lambda n,k:f[n]*inv[n-k]*inv[k]%M\n print((pow(k,m,M)-sum(comb(m,i)*comb(m-i,i)*pow(k-2,m-i-i,M)for i in range(m//2+1)))*pow(k,n-m,M)*inv[2]%M)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "816e1ff32da48aada817a6dfb4d7c4fb", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "PyPy 3", "source_code": "def main():\n M=998244353\n n,k,*h=map(int,open(0).read().split())\n m=sum(i!=j for i,j in zip(h,h[1:]+h[:1]))\n f=[0]*(m+1)\n f[0]=b=1\n for i in range(1,m+1):f[i]=b=b*i%M\n inv=[0]*(m+1)\n inv[m]=b=pow(f[m],M-2,M)\n for i in range(m,0,-1):inv[i-1]=b=b*i%M\n comb=lambda n,k:f[n]*inv[n-k]*inv[k]%M\n print((pow(k,m)-sum(comb(m,i)*comb(m-i,i)*pow(k-2,m-i-i,M)for i in range(m//2+1)))*pow(k,n-m,M)*inv[2]%M)\nmain()", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e2957addeb760122f16a3ca746bf908e", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "Python 2", "source_code": "def f(start,ends_with):\n n1=len(start)\n n2=len(ends_with)\n ans=\"\"\n if n1int(start)):\n return ends_with\n else:\n return '1'+ends_with\n if(int(start[n1-n2:])=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\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][x]):\n continue\n Y=[]\n for j in range(len(Children[i])):\n child=Children[i][j]\n Parent[child]=-1\n Rem[i]+=C[child]\n Seen[i][child]=True\n Seen[child][i]=True\n if(DFS(child)):\n Seen[i][child]=False\n Seen[child][i]=False\n continue\n Seen[i][child]=False\n Seen[child][i]=False\n Parent[child]=i\n Rem[i]-=C[child]\n Y.append(child)\n Children[i]=list(Y)\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\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=[]\nfor i in range(n):\n Seen.append([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": "af06930d2bd4fa844051480277fcdae5", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\n\nfreq = [c.count(i) for i in range(n+1)]\n\nanswer = \"NO\"\n\ndef backtrack(stack, avail, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # try to shift a 1\n if avail[1] > 0:\n avail[1] -= 1\n backtrack(stack + [1], avail, sumleft - 1)\n avail[1] += 1\n\n # reduce if possible\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n backtrack(stack[:-i] + [s], avail, sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], freq, sum(c))\nprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "428c5eb673b9dd3002bde5304fc9fc1c", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\nc = sorted(c)\n\nF = [0] * (n+1)\nfor _c in c:\n F[_c] += 1\n\n#print n, c, F\nanswer = \"NO\"\n\ndef backtrack(stack, avail, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # shift\n if avail[1] > 0:\n avail[1] -= 1\n #print \"shift\", i\n backtrack(stack + [1], avail, sumleft - 1)\n avail[1] += 1\n\n # reduce\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n #print \"reduce\", s\n backtrack(stack[:-i] + [s], avail, sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], F, sum(c))\nprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c783a945e9177a54880248ece194e106", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "#!/usr/bin/python\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\n\nn = Ni()[0]\nc = Ni()\nc = sorted(c)\n\nF = [0] * (n+1)\nfor _c in c:\n F[_c] += 1\n\n#print n, c, F\nanswer = \"NO\"\n\ndef backtrack(stack, avail, sumleft):\n #print stack, avail, sumleft\n if len(stack) == 1 and sumleft == 0:\n print \"YES\"\n sys.exit(0)\n\n # shift\n for i, a in enumerate(avail):\n if a > 0:\n avail[i] -= 1\n #print \"shift\", i\n backtrack(stack + [i], avail, sumleft - i)\n avail[i] += 1\n\n # reduce\n if len(stack) < 2:\n return\n\n s = 1 + stack[-1]\n for i in range(2, len(stack) + 1):\n s += stack[-i]\n if s >= n + 1:\n break\n\n if avail[s] > 0:\n avail[s] -= 1\n #print \"reduce\", s\n backtrack(stack[:-i] + [s], avail, sumleft - s)\n avail[s] += 1\n \n\nbacktrack([], F, sum(c))\nprint \"NO\"\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d6d5b68be5e69e96ed8a9ee7947c0ba1", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "def DFS(x):\n for i in range(x):\n if(Seen[i]):\n continue\n if(Rem[i]>=C[x]):\n if(Rem[i]==C[x] and len(Children[i])==0):\n continue\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 if(Rem[i]==C[x] and len(Children[i])==0):\n continue\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": "390143cff53bcf9bbde91f4c68fc4f37", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "PyPy 3", "source_code": "def c(n, k):\n\tif k > n:\n\t\treturn 0\n\ta = b = 1\n\tfor i in range(n - k + 1, n + 1):\n\t\ta *= i\n\tfor i in range(1, k + 1):\n\t\tb *= i\n\treturn a // b\na, b, k, t = map(int, input().split())\nn, m, s = 2 * k + 1, 2 * t, 2 * k * t + b - a\nans, mod = 0, 1000000007\nfor i in range(m + 1):\n\tans = (ans + [1, -1][i & 1] * c(m, i) * c(m + s - n * i, m)) % mod\nprint((pow(n, m, mod) - ans) % mod)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bafaa192edd5176743641c753e23d9d5", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "Python 2", "source_code": "n_and_c=raw_input().split(' ')\nn=int(n_and_c[0])\nc=int(n_and_c[1])\n\ndef factorial_modulo(n, d):\n count=1\n i=1\n while i<=n:\n count*=i\n count = count % d\n i+=1\n return count\n\nf = factorial_modulo(n+c, 10**6+3)\npre_f1 = factorial_modulo(n, 10**6+3)\nf1 = pow(pre_f1, 10**6+1, 10**6+3)\npre_f2 = factorial_modulo(c, 10**6+3)\nf2 = pow(pre_f2, 10**6+1, 10**6+3)\n\n\nprint f*f1*f2 % (10**6+3) - 1\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8298e3594891083a44ed189888d3cabc", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "fact = [1]*1000000\nmod = 10**6+3\nfor i in range(2,1000000):\n fact[i] = (i*fact[i-1])%mod\nn,c = map(int,raw_input().split())\nans = fact[n+c]*pow(fact[c],mod-2,mod)*pow(fact[n],mod-2,mod)\nprint ((ans-1)%mod+mod)%mod", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3ceded4d6543d2cbe088345e41933ac3", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import sys\n#with open(filename, 'r') as f:\nwith sys.stdin as f:\n n, C = f.readline().split(\" \")\n n, C = int(n), int(C)\np = 1000003\n\ndef compute_mod_fact(n, p):\n # n! (mod p)\n res = 1\n for i in range(1, n+1):\n res = (res * i) % p\n return res\ndef compute_mod_mult(n, a, p):\n # n**a (mod p)\n res = 1\n for _ in range(a):\n res = (res * n) % p\n return res\nres = compute_mod_fact(n+C, p)\nres1 = compute_mod_fact(n, p)\nres1 = compute_mod_mult(res1, p-2, p)\nres2 = compute_mod_fact(C, p)\nres2 = compute_mod_mult(res2, p-2, p)\n#print(res, res1, res2)\nres = (res * res1 * res2 - 1) % p \nprint(res)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d00b9d2fa2d04bf17c8e91aa707cba6c", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 3", "source_code": "import math \nm = int(1e6 + 3)\na,b = input().split()\na = int(a)\nb = int(b)\nA = 1\nB = 1\nfor i in range(2,a + b + 1):\n A=(A*i)%m\n if i<=a:\n B=(B*i)%m\n if i<=b:\n B=(B*i)%m\nprint((A*pow(B,m-2,m)-1)%m)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "fa2b643bb7a21357fbfbbdb9851e1795", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "import math\nn_and_c=raw_input().split(' ')\nn=int(n_and_c[0])\nc=int(n_and_c[1])\ncount=0\ni=1\nwhile i<=n:\n count+=math.factorial(c+i-1)/(math.factorial(c-1)*math.factorial(i))\n i+=1\nprint count\nprint count % (10**6+3)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2d8b799d8edee0a280db51fb929fc134", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\na, b, c = [], [], []\ns = raw_input()\nfrom collections import defaultdict\ndp = defaultdict(lambda : float(\"inf\"))\ndef count(a, st, x):\n ret = 0\n i = st\n while i < len(a) and a[i] < x:\n ret += 1\n i += 1\n return ret\nfor i in xrange(len(s)):\n if s[i] == \"V\":\n a.append(i)\n elif s[i] == \"K\":\n b.append(i)\n else :\n c.append(i)\ndp[(0,0,0,0)] = 0\nfor i in xrange(len(a)+1):\n for j in xrange(len(b)+1):\n for k in xrange(len(c)+1):\n for p in xrange(2):\n if i < len(a):\n dp[(i+1,j,k,1)] = min(dp[(i+1,j,k,1)], dp[(i,j,k,p)] + count(a,i,a[i])+count(b,j,a[i])+count(c,k,a[i]))\n if j < len(b) and p == 0:\n dp[(i,j+1,k,0)] = min(dp[(i,j+1,k,0)], dp[(i,j,k,p)]+count(a,i,b[j])+count(b,j,b[j])+count(c,k,b[j]))\n if k < len(c):\n dp[(i,j,k+1,0)]=min(dp[(i,j,k+1,0)],dp[(i,j,k,p)]+count(a,i,c[k])+count(b,j,c[k])+count(c,k,c[k]))\nprint min(dp[(len(a),len(b),len(c),0)],dp[(len(a),len(b),len(c),1)])\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "bba8bd6c7f7cbfc8892ba62acd093700", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "# http://codeforces.com/contest/771/problem/D\n\"\"\"\nDP-solution.\n\nFor each state (v, k, x, v_is_last_letter) we trial a step along the v, k and x\naxes and check that\ndp[future_state] = min(dp[future_state], dp[state] + cost_of_move)\nHence this implicitly reults in the one with least cost.\n\nV, K, X are arrays that contain the number of occurences of v, k, x at the i'th\nindex of s.\n\"\"\"\n\n\ndef cost_of_move(state, ss_ind):\n \"\"\"\n eg. ss = s[0:K.index(k+1)]\n Note: ss includes the i+1'th occurence of letter I. We hence want\n ss = s[0:ss_ind-1]\n And then we cound the number of occurences of V, K, X in this substring.\n\n However, we don't need ss now - this info is contained in lists V, K, X.\n \"\"\"\n\n curr_v, curr_k, curr_x = state\n cost = sum([max(0, V[ss_ind-1] - curr_v), max(0, K[ss_ind-1] - curr_k),\n max(0, X[ss_ind-1] - curr_x)])\n return cost\n\n\nif __name__ == \"__main__\":\n\n n = int(input())\n s = input()\n\n V = [s[0:i].count('V') for i in range(n+1)]\n K = [s[0:i].count('K') for i in range(n+1)]\n X = [(i - V[i] - K[i]) for i in range(n+1)]\n\n # Initialising\n n_v, n_k, n_x = V[n], K[n], X[n]\n\n dp = [[[[float('Inf') for vtype in range(2)] for x in range(n_x+1)]\n for k in range(n_k+1)] for v in range(n_v+1)]\n dp[0][0][0][0] = 0\n\n for v in range(n_v + 1):\n for k in range(n_k + 1):\n for x in range(n_x + 1):\n for vtype in range(2):\n orig = dp[v][k][x][vtype]\n if v < n_v:\n dp[v+1][k][x][1] = min(dp[v+1][k][x][vtype],\n orig + cost_of_move([v, k, x], V.index(v+1)))\n if k < n_k and vtype == 0:\n dp[v][k+1][x][0] = min(dp[v][k+1][x][0],\n orig + cost_of_move([v, k, x], K.index(k+1)))\n if x < n_x:\n dp[v][k][x+1][0] = min(dp[v][k][x+1][0],\n orig + cost_of_move([v, k, x], X.index(x+1)))\n print(min(dp[n_v][n_k][n_x]))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "023f730f887ef8821f5aaa17395513c7", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "base=998244353;\ndef power(x, y):\n if(y==0):\n return 1\n t=power(x, y//2)\n t=(t*t)%base\n if(y%2):\n t=(t*x)%base\n return t;\ndef inverse(x):\n return power(x, base-2)\nf=[1]\niv=[1]\nfor i in range(1, 5555):\n f.append((f[i-1]*i)%base)\n iv.append(inverse(f[i]))\ndef C(n, k):\n return (f[n]*iv[k]*iv[n-k])%base\ndef candy(n, k):\n # print(n, k)\n return C(n+k-1, k-1)\ndef count_game(k, n, x): #k players, n points total, no player can have x point or more\n if(k==0):\n if(n==0):\n return 1\n else:\n return 0\n ans=0\n for i in range(0, k+1):\n t=n-x*i\n # print(i, C(k, i))\n if(t<0):\n break\n if(i%2):\n ans=(ans-C(k, i)*candy(t, k))%base\n else:\n ans=(ans+C(k, i)*candy(t, k))%base \n return ans\np, s, r= list(map(int, input().split()))\ngamesize=count_game(p, s-r, int(1e18))\ngamesize=inverse(gamesize)\nans=0;\nfor q in range(r, s+1):\n for i in range(0, p): #exactly i people have the same score\n t=s-(i+1)*q\n if(t<0):\n break\n # print(q, i, count_game(p-i-1, t, q));\n ans=(ans+C(p-1, i)*count_game(p-i-1, t, q)*gamesize*inverse(i+1))%base\nprint(ans)\n \n ", "lang_cluster": "Python", "compilation_error": false, "code_uid": "167e001ce033a9cba6653b5eaa0dd0be", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "c = [[0 for i in range(5205)] for j in range(5205)]\nK = 998244353\ninv = [0 for i in range(5205)]\n\ndef mu(a, n):\n\tif n == 0: return 1\n\tq = mu(a, n // 2)\n\tif n % 2 == 0:\n\t\treturn q * q % K\n\telse: return q * q % K * a % K\n\ndef calc(m, d, S):\n\tres = 0\n\tif m == 0:\n\t\tif S == 0: return 1\n\t\treturn 0\n\n\tfor u in range(0, m + 1):\n\t\tif (u * d > S): break\n\t\tU = c[m][u] * c[S - u * d + m - 1][m - 1] % K \n\t\tif u % 2 == 0:\n\t\t\tres = (res + U) % K\n\t\telse: res = (res - U + K) % K \n\treturn res\n\n\nc[0][0] = 1\ninv[0] = 1\nfor i in range(1, 5101):\n\tinv[i] = mu(i, K - 2)\n\nfor i in range(1, 5101):\n\tc[i][0] = 1\n\tfor j in range (1, i):\n\t\tc[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % K\n\tc[i][i] = 1\n\np, s, r = map(int, input().split())\n\nres = 0\nden = 0\n\nfor i in range(1, p + 1):\n\tA = 0\n\tfor d in range(r, s // i + 1):\n\t\tif (i < p): A = (A + calc(p - i, d, s - d * i)) % K\n\t\telse:\n\t\t\tif (s - i * d == 0): A += 1\n\tA = A * inv[i] % K\n\tres = (res + A * c[p - 1][i - 1] % K) % K\n\nden = c[s - r + p - 1][p - 1]\nres = res * mu(den, K - 2) % K\nprint(res)\n\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ace48be0b00b05e000e83d3c1d5dc092", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom math import *\n\ndef pro():\n\treturn sys.stdin.readline().strip()\n\ndef rop():\n\treturn map(int, pro().split())\n\nz = int(pro())\nqwe = 1000000007\na = [0] * z\nx = {}\ny = {}\nfor i in range(z):\n\ts = tuple(rop())\n\ta[i] = s\n\tif s[0] in x:\n\t\tx[s[0]].append(i)\n\telse:\n\t\tx[s[0]] = [i]\n\tif s[1] in y:\n\t\ty[s[1]].append(i)\n\telse:\n\t\ty[s[1]] = [i]\n\ndel(pow)\nr = 1\nq = [0] * z\nw = [True] * z\no = 0\npo = 0\nfor i in range(z):\n\tif w[i]:\n\t\tw[i] = False\n\t\tq[po] = i\n\t\tpo += 1\n\t\tpoi = o\n\t\te = 0\n\t\txs = set()\n\t\tys = set()\n\t\twhile o < po:\n\t\t\tv = q[o]\n\t\t\to += 1\n\t\t\ts = a[v]\n\t\t\tif s[0] not in xs:\n\t\t\t\txs.add(s[0])\n\t\t\t\te -= 1\n\t\t\t\tfor u in x[s[0]]:\n\t\t\t\t\te += 1\n\t\t\t\t\tif w[u]:\n\t\t\t\t\t\tw[u] = False\n\t\t\t\t\t\tq[po] = u\n\t\t\t\t\t\tpo += 1\n\t\t\tif s[1] not in ys:\n\t\t\t\tys.add(s[1])\n\t\t\t\te -= 1\n\t\t\t\tfor u in y[s[1]]:\n\t\t\t\t\te += 1\n\t\t\t\t\tif w[u]:\n\t\t\t\t\t\tw[u] = False\n\t\t\t\t\t\tq[po] = u\n\t\t\t\t\t\tpo += 1\n\t\tvc = o - poi\n\t\tif vc - 1 == e:\n\t\t\tr = (r * (pow(2, vc + 1 , qwe) - 1)) % qwe\n\t\telse:\n\t\t\tr = (r * (pow(2, len(xs) + len(ys), qwe))) % qwe\nprint(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "1fb08336e77efc6721dea0537b7b4410", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "n = int(raw_input())\ndisjointSet = [-1] * n\ndef root(x, level=200):\n dp = []\n while disjointSet[x] >= 0:\n dp.append(x)\n x = disjointSet[x]\n for i in dp:\n disjointSet[i] = x\n return 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,raw_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 ans %= 10 ** 9 + 7\n\nprint(ans % (10 ** 9 + 7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9013b01709c8848b119d38545e97c82e", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\nn = mint()\np = [0]*n\nx = dict()\ny = dict()\nfor i in range(n):\n\ta = tuple(mints())\n\tp[i] = a\n\tif a[0] in x:\n\t\tx[a[0]].append(i)\n\telse:\n\t\tx[a[0]] = [i]\n\tif a[1] in y:\n\t\ty[a[1]].append(i)\n\telse:\n\t\ty[a[1]] = [i]\n\ndel(pow)\nr = 1\nq = [0]*n\nw = [True]*n\nql = 0\nqr = 0\nfor i in range(n):\n\tif w[i]:\n\t\tw[i] = False\n\t\tq[qr] = i\n\t\tqr += 1\n\t\tqlb = ql\n\t\te = 0\n\t\txs = set()\n\t\tys = set()\n\t\twhile ql < qr:\n\t\t\tv = q[ql]\n\t\t\tql += 1\n\t\t\ta = p[v]\n\t\t\txs.add(a[0])\n\t\t\tys.add(a[1])\n\t\t\tfor u in x[a[0]]:\n\t\t\t\te += 1\n\t\t\t\tif w[u]:\n\t\t\t\t\tw[u] = False\n\t\t\t\t\tq[qr] = u\n\t\t\t\t\tqr += 1\n\t\t\tfor u in y[a[1]]:\n\t\t\t\te += 1\n\t\t\t\tif w[u]:\n\t\t\t\t\tw[u] = False\n\t\t\t\t\tq[qr] = u\n\t\t\t\t\tqr += 1\n\t\tvc = ql-qlb\n\t\t#print(vc,e,vc*3-1)\n\t\tif vc*3-1 == e:\n\t\t\tr = (r*(pow(2,vc-1,1000000007)+(vc+1)+2*(vc-1)))%1000000007\n\t\telse:\n\t\t\tr = (r*(pow(2,len(xs)+len(ys),1000000007)))%1000000007\nprint(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "7bdc959aa9b6897f80da78f661aa4774", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "import sys\nfrom math import *\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\nn = mint()\np = [0]*n\nx = dict()\ny = dict()\nfor i in range(n):\n\ta = tuple(mints())\n\tp[i] = a\n\tif a[0] in x:\n\t\tx[a[0]].append(i)\n\telse:\n\t\tx[a[0]] = [i]\n\tif a[1] in y:\n\t\ty[a[1]].append(i)\n\telse:\n\t\ty[a[1]] = [i]\n\ndel(pow)\nr = 1\nq = [0]*n\nw = [True]*n\nql = 0\nqr = 0\nfor i in range(n):\n\tif w[i]:\n\t\tw[i] = False\n\t\tq[qr] = i\n\t\tqr += 1\n\t\tqlb = ql\n\t\te = 0\n\t\txs = set()\n\t\tys = set()\n\t\twhile ql < qr:\n\t\t\tv = q[ql]\n\t\t\tql += 1\n\t\t\ta = p[v]\n\t\t\txs.add(a[0])\n\t\t\tys.add(a[1])\n\t\t\tfor u in x[a[0]]:\n\t\t\t\te += 1\n\t\t\t\tif w[u]:\n\t\t\t\t\tw[u] = False\n\t\t\t\t\tq[qr] = u\n\t\t\t\t\tqr += 1\n\t\t\tfor u in y[a[1]]:\n\t\t\t\te += 1\n\t\t\t\tif w[u]:\n\t\t\t\t\tw[u] = False\n\t\t\t\t\tq[qr] = u\n\t\t\t\t\tqr += 1\n\t\tvc = ql-qlb\n\t\t#print(vc,e,vc*3-1)\n\t\tif vc*3-1 == e:\n\t\t\tr = (r*(pow(2,vc+1,1000000007)-1))%1000000007\n\t\telse:\n\t\t\tr = (r*(pow(2,len(xs)+len(ys),1000000007)))%1000000007\nprint(r)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d60f5c0dd1851c9647d993a55ed56f1", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "n = int(input())\ndisjointSet = [-1] * n\ndef root(x, level=200):\n if disjointSet[x] < 0:\n return x\n if level < 1:\n while disjointSet[x] >= 0:\n x = disjointSet[x]\n return x\n disjointSet[x] = root(disjointSet[x], level - 1)\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 ans %= 10 ** 9 + 7\n\nprint(ans % (10 ** 9 + 7))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "20c435633187332d07c3dce4d959f325", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "Python 2", "source_code": "from collections import deque\ndef main():\n n, m = map(int, raw_input().split())\n b = [list(raw_input().strip()) for _ in xrange(n)]\n def inboard(y, x):\n return 0 <= y < n and 0 <= x < m\n c = 0\n for i in xrange(n):\n for j in xrange(m):\n if b[i][j] in '123456789':\n c += 1\n b[i][j] = chr(ord(b[i][j]) - 1)\n elif b[i][j] == 'S':\n sy, sx = i, j\n v = [int(raw_input()) for _ in xrange(c)]\n inf = 1000000\n up = [[0] * m for i in xrange(n)]\n down = [[0] * m for i in xrange(n)]\n for i in xrange(n):\n for j in xrange(m):\n if b[i][j] in '0123456789':\n for l in xrange(j+1, m):\n up[i][l] |= 1 << int(b[i][j])\n down[i][l] |= 1 << int(b[i][j])\n elif b[i][j] == 'B':\n for l in xrange(j+1, m):\n up[i][l] |= 1 << c\n down[i][l] |= 1 << c\n v.append(-inf)\n c += 1\n dp = [[[inf] * (1 << c) for j in xrange(m)] for i in xrange(n)]\n dp[sy][sx][0] = 0\n d = [(-1, 0), (1, 0), (0, 1), (0, -1)]\n q = deque()\n q.append((sy, sx, 0, 0))\n while q:\n y, x, mask, t = q.popleft()\n if t > dp[y][x][mask]: continue\n nt = t + 1\n for dy, dx in d:\n ny, nx, nmask = dy + y, dx + x, mask\n if not inboard(ny, nx) or b[ny][nx] not in '.S': continue\n if dx == 0:\n if dy == 1:\n nmask ^= down[ny][nx]\n else:\n nmask ^= down[y][x]\n if dp[ny][nx][nmask] > nt:\n dp[ny][nx][nmask] = nt\n q.append((ny, nx, nmask, nt))\n print max(sum(v[j] for j in xrange(c) if ((i >> j) & 1))-dp[sy][sx][i] for i in xrange(1 << c))\nmain()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b11ba6b227ece1d6c785e9558b23e112", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353\n\nclass sumseg:\n def __init__(self,n):\n m = 1\n while m0:\n self.data[ind] = (self.data[ind]+val)%MOD\n ind//=2\n\n\nn,k = [int(x) for x in input().split()]\n\nswitchers = [0]*(n+1)\n\nfor h in range(1,n+1):\n DP = sumseg(n+1)#[0]*(n+1)\n DP.add(0,2)#DP[0] = 2\n max_width = (k+h-1)//h - 1\n for i in range(1,n+1):\n a = max(i-max_width,0)\n b = i\n if a i):\n cur -= l[j - i - 1]\n cur = norm(cur)\n l.append(cur)\n dp1.append(l[n])\n dp2.append(norm(dp1[i + 1] - dp1[i]))\n\nans = 0\nfor i in range(n + 1):\n for j in range(n + 1):\n if(i * j < k):\n ans = norm(ans + dp2[i] * dp2[j])\n\nans = norm(ans * 2)\n\nprint(ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "57b12c68cd8a1a4b3b42945282b3f893", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import sys\nfrom array import array # noqa: F401\n\n\ndef readline(): return sys.stdin.buffer.readline().decode('utf-8')\n\n\nn, k = map(int, readline().split())\nmod = 998244353\n\nif k == 1:\n print(0)\n exit()\n\n\ndp1 = [array('i', [0])*n for _ in range(n)]\ndp2 = [array('i', [0])*n for _ in range(n)]\ndp1[0][0] = 1\n\nfor i in range(n-1):\n for j in range(i+1):\n for l in range(j+1):\n dp2[j][0] += dp1[j][l]\n if dp2[j][0] >= mod:\n dp2[j][0] -= mod\n\n dp2[j+1 if j == l else j][l+1] += dp1[j][l]\n if dp2[j+1 if j == l else j][l+1] >= mod:\n dp2[j+1 if j == l else j][l+1] -= mod\n\n dp1[j][l] = 0\n\n dp1, dp2 = dp2, dp1\n\nans = 0\nfor i in range(1, n+1):\n t = (k-1) // i\n if t == 0:\n break\n\n dps1 = array('i', [0])*(t+1)\n dps2 = array('i', [0])*(t+1)\n dps1[0] = 1\n\n for j in range(n-1):\n for l in range(min(j+1, t)):\n dps2[0] += dps1[l]\n if dps2[0] >= mod:\n dps2[0] -= mod\n\n dps2[l+1] += dps1[l]\n if dps2[l+1] >= mod:\n dps2[l+1] -= mod\n\n dps1[l] = 0\n\n dps1, dps2 = dps2, dps1\n\n x = sum(dp1[i-1]) % mod\n ans = (ans + x * sum(dps1[:-1])) % mod\n\nprint(ans * 2 % mod)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b9204b4c41a37bb35446bacaa33c7e0a", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "import math\ndef phi(n):\n res = n\n for i in range(2, int(math.sqrt(n)) + 1):\n if(n % i == 0):\n while(n % i == 0):\n n /= i\n res -= res/i\n if(n > 1):\n res -= int(res / n)\n return res\nn, k = map(int, input().split())\nres = n\nk = int((k + 1) / 2)\nwhile(res != 1 and k != 0):\n res = phi(res)\n k -= 1\nprint(\"{}\".format(int(res % (1e9 + 7))))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "64a8696d5258eb6aa789e7e6683db0f5", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0} {"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\n\n\ndef euler(n):\n res = n\n i = 2\n while i * i <= n:\n if n % i == 0:\n res = res / i * (i - 1)\n while n % i == 0:\n n /= i\n i += 1\n if n != 1:\n res = res / n * (n - 1)\n return res\n\n\nwhile k > 0 and n > 1:\n if(k%2==1):\n n = euler(n)\n k-=1\nprint n%1000000007\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d2697411574bed72b9a74428a42acee5", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "N = 10 ** 6 * 2 \nMOD = 1000000007\nprime = []\nisPrime = [True for i in range(N)]\nfor i in range(2, N):\n if isPrime[i]:\n prime.append(i)\n for j in range(i * i, N, i):\n isPrime[j] = False\ndef phi(n):\n ans = 1\n for i in pf(n):\n ans *= pow(i[0],i[1]-1)*(i[0]-1)\n return ans\ndef pf(n):\n for i in prime:\n cnt = 0\n if n % i == 0:\n while n % i == 0:\n n //= i\n cnt += 1\n yield (i,cnt)\n if n > 1:\n yield (n,1)\nn,k = map(int,input().split())\nk = (k+1)//2\nans = n\nfor i in range(k):\n ans = phi(ans)\n if ans == 1:\n break\nprint(ans % MOD)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "de1c91a9e21df824dd4bef414156f74e", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0} {"lang": "Python 3", "source_code": "from math import sqrt, ceil\n\nMAX_N = 10 ** 6 * 2 \n\n\nprime = []\nisPrime = [True for i in range(MAX_N)]\n\nfor i in range(2, MAX_N):\n if isPrime[i]:\n prime.append(i)\n for j in range(i * i, MAX_N, i):\n isPrime[j] = False\n\n\ndef factor(a):\n divs = []\n for i in prime:\n cnt = 0\n while a % i == 0:\n a //= i\n cnt += 1\n\n if cnt:\n divs.append((i, cnt,))\n\n if a > 1:\n divs.append((a, 1,))\n\n return divs\n\n\ndef f(n):\n ans = 1\n for div in factor(n):\n ans *= div[0] ** (div[1] - 1) * (div[0] - 1)\n\n return ans\n\ndef g(n):\n return n\n\ndef F(n, k):\n cur = n\n for i in range(1, k + 1):\n #print(i)\n #print(factor(cur))\n if i == 1:\n cur = f(g(cur))\n elif i % 2 == 0:\n cur = g(cur)\n else:\n cur = f(cur)\n\n #print(i, cur)\n\n if cur == 1:\n break\n\n return cur % (10 ** 9 + 7)\n\nn, k = [int(i) for i in input().split(' ')]\n#print(factor(n - 1))\nprint (F(n, k))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8863a2f773b6e5c271c76e2479fa581e", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.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 ans = phi(ans)\nprint(ans % MOD)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dca4cb3caa6f10680a11dd469eb6f1a0", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "from collections import defaultdict\n\ndef calcBinomials(N):\n global binom\n N += 1\n binom = [[0]*N for _ in range(N)]\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())\na = list(map(int, input().split()))\nS, res = sum(a), 0\ndp = [defaultdict(lambda: 0) for _ in range(S+1)]\ndp[0][0] = 1\n\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\n\ncalcBinomials(n)\nfor x, c in cnt.items():\n for i in range(1, c+1):\n if dp[x*i][i] == binom[c][i] or dp[S - x*i][n-i] == binom[c][c-i]:\n res = max(res, i)\nif len(cnt) <= 2: res = n\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b1c0b779f5339f088b25e555b4ee96e9", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.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())\na = list(map(int, input().split()))\nS, res = sum(a), 0\ndp = [defaultdict(lambda: 0) for _ in range(S+1)]\ndp[0][0] = 1\n\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\n\ncalcBinomials(n)\nfor x, c in cnt.items():\n for i in range(1, c+1):\n if dp[x*i][i] == binom[c][i] or dp[S - x*i][n-i] == binom[c][c-i]:\n res = max(res, i)\nprint(res)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "3a59d0b1219e7c590f9c8d955dff4669", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.0} {"lang": "PyPy 3", "source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\n# region fastio\nBUFSIZE = 8192\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()\n \n# ------------------------------\n \ndef RL(): return map(int, sys.stdin.readline().split())\ndef RLL(): return list(map(int, sys.stdin.readline().split()))\ndef N(): return int(input())\ndef print_list(l):\n print(' '.join(map(str,l)))\n# import heapq as hq\n# import bisect as bs\n# from collections import deque as dq\n# from collections import defaultdict as dc \n# from math import ceil,floor,sqrt\n# from collections import Counter\n\n\nn = N()\ndic = [set() for _ in range(n+1)]\ndic2 = [[] for _ in range(n+1)]\nfor _ in range(n-1):\n u,v = RL()\n dic[u].add(v)\n dic[v].add(u)\nnow = [1]\nfather,gress,leaf = [0]*(n+1),[0]*(n+1),[]\nfor i in range(2,n+1):\n gress[i] = len(dic[i])-1\n if gress[i]==0:\n leaf.append(i)\nwhile now:\n node = now.pop()\n dic[node].discard(father[node])\n for child in dic[node]:\n father[child] = node \n now.append(child)\nres = 0\nans = [0]*(n+1)\nwhile leaf:\n p = leaf.pop()\n f = father[p]\n if not dic2[p]:\n dic2[f].append(p)\n else:\n t = len(dic2[p])\n res+=t*2\n while t>2:\n t-=2\n a,b = dic2[p].pop(),dic2[p].pop()\n ans[a] = b \n ans[b] = a \n if t==1:\n a = dic2[p].pop()\n ans[a] = p \n ans[p] = a \n else:\n a,b = dic2[p].pop(),dic2[p].pop()\n ans[a] = p \n ans[p] = b \n ans[b] = a \n gress[f]-=1\n if gress[f]==0:\n leaf.append(f)\np = 1\nif not dic2[p]:\n res+=2\n m = dic[p].pop()\n b = ans[m]\n a = ans[b]\n if a!=m:\n ans[a] = b \n ans[m] = p \n ans[p] = m \n else:\n ans[p] = m \n ans[m] = b \n ans[b] = p\nelse:\n t = len(dic2[p])\n res+=t*2\n while t>2:\n t-=2\n a,b = dic2[p].pop(),dic2[p].pop()\n ans[a] = b \n ans[b] = a \n if t==1:\n a = dic2[p].pop()\n ans[a] = p \n ans[p] = a \n else:\n a,b = dic2[p].pop(),dic2[p].pop()\n ans[a] = p \n ans[p] = b \n ans[b] = a \nprint(res)\nprint_list(ans[1:])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "a6916fe86afe9848f3a148377e8f0f3b", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.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\ncoupl = [[] for _ in range(n)]\nfor _ in range(n - 1):\n u = inp[ii] - 1; ii += 1\n v = inp[ii] - 1; ii += 1\n coupl[u].append(v)\n coupl[v].append(u)\n\nP = [-1] * n\nroot = 0\nbfs = [root]\nP[root] = root\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n P[nei] = node\n\nans = list(range(n));cost = 0\nfor node in reversed(bfs):\n if ans[node] != node:continue\n cost += 2\n if node != root:p = P[node]\n else:p = coupl[node][0]\n ans[node],ans[p] = ans[p],ans[node]\nprint cost;print ' '.join(str(x + 1) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "eee06d8fabd76f1dea393a677e8e2a8d", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.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\ncoupl = [[] for _ in range(n)]\nfor _ in range(n - 1):\n u = inp[ii] - 1; ii += 1\n v = inp[ii] - 1; ii += 1\n coupl[u].append(v)\n coupl[v].append(u)\n\nP = [-1] * n\nroot = 0\nbfs = [root]\nP[root] = root\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n P[nei] = node\n\n\nans = list(range(n))\ncost = 0\n\nfor node in reversed(bfs):\n if ans[node] != node:\n continue\n cost += 2\n if node != root:\n p = P[node]\n else:\n p = coupl[node][0]\n ans[node],ans[p] = ans[p],ans[node]\n\nprint cost\nprint ' '.join(str(x + 1) for x in ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "978dffc0dd6253da02b4da433a37bc6e", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "PyPy 2", "source_code": "import sys;range = xrange;input = raw_input;inp = [int(x) for x in sys.stdin.read().split()]; ii = 0;n = inp[ii]; ii += 1;coupl = [[] for _ in range(n)]\nfor _ in range(n - 1):u = inp[ii] - 1; ii += 1;v = inp[ii] - 1; ii += 1;coupl[u].append(v);coupl[v].append(u)\nP = [-1] * n;root = 0;bfs = [root];P[root] = root\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei);P[nei] = node\nans = list(range(n));cost = 0\nfor node in reversed(bfs):\n if ans[node] != node:continue\n cost += 2\n if node != root:p = P[node]\n else:p = coupl[node][0]\n ans[node],ans[p] = ans[p],ans[node]\nprint cost;print ' '.join(str(x + 1) for x in ans)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "9fbc5192e640fcbf57d675d163edb889", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.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\ncoupl = [[] for _ in range(n)]\nfor _ in range(n - 1):\n u = inp[ii] - 1; ii += 1\n v = inp[ii] - 1; ii += 1\n coupl[u].append(v)\n coupl[v].append(u)\n\nP = [-1] * n\nroot = 0\nbfs = [root]\nP[root] = root\nfor node in bfs:\n for nei in coupl[node]:\n del coupl[nei][coupl[nei].index(node)]\n bfs.append(nei)\n P[nei] = node\n\nans = [-1] * n\n\ncost = - 2 * n\n\nhouses = [[i] for i in range(n)]\npeople = [[i] for i in range(n)]\nfor node in reversed(bfs):\n H = houses[node]\n Pe = people[node]\n\n cost += len(H) + len(Pe)\n\n Pe.reverse()\n if len(H) > 1 or len(Pe) > 1:\n while H and Pe:\n house = H.pop()\n p = Pe.pop()\n ans[house] = p\n\n houses[P[node]] += H\n people[P[node]] += reversed(Pe)\n\nprint cost\nprint ' '.join(str(x + 1) for x in ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "352271d478bca7d36e89197f6b0bf18c", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.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(dn):\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):ret = 0\n elif (h1,m1)>(h2,m2):\n ret = f(h1, m1, H-1, M-1) + f(0, 0, h2, m2) + ( dif(H-1,M-1,0,0) >= k)\n else:\n for hh in pow10:\n if (h1+hh, m1)<=(h2, m2) and h1/hh%10!=9:\n ret = g(hh,0)+f(h1+hh, m1, h2, m2)\n break\n else:\n for mm in pow10:\n if m1+mm=k ) + f(nh,nm,h2,m2)\n #print h1,m1,h2,m2,ret\n return ret\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": "4346bb1e605de09ceddfca9b2d942955", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.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(dn):\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):ret = 0\n elif (h1,m1)>(h2,m2):\n ret = f(h1, m1, H-1, M-1) + f(0, 0, h2, m2) + ( dif(H-1,M-1,0,0) >= k)\n else:\n for hh in pow10:\n if (h1+hh, m1)<=(h2, m2) and h1/hh%10!=9:\n ret = g(hh,0)+f(h1+hh, m1, h2, m2)\n break\n else:\n for mm in pow10:\n if m1+mm=k ) + f(nh,nm,h2,m2)\n #print h1,m1,h2,m2,ret\n return ret\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": "2e0ca91c819de10057848fef82df6b7c", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.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(dn):\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):ret = 0\n elif (h1,m1)>(h2,m2):\n ret = f(h1, m1, H-1, M-1) + f(0, 0, h2, m2) + ( dif(h1,m1,h2,m2) >= k)\n else:\n for hh in pow10:\n if (h1+hh, m1)<=(h2, m2) and h1/hh%10!=9:\n ret = g(hh,0)+f(h1+hh, m1, h2, m2)\n break\n else:\n for mm in pow10:\n if m1+mm=k ) + f(nh,nm,h2,m2)\n #print h1,m1,h2,m2,ret\n return ret\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": "5d5e61d02cb2886ba439e59a753f4296", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.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(dn):\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):ret = 0\n elif (h1,m1)>(h2,m2):\n ret = f(h1, m1, H-1, M-1) + f(0, 0, h2, m2) + ( dif(H-1,M-1,0,0) >= k)\n else:\n for hh in pow10:\n if (h1+hh, m1)<=(h2, m2) and h1/hh%10!=9:\n ret = g(hh,0)+f(h1+hh, m1, h2, m2)\n break\n else:\n for mm in pow10:\n if m1+mm=k ) + f(nh,nm,h2,m2)\n #print h1,m1,h2,m2,ret\n return ret\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": "81fb4779887d4b3f67d886ab0b954e82", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "Python 2", "source_code": "from random import*\nimport sys\nsys.setrecursionlimit(10000)\nopr = ['#', '^', '&', '$']\nnamespace = { \"res\" : (False, \"res\") }\nrules = dict()\nlookup = dict()\ncnt = -1\ndef get_tag(var):\n if var in namespace:\n return namespace[var][1]\n else:\n return var\nN = int(raw_input())\nfor _ in range(N):\n lval, rval = raw_input().split('=')\n for c in opr:\n if c in rval:\n arg1, arg2 = map(get_tag, rval.split(c))\n rule = (arg1, arg2, c)\n if rule in rules:\n namespace[lval] = (True, rules[rule])\n else:\n cnt += 1\n namespace[lval] = (True, cnt)\n rules[rule] = cnt\n lookup[cnt] = rule\n break\n else:\n if rval in namespace:\n namespace[lval] = namespace[rval]\n else:\n namespace[lval] = (False, rval)\nif namespace[\"res\"] == (False, \"res\"):\n print(\"0\")\n exit()\nprogram = []\nmyvars = dict()\ndef reserve():\n return ''.join(chr(randint(0, 25) + ord('a')) for _ in range(4)) \ndef implement(rule, final):\n if type(rule) == str:\n return rule\n elif rule in myvars:\n return myvars[rule]\n else:\n if final:\n name = \"res\"\n else:\n name = reserve()\n myvars[rule] = name\n arg1, arg2, op = lookup[rule]\n var1, var2 = implement(arg1, False), implement(arg2, False)\n program.append(name + \"=\" + var1 + op + var2)\n return name\nseed(123)\nif namespace[\"res\"][0]:\n implement(namespace[\"res\"][1], True)\nelse:\n program.append(\"res=\" + namespace[\"res\"][1])\nprint(len(program))\nprint(\"\\n\".join(program))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "84cad9192fba122d5c7cfd3b3746fbb9", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "from random import seed, randint\nimport sys\nsys.setrecursionlimit(10000)\n\nopr = ['#', '^', '&', '$']\nnamespace = { \"res\" : (False, \"res\") }\nrules = dict()\nlookup = dict()\ncnt = -1\n\ndef get_tag(var):\n if var in namespace:\n return namespace[var][1]\n else:\n return var\n\nN = int(input())\nfor _ in range(N):\n lval, rval = input().split('=')\n for c in opr:\n if c in rval:\n arg1, arg2 = map(get_tag, rval.split(c))\n rule = (arg1, arg2, c)\n if rule in rules:\n namespace[lval] = (True, rules[rule])\n else:\n cnt += 1\n namespace[lval] = (True, cnt)\n rules[rule] = cnt\n lookup[cnt] = rule\n break\n else:\n if rval in namespace:\n namespace[lval] = namespace[rval]\n else:\n namespace[lval] = (False, rval)\n\nif namespace[\"res\"] == (False, \"res\"):\n print(\"0\")\n exit()\n\nprogram = []\nmyvars = dict()\n\ndef reserve():\n return ''.join(chr(randint(0, 25) + ord('a')) for _ in range(4)) \n\ndef implement(rule, final):\n if type(rule) == str:\n return rule\n elif rule in myvars:\n return myvars[rule]\n else:\n if final:\n name = \"res\"\n else:\n name = reserve()\n myvars[rule] = name\n arg1, arg2, op = lookup[rule]\n var1, var2 = implement(arg1, False), implement(arg2, False)\n program.append(name + \"=\" + var1 + op + var2)\n return name\n\nseed(123)\nif namespace[\"res\"][0]:\n implement(namespace[\"res\"][1], True)\nelse:\n program.append(\"res=\" + namespace[\"res\"][1])\nprint(len(program))\nprint(\"\\n\".join(program))\n\n#print(namespace)\n#print(rules)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b3ced3e57237199b214bc43e0496832b", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "from random import seed, randint\n\nopr = ['#', '^', '&', '$']\nnamespace = { \"res\" : (False, \"res\") }\nrules = dict()\nlookup = dict()\ncnt = -1\n\ndef get_tag(var):\n if var in namespace:\n return namespace[var][1]\n else:\n return var\n\nN = int(input())\nfor _ in range(N):\n lval, rval = input().split('=')\n for c in opr:\n if c in rval:\n arg1, arg2 = map(get_tag, rval.split(c))\n rule = (arg1, arg2, c)\n if rule in rules:\n namespace[lval] = (True, rules[rule])\n else:\n cnt += 1\n namespace[lval] = (True, cnt)\n rules[rule] = cnt\n lookup[cnt] = rule\n break\n else:\n if rval in namespace:\n namespace[lval] = namespace[rval]\n else:\n namespace[lval] = (False, rval)\n\nif namespace[\"res\"] == (False, \"res\"):\n print(\"0\")\n exit()\n\nprogram = []\nmyvars = dict()\n\ndef reserve():\n return ''.join(chr(randint(0, 25) + ord('a')) for _ in range(4)) \n\ndef implement(rule, final):\n if type(rule) == str:\n return rule\n elif rule in myvars:\n return myvars[rule]\n else:\n if final:\n name = \"res\"\n else:\n name = reserve()\n myvars[rule] = name\n arg1, arg2, op = lookup[rule]\n var1, var2 = implement(arg1, False), implement(arg2, False)\n program.append(name + \"=\" + var1 + op + var2)\n return name\n\nseed(123)\nif namespace[\"res\"][0]:\n implement(namespace[\"res\"][1], True)\nelse:\n program.append(\"res=\" + namespace[\"res\"][1])\nprint(len(program))\nprint(\"\\n\".join(program))\n\n#print(namespace)\n#print(rules)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6e609e2466e8b66b7dc48832b437d8da", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "from random import seed, randint\n\nopr = ['#', '^', '&', '$']\nnamespace = { \"res\" : (False, \"res\") }\nrules = dict()\nlookup = dict()\ncnt = -1\n\ndef get_tag(var):\n if var in namespace:\n return namespace[var][1]\n else:\n return var\n\nN = int(input())\nfor _ in range(N):\n lval, rval = input().split('=')\n for c in opr:\n if c in rval:\n arg1, arg2 = map(get_tag, rval.split(c))\n rule = (arg1, arg2, c)\n if rule in rules:\n namespace[lval] = (True, rules[rule])\n else:\n cnt += 1\n namespace[lval] = (True, cnt)\n rules[rule] = cnt\n lookup[cnt] = rule\n break\n else:\n if rval in namespace:\n namespace[lval] = namespace[rval]\n else:\n namespace[lval] = (False, rval)\n\nif namespace[\"res\"] == (False, \"res\"):\n print(\"0\")\n exit()\n\nprogram = []\nmyvars = dict()\n\ndef reserve():\n return ''.join(chr(randint(0, 25) + ord('a')) for _ in range(4)) \n\ndef implement(rule, final):\n if type(rule) == str:\n return rule\n elif rule in myvars:\n return myvars[rule]\n else:\n if final:\n name = \"res\"\n else:\n name = reserve()\n myvars[rule] = name\n arg1, arg2, op = lookup[rule]\n var1, var2 = implement(arg1, False), implement(arg2, False)\n program.append(name + \"=\" + var1 + op + var2)\n return name\n\nseed(123)\nimplement(namespace[\"res\"][1], True)\nprint(len(program))\nprint(\"\\n\".join(program))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "6f52406dfb4c8506b4e16fe6e8d7ca71", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Python 3", "source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\n\nmaxe = max(a)\ncnt = []\ncur = 1\nk = 0\ni = 0\nwhile i < n:\n cnt.append(0)\n while i < n and a[i] < cur:\n cnt[2 * k] += 1\n i += 1\n cnt.append(0)\n while i < n and a[i] == cur:\n cnt[2 * k + 1] += 1\n i += 1\n k += 1\n cur *= 2\ncnt.append(0)\ncnt.append(0)\nmaxe = len(cnt) - 1\n\nmaxk = cnt[1]\nwas = False\nfor l in range(maxk):\n cur = 1\n while cnt[cur] > 0:\n cnt[cur] -= 1\n cur += 2\n cnt[cur] -= 1\n cursum = 0\n ok = True\n for t in range(maxe, 0, -1):\n cursum += cnt[t]\n if cursum > 0:\n ok = False\n break\n if ok:\n print(l + 1, end=\" \")\n was = True\n\nif not was:\n print(-1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "755c27bffb5c3f7af46c0e71d3988ef3", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "Python 3", "source_code": "n = int(input())\n\na = sorted(list(map(int, input().split())))\n\n\n\nmaxe = max(a)\n\ncnt = []\n\ncur, k, i = 1, 0, 0\n\n\n\nwhile i < n:\n\n cnt.append(0)\n\n while i < n and a[i] < cur:\n\n cnt[2 * k] += 1\n\n i += 1\n\n cnt.append(0)\n\n while i < n and a[i] == cur:\n\n cnt[2 * k + 1] += 1\n\n i += 1\n\n k += 1\n\n cur *= 2\n\ncnt.append(0)\n\ncnt.append(0)\n\nmaxe = len(cnt) - 1\n\n\n\nmaxk = cnt[1]\n\nwas = False\n\nfor l in range(maxk):\n\n cur = 1\n\n while cnt[cur] > 0:\n\n cnt[cur] -= 1\n\n cur += 2\n\n cnt[cur] -= 1\n\n cursum = 0\n\n ok = True\n\n for t in range(maxe, 0, -1):\n\n cursum += cnt[t]\n\n if cursum > 0:\n\n ok = False\n\n break\n\n if ok:\n\n print(l + 1, end=\" \")\n\n was = True\n\n\n\nif not was:\n\n print(-1)\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "compilation_error": false, "code_uid": "863e4c4173ed6370a799d59592fe99a5", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "PyPy 3", "source_code": "from math import factorial\nMOD = 10**9+7\n\nk = int(input())\nbink = list(map(int, bin(k)[2:]))\nN = len(bink)\n\n# dp[i][j][k] = first i bits, j bases,\n# k = 1 if maxor matches k, 0 else\ndp = [[[0,0] for j in range(i+2)] for i in range(N+1)]\ndp[0][0][1] = 1\nfor i in range(1, N+1):\n for j in range(i+1):\n # k = 0 -> 0\n dp[i][j][0]+= 2**j * dp[i-1][j][0] # distribute\n if j: dp[i][j][0]+= dp[i-1][j-1][0] # new base\n # k = 1 -> 0\n odd = 2**(j-1) if j else 0\n even = 2**j - odd\n if bink[i-1] == 1:\n dp[i][j][0]+= even * dp[i-1][j][1] # distribute even\n # k = 1 -> 1\n if bink[i-1] == 0:\n dp[i][j][1]+= even * dp[i-1][j][1] # distribute even\n else:\n dp[i][j][1]+= odd * dp[i-1][j][1] # distribute odd\n if j: dp[i][j][1]+= dp[i-1][j-1][1] # new base\nans = sum(map(sum, dp[-1]))\nprint(ans % MOD)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ab66ac0f2f27868c028cd95172efda6f", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "PyPy 3", "source_code": "from math import factorial\nMOD = 10**9+7\n\ndef binom(n, k):\n if k > n-k: return binom(n, n-k)\n res = 1\n for i in range(k): res = res*(n-i)//(i+1)\n return res\n\ndef comp_ones_vecs(k, n):\n # k ones, n vectors\n if k < n: return 0\n ans = 0\n for Z in range(n):\n ans+= (-1)**Z * binom(n,Z) * (n-Z)**k\n return ans // factorial(n)\n\ndef comp_ones_frees_vecs(k, f, n):\n # k prefixed ones, f digits of freedom, n vectors\n ans = 0\n for i in range(f+1):\n ans+= comp_ones_vecs(k+i, n) * binom(f, i)\n return ans\n\ndef comp_ones_frees(k, f):\n # k prefixed ones, f digits of freedom\n ans = 0\n for n in range(1, k+f+1):\n ans+= comp_ones_frees_vecs(k, f, n)\n return ans\n\nk = int(input())\nbink = list(map(int, bin(k)[2:]))\nans = 1 + comp_ones_frees(sum(bink), 0)\nones = 0\nfor i in range(len(bink)):\n if bink[i] == 0: continue\n ans+= comp_ones_frees(ones, len(bink)-i-1)\n ones+= 1\nprint(ans % MOD)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "95d58f686cc9df9c29d0ae7b8f1a0af8", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.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)\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "033292923cb95b91d69d20e79c1fe830", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.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())\nlelem=[]\ndef getind(x,y):\n for n,(xx,yy) in enumerate(lelem):\n if abs(x-xx)<0.000001 and abs(y-yy)<0.0000001:\n return n\n return -1\nfor i in xrange(n):\n for x,y in zz:\n if getind(x+i*otrx,y+i*otry)==-1:\n lelem.append((x+i*otrx,y+i*otry))\npo=[]\nfor i in xrange(n):\n po.append((-100,)+tuple(getind(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 str(x).ljust(30,'0'),str(y).ljust(30,'0')\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": "ef198ecea4fd5ac4932abc027e2e14d1", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.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())\nlelem=[]\ndef getind(x,y):\n for n,(xx,yy) in enumerate(lelem):\n if abs(x-xx)<0.000001 and abs(y-yy)<0.0000001:\n return n\n return -1\nfor i in xrange(n):\n for x,y in zz:\n if getind(x+i*otrx,y+i*otry)==-1:\n lelem.append((x+i*otrx,y+i*otry))\npo=[]\nfor i in xrange(n):\n po.append((-100,)+tuple(getind(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": "5d09b7f05bf3fd4b611187eabb16cc8f", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0} {"lang": "Python 3", "source_code": "F = {}\n\ndef f(k):\n if not k in F:\n s, i, j = 0, 4, 4\n while i <= k:\n s += i * f(k // i)\n i += j + 1\n j += 2\n F[k] = (k * (k + 1)) // 2 - s\n return F[k]\n\ndef g(k):\n s, i, j = 0, 4, 4\n while i <= k:\n s += (i - 1) * f(k // i)\n i += j + 1\n j += 2\n return (k * (k + 1)) // 2 - s\n\na, n = map(int, input().split())\nprint(g(a + n - 1) - g(a - 1))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f8e53456e61b862696c6eb4d36d83255", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0} {"lang": "Python 2", "source_code": "F = {}\n\ndef f(k):\n if not k in F:\n s, i, j = 0, 4, 4\n while i <= k:\n s += i * f(k / i)\n i += j + 1\n j += 2\n F[k] = (k * (k + 1)) / 2 - s\n return F[k]\n\ndef g(k):\n s, i, j = 0, 4, 4\n while i <= k:\n s += (i - 1) * f(k / i)\n i += j + 1\n j += 2\n return (k * (k + 1)) / 2 - s\n\na, n = map(int, raw_input().split())\nprint g(a + n - 1) - g(a - 1)", "lang_cluster": "Python", "compilation_error": false, "code_uid": "34e19f4c61d3d5df3a74142da6b3159a", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.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;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "8d25d24ef6b8855a50b02afce2b279b7", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.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;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "b15b8e3e02138462df52b733a6acc5a6", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.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;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "42d0ee6734bcac65e47a9c917987eac4", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.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;\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "490aca1a397213d21949a157d568387d", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0} {"lang": "Python 2", "source_code": "p=10**9+7\ndef S(x):\n if x==0:\n return 0\n elif x==1:\n return 4\n elif x&1:\n return 11*pow(3,x/2,p)-7\n else:\n return 19*pow(3,x/2-1,p)-7\ndef G(x):\n return (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": "9b254a1022164c45ae309f713f0e1e05", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0} {"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nP = []\nfor i in range(2, 59):\n if not any(i % p == 0 for p in P):\n P.append(i)\n\nnumbs = []\nfor i in range(1, 59):\n x = 0\n for j in range(len(P)):\n if i % P[j] == 0:\n x += 1 << j\n numbs.append(x)\n\nn = int(input())\nA = [int(x) for x in input().split()]\n\n\nstates = 1 << 17\n\nDP = [[0]*states]\nhow = []\n\nfor i in range(n):\n a = A[i]\n aa = abs(a - 1)\n \n oldDP = DP[-1]\n\n newDP = [d + aa for d in oldDP]\n DP.append(newDP)\n \n newHow = [1]*states\n how.append(newHow)\n\n for x in range(2, 59):\n xx = abs(a - x)\n\n y = numbs[x - 1]\n yy = ~y\n\n s = (states - 1) & yy\n while s:\n if newDP[s ^ y] > oldDP[s] + xx:\n newDP[s ^ y] = oldDP[s] + xx\n newHow[s ^ y] = x\n s = (s - 1) & yy\n \n if newDP[s ^ y] > oldDP[s] + xx:\n newDP[s ^ y] = oldDP[s] + xx\n newHow[s ^ y] = x\n\nkey = min(range(states), key = DP[-1].__getitem__)\nans = []\nfor newHow in reversed(how):\n x = newHow[key]\n ans.append(x)\n key &= ~numbs[x - 1]\n\n\nprint ' '.join(str(x) for x in reversed(ans))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "c28b2206ae76fc620e8e30693e49adfd", "src_uid": "f26c74f27bbc723efd69c38ad0e523c6", "difficulty": 2000.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 ** 6\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": "cad39747bffb09d28f450d5526ac1bc8", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.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 ** 6\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\n\r\n\r\n\r\n@lru_cache(maxsize = None)\r\ndef count(a, b):\r\n if b == 0:\r\n if a == 0:\r\n return 1\r\n return modmul(a, count(a - 1, 0))\r\n\r\n if a:\r\n o1 = modmul(a, count(a, b - 1))\r\n else:\r\n o1 = 0\r\n\r\n if b > 1:\r\n o2 = modmul(b - 1, count(a, b - 1))\r\n else:\r\n o2 = 0\r\n\r\n\r\n return (o1 + o2) % M\r\n\r\nfor i in range(5000):\r\n for j in range(5000):\r\n count(i, j)\r\n\r\nn = k\r\n\r\nout = 0\r\nfor i in range(1, 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\r\n order = count(j, n - i - j)\r\n\r\n u1 = pow(n - i, i - j, M)\r\n u2 = pow(n - 1, j, M)\r\n\r\n #print(i, j, stab, app, order, u1, u2)\r\n \r\n out += modmul(modmul(modmul(stab, app), order), modmul(u1, u2))\r\n\r\nprint(out % M)\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "325906d369fd36f9a0bee46dd11d0285", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.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 ** 6\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\n\r\n\r\n\r\n@lru_cache(maxsize = None)\r\ndef count(a, b):\r\n if b == 0:\r\n if a == 0:\r\n return 1\r\n return modmul(a, count(a - 1, 0))\r\n\r\n if a:\r\n o1 = modmul(a, count(a, b - 1))\r\n else:\r\n o1 = 0\r\n\r\n if b > 1:\r\n o2 = modmul(b - 1, count(a, b - 1))\r\n else:\r\n o2 = 0\r\n\r\n\r\n return (o1 + o2) % M\r\n\r\nn = k\r\n\r\nout = 0\r\nfor i in range(1, 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\r\n order = count(j, n - i - j)\r\n\r\n u1 = pow(n - i, i - j, M)\r\n u2 = pow(n - 1, j, M)\r\n\r\n #print(i, j, stab, app, order, u1, u2)\r\n \r\n out += modmul(modmul(modmul(stab, app), order), modmul(u1, u2))\r\n\r\nprint(out % M)\r\n \r\n \r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2402f7a74de489d93e7e09c86966453e", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.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\nextra = 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 = (ans + par(i + 1 + n) * mo(choose(n, i), tmp)) % MOD\n \n exp = modmul(n, n - i, MOD - 1) + i\n extra = (extra + par(i + 1) * mo(choose(n, i), po(3, exp))) % MOD\n\nprint (3 * ans + 2 * extra) % MOD\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "ccf0b0dfe0f24bd304b4d862fdafb01d", "src_uid": "6e4b0ee2e1406041a961582ead299a3a", "difficulty": 2500.0} {"lang": "Python 3", "source_code": "F = ['', 'a', 'b', 'ba', 'bab', 'babba', 'babbabab', 'babbababbabba', 'babbababbabbababbabab', 'babbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbabab', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabab', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabba', 'babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabab']\nwhile len(F[-3]) < 100000: F.append(F[-1] + F[-2])\nd = 1000000007\n\ndef sqr(t):\n return [[sum(t[i][k] * t[k][j] for k in range(4)) % d for j in range(4)] for i in range(4)]\n\ndef mul(a, b):\n return [[sum(a[i][k] * b[k][j] for k in range(4)) % d for j in range(4)] for i in range(4)]\n\ndef fib(k):\n s, p = format(k, 'b')[:: -1], [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]\n t = [[[0, 1, 0, 0], [1, 1, 1, 0], [0, 0, 0, 1], [0, 0, 1, 0]]] + [0] * (len(s) - 1)\n for i in range(1, len(s)):\n t[i] = sqr(t[i - 1]) \n for i, k in enumerate(s):\n if k == '1': p = mul(p, t[i]) \n return p\n\ndef cnt(t, p):\n s, i = 0, p.find(t) + 1\n while i > 0:\n i = p.find(t, i) + 1\n s += 1\n return s\n\ndef f(t, p, k):\n l = len(t) - 1\n if l: x, y = cnt(t, F[k - 1][- l: ] + F[k][:l ]), cnt(t, F[k][- l: ] + F[k + 1][:l ])\n else: x, y = 0, 0\n a, b = cnt(t, F[k - 1]), cnt(t, F[k])\n return (p[0] * a + p[1] * b + p[2] * y + p[3] * x) % d\n \nk, m = map(int, input().split())\nif k > 15:\n x, y, z = len(F[7]), len(F[17]), len(F) - 4\n a, b, c = fib(k - 7)[0], fib(k - 17)[0], fib(k - z)[0]\n for i in range(m):\n t = input()\n if len(t) < x: print(f(t, a, 8))\n elif len(t) < y: print(f(t, b, 18))\n else: print(f(t, c, z + 1))\nelse:\n p = F[k]\n for i in range(m):\n print(cnt(input(), p))\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "da10c912d6d7f736d0ecac983215e5f7", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0} {"lang": "PyPy 3", "source_code": "from sys import stdout\n\n\nclass Mock:\n def __init__(self, cap, a):\n self.a, self.cap = a, cap\n self.n, self.q = len(a), []\n\n def ask(self, i):\n result = self.a[i] in self.q\n self.q.append(self.a[i])\n if len(self.q) > self.cap:\n self.q = self.q[1:]\n return result\n\n def reset(self):\n self.q = []\n\n def out(self, result):\n print('!', result)\n\n\nclass IO:\n def __init__(self):\n self.n, self.cap = map(int, input().split())\n\n def ask(self, i):\n print('?', i + 1)\n stdout.flush()\n return input() == 'Y'\n\n def reset(self):\n print('R')\n stdout.flush()\n\n def out(self, result):\n print('!', result)\n\n\ndef solve(io):\n n, cap = io.n, io.cap\n size = cap + 1 >> 1\n count = n // size\n removed = [False] * n\n for d in range(1, count):\n for r in range(min(d, count - d)):\n for i in range(r, count, d):\n for j in range(i * size, (i + 1) * size):\n if not removed[j] and io.ask(j):\n removed[j] = True\n io.reset()\n return removed.count(False)\n\n\n# io = Mock(2, [1, 4, 1, 3])\n# io.out(solve(io))\n\n# io = Mock(8, [1, 2, 3, 4, 5, 6, 6, 6])\n# io.out(solve(io))\n\nio = IO()\nio.out(solve(io))", "lang_cluster": "Python", "compilation_error": false, "code_uid": "519478c893388c1a8dca2201b864ab2a", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "PyPy 3", "source_code": "import sys\n\ndef ask(s):\n print(s)\n sys.stdout.flush()\n\n\ndef solve():\n n, k = map(int, input().split())\n \n head = [True] * (n+1)\n head[0] = False\n\n if k == 1:\n N = 2*int(n/(k+1))\n else:\n N = 2*int(n/k)\n #print(N)\n\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 #print(\"_\",cl,cr)\n for j in range(1,i):\n l = (j-1)*int((k+1)/2)+1\n r = j*int((k+1)/2)\n #print(\"__\",l,r)\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 #print(head)\n ans = sum(map(int, head))\n ask(\"! \"+str(ans))\n\n\nsolve()\n\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "d1ad4a6e72bd583336bad123e11414f7", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "PyPy 3", "source_code": "MOD = 1000000007\ndef isSubset(a, b):\n return (a & b) == a\ndef isIntersect(a, b):\n return (a & b) != 0\ndef cntOrder(s, t):\n p = len(s)\n m = len(t)\n inMask = [0 for i in range(m)]\n for x in range(p):\n for i in range(m):\n if t[i] % s[x] == 0:\n inMask[i] |= 1 << x\n cnt = [0 for mask in range(1 << p)]\n for mask in range(1 << p):\n for i in range(m):\n if isSubset(inMask[i], mask):\n cnt[mask] += 1\n dp = [[0 for mask in range(1 << p)] for k in range(m + 1)]\n for i in range(m):\n dp[1][inMask[i]] += 1\n for k in range(m):\n for mask in range(1 << p):\n for i in range(m):\n if not isSubset(inMask[i], mask) and isIntersect(inMask[i], mask):\n dp[k + 1][mask | inMask[i]] = (dp[k + 1][mask | inMask[i]] + dp[k][mask]) % MOD\n dp[k + 1][mask] = (dp[k + 1][mask] + dp[k][mask] * (cnt[mask] - k)) % MOD\n return dp[m][(1 << p) - 1]\ndef dfs(u):\n global a, graph, degIn, visited, s, t\n\n visited[u] = True\n if degIn[u] == 0:\n s.append(a[u])\n else:\n t.append(a[u])\n\n for v in graph[u]:\n if not visited[v]:\n dfs(v)\ndef main():\n global a, graph, degIn, visited, s, t\n n = int(input())\n a = list(map(int, input().split()))\n c = [[0 for j in range(n)] for i in range(n)]\n for i in range(n):\n c[i][0] = 1\n for j in range(1, i + 1):\n c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD\n degIn = [0 for u in range(n)]\n graph = [[] for u in range(n)]\n for u in range(n):\n for v in range(n):\n if u != v and a[v] % a[u] == 0:\n graph[u].append(v)\n graph[v].append(u)\n degIn[v] += 1\n ans = 1\n curLen = 0\n visited = [False for u in range(n)]\n for u in range(n):\n if not visited[u]:\n s = []\n t = []\n dfs(u)\n if len(t) > 0:\n sz = len(t) - 1\n cnt = cntOrder(s, t)\n ans = (ans * cnt) % MOD\n ans = (ans * c[curLen + sz][sz]) % MOD\n curLen += sz\n print(ans)\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f21cd5606202b11a6c79b0279599ae73", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "Python 2", "source_code": "print[0,1,9,245,126565,54326037,321837880,323252721,754868154,328083248,838314395,220816781,893672292,166441208,251255697,114256285,118775501,482714697,11784725,460862131,550384565,106742050,425241115,626692854,674266678,320014275,345949512,527320049,897822749,137190263,491039182,810384961,482023334,658099864,886790989,845381174,371433224,278969124,420088324,696766322,388302635,141033366,46387851,932125021,278342766,371131134,922501918,110778457,506223573,806353719,391845991,923507761,780307355,109951115,830090230,605558495,344686604,988110893,944684429,715019947,799898820,384672708,907325090,758952329,550672104,368337206,394915145,401744167,923781939,831857516,407845661,329267374,927004007,891609656,897919613,481297880,737337940,651873737,287246681,973133651,679864988,784719328,820504764,875613823,806512665,164851642,500228957,951814419,447763649,273141670,979349615,964027956,809510400,276634497,116631976,426739449,175282420,885948162,62270880,974395255,675165056,759589968,837957573,931897605,152352780,585420109,1772087,333401718,898833639,745874265,786209423,691982338,498790927,473374639,274302623,971280670,241671319,13070005,302088807,550276351,436592588,631667314,548656698,730626984,146295220,674398632,400383348,454138904,786220712,118620797,233440672,217349271,274853536,310607544,105221205,769566615,853585061,800665807,695377419,924327065,388199705,551624811,721435546,501720515,308465454,825369234,396065729,451899519,295058424,142088952,473485086,378771634,734511215,462404399,959198328,337668263,794122911,38911400,951992982,472696081,373904752,105884826,630251717,28980684,845136347,353665773,691661192,19922354,231463797,757917231,242739918,979036950,713722080,234689388,2243164,209872853,240808787,539523346,425797848,913772061,224613100,421742777,222232478,92712941,215137570,949901408,274827432,15162482,593145989,274574232,239282092,762720192,804146934,500629424,565985054,81127381,671811155,655565571,890331075,237994348,743647404,667160634,713914299,668506729,741341289,277636808,762781382,14272789,902864131,567443405,149113383,648844381,825489976,933016723,192288078,734493315,240985733,861817693,762711459,525904609,532463481,377133989,620711079,772561562,980733194,227599811,162774370,209512798,787116594,3509258,748795368,378035466,612938915,802091952,857679599,481748937,493370392,358420805,48301629,412001241,463126722,509578422,967799131,994766554,687287243,863623583,771554899,690911527,855314994,923686429,246862514,192479791,133487041,703444043,295281758,801816257,920762934,749306433,973004841,848644684,560026478,952127278,616654635,839390326,975154012,409583672,635350249,343228425,335331602,223826406,952341037,589677800,249747234,555694261,137143500,628190328,461598392,431912756,29349807,759199489,783281228,781971312,915823407,388508707,718062705,27424111,309999451,963383322,831185229,132910888,347028136,850484840,223055285,142335980,144754000,772005560,81796039,167696020,79454283,172772542,201056991,484957644,716630285,763194701,211505841,903448791,926964672,257752668,482951716,411539070,620249847,592476107,170473128,814662613,898000271,57354872,361106091,488697643,889007954,138725767,684860983,36248116,304610143,137633385,413715776,99010024,779653665,100387568,286328069,564731826,621740468,943513219,506666491,249987886,553719884,769853086,337485319,702455584,809637762,755400257,892290368,502180086,364275817,118162370,873374339,261271695,970132574,744105500,434447173,117975095,383088393,625447969,180281249,545367713,133236931,360175662,148087453,806871297,498529036,886076476,65645000,465138299,967109895,331362616,472283705,796894900,199697765,503759892,472807906,187586706,941198065,782234442,57693411,18678611,82626204,395317191,570588915,152519440,449852456,63696518,763741345,878748386,494317541,444782633,93316211,929164666,529288371,165769871,730546850,955877127,994202767,492009567,275683011,415902127,95725776,718047399,786963365,73091278,986172399,174591541,913259286][input()]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "94af2d0677d5123acfcacd75fc309d5d", "src_uid": "fda761834f7b5800f540178ac1c79fca", "difficulty": 2800.0} {"lang": "Python 3", "source_code": "def Solve(x,B):\n if((X,x,B) in Mem):\n return Mem[(X,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(sorted(A)))):\n Mem[(X,x,B)]=True\n return True\n A[e]=r\n A+=[L[x]]\n if(Solve(x+1,tuple(sorted(A)))):\n Mem[(X,x,B)]=True\n return True\n Mem[(X,x,B)]=False\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\nMem={}\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": "5782ee859c086b02aafc4bfc6f531818", "src_uid": "359f5d1264ce16c5c5293fd59db95628", "difficulty": 2200.0} {"lang": "PyPy 3-64", "source_code": "import sys\r\nfrom math import gcd\r\n# sys.setrecursionlimit(10000)\r\n\r\n\r\nclass BinaryField:\r\n def __init__(self, s):\r\n \"\"\"Given a binary string, return a BinaryField element.\r\n Input:\r\n s: Has to take one of the following form:\r\n 1. A binary string, with MSB as the highest degree polynomial\r\n 2. An integer, with MSB as the highest degree polynomial\"\"\"\r\n if type(s) == int:\r\n self.poly = s\r\n\r\n else:\r\n self.poly = 0\r\n\r\n for c in s:\r\n self.poly = (self.poly << 1) + int(c)\r\n\r\n if self.poly == 0:\r\n self.deg = float('-inf')\r\n else:\r\n self.deg = len(bin(self.poly)) - 3\r\n\r\n def __repr__(self):\r\n return f'BinaryField(poly={bin(self.poly)[2:]}, deg={self.deg})'\r\n\r\n def __eq__(self, other):\r\n return self.poly == other.poly\r\n\r\n def __add__(self, other):\r\n return BinaryField(self.poly ^ other.poly)\r\n\r\n def __mul__(self, other):\r\n temp = other.poly\r\n answer = 0\r\n align = self.poly\r\n\r\n while temp:\r\n if temp & 1:\r\n answer ^= align\r\n\r\n align <<= 1\r\n temp >>= 1\r\n\r\n return BinaryField(answer)\r\n\r\n def __truediv__(self, other):\r\n if other.poly == 0:\r\n raise ZeroDivisionError\r\n\r\n answer = 0\r\n temp = self.poly\r\n\r\n for d in range(max(self.deg - other.deg, 0), -1, -1):\r\n if temp & (1 << (other.deg + d)):\r\n answer += (1 << d)\r\n temp ^= (other.poly << d)\r\n\r\n return BinaryField(answer)\r\n\r\n def __mod__(self, other):\r\n if other.poly == 0:\r\n raise ZeroDivisionError\r\n\r\n answer = 0\r\n temp = self.poly\r\n\r\n for d in range(max(self.deg - other.deg, 0), -1, -1):\r\n if temp & (1 << (other.deg + d)):\r\n answer += (1 << d)\r\n temp ^= (other.poly << d)\r\n\r\n return BinaryField(temp)\r\n\r\n def square(self):\r\n \"\"\"Returns the square of the polynomial itself.\r\n Faster than a * a\"\"\"\r\n answer = 0\r\n temp = self.poly\r\n\r\n while temp:\r\n lsb = temp & (-temp)\r\n answer += lsb ** 2\r\n\r\n temp -= lsb\r\n\r\n return BinaryField(answer)\r\n\r\n def powmod(self, exp, mod):\r\n \"\"\"Return (self**exp) % mod\r\n Inputs:\r\n exp: An integer power\r\n mod: A BinaryField element representing the modulus\"\"\"\r\n answer, temp = BinaryField(1), self\r\n\r\n while exp:\r\n if exp & 1:\r\n answer = (answer * temp) % mod\r\n\r\n exp >>= 1\r\n temp = temp.square() % mod\r\n\r\n return answer\r\n\r\n @staticmethod\r\n def gcd(poly1, poly2):\r\n \"\"\"Given two BinaryField elements, return its gcd\r\n Input:\r\n poly1, poly2: two BinaryField elements.\r\n Output:\r\n The gcd of poly1 and poly2 as a BinaryField instance.\"\"\"\r\n if poly1.deg < poly2.deg:\r\n poly1, poly2 = poly2, poly1\r\n\r\n p1, p2 = poly1, poly2\r\n while p2.poly != 0:\r\n p1, p2 = p2, p1 % p2\r\n\r\n return p1\r\n\r\n @staticmethod\r\n def factorize(poly):\r\n \"\"\"Factorize a BinaryField object\r\n Input:\r\n poly: A BinaryField element\r\n Return: A list of tuples (poly, exp).\"\"\"\r\n answer = []\r\n temp = poly\r\n\r\n for d in range(2, 2**(1+poly.deg//2)):\r\n div = BinaryField(d)\r\n\r\n e = 0\r\n while temp % div == BinaryField(0):\r\n temp = temp / div\r\n e += 1\r\n\r\n if e:\r\n answer.append((div, e))\r\n\r\n if temp == BinaryField(1): break\r\n\r\n if temp != BinaryField(1):\r\n answer.append((temp, 1))\r\n\r\n return answer\r\n\r\n\r\ndef input_general():\r\n return sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\ndef input_num():\r\n return int(sys.stdin.readline().rstrip(\"\\r\\n\"))\r\n\r\n\r\ndef input_multi(x=int):\r\n return map(x, sys.stdin.readline().rstrip(\"\\r\\n\").split())\r\n\r\n\r\ndef input_list(x=int):\r\n return list(input_multi(x))\r\n\r\n\r\ndef main(s):\r\n def get_factor(n):\r\n factors = {1}\r\n\r\n for p in range(2, 1 + int(n**0.5)):\r\n e = 0\r\n\r\n while n % p == 0:\r\n n //= p\r\n e += 1\r\n\r\n if e:\r\n factors = {f * (p**i) for f in factors for i in range(e+1)}\r\n\r\n if n == 1: break\r\n\r\n if n != 1:\r\n factors = {f * g for f in factors for g in (1, n)}\r\n\r\n return factors\r\n\r\n s = s.rstrip('0')\r\n leading_0 = s.find('1')\r\n\r\n answer = 1\r\n\r\n if leading_0 == -1:\r\n print('-1')\r\n return\r\n\r\n f2s = BinaryField(s)\r\n x = BinaryField(2)\r\n factors_bin = BinaryField.factorize(f2s)\r\n\r\n for f, exp in factors_bin:\r\n factors_pow = sorted(list(get_factor(2**f.deg-1)))\r\n\r\n for e in factors_pow:\r\n if x.powmod(e, f) == BinaryField(1):\r\n if exp == 1:\r\n need = e\r\n else:\r\n need = e * (2**(len(bin(exp-1)) - 2))\r\n\r\n g = gcd(answer, need)\r\n answer = answer * need // g\r\n\r\n break\r\n\r\n print(1 + leading_0, 1 + leading_0 + answer)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n s = input_general()\r\n\r\n main(s)\r\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "f7052132579824d53a816a4ec9de46df", "src_uid": "6bf798edef30db7d0ce2130e40084e6b", "difficulty": 2900.0} {"lang": "Python 2", "source_code": "import fileinput\n\ninput = fileinput.input()\ndef readstr():\n return input.readline().rstrip()\n\ndef readints():\n return [int(x) for x in readstr().split(' ')]\n\ndef sign(n):\n return 1-(n&1)*2\n\ndef coeffs(d,p):\n inv = [1]*(d+1)\n for i in xrange(2,d+1):\n inv[i] = (-(p/i)*inv[p%i])%p\n finv = [1]*(d+1)\n for i in xrange(d):\n finv[i+1]=(finv[i]*inv[i+1])%p\n sumd=d*(d+1)/2\n sumd2=d*(d+1)*(2*d+1)/6\n return [(inv[d]*inv[d-1]*sign(d-j)*((sumd-j)**2-sumd2+(j**2))*finv[j]*finv[d-j])%p for j in xrange(d+1)]\n\n# cell[z]=cell[x]+cell[y]\ndef plus(x,y,z):\n print '+ {} {} {}'.format(x,y,z)\n\n# cell[y]=cell[x]^d\ndef powd(x,y):\n print '^ {} {}'.format(x,y)\n\ndef output(x):\n print 'f {}'.format(x)\n\n# cell[y]+=k*cell[x]\n# Modifies cell[x]\ndef kplus(k,x,y):\n k=k%p\n while k:\n if k&1: plus(x,y,y)\n k/=2\n plus(x,x,x)\n\n# cell[y]+=k*cell[x]^2\n# Requires c=coeffs(d,p) and cell[one]==1\n# Modifies cell[x] and cell[z]\ndef ksquare(k,x,y,c,one,tmp):\n for j in xrange(d+1):\n if j: plus(x,one,x)\n powd(x,tmp)\n kplus(c[j]*k,tmp,y)\n\n# x, y, x+y, 1, result, tmp\nd,p = readints()\nc=coeffs(d,p)\nhalf=(p+1)/2\nplus(1,2,3)\nkplus(-1,6,5)\nksquare(-half,1,5,c,4,6)\nksquare(-half,2,5,c,4,6)\nksquare(half,3,5,c,4,6)\noutput(5)\n\ndef test(d,p):\n c=coeffs(d,p)\n for x in xrange(1000):\n assert pow(x,2,p)==sum(pow(x+j,d,p)*cj for j,cj in enumerate(c))%p\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "2c1f55a06a606ee54ff755ed043a0d15", "src_uid": "bbdc2a3d58f5229d7e9b67e4de70067f", "difficulty": 3300.0} {"lang": "Python 2", "source_code": "d = '0123456789ABCDEFGH'\nprev = {d[i]: d[i - 1] for i in range(1, 18)}\nnext = {d[i]: d[i + 1] for i in range(17)}\n\nn, m = raw_input().split()\np, m = ['0'] * 10, int(m)\nk, l = 1, len(n)\nfor x in map(int, n): p[x] = next[p[x]]\n\na = ''.join(p)\nu, v = {a: [0] * m}, {}\nu[a][0] = 1\n\nfor r in range(1, l + 1):\n if r == l and '0' in n: u.pop('1000000000')\n for a in u:\n for i in range(10):\n if a[i] != '0':\n b = a[: i] + prev[a[i]] + a[i + 1: ]\n if not b in v: v[b] = [0] * m\n i = (k * i) % m - m\n x, y = v[b], u[a]\n for j in range(m): x[j + i] += y[j]\n u, v = v, {}\n k = 10 * k % m\n\nprint u['0000000000'][0]", "lang_cluster": "Python", "compilation_error": false, "code_uid": "dd35de6e223908400d2ded62e5a3b265", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0} {"lang": "PyPy 3", "source_code": "mod = int(1e9 + 7)\nn, m = map(int, input().split())\nf = [ [0 for i in range(60)] for j in range(60) ]\ng = [ [0 for i in range(60)] for j in range(60) ]\ns = [ [0 for i in range(60)] for j in range(60) ]\ninv = [ 1 ]\nf[0][0] = s[0][0] = 1\n\ndef pow(x, exp) :\n res = 1\n for i in range(0, 31) :\n if exp & 1 : res = res * x % mod\n exp >>= 1\n if exp == 0 : break\n x = x * x % mod\n return res\n\nfor i in range(1, n + 1) :\n inv.append( pow(i, mod - 2) )\n\nfor node in range(1, n + 1) :\n for cut in range(1, n + 1) :\n tmp = 0\n for ln in range(node) :\n for lc in range(cut - 1, n + 1) :\n if f[ln][lc] == 0 : continue\n if lc == cut - 1 :\n tmp = ( tmp + f[ln][lc] * s[node - ln - 1][cut - 1] ) % mod\n else :\n tmp = ( tmp + f[ln][lc] * f[node - ln - 1][cut - 1] ) % mod\n cnt = 1\n if tmp != 0 :\n cn, cc = 0, 0\n for i in range(1, n + 1) :\n cn += node\n cc += cut\n cnt = cnt * (tmp + i - 1) % mod * inv[i] % mod\n if cn > n or cc > n : break\n for j in range(n - cn, -1, -1) :\n for k in range(n - cc, -1, -1) :\n if f[j][k] == 0 : continue\n g[j + cn][k + cc] += f[j][k] * cnt\n g[j + cn][k + cc] %= mod\n for i in range(n + 1) :\n for j in range(n + 1) :\n f[i][j] = (f[i][j] + g[i][j]) % mod\n g[i][j] = 0\n \n for cut in range(n, -1, -1) :\n s[node][cut] = ( s[node][cut + 1] + f[node][cut] ) % mod\nprint(f[n][m - 1])", "lang_cluster": "Python", "compilation_error": false, "code_uid": "e8630bf7aaab135b310c8fcef32329ab", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "Python 3", "source_code": "n,p=map(int,input().split())\nnums=[0]+list(map(int,input().split()))\nmod=10**9+7\n\nf=[[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(n+1)]\n\n_2=[0]*(n+1)\n_2[0]=1\nfor i in range(1,n+1):\n _2[i]=(_2[i-1]<<1)%mod\n \nf[0][0][0][0]=1\nif nums[1]!=0:\n f[1][1][0][1]+=1\nif nums[1]!=1:\n f[1][1][1][0]+=1\n\nfor i in range(2,n+1):\n for j in range(2):\n for ob in range(2):\n for ow in range(2):\n qwq=f[i-1][j][ob][ow]\n if nums[i]!=0:\n if ob:\n f[i][j][ob][ow]=(f[i][j][ob][ow]+qwq*_2[i-2])%mod\n f[i][j^1][ob][ow|1]=(f[i][j^1][ob][ow|1]+qwq*_2[i-2])%mod\n else:\n f[i][j^1][ob][ow|1]=(f[i][j^1][ob][ow|1]+qwq*_2[i-1])%mod\n if nums[i]!=1:\n if ow:\n f[i][j][ob][ow]=(f[i][j][ob][ow]+qwq*_2[i-2])%mod\n f[i][j^1][ob|1][ow]=(f[i][j^1][ob|1][ow]+qwq*_2[i-2])%mod\n else:\n f[i][j^1][ob|1][ow]=(f[i][j^1][ob|1][ow]+qwq*_2[i-1])%mod\n\n\nans=0\nfor i in range(2):\n for j in range(2):\n ans=(ans+f[n][p][i][j])%mod\nprint(ans)\n", "lang_cluster": "Python", "compilation_error": false, "code_uid": "0a1949d72998bec96f8a48e980c52666", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0}