{"lang": "Python 3", "source_code": "l=[]\nfor i in range(4):\n    l.append(input())\nans=0\na=b=c=d=''\nfor i in range(4):\n    for j in range(4):\n        if j<2:\n            a=l[i][j]+l[i][j+1]+l[i][j+2]\n        if i<2:\n            b=l[i][j]+l[i+1][j]+l[i+2][j]\n        if i<2 and j<2:\n            c=l[i][j]+l[i+1][j+1]+l[i+2][j+2]\n        if i<2 and j>1:\n            d=l[i][j]+l[i+1][j-1]+l[i+2][j-2]\n        for k in (a,b,c,d):\n            if k.count('.')==1 and k.count('x')==2:\n                ans=1\nprint('YES' if ans else 'NO')", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "c4cee99a3024061a39808d2d59b4811f", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nn=int(sys.stdin.readline().strip())\nword=sys.stdin.readline().strip()\nvow=set(['a', 'e', 'i', 'o','u','y'])\nnew_w=[]\nidx=0\n\nwhile idx<len(word):\n    if word[idx] not in vow:\n        new_w+=[word[idx]]\n        idx+=1\n        continue\n    if idx<len(word):\n        i=idx+1\n        new_w+=[word[idx]]\n        while i<len(word):\n            if word[i] in vow:\n                i+=1\n            else:\n                break\n        idx=i\n\nprint \"\".join(new_w)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7319e8922b6ee55d073ac85fe7a55b25", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import sqrt\n\n\ndef genprimes(limit):\n    lim = limit // 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 * 2 + 3 for i, f in enumerate(sieve) if f]\n    for i, p in enumerate((2, 3, 5, 7)):\n        res[i] = p\n    while res[-1] >= limit:\n        del res[-1]\n    return res\n\n\ndef main():\n    n, res = int(input()), 1\n    for p in genprimes(int(sqrt(n)) + 12):\n        if not n % p:\n            res *= p\n            while not n % p:\n                n //= p\n            if n == 1:\n                break\n    print(res * n)\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "a0b62df8d7c4ca515ba545d52359b59d", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from sys import stdin\nrr = lambda: stdin.readline().strip()\nrri = lambda: int(rr())\nrrm = lambda: map(int, rr().split())\ndef rry(N = None, f = rri):\n    for i in xrange(N or rri()):\n        yield f()\n\ndebug=0\nif debug:\n    fi = open('t.txt','r')\n    rr = lambda: fi.readline().replace('\\n','')\n\nN = rri()\nA = rrm()\nBIG = 1000050\nB = [False] * BIG\nfor x in A:\n    B[x] = True\n\n#add 25-K people\nto_add = 25-N\nif to_add:\n    for x in xrange(1, BIG):\n        if not B[x]:\n            B[x] = True\n            to_add -= 1\n            if to_add == 0: break\n\n\ninvited = 0\nans = 0\nfor x in xrange(1, BIG):\n    if B[x]:\n        invited += 1\n        if invited == 25: break\n    else:\n        ans += 1\nprint ans\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "9a871ab1f4294b034f8d8ace151875db", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#a=int(input());  \n#if(a&1==1) and a!=0 and a!=2:  \n#    print(\"NO\")    \n#else:  \n#\tp1=a/2\n#\tif(p1&1!=1):\n #       #print(\"YES\")\n  #      \tprint(\"YES\")\n    \na=int(input()); \nif(a&1==1) or a==0 or a==2:\n\tprint(\"NO\")\nelse:\n\ta2=a-2\n\tif(a2&1!=1):\n\t\tprint(\"YES\")", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "ad9793a05c0029b39c81a38ee1f7ad14", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\n\nt = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n\nn = 0\ndatas = None\n\ndef test(i):\n\tglobal n, datas, t\n\tfor j in range(n):\n\t\t#print \"datas[%2d]: %2d, t[%2d]: %2d\"%(j, datas[j], i, t[i])\n\t\tif datas[j] != t[i]:\n\t\t\treturn False\n\t\ti = (i+1) % 30\n\treturn True\n\nif __name__ == \"__main__\":\n\tn = int(raw_input())\t\n\tdatas = [int(x) for x in raw_input().split()]\n\tif n == 1:\n\t\tif datas[0] == 15:\n\t\t\tprint \"DOWN\"\n\t\telif datas[0] == 0:\n\t\t\tprint \"UP\"\n\t\telse:\n\t\t\tprint \"-1\"\n\t\tsys.exit(0)\n\n\ti = datas[0]\n\tj = 0\n\tfor j in range(29, -1, -1):\n\t\tif t[j] == datas[0]:\n\t\t\tbreak\n\t#print \"datas[0]: %2d, t[i]: %2d, t[j]: %2d\"%(datas[0], t[i], t[j])\n\n\tif not test(i) and not test(j):\n\t\tprint \"-1\"\n\t\tsys.exit(0)\n\n\tif datas[n-1] == 0:\n\t\tprint \"UP\"\n\t\tsys.exit(0)\n\n\tif datas[n-1] == 15:\n\t\tprint \"DOWN\"\n\t\tsys.exit(0)\n\n\tdelta = datas[n-1] - datas[n-2];\n\tprint \"UP\" if delta > 0 else \"DOWN\"", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d2a292ba065c835aed71e5389cae3030", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "vp = int(input())\nvd = int(input())\nt = int(input())\nf = int(input())\nc = int(input())\ncurrentD = 0\nans = 0\n\nif vp >= vd:\n    ans = 0\nelse:\n    currentD = vp * t\n    \n    while currentD < c:\n        currentD += (vp * currentD) / (vd - vp)\n\n        if currentD >= c:\n            break\n        \n        ans += 1\n        currentD += (f + currentD / vd) * vp\n\nprint(ans)\n        \n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "ee7a6b063327a0d04d54df9f8670b518", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "\"\"\"                         \nBeautiful is better than ugly.\n    Explicit is better than implicit.\nSimple is better than complex.\n    Complex is better than complicated.\nFlat is better than nested.\n    Sparse is better than dense.\n                    \n    * Readability counts *\n\n // Author : raj1307 - Raj Singh\n // Date   : 21.06.19\n\n\"\"\"\n\nfrom __future__ import division, print_function\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\nelse:\n    _str = str\n    str = lambda x=b\"\": x if type(x) is bytes else _str(x).encode()\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,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,pow,pi\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *,threading\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,MOD=1000000007,998244353\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)%p1\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# 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    #for _ in range(ii()):\n    \n    n=ii()\n    \n    if n==1: \n        print(1)\n    else:\n        \n        r=1\n        ans=1\n        for i in range(1,n):\n            \n           ans+=i*4\n           \n           \n           \n           \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# 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        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    #dmain()", "lang_cluster": "Python", "tags": ["math", "dp", "implementation"], "code_uid": "2ad720afa23bbfb429bd2e0d1c991721", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\nif n == 0:\n    print 1\nelse:\n    n = n%4\n    if n == 1:\n        print 8\n    elif n == 2:\n        print 4\n    elif n==3:\n        print 2\n    elif n == 0:\n        print 6\n", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "a9371c4293a544a030a72785b4d314c0", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\nn,k = map(int,input().split())\nstring = input()\ngpos = string.index('G')\ntpos = string.index('T')\n\nno = 0\nif gpos < tpos:\n    while gpos != tpos:\n        gpos += k\n        if gpos >= n or gpos > tpos or string[gpos] == '#':\n            no = 1\n            break\n\nelse:\n    while gpos != tpos:\n        gpos -= k\n        if gpos < 0 or gpos < tpos or string[gpos] == '#':\n            no = 1\n            break\nif no == 0:\n    print('YES')\nelse:\n    print('NO')\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "a4dd0667f7043408e4e3c1fb24c3c23b", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import os\n\n#first_line = map(int,raw_input().split())\nn = int(raw_input())\ntimes = n/3\nremaining = n%3\nans = times*2\nif remaining!=0:\n\tans+=1\nprint ans", "lang_cluster": "Python", "tags": ["math"], "code_uid": "3ee1e35cc0ad28d66ef6d4f2acc6788e", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = input()\nvowels = 'aeiouyAEIOUY'\nif s.split()[-1] == '?':\n    if s.split()[-2][-1] in vowels:\n        print('YES')\n    else:\n        print('NO')\nelse:\n    if s.split()[-1][:-1][-1] in vowels:\n        print('YES')\n    else:\n        print('NO')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e0936e5e62ffeda0bcb32579b1a80625", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "I=input\na=I().split()\ndef f(s,z):\n\tif not z:return int(s[0])\n\tm=10**99\n\tfor i in s:\n\t\tt=s[::];t.remove(i)\n\t\tfor j in t:k=t[::];k.remove(j);m=min(m,f(k+[str(eval(i+z[0]+j))],z[1:]))\n\treturn m\nprint(f(a,I().split()))", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "dd66e205e4ba8e2c7ada0b83a33f32c7", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "z,x,c=map(int,input().split())\nif (z+x)>c:\n\tif x>z and x>c:\n\t\td=2*(z+c)\n\telif z>x and z>c:\n\t\td=2*(x+c)\n\telse:\t\n\t\td=x+z+c\nif z+x<=c:\n\td=2*z+2*x\nprint(d)\t\t\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e805b36813d71d7bb7cff9b22ff2cd6f", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, dic = int(input()), {}\ns = input()\nfor i in range(1, n):\n    try:dic[s[i-1:i+1]]+=1\n    except:dic[s[i-1:i+1]]=1\nprint(max(dic.keys(), key=dic.get))", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "4f41b1b0eee48f1412343bd50c45ed2d", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"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 <hello@cheran.io>\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, k = map(int, input().split())\n    print(int(math.ceil((2 * n) / k) + math.ceil((5 * n) / k) + math.ceil((8 * n) / k)))\n\n\nif __name__ == '__main__':\n    sync_with_stdio(False)\n    main()\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "9835201ebd2727cf86761b4f29884a44", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def main():\n    [w1, h1, w2, h2] = [int(_) for _ in input().split()]\n    marked = (w1 + 2) + (h1 * 2) + (h2 * 2) + (w2 + 2) + (w1 - w2)\n\n    print(marked)\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "06887143c901796fe0c069c17613e786", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\ndef main():\n    s = int(sys.stdin.readline().rstrip())\n    if s == 3:\n        return 5\n    \n    l = [\n     (1, 1),\n     (3, 5),\n     (5, 13),\n     (7, 25),\n     (9, 41),\n     (11, 61),\n     (13, 85),\n     (15, 113)\n    ]\n    for x in l:\n        if s <= x[1]:\n            return x[0]\n\n\nif __name__ == \"__main__\":\n    print main()", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "458a4eece101e3a2ce964a90979844f8", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\nl = (k - 1) // (2 * m) + 1\n\nprint(l, ((k - 1) % (2 * m))  // 2 + 1, 'L' if k & 1 else 'R')", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "d86339ab1fa6be9a6f63934126cb589d", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a=list(map(int,input().split()))\na.sort()\nif a[0]+a[-1]==a[1]+a[2] or a[0]+a[1]+a[2]==a[3]:\n    print('YES')\nelse:\n    print('NO')\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "a3bc360f44a2a81593a5070d8ecb851e", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\n# import bisect\nimport sys\n# from collections import Counter\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\ndef print_fract(p,q):\n\tg = math.gcd(p,q)\n\tp//=g\n\tq//=g\n\tprint(str(p)+\"/\"+str(q))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\na, b, c, d = invr()\nif (a >= c and b >= d) or (a < c and b < d):\n\tfl = True\n\tarea = 0\n\tif d*(a/c) <= b:\n\t\tarea = d*a*a/c\t\n\tif c*(b/d) <= a:\n\t\tif area < c*b*b/d:\n\t\t\tfl = False\n\t\t\tp = (a*d) - (b*c)\n\t\t\tq = a*d\n\t\t\tprint_fract(p,q)\n\tif fl:\n\t\tp = (b*c) - (a*d)\n\t\tq = b*c\n\t\tprint_fract(p,q)\nelif a >= c and b < d:\n\tp = (a*d) - (b*c)\n\tq = a*d\n\tprint_fract(p,q)\nelif a < c and b >= d:\n\tp = (b*c) - (a*d)\n\tq = b*c\n\tprint_fract(p,q)", "lang_cluster": "Python", "tags": ["math", "greedy", "number theory"], "code_uid": "02b6edb5f60ecafd7cc7cbc63c9a0aa4", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def pow3(N, M):\n  if N == 0:\n    return 0\n  if N == 1:\n    return 3 % M\n  res = pow3(N / 2, M) ** 2\n  if N % 2 == 1:\n    res *= 3\n  return res % M\n\ndef solve(N, M):\n  return (pow3(N, M) + M - 1) % M\n\nimport sys\ninput = sys.stdin\nN, M = map(int, input.readline().split())\nprint solve(N, M)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "33fb643d578dc1d343d2c42f9e041b6c", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import itertools\n \nprint(sum(map(lambda x:(x==('Q','A','Q')), itertools.combinations(input(),3))))", "lang_cluster": "Python", "tags": ["brute force", "dp"], "code_uid": "7b81a4801fc6c454082998b70a435eae", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "class CodeforcesTask980ASolution:\n    def __init__(self):\n        self.result = ''\n        self.necklace = ''\n\n    def read_input(self):\n        self.necklace = input()\n\n    def process_task(self):\n        try:\n            if not self.necklace.count(\"-\") % self.necklace.count(\"o\"):\n                self.result = \"YES\"\n            else:\n                self.result = \"NO\"\n        except ZeroDivisionError:\n            self.result = \"YES\"\n\n    def get_result(self):\n        return self.result\n\n\nif __name__ == \"__main__\":\n    Solution = CodeforcesTask980ASolution()\n    Solution.read_input()\n    Solution.process_task()\n    print(Solution.get_result())\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "e8699007cb7625d4d3f84643b6e03dd5", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "(n, m) = map(int, input().split())\nif n <= m:\n\tprint(n)\nelse:\n\taM = m\n\tn -= m\n\t(l, r) = (0, int(2e9))\n\twhile l < r:\n\t\tm = (l + r) // 2;\n\t\tval = m * (m+1) // 2;\n\t\tif val >= n:\n\t\t\tr = m\n\t\telse:\n\t\t\tl = m+1\n\tprint(l + aM)", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "5cb6bf0ddff3f71d687ad26bb8116d6c", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "'''input\nabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv\n'''\npos = 12\ng = ['o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a',\n     'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n']\n\ns = raw_input()\nans, p1 = 0, -1\nfor x in s:\n    for y in xrange(0, pos):\n        if x == g[y]:\n            p1 = y\n            break\n    for y in xrange(pos, len(g)):\n        if x == g[y]:\n            p1 = y\n            break\n    ans += min(abs(pos - p1), 26 - abs(pos - p1))\n    pos = p1\nprint ans\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "ff78dba739d89f6055591ca4654a7059", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\nif __name__ == \"__main__\":\n\tn = int(input())\n\tfingers = list(map(int, input().split()))\n\ttotal_fingers = 0\n\tfor finger in fingers:\n\t\ttotal_fingers = (total_fingers + finger)\n\tm = 0\n\tunwanted_sums = list(range(1,5*n+6,n+1))\n\t#print(unwanted_sums)\n\tfor i in range(1, 6):\n\t\tif (total_fingers + i) not in unwanted_sums:\n\t\t\t#print(i)\n\t\t\tm += 1\t\t\n\t#print(\"----------\" + str(m) + \"-------------\")\n\tprint(m)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "6d959e8368e7fcab0d0d2962f2f531e4", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef read_i():\n    return list(map(int, input().split()))\n\n\nclass Combinations:\n    def __init__(self, max_num, mod):\n        self.mod = mod\n        self.factorials = [1]\n        for i in range(1, max_num + 1):\n            self.factorials.append((self.factorials[-1] * i) % mod)\n        self.invs = [pow(self.factorials[-1], mod - 2, mod)]\n        for i in reversed(range(1, max_num + 1)):\n            self.invs.append(self.invs[-1] * i % mod)\n        self.invs = self.invs[::-1]\n\n    def __call__(self, n, k):\n        return self.factorials[n] * self.invs[k] * self.invs[n - k] % self.mod\n\n\nn, m = read_i()\nMOD = 10**9 + 7\ncombinations = Combinations(max(n, m), MOD)\nres = 0\nfor i in range(n // 2 + 1):\n    res += combinations(n - i, i)\n    res %= MOD\nfor i in range(m // 2 + 1):\n    res += combinations(m - i, i)\n    res %= MOD\nres = 2 * (res - 1 + MOD) % MOD\nprint(res)", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "da150b86890ad71c84f4cb66f7173b3b", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, d, m = map(int, raw_input().split())\ng, p, b = map(int, raw_input().split())\ntot = g + p + b\nans = \"YES\"\nif g < a:\n    ans = \"NO\"\nelse:\n    g -= a\nif  g + p < d:\n    ans = \"NO\"\nif tot - a - d  < m:\n    ans = \"NO\"\nprint ans ", "lang_cluster": "Python", "tags": ["brute force", "greedy", "implementation"], "code_uid": "955d6993d2ffc4fd901b1554dcbc958b", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "r,c=map(int,input().split())\na=[input() for i in range(r)]\nprint(r*c-len([1 for i in a if 'S' in i])*len([1 for i in zip(*a) if 'S' in i]))", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "a7afb6ae2d69f0f380c0413bf2f5a8bd", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "x, n = map(int, input().split())\n\n\ndef dividers(n):\n    divs = []\n    i = 2\n    while i ** 2 <= n:\n        if n % i == 0:\n            divs.append(i)\n            while n % i == 0:\n                n //= i\n        i += 1\n    if n != 1:\n        divs.append(n)\n    return divs\n\n\ndef h(n, p):\n    result = 0\n    pi = p\n    while n >= pi:\n        result += n // pi\n        pi *= p\n    return result\n\n\nans = 1\nfor p in dividers(x):\n    ans *= pow(p, h(n, p), 10 ** 9 + 7)\n    ans %= (10 ** 9 + 7)\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "ce168cbe561223c3546e96b290197489", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def main():\n   n, s  = map(int,input().split())\n   a = BS(1,n,s)\n   print(n-a+1)\n   \ndef BS(f,l,d):\n    if(f>l): \n        return f\n    mi = (f+l)//2\n    if(mi-sum([int(j) for j in str(mi)]) >= d):\n        return BS(f,mi-1,d)\n    else:\n        return BS(mi+1,l,d)\n\nif __name__ == \"__main__\":\n    main()\n", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "81427ed3571d31691fd91becefaa3e99", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "print(str(bin(int(input()))).count(\"1\"))", "lang_cluster": "Python", "tags": ["bitmasks"], "code_uid": "f37900bd3508c13a1542c2100264dcca", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\"\"\".\"\"\"\nstor_size, steps_nr = (int(x) for x in input().split())\nstorage = sorted(list(input()))\n\nbest_weight = 1e+9\nfor start_idx in range(stor_size):\n    curr_weight = 0\n    curr_last = 'A'\n    length = 0\n    for letter in storage[start_idx:]:\n        if ord(letter) - ord(curr_last) >= 2:\n            curr_weight += ord(letter) - ord('a') + 1\n            curr_last = letter\n            length += 1\n        if length == steps_nr:\n            break\n    if length == steps_nr:\n        best_weight = min(curr_weight, best_weight)\nif best_weight == 1e+9:\n    best_weight = -1\nprint(best_weight)\n", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "dd225bab20e5302d0ee3673127b4c3bc", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\ns = str(input())\na = str('Danil')\nb = str('Olya')\nc = str('Slava')\nd = str('Ann')\nf = str('Nikita')\nk = 0\nif s.find(a) == s.rfind(a) and s.rfind(a) != -1:\n    k = k + 1\nelif s.find(a) != s.rfind(a):\n    k = k + 10\nif s.find(b) == s.rfind(b) and s.rfind(b) != -1:\n    k = k + 1\nelif s.find(b) != s.rfind(b):\n    k = k + 10\nif s.find(c) == s.rfind(c) and s.rfind(c) != -1:\n    k = k + 1\nelif s.find(c) != s.rfind(c):\n    k = k + 10\nif s.find(d) == s.rfind(d) and s.rfind(d) != -1:\n    k = k + 1\nelif s.find(d) != s.rfind(d):\n    k = k + 10\nif s.find(f) == s.rfind(f) and s.rfind(f) != -1:\n    k = k + 1\nelif s.find(f) != s.rfind(f):\n    k = k + 10\nif k == 1:\n    print('YES')\nelse:\n    print('NO')\n            \n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "b8cceb67524027b3d9e231f3ad81136b", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\n\nnumbers = \"\"\"\n    111111101010101111100101001111111\n    100000100000000001010110001000001\n    101110100110110000011010001011101\n    101110101011001001111101001011101\n    101110101100011000111100101011101\n    100000101010101011010000101000001\n    111111101010101010101010101111111\n    000000001111101111100111100000000\n    100010111100100001011110111111001\n    110111001111111100100001000101100\n    011100111010000101000111010001010\n    011110000110001111110101100000011\n    111111111111111000111001001011000\n    111000010111010011010011010100100\n    101010100010110010110101010000010\n    101100000101010001111101000000000\n    000010100011001101000111101011010\n    101001001111101111000101010001110\n    101101111111000100100001110001000\n    000010011000100110000011010000010\n    001101101001101110010010011011000\n    011101011010001000111101010100110\n    111010100110011101001101000001110\n    110001010010101111000101111111000\n    001000111011100001010110111110000\n    000000001110010110100010100010110\n    111111101000101111000110101011010\n    100000100111010101111100100011011\n    101110101001010000101000111111000\n    101110100011010010010111111011010\n    101110100100011011110110101110000\n    100000100110011001111100111100000\n    111111101101000101001101110010001\n\"\"\".split()\n\na1, a2 = map(int, sys.stdin.readline().strip().split())\nprint numbers[a1][a2]", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "0e2a32a28041b0d909840c477d743213", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\ninput=sys.stdin.readline\nn=input()\nl=list(map(int,input().split()))\nm=list(map(int,input().split()))\nprint(\"YNeos\"[sum(l)<sum(m)::2])\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "8ac939c3a33e75182cc0b934805efc7e", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "input()\na = input().split()\nb = set(a)\nc = []\n\nfor i in a[::-1]:\n    if i in b:\n        c.insert(0, i)\n        b.remove(i)\n\nprint(len(c))\nprint(\" \".join(c))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "6559fef6639b6cbbd788d7363509e415", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "c1=int(input())\nc2=int(input())\nc3=int(input())\nc4=int(input())\n\nif 1:\n    if c3>0:\n\n        if c1>0 and c1==c4:\n            print(\"1\")\n        else:\n            print(\"0\")\n    else:\n        if c1==c4:\n            print(\"1\")\n        else:\n            print(\"0\")", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "d081537e3f6a3e4d207a238d2f14c207", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = input().split()\na.sort()\nif a[0] == a[1] == a[2]:\n    print(0)\nelif (int(a[0][0]) + 1 == int(a[1][0]) == int(a[2][0]) - 1) and a[0][1] == a[1][1] == a[2][1]:\n    print(0)\nelif (a[0] == a[1] or a[0] == a[2] or a[1]==a[2]):\n    print(1)\nelif (int(a[0][0]) + 1 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) + 1 == int(a[2][0]) and a[0][1] == a[2][1]) or (int(a[1][0]) + 1 == int(a[2][0]) and a[1][1] == a[2][1]):\n    print(1)\nelif (int(a[0][0]) + 2 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) + 2 == int(a[2][0]) and a[0][1] == a[2][1]) or (int(a[1][0]) + 2 == int(a[2][0]) and a[1][1] == a[2][1]):\n    print(1)\nelse:\n    print(2)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "471ae40b59973f9341f4363d79008654", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "str = input()\nans = 'YES'\nif str[0] == '1':\n    for i in range(1, len(str) - 1):\n        if str[i] != '1' and str[i] != '4':\n            ans = 'NO'\n            break\n        if str[i] == '4' and str[i - 1] == '4' and str[i + 1] != '1':\n            ans = 'NO'\n            break\n    if str[-1] != '1' and str[-1] != '4':\n        ans = 'NO'\n    if str[-1] == '4' and str[-2] == '4' and str[-3] != '1':\n        ans = 'NO'\nelse:\n    ans = 'NO'\nprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "f7add11e3c86ca17661d3065f80aec71", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def fact(n):\n\tans = 1\n\tfor i in range(1, n + 1):\n\t\tans *= i\n\t\tans %= mod\n\treturn ans\n\n\ndef binary_search(n, x, idx):\n\tl = 0\n\tr = n\n\tans = 1\n\tbigger = 0\n\tsmaller = 0\n\twhile l < r:\n\t\tmid = (l + r) // 2\n\t\tif mid > idx:\n\t\t\tans *= (n - x - bigger)\n\t\t\tans %= mod\n\t\t\tbigger += 1\n\t\t\tr = mid\n\t\telif mid < idx:\n\t\t\tl = mid + 1\n\t\t\tans *= (x - 1 - smaller)\n\t\t\tans %= mod\n\t\t\tsmaller += 1\n\t\telse:\n\t\t\tl = mid + 1\n\tans *= fact(n - smaller - bigger - 1)\n\treturn ans % mod\n\n\n# if ar[mid] <= x:\n# \tl = mid + 1\n# else:\n# \tr = mid\n\n\nmod = 1000000007\nn, x, pos = map(int, input().split())\nprint(binary_search(n, x, pos))\n", "lang_cluster": "Python", "tags": ["binary search", "combinatorics"], "code_uid": "1e7053a5f137b07a11465feea265a692", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = input()\ns = input()\nz = ''\nk1 = '\"\"qwertyuiop\"\"'\nk2 = '\"\"asdfghjkl;\"\"'\nk3 = '\"\"zxcvbnm,./\"\"'\nfor i in s:\n    if a == 'R':\n        if i in k1:\n            z += k1[k1.find(i)-1]\n        elif i in k2:\n            z += k2[k2.find(i)-1]\n        elif i in k3:\n            z += k3[k3.find(i)-1]\n    elif a == 'L':\n        if i in k1:\n            z += k1[k1.find(i)+1]\n        elif i in k2:\n            z += k2[k2.find(i)+1]\n        elif i in k3:\n            z += k3[k3.find(i)+1]\nprint(z)\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "98ac9b6db421d70cea53de99f5ba75a1", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "cache = [[0 for i in range(3)] for j in range(101)]\nn = input()\nstate = [0]\nstate += map(int,raw_input().split())\nfor i in range(1,n+1) :\n\tif state[i] == 0 :\n\t\tcache[i][0] = min(cache[i-1])+1\n\t\tcache[i][1] = 987654321\n\t\tcache[i][2] = 987654321\n\telif state[i] == 1 :\n\t\tcache[i][0] = min(cache[i-1])+1\n\t\tcache[i][1] = 987654321\n\t\tcache[i][2] = min(cache[i-1][0],cache[i-1][1])\n\telif state[i] == 2 :\n\t\tcache[i][0] = min(cache[i-1])+1\n\t\tcache[i][1] = min(cache[i-1][0],cache[i-1][2])\n\t\tcache[i][2] = 987654321\n\telif state[i] == 3 :\n\t\tcache[i][0] = min(cache[i-1])+1\n\t\tcache[i][1] = min(cache[i-1][0],cache[i-1][2])\n\t\tcache[i][2] = min(cache[i-1][0],cache[i-1][1])\nprint min(cache[n][0],cache[n][1],cache[n][2])", "lang_cluster": "Python", "tags": ["brute force", "dp"], "code_uid": "576111b74dc29e2eb6dc626745b88d5c", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "t=map(int,raw_input().split());\nm=map(int,raw_input().split());\nL=[];S=[];\nfor i in xrange(t[0]-1):\n    L.append(m[i+1]-m[i]);\nfor i in xrange(t[0]-2):\n    S.append(m[i+2]-m[i]);\nprint max(max(L),min(S));\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "6223e0d8b3cb63b13b16946f57f5afd5", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b = map(int,raw_input().split())\nf = 0\nd = 0\ns = 0\nfor i in range(1,7):\n\tif(abs(i-a)<abs(i-b)):\n\t\tf = f+1\n\telif(abs(i-a)==abs(i-b)):\n\t\td = d+1\n\telse:\n\t\ts = s+1\nprint f,\nprint d,\nprint s,", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "34bb7fe82c93a65972c730423f9dbb01", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from collections import deque\ndef valid(x,y):\n    if x>=9 or y>=9 or x<0 or y<0:\n        return 0\n    elif v1[x][y]==1:\n        return 0\n    return 1\ndef king(i,j):\n    v1[i][j]=True\n    q=deque()\n    q.append([i,j])\n    dx=[1,0,-1,0,-1,-1,1,1]\n    dy=[0,-1,0,1,-1,1,-1,1]\n    while q:\n        node=q.popleft()\n        x=node[0]\n        y=node[1]\n        for i in range(8):\n            if valid(x+dx[i],y+dy[i]):\n                newx=x+dx[i]\n                newy=y+dy[i]\n                d1[newx][newy]=d1[x][y]+1\n                v1[newx][newy]=1\n                q.append([newx,newy])\ns1,s2,e1,e2=map(int,input().split())\nv1=[[False for i in range(9)]for j in range(9)]\nv2=[[False for i in range(9)]for j in range(9)]\nd1=[[0 for i in range(9)]for j in range(9)]\nking(s1,s2)\nif s1==e1 or s2==e2:\n    rook=1\nelse:\n    rook=2\nif (s1+e1)%2!=(s2+e2)%2:\n    bishop=0\nelif s1+s2==e1+e2 or s1-s2==e1-e2:\n    bishop=1\nelse:\n    bishop=2\nprint(rook,bishop,d1[e1][e2])\n    \n", "lang_cluster": "Python", "tags": ["math", "graphs", "shortest paths"], "code_uid": "470dea4a83c45dac5669f029393e9ee3", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 5, 7, 10, 10, 10, 10, 11, 11, 14, 16, 19, 19, 26, 32, 39, 43, 52, 58, 65, 65, 65, 65, 66, 66, 69, 71, 74, 74, 81, 87, 94, 98, 107, 113, 120, 120, 135, 149, 164, 176, 193, 207, 222, 230, 251, 269, 288, 300, 321, 335, 350, 350, 350, 350, 351, 351, 354, 356, 359, 359, 366, 372, 379, 383, 392, 398, 405, 405, 420, 434, 449, 461, 478, 492, 507, 515, 536, 554, 573, 585, 606, 620, 635, 635, 666, 696, 727, 755, 788, 818, 849, 873, 910, 944, 979, 1007, 1044, 1074, 1105, 1121, 1166, 1208, 1251, 1287, 1332, 1370, 1409, 1433, 1482, 1524, 1567, 1595, 1640, 1670, 1701, 1701, 1701, 1701, 1702, 1702, 1705, 1707, 1710, 1710, 1717, 1723, 1730, 1734, 1743, 1749, 1756, 1756, 1771, 1785, 1800, 1812, 1829, 1843, 1858, 1866, 1887, 1905, 1924, 1936, 1957, 1971, 1986, 1986, 2017, 2047, 2078, 2106, 2139, 2169, 2200, 2224, 2261, 2295, 2330, 2358, 2395, 2425, 2456, 2472, 2517, 2559, 2602, 2638, 2683, 2721, 2760, 2784, 2833, 2875, 2918, 2946, 2991, 3021, 3052, 3052, 3115, 3177, 3240, 3300, 3365, 3427, 3490, 3546, 3615, 3681, 3748, 3808, 3877, 3939, 4002, 4050, 4127, 4201, 4276, 4344, 4421, 4491, 4562, 4618, 4699, 4773, 4848, 4908, 4985, 5047, 5110, 5142, 5235, 5325, 5416, 5500, 5593, 5679, 5766, 5838, 5935, 6025, 6116, 6192, 6285, 6363, 6442, 6490, 6595, 6693, 6792, 6876, 6977, 7063, 7150, 7206, 7311, 7401, 7492, 7552, 7645, 7707, 7770, 7770, 7770, 7770, 7771, 7771, 7774, 7776, 7779, 7779, 7786, 7792, 7799, 7803, 7812, 7818, 7825, 7825, 7840, 7854, 7869, 7881, 7898, 7912, 7927, 7935, 7956, 7974, 7993, 8005, 8026, 8040, 8055, 8055, 8086, 8116, 8147, 8175, 8208, 8238, 8269, 8293, 8330, 8364, 8399, 8427, 8464, 8494, 8525, 8541, 8586, 8628, 8671, 8707, 8752, 8790, 8829, 8853, 8902, 8944, 8987, 9015, 9060, 9090, 9121, 9121, 9184, 9246, 9309, 9369, 9434, 9496, 9559, 9615, 9684, 9750, 9817, 9877, 9946, 10008, 10071, 10119, 10196, 10270, 10345, 10413, 10490, 10560, 10631, 10687, 10768, 10842, 10917, 10977, 11054, 11116, 11179, 11211, 11304, 11394, 11485, 11569, 11662, 11748, 11835, 11907, 12004, 12094, 12185, 12261, 12354, 12432, 12511, 12559, 12664, 12762, 12861, 12945, 13046, 13132, 13219, 13275, 13380, 13470, 13561, 13621, 13714, 13776, 13839, 13839, 13966, 14092, 14219, 14343, 14472, 14598, 14725, 14845, 14978, 15108, 15239, 15363, 15496, 15622, 15749, 15861, 16002, 16140, 16279, 16411, 16552, 16686, 16821, 16941, 17086, 17224, 17363, 17487, 17628, 17754, 17881, 17977, 18134, 18288, 18443, 18591, 18748, 18898, 19049, 19185, 19346, 19500, 19655, 19795, 19952, 20094, 20237, 20349, 20518, 20680, 20843, 20991, 21156, 21306, 21457, 21577, 21746, 21900, 22055, 22179, 22336, 22462, 22589, 22653, 22842, 23028, 23215, 23395, 23584, 23766, 23949, 24117, 24310, 24496, 24683, 24855, 25044, 25218, 25393, 25537, 25738, 25932, 26127, 26307, 26504, 26686, 26869, 27021, 27222, 27408, 27595, 27751, 27940, 28098, 28257, 28353, 28570, 28780, 28991, 29187, 29400, 29598, 29797, 29965, 30182, 30384, 30587, 30759, 30964, 31138, 31313, 31425, 31650, 31860, 32071, 32251, 32464, 32646, 32829, 32949, 33166, 33352, 33539, 33663, 33852, 33978, 34105, 34105, 34105, 34105, 34106, 34106, 34109, 34111, 34114, 34114, 34121, 34127, 34134, 34138, 34147, 34153, 34160, 34160, 34175, 34189, 34204, 34216, 34233, 34247, 34262, 34270, 34291, 34309, 34328, 34340, 34361, 34375, 34390, 34390, 34421, 34451, 34482, 34510, 34543, 34573, 34604, 34628, 34665, 34699, 34734, 34762, 34799, 34829, 34860, 34876, 34921, 34963, 35006, 35042, 35087, 35125, 35164, 35188, 35237, 35279, 35322, 35350, 35395, 35425, 35456, 35456, 35519, 35581, 35644, 35704, 35769, 35831, 35894, 35950, 36019, 36085, 36152, 36212, 36281, 36343, 36406, 36454, 36531, 36605, 36680, 36748, 36825, 36895, 36966, 37022, 37103, 37177, 37252, 37312, 37389, 37451, 37514, 37546, 37639, 37729, 37820, 37904, 37997, 38083, 38170, 38242, 38339, 38429, 38520, 38596, 38689, 38767, 38846, 38894, 38999, 39097, 39196, 39280, 39381, 39467, 39554, 39610, 39715, 39805, 39896, 39956, 40049, 40111, 40174, 40174, 40301, 40427, 40554, 40678, 40807, 40933, 41060, 41180, 41313, 41443, 41574, 41698, 41831, 41957, 42084, 42196, 42337, 42475, 42614, 42746, 42887, 43021, 43156, 43276, 43421, 43559, 43698, 43822, 43963, 44089, 44216, 44312, 44469, 44623, 44778, 44926, 45083, 45233, 45384, 45520, 45681, 45835, 45990, 46130, 46287, 46429, 46572, 46684, 46853, 47015, 47178, 47326, 47491, 47641, 47792, 47912, 48081, 48235, 48390, 48514, 48671, 48797, 48924, 48988, 49177, 49363, 49550, 49730, 49919, 50101, 50284, 50452, 50645, 50831, 51018, 51190, 51379, 51553, 51728, 51872, 52073, 52267, 52462, 52642, 52839, 53021, 53204, 53356, 53557, 53743, 53930, 54086, 54275, 54433, 54592, 54688, 54905, 55115, 55326, 55522, 55735, 55933, 56132, 56300, 56517, 56719, 56922, 57094, 57299, 57473, 57648, 57760, 57985, 58195, 58406, 58586, 58799, 58981, 59164, 59284, 59501, 59687, 59874, 59998, 60187, 60313, 60440, 60440, 60695, 60949, 61204, 61456, 61713, 61967, 62222, 62470, 62731, 62989, 63248, 63500, 63761, 64015, 64270, 64510, 64779, 65045, 65312, 65572, 65841, 66103, 66366, 66614, 66887, 67153, 67420, 67672, 67941, 68195, 68450, 68674, 68959, 69241, 69524, 69800, 70085, 70363, 70642, 70906, 71195, 71477, 71760, 72028, 72313, 72583, 72854, 73094, 73391, 73681, 73972, 74248, 74541, 74819, 75098, 75346, 75643, 75925, 76208, 76460, 76745, 76999, 77254, 77446, 77763, 78077, 78392, 78700, 79017, 79327, 79638, 79934, 80255, 80569, 80884, 81184, 81501, 81803, 82106, 82378, 82707, 83029, 83352, 83660, 83985, 84295, 84606, 84886, 85215, 85529, 85844, 86128, 86445, 86731, 87018, 87242, 87587, 87925, 88264, 88588, 88929, 89255, 89582, 89878, 90223, 90553, 90884, 91184, 91517, 91819, 92122, 92362, 92715, 93053, 93392, 93700, 94041, 94351, 94662, 94910, 95255, 95569, 95884, 96136, 96453, 96707, 96962, 97090, 97471, 97849, 98228, 98600, 98981, 99355, 99730, 100090, 100475, 100853, 101232, 101596, 101977, 102343, 102710, 103046, 103439, 103825, 104212, 104584, 104973, 105347, 105722, 106066, 106459, 106837, 107216, 107564, 107945, 108295, 108646, 108934, 109343, 109745, 110148, 110536, 110941, 111331, 111722, 112082, 112491, 112885, 113280, 113644, 114041, 114407, 114774, 115078, 115495, 115897, 116300, 116672, 117077, 117451, 117826, 118138, 118547, 118925, 119304, 119620, 120001, 120319, 120638, 120830, 121271, 121705, 122140, 122560, 122997, 123419, 123842, 124234, 124675, 125101, 125528, 125924, 126353, 126751, 127150, 127486, 127935, 128369, 128804, 129208, 129645, 130051, 130458, 130802, 131243, 131653, 132064, 132412, 132825, 133175, 133526, 133750, 134215, 134665, 135116, 135536, 135989, 136411, 136834, 137194, 137651, 138077, 138504, 138868, 139297, 139663, 140030, 140270, 140735, 141169, 141604, 141976, 142413, 142787, 143162, 143410, 143851, 144229, 144608, 144860, 145241, 145495, 145750, 145750, 145750, 145750, 145751, 145751, 145754, 145756, 145759, 145759, 145766, 145772, 145779, 145783, 145792, 145798, 145805, 145805, 145820, 145834, 145849, 145861, 145878, 145892, 145907, 145915, 145936, 145954, 145973, 145985, 146006, 146020, 146035, 146035, 146066, 146096, 146127, 146155, 146188, 146218, 146249, 146273, 146310, 146344, 146379, 146407, 146444, 146474, 146505, 146521, 146566, 146608, 146651, 146687, 146732, 146770, 146809, 146833, 146882, 146924, 146967, 146995, 147040, 147070, 147101, 147101, 147164, 147226, 147289, 147349, 147414, 147476, 147539, 147595, 147664, 147730, 147797, 147857, 147926, 147988, 148051, 148099, 148176, 148250, 148325, 148393, 148470, 148540, 148611, 148667, 148748, 148822, 148897, 148957, 149034, 149096, 149159, 149191, 149284, 149374, 149465, 149549, 149642, 149728, 149815, 149887, 149984, 150074, 150165, 150241, 150334, 150412, 150491, 150539, 150644, 150742, 150841, 150925, 151026, 151112, 151199, 151255, 151360, 151450, 151541, 151601, 151694, 151756, 151819, 151819, 151946, 152072, 152199, 152323, 152452, 152578, 152705, 152825, 152958, 153088, 153219, 153343, 153476, 153602, 153729, 153841, 153982, 154120, 154259, 154391, 154532, 154666, 154801, 154921, 155066, 155204, 155343, 155467, 155608, 155734, 155861, 155957, 156114, 156268, 156423, 156571, 156728, 156878, 157029, 157165, 157326, 157480, 157635, 157775, 157932, 158074, 158217, 158329, 158498, 158660, 158823, 158971, 159136, 159286, 159437, 159557, 159726, 159880, 160035, 160159, 160316, 160442, 160569, 160633, 160822, 161008, 161195, 161375, 161564, 161746, 161929, 162097, 162290, 162476, 162663, 162835, 163024, 163198, 163373, 163517, 163718, 163912, 164107, 164287, 164484, 164666, 164849, 165001, 165202, 165388, 165575, 165731, 165920, 166078, 166237, 166333, 166550, 166760, 166971, 167167, 167380, 167578, 167777, 167945, 168162, 168364, 168567, 168739, 168944, 169118, 169293, 169405, 169630, 169840, 170051, 170231, 170444, 170626, 170809, 170929, 171146, 171332, 171519, 171643, 171832, 171958, 172085, 172085, 172340, 172594, 172849, 173101, 173358, 173612, 173867, 174115, 174376, 174634, 174893, 175145, 175406, 175660, 175915, 176155, 176424, 176690, 176957, 177217, 177486, 177748, 178011, 178259, 178532, 178798, 179065, 179317, 179586, 179840, 180095, 180319, 180604, 180886, 181169, 181445, 181730, 182008, 182287, 182551, 182840, 183122, 183405, 183673, 183958, 184228, 184499, 184739, 185036, 185326, 185617, 185893, 186186, 186464, 186743, 186991, 187288, 187570, 187853, 188105, 188390, 188644, 188899, 189091, 189408, 189722, 190037, 190345, 190662, 190972, 191283, 191579, 191900, 192214, 192529, 192829, 193146, 193448, 193751, 194023, 194352, 194674, 194997, 195305, 195630, 195940, 196251, 196531, 196860, 197174, 197489, 197773, 198090, 198376, 198663, 198887, 199232, 199570, 199909, 200233, 200574, 200900, 201227, 201523, 201868, 202198, 202529, 202829, 203162, 203464, 203767, 204007, 204360, 204698, 205037, 205345, 205686, 205996, 206307, 206555, 206900, 207214, 207529, 207781, 208098, 208352, 208607, 208735, 209116, 209494, 209873, 210245, 210626, 211000, 211375, 211735, 212120, 212498, 212877, 213241, 213622, 213988, 214355, 214691, 215084, 215470, 215857, 216229, 216618, 216992, 217367, 217711, 218104, 218482, 218861, 219209, 219590, 219940, 220291, 220579, 220988, 221390, 221793, 222181, 222586, 222976, 223367, 223727, 224136, 224530, 224925, 225289, 225686, 226052, 226419, 226723, 227140, 227542, 227945, 228317, 228722, 229096, 229471, 229783, 230192, 230570, 230949, 231265, 231646, 231964, 232283, 232475, 232916, 233350, 233785, 234205, 234642, 235064, 235487, 235879, 236320, 236746, 237173, 237569, 237998, 238396, 238795, 239131, 239580, 240014, 240449, 240853, 241290, 241696, 242103, 242447, 242888, 243298, 243709, 244057, 244470, 244820, 245171, 245395, 245860, 246310, 246761, 247181, 247634, 248056, 248479, 248839, 249296, 249722, 250149, 250513, 250942, 251308, 251675, 251915, 252380, 252814, 253249, 253621, 254058, 254432, 254807, 255055, 255496, 255874, 256253, 256505, 256886, 257140, 257395, 257395, 257906, 258416, 258927, 259435, 259948, 260458, 260969, 261473, 261990, 262504, 263019, 263527, 264044, 264554, 265065, 265561, 266086, 266608, 267131, 267647, 268172, 268690, 269209, 269713, 270242, 270764, 271287, 271795, 272320, 272830, 273341, 273821, 274362, 274900, 275439, 275971, 276512, 277046, 277581, 278101, 278646, 279184, 279723, 280247, 280788, 281314, 281841, 282337, 282890, 283436, 283983, 284515, 285064, 285598, 286133, 286637, 287190, 287728, 288267, 288775, 289316, 289826, 290337, 290785, 291358, 291928, 292499, 293063, 293636, 294202, 294769, 295321, 295898, 296468, 297039, 297595, 298168, 298726, 299285, 299813, 300398, 300976, 301555, 302119, 302700, 303266, 303833, 304369, 304954, 305524, 306095, 306635, 307208, 307750, 308293, 308773, 309374, 309968, 310563, 311143, 311740, 312322, 312905, 313457, 314058, 314644, 315231, 315787, 316376, 316934, 317493, 317989, 318598, 319192, 319787, 320351, 320948, 321514, 322081, 322585, 323186, 323756, 324327, 324835, 325408, 325918, 326429, 326813, 327450, 328084, 328719, 329347, 329984, 330614, 331245, 331861, 332502, 333136, 333771, 334391, 335028, 335650, 336273, 336865, 337514, 338156, 338799, 339427, 340072, 340702, 341333, 341933, 342582, 343216, 343851, 344455, 345092, 345698, 346305, 346849, 347514, 348172, 348831, 349475, 350136, 350782, 351429, 352045, 352710, 353360, 354011, 354631, 355284, 355906, 356529, 357089, 357762, 358420, 359079, 359707, 360368, 360998, 361629, 362197, 362862, 363496, 364131, 364703, 365340, 365914, 366489, 366937, 367634, 368324, 369015, 369691, 370384, 371062, 371741, 372389, 373086, 373768, 374451, 375103, 375788, 376442, 377097, 377689, 378394, 379084, 379775, 380435, 381128, 381790, 382453, 383053, 383750, 384416, 385083, 385687, 386356, 386962, 387569, 388049, 388770, 389476, 390183, 390859, 391568, 392246, 392925, 393541, 394254, 394936, 395619, 396239, 396924, 397546, 398169, 398665, 399386, 400076, 400767, 401395, 402088, 402718, 403349, 403853, 404550, 405184, 405819, 406327, 406964, 407474, 407985, 408241, 409006, 409768, 410531, 411287, 412052, 412810, 413569, 414313, 415082, 415844, 416607, 417355, 418120, 418870, 419621, 420341, 421118, 421888, 422659, 423415, 424188, 424946, 425705, 426433, 427210, 427972, 428735, 429467, 430232, 430966, 431701, 432373, 433166, 433952, 434739, 435511, 436300, 437074, 437849, 438593, 439386, 440164, 440943, 441691, 442472, 443222, 443973, 444661, 445462, 446248, 447035, 447791, 448580, 449338, 450097, 450793, 451586, 452348, 453111, 453811, 454576, 455278, 455981, 456557, 457382, 458200, 459019, 459823, 460644, 461450, 462257, 463033, 463858, 464668, 465479, 466259, 467072, 467854, 468637, 469357, 470190, 471008, 471827, 472615, 473436, 474226, 475017, 475745, 476570, 477364, 478159, 478891, 479688, 480422, 481157, 481765, 482614, 483448, 484283, 485087, 485924, 486730, 487537, 488281, 489122, 489932, 490743, 491491, 492304, 493054, 493805, 494429, 495278, 496096, 496915, 497671, 498492, 499250, 500009, 500641, 501466, 502228, 502991, 503627, 504392, 505030, 505669, 506053, 506942, 507824, 508707, 509575, 510460, 511330, 512201, 513041, 513930, 514804, 515679, 516523, 517400, 518246, 519093, 519877, 520774, 521656, 522539, 523391, 524276, 525130, 525985, 526777, 527666, 528524, 529383, 530179, 531040, 531838, 532637, 533309, 534222, 535120, 536019, 536887, 537788, 538658, 539529, 540337, 541242, 542116, 542991, 543803, 544680, 545494, 546309, 546997, 547910, 548792, 549675, 550495, 551380, 552202, 553025, 553721, 554610, 555436, 556263, 556963, 557792, 558494, 559197, 559645, 560590, 561520, 562451, 563351, 564284, 565186, 566089, 566929, 567866, 568772, 569679, 570523, 571432, 572278, 573125, 573845, 574790, 575704, 576619, 577471, 578388, 579242, 580097, 580825, 581746, 582604, 583463, 584195, 585056, 585790, 586525, 587005, 587966, 588896, 589827, 590695, 591628, 592498, 593369, 594113, 595050, 595924, 596799, 597547, 598424, 599174, 599925, 600421, 601366, 602248, 603131, 603887, 604772, 605530, 606289, 606793, 607682, 608444, 609207, 609715, 610480, 610990, 611501, 611501, 611501, 611501, 611502, 611502, 611505, 611507, 611510, 611510, 611517, 611523, 611530, 611534, 611543, 611549, 611556, 611556, 611571, 611585, 611600, 611612, 611629, 611643, 611658, 611666, 611687, 611705, 611724, 611736, 611757, 611771, 611786, 611786, 611817, 611847, 611878, 611906, 611939, 611969, 612000, 612024, 612061, 612095, 612130, 612158, 612195, 612225, 612256, 612272, 612317, 612359, 612402, 612438, 612483, 612521, 612560, 612584, 612633, 612675, 612718, 612746, 612791, 612821, 612852, 612852, 612915, 612977, 613040, 613100, 613165, 613227, 613290, 613346, 613415, 613481, 613548, 613608, 613677, 613739, 613802, 613850, 613927, 614001, 614076, 614144, 614221, 614291, 614362, 614418, 614499, 614573, 614648, 614708, 614785, 614847, 614910, 614942, 615035, 615125, 615216, 615300, 615393, 615479, 615566, 615638, 615735, 615825, 615916, 615992, 616085, 616163, 616242, 616290, 616395, 616493, 616592, 616676, 616777, 616863, 616950, 617006, 617111, 617201, 617292, 617352, 617445, 617507, 617570, 617570, 617697, 617823, 617950, 618074, 618203, 618329, 618456, 618576, 618709, 618839, 618970, 619094, 619227, 619353, 619480, 619592, 619733, 619871, 620010, 620142, 620283, 620417, 620552, 620672, 620817, 620955, 621094, 621218, 621359, 621485, 621612, 621708, 621865, 622019, 622174, 622322, 622479, 622629, 622780, 622916, 623077, 623231, 623386, 623526, 623683, 623825, 623968, 624080, 624249, 624411, 624574, 624722, 624887, 625037, 625188, 625308, 625477, 625631, 625786, 625910, 626067, 626193, 626320, 626384, 626573, 626759, 626946, 627126, 627315, 627497, 627680, 627848, 628041, 628227, 628414, 628586, 628775, 628949, 629124, 629268, 629469, 629663, 629858, 630038, 630235, 630417, 630600, 630752, 630953, 631139, 631326, 631482, 631671, 631829, 631988, 632084, 632301, 632511, 632722, 632918, 633131, 633329, 633528, 633696, 633913, 634115, 634318, 634490, 634695, 634869, 635044, 635156, 635381, 635591, 635802, 635982, 636195, 636377, 636560, 636680, 636897, 637083, 637270, 637394, 637583, 637709, 637836, 637836, 638091, 638345, 638600, 638852, 639109, 639363, 639618, 639866, 640127, 640385, 640644, 640896, 641157, 641411, 641666, 641906, 642175, 642441, 642708, 642968, 643237, 643499, 643762, 644010, 644283, 644549, 644816, 645068, 645337, 645591, 645846, 646070, 646355, 646637, 646920, 647196, 647481, 647759, 648038, 648302, 648591, 648873, 649156, 649424, 649709, 649979, 650250, 650490, 650787, 651077, 651368, 651644, 651937, 652215, 652494, 652742, 653039, 653321, 653604, 653856, 654141, 654395, 654650, 654842, 655159, 655473, 655788, 656096, 656413, 656723, 657034, 657330, 657651, 657965, 658280, 658580, 658897, 659199, 659502, 659774, 660103, 660425, 660748, 661056, 661381, 661691, 662002, 662282, 662611, 662925, 663240, 663524, 663841, 664127, 664414, 664638, 664983, 665321, 665660, 665984, 666325, 666651, 666978, 667274, 667619, 667949, 668280, 668580, 668913, 669215, 669518, 669758, 670111, 670449, 670788, 671096, 671437, 671747, 672058, 672306, 672651, 672965, 673280, 673532, 673849, 674103, 674358, 674486, 674867, 675245, 675624, 675996, 676377, 676751, 677126, 677486, 677871, 678249, 678628, 678992, 679373, 679739, 680106, 680442, 680835, 681221, 681608, 681980, 682369, 682743, 683118, 683462, 683855, 684233, 684612, 684960, 685341, 685691, 686042, 686330, 686739, 687141, 687544, 687932, 688337, 688727, 689118, 689478, 689887, 690281, 690676, 691040, 691437, 691803, 692170, 692474, 692891, 693293, 693696, 694068, 694473, 694847, 695222, 695534, 695943, 696321, 696700, 697016, 697397, 697715, 698034, 698226, 698667, 699101, 699536, 699956, 700393, 700815, 701238, 701630, 702071, 702497, 702924, 703320, 703749, 704147]\nprint(a[int(input())])", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "f006d77bad35b82bc0416f8d13ce55b2", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "k,n,w=map(int,input().split())\nl=[]\nfor i in range(1,w+1):\n    l.append(i)\np=0\nfor ele in range(0,len(l)):\n    p=p+l[ele]\nr=((p)*k)-n\nif (r>0):\n    print(r)\nelse:\n    print(\"0\")\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "757dd003778f7c7a419688f3b4663dbc", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,k = map(int,raw_input().split())\nprint max(0,3*n-k)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "a3aa2e91f9a0c0bfbbfd9146604189eb", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = list(map(int, input().split()))\na = set()\nb = set()\nfor i in range(n[2]//n[0]):\n a.add((i+1)*n[0])\nfor i in range(n[2]//n[1]):\n b.add((i+1)*n[1])\nprint(len(a & b))", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "d62c78efb9dc6541e7ef583be9972947", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\npieces = list(map(int, input().split(' ')))\npieces.sort()\ndef even():\n    diffEven = 0\n    for i in range(len(pieces)):\n        diffEven += abs(pieces[i] - ((i+1)*2))\n        \n    return(diffEven)\n    \ndef odd():\n    diffOdd = 0\n    for j in range(len(pieces)):\n        diffOdd += abs(pieces[j] - ((j*2)+1))\n        \n    return(diffOdd)\n\nwhite = even()\nblack = odd()\n\nprint(min(black, white))\n        ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e567b9b9502a54ff54e9a6846087d2da", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "\r\nn, x = map(int, input().split(\" \"))\r\nmodulus = 998244353\r\nnegceil = lambda x: 0 if x < 0 else x\r\ndp = [[-1 for _ in range(1000)] for _ in range(505)]\r\n\r\nmx = 505\r\nfac = [1] * mx\r\nfor i in range(1, mx):\r\n    fac[i] = fac[i - 1] * i % modulus\r\nifac = [1] * 505\r\nifac[-1] = pow(fac[-1], modulus - 2, modulus)\r\nfor i in range(mx - 2, 0, -1):\r\n    ifac[i] = (i + 1) * ifac[i + 1] % modulus\r\ndef C(a, b):\r\n    return fac[a] * ifac[a - b] % modulus * ifac[b] % modulus\r\n\r\ndef solve(rem, thresh):\r\n    prev_thresh = thresh - rem + 1\r\n    global dp\r\n    if rem == 1:\r\n        return 0\r\n    if rem == 0:\r\n        return 1\r\n    if prev_thresh >= x:\r\n        return 0\r\n\r\n    if dp[rem][thresh] != -1:\r\n        return dp[rem][thresh]\r\n\r\n\r\n    dp[rem][thresh] = 0\r\n\r\n    for p in range(rem + 1):\r\n        combs = C(rem, p)\r\n        assigns = pow( (min(thresh, x) - prev_thresh), p, modulus)\r\n        dp[rem][thresh] += combs * assigns * solve(rem - p, thresh + (rem - p - 1))\r\n        dp[rem][thresh] %= modulus\r\n\r\n    return dp[rem][thresh]\r\n\r\nprint(solve(n, n - 1))\r\n\r\n\"\"\"\r\n+31 247 247 247 \r\n\r\nback office GGP\r\n08005090\r\n\"\"\"", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "54e3d9c2504f85b70a113ece0006065a", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "variants, volume = map(int, input().split())\ncost = [int(x) for x in input().split()]\nfor i in range(1, variants):\n    cost[i] = min(cost[i], 2*cost[i-1])\nwhile len(cost) < 32:\n    cost.append(cost[-1]*2)\nans = 0\nbinaryRepresentation = list(bin(volume)[2:])\nwhile len(binaryRepresentation) < 32:\n    binaryRepresentation = ['0'] + binaryRepresentation\nbinaryRepresentation.reverse()\nfor i in range(len(cost)):\n    if binaryRepresentation[i] == '1':\n        ans += cost[i]\n    else:\n        ans = min(ans, cost[i])\nprint(ans)", "lang_cluster": "Python", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "9a8ed7db84963417705eaa019ff07e68", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=input()\nt=n[0]\nu=n[1]\nf=0\nli=[]\nk=list(map(str,input().split()))\nfor i in k:\n  for j in i:\n    li.append(j)\nif t in li:\n  f=1\nif u in li:\n  f=1\nif f==1:\n  print(\"YES\")\nelse:\n  print(\"NO\")\n\n\n\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "d03c9b7527e3b701d6888fe5ef8b7702", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nn = int(input())\ns = input()\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", "tags": ["dp"], "code_uid": "f236543d41a3e01940ffff752ca564be", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from math import sqrt\ndef calc(n,m):\n    count = 0\n    for a in range(m+1):\n        if a**2 + sqrt(m-a) == n:\n            count += 1\n    return count\n\n# get inputs\nn,m = map(int, input().split())\n\nprint(calc(n,m))\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "987bed3a8fa971502776f22761c82a06", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import  math\nimport urllib\nimport  urllib2\nlen=0\ndict=[]\nn =input()\narr=map(int,raw_input().split())\narr.sort(reverse=True)\nfor i  in range(n):\n    while dict.count(arr[i]):\n        arr[i]-=1\n    if(arr[i]>0):\n        len+=arr[i]\n        dict.append(arr[i])\nprint len", "lang_cluster": "Python", "tags": ["sortings", "greedy"], "code_uid": "b544cf4f80c7f4fb6acb73bbca383267", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "N, M, K = map(int, input().split())\nN = N // K + bool(N % K)\nM = M // K + bool(M % K)\n\nprint(N * M)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "e5c99b4a159a55022a36f5789104fba4", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from itertools import product\nn = raw_input()\nprint sum([len(list(product('47', repeat=len(n) - i))) for i in xrange(1, len(n))]) + list(product('47', repeat=len(n))).index(tuple(n)) + 1\n", "lang_cluster": "Python", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "ff5a583678e3d345c2419861ca7e133b", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "t = raw_input()\ns = [c for c in t]\n\nl = len(t);\nd = (l>>1) + (l&1);\nk=-1\nfor i in range(l):\n    d += k*i\n    s[i] = t[d-1]\n    k = -k\n\n    \nprint ''.join(s)\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "3015283ecadd3c0784c0e0f56d37e779", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn = int(input())\na = [int(i) for i in input().split() ]\navr = 0\na.sort()\nfor i in a:\n    avr += i\navr = avr / n\nif avr-4.5 >=0:\n    print(0)\nelse:\n    num = 4.5 - avr\n    num = num * n\n    if abs(int(num)-num)>0.0000001:\n        num = math.ceil(num)\n    else:\n        num = int(num)\n    cnt = 0\n    for i in a:\n        num += i - 5\n        cnt += 1\n        if num <= 0:\n            break\n    print(cnt)\n", "lang_cluster": "Python", "tags": ["sortings", "greedy"], "code_uid": "fb1c8fac37d67d0a0d0043deea8d9d53", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "words = set(\"abcdefghijklmnopqrstuvwxyz\")\nchar_list = set()\nfor x in words:\n    char_list.add(x)\ninput()\nfor x in set(input().lower()):\n    if x in char_list:\n        char_list.remove(x)\n        if len(char_list) == 0:\n            break\n        \nif len(char_list) == 0:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "c35b7f2ab244c095a9a78cd17ac9d292", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "# coding: utf-8\r\n\r\nh, w = map(int, input().split())\r\na = [input() for i in range(h)]\r\nberries = i = j = 0\r\n\r\nwhile i < h and j < w:\r\n  if a[i][j] == '*':\r\n    berries += 1\r\n    \r\n  if i < h - 1 and a[i + 1][j] == '*':\r\n    i += 1\r\n    \r\n  else:\r\n    if j < w - 1:\r\n      j += 1\r\n      \r\n    else:\r\n      i += 1\r\n      \r\nprint(berries)", "lang_cluster": "Python", "tags": ["greedy", "implementation", "shortest paths"], "code_uid": "0419201f09a3763d9f1a3446003bcc04", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "x=input()\nif x%4==0:\n    print \"1 A\"\nelif x%4==1:\n    print \"0 A\"\nelif x%4==2:\n    print \"1 B\"\nelse:\n    print \"2 A\"\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "387c2e7f5691d6b25bab7b62d2414ecf", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\n\nif n % 2 == 1:\n    print 1\nelse:\n    print 2\n    \n", "lang_cluster": "Python", "tags": ["math", "games"], "code_uid": "c79a99c27b861e8560d6f44f6b087ef3", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "x=input()\na=map(int,raw_input().split())\nif min(a) < 0:\n\tx1=0\n\tx2=0\n\tfor i in a:\n\t\tif i>0:x1+=i\n\t\telse:x2+=i\n\tprint x1-x2\nelse:\n\tprint sum(a)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "b5f9358405f85d818de3cb8b5fd86bac", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nl=c*2\nx=min(a,b)\nl+=x*2\nif(b>a):\n    b=b-a\n    a=a-x\nelse:\n    a=a-b\n    b=b-x\nif(a!=0 or b!=0):\n    l+=1\nprint(l)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "c959aa60228a4526c9a2099cb1fb8030", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x=input()\nx=x.split(' ')\nn=int(x[0])\nd=int(x[1])\nx=input()\nx=x.split(' ')\nfor i in range(n):\n    x[i]=int(x[i])\nx.sort()\nl = []\nfor i in range(0, n):\n    for j in range(i+1, n):\n        if (x[j]-x[i])<=d:\n            l.append(i + (n - j) - 1)\nif l == []:\n    print(n-1)\nelse:\n     print(min(l))\n", "lang_cluster": "Python", "tags": ["brute force", "sortings", "greedy"], "code_uid": "20c768b19dd414a5b3f4e10cbe7b2a4e", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def main():\n\tn = int(input())\n\tprint(solver(n))\n\ndef solver(n):\n\tfactors = [2, 3, 5, 7]\n\tsingles = n // 2 + n // 3 + n // 5 + n // 7\n\tpairs = n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + \\\n\tn // (3 * 5) + n // (3 * 7) + n // (5 * 7)\n\ttriples = n // (2 * 3 * 5) + n // (2 * 3 * 7) + \\\n\tn // (2 * 5 * 7) + n // (3 * 5 * 7)\n\tquads = n // (2 * 3 * 5 * 7)\n\treturn n - singles + pairs - triples + quads\n\nmain()", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "55019f26f970076f44fd5b6f9d161b40", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import heapq\n\nclass mcf_graph_int_cost:\n\n    def __init__(self, n):\n        self.n = n\n        self.pos = []\n        self.g = [[] for _ in range(n)]\n\n\n    def add_edge(self, from_, to, cap, cost):\n        # assert 0 <= from_ < self.n\n        # assert 0 <= to < self.n\n        m = len(self.pos)\n        self.pos.append((from_, len(self.g[from_])))\n        self.g[from_].append(self.__class__._edge(to, len(self.g[to]), cap, cost))\n        self.g[to].append(self.__class__._edge(from_, len(self.g[from_]) - 1, 0, -cost))\n        return m\n\n\n    class edge:\n        def __init__(self, from_, to, cap, flow, cost):\n            self.from_ = from_\n            self.to = to\n            self.cap = cap\n            self.flow = flow\n            self.cost = cost\n\n\n    def get_edge(self, i):\n        _e = self.g[self.pos[i][0]][self.pos[i][1]]\n        _re = self.g[_e.to][_e.rev]\n        return self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost)\n\n\n    def edges(self):\n        ret = []\n        for i in range(len(self.pos)):\n            _e = self.g[self.pos[i][0]][self.pos[i][1]]\n            _re = self.g[_e.to][_e.rev]\n            ret.append(self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost))\n        return ret\n\n\n    def _dual_ref(self, s, t):\n        self.dist = [4294967295] * self.n\n        self.pv = [-1] * self.n\n        self.pe = [-1] * self.n\n        self.vis = [False] * self.n\n\n        que = [s] # s ==  (0 << 32) + s \n        self.dist[s] = 0\n        while que:\n            v = heapq.heappop(que) & 4294967295\n            if self.vis[v]:\n                continue\n            self.vis[v] = True\n            if v == t:\n                break\n            for i in range(len(self.g[v])):\n                e = self.g[v][i]\n                if self.vis[e.to] or e.cap == 0:\n                    continue\n                cost = e.cost - self.dual[e.to] + self.dual[v]\n                if self.dist[e.to] > self.dist[v] + cost:\n                    self.dist[e.to] = self.dist[v] + cost\n                    self.pv[e.to] = v\n                    self.pe[e.to] = i\n                    heapq.heappush(que, ((self.dist[e.to] << 32) + e.to))\n        if not self.vis[t]:\n            return False\n\n        for v in range(self.n):\n            if not self.vis[v]:\n                continue\n            self.dual[v] -= self.dist[t] - self.dist[v]\n        \n        return True\n\n\n    def slope(self, s, t, flow_limit=4294967295):\n        # assert 0 <= s < self.n\n        # assert 0 <= t < self.n\n        # assert s != t\n        \n        self.dual = [0] * self.n\n        self.dist = [4294967295] * self.n\n        self.pv = [-1] * self.n\n        self.pe = [-1] * self.n\n        self.vis = [False] * self.n\n        \n        flow = 0\n        cost = 0\n        prev_cost = -1\n        result = [(flow, cost)]\n        while flow < flow_limit:\n            if not self._dual_ref(s, t):\n                break\n            c = flow_limit - flow\n            v = t\n            while v != s:\n                c = min(c, self.g[self.pv[v]][self.pe[v]].cap)\n                v = self.pv[v]\n            v = t\n            while v != s:\n                e = self.g[self.pv[v]][self.pe[v]]\n                e.cap -= c\n                self.g[v][e.rev].cap += c\n                v = self.pv[v]\n            d = -self.dual[s]\n            flow += c\n            cost += c * d\n            if prev_cost == d:\n                result.pop()\n            result.append((flow, cost))\n            prev_cost = cost\n        return result\n\n\n    def flow(self, s, t, flow_limit=4294967295):\n        return self.slope(s, t, flow_limit)[-1]\n\n    \n    class _edge:\n        def __init__(self, to, rev, cap, cost):\n            self.to = to\n            self.rev = rev\n            self.cap = cap\n            self.cost = cost\n\nINF = 10 ** 9\n\nn = int(input())\na1, a2, a3 = map(int, input().split())\nb1, b2, b3 = map(int, input().split())\n\ng = mcf_graph_int_cost(8)\ng.add_edge(0, 1, a1, 0)\ng.add_edge(0, 2, a2, 0)\ng.add_edge(0, 3, a3, 0)\ng.add_edge(4, 7, b1, 0)\ng.add_edge(5, 7, b2, 0)\ng.add_edge(6, 7, b3, 0)\nfor i in range(1, 4):\n    for j in range(4, 7):\n        cost = 1 if (j - i) % 3 == 1 else 0\n        g.add_edge(i, j, INF, cost)\n\nf, ans1 = g.flow(0, 7)\n\nans2 = min(a1, b2) + min(a2, b3) + min(a3, b1)\nprint(ans1, ans2)\n\n", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "8806dfdbd7ab0547c928aa6cc522d66f", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import re\nl = raw_input()\ns = raw_input()\nbat = []\nfor i in re.findall('\\((.*?)\\)', s):\n    bat.extend([j for j in i.split('_') if j != ''])\n\ncat = [len(i )for i in re.sub('\\((.*?)\\)','_', s).split('_')]\nprint max(cat), len(bat)", "lang_cluster": "Python", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "e33fa27521bc995e8c563efb637701f5", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, a, x, b, y = map(int, input().split())\n\ni = a\nj = b\n\nwhile (i != x and j != y):\n    if (i == j):\n        print('YES')\n        quit()\n\n    i = i + 1\n    j = j - 1\n\n    if (i > n):\n        i = 1\n    if (j == 0):\n        j = n\n\nif (i == j):\n    print('YES')\n    quit()\n\nprint('NO')\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "d5d75a528693c9ea5e385f401ecf840b", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b, c =[int(q) for q in input().split()]\nx, y, z =[int(q) for q in input().split()]\nif a>=x:\n    a -=x\n    x=0\nelse:\n    x -=a\n    a=0\nif b>=y:\n    b -=y\n    y=0\nelse:\n    y -=b\n    b=0\nif c>=z:\n    c -=z\n    z=0\nelse:\n    z -=c\n    c=0\nif x+y+z<=a//2+b//2+c//2:\n    print(\"Yes\")\nelse:\n    print(\"No\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "4fa49fbef2bc1a3b13d419c7ffeabf4a", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\nc = [0]*n + [1] + [0]*n\nfor i in range(n-1, 0, -1):\n    c[i] = 2*c[i+1] % m\n    for j in range(2, n//i + 1):\n        c[i] = (c[i] + c[i*j] - c[(i+1)*j]) % m\n \nprint((c[1] - c[2]) % m)", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "58928e717bec55ed2fb9cd0ed320b787", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n1,n2,k1,k2=map(int,input().split())\n\nif n1==n2:\n    print(\"Second\")\nelif n1>n2:\n    print(\"First\")\nelse:\n    print(\"Second\")", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "bbea24da1a20ad55103a27bad51c5882", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k=map(int,input().split())\nif n%2==0 :\n    if (k > n//2) :\n        print((k-n//2)*2)\n    else :\n        print(2*k - 1)\nelse :\n    if (k > ((n-1)//2)+ 1) :\n        print((k-1-((n-1)//2))*2)\n    else :\n        print(2*k - 1)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "e30a8a57dd6baed05c58727c914bbf11", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 31 18:23:00 2019\n\n@author: apple\n\"\"\"\nn=int(input())\nes=input()\nc=[]\nsum=0\nfor i in range(n):\n    if(sum<n):\n        c.append(es[sum])\n        sum+=i\n    else:\n        break\ns=\"\"\nfor i in range(len(c)):               #coonteestt\n     s+=c[i] \nif(n>1):\n   print(s[1:])\nelse:\n    print(es)\n     ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "224b877d5109632528b49e9833f2207b", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def f(n):\n    # Build maximum number of pieces for\n    #length 1 upto n in bottom up manner\n    dp = [float(\"-inf\")] * (n + 1)\n \n    # Base Case\n    dp[0] = 0\n \n    # dp[i] gives maximum number of pieces that can\n    # be obtained by cutting ribbon of length  i into pieces\n    # of length a, b or c\n    # dp[i] = -inf if it is not possible to cut the ribbon into pieces\n    for i in range(1, n + 1):\n        for length in l:\n            # Cut into pieces if only we dont have negative length of ribbon\n            if i - length >= 0:\n                dp[i] = max(dp[i], 1 + dp[i - length])\n    # return maximum number of pieces possible for ribbon with length n\n    return dp[n]\n \n \nl = list(map(int, input().split()))\nn, l = l[0], l[1:]\nprint(f(n))", "lang_cluster": "Python", "tags": ["brute force", "dp"], "code_uid": "c155139d34bf2eb226311b8978705e78", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def whereis(k):\n    n = 1\n    while k > 0:\n        k -= 9*10**(n-1)*n\n        n+=1\n    else:\n        n-= 1\n        return n\n\ndef kthdigit(k):\n    a = whereis(k)\n    sequence = ''\n    sum = 0\n    for b in range(1, a):\n        sum += 9*10**(b-1)*b\n    i = k-sum\n    divider = (i-1)/a    \n    remainder = (i-1)%a    \n    number = divider + 10**(a-1)\n    string = ''\n    for huh in range (number, number+1):\n        string += str(huh)\n        \n    return string[remainder]\nwe = input()\nprint kthdigit(we)\n\n        \n\n    \n    ", "lang_cluster": "Python", "tags": ["divide and conquer", "implementation", "binary search"], "code_uid": "3f404a6603229844d1cde69a8ca5d611", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\n\nif __name__ == '__main__':\n    num = int(input().strip())\n    segments = []\n    for i in range(1,num + 1):\n        for j in range(num):\n            if j + i > num:\n                break\n            segments.append((j,j+i))\n    #print(segments)\n    segments.sort(key = lambda x: (x[0],x[1]))\n    count = 0\n    while segments != []:\n        right_end = segments[0][1]\n        j = 0\n        while j < len(segments):\n            if segments[j][0] == right_end:\n                right_end = segments[j][1]\n                segments.remove(segments[j])\n            else:\n                j += 1\n        count += 1\n        segments.remove(segments[0])\n    print(count)\n", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "957d5565049afd643fbb5a2a02419438", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, m = map(int, raw_input().strip().split())\na = map(int, raw_input().strip().split())\n\na = sorted(a)\na.reverse()\n\ndef solve(mid):\n    s = 0\n    for i in range(n):\n        now = a[i] - i/mid\n        if now <= 0:\n            break\n        else:\n            s += now\n    if s >= m:\n        return True\n    else:\n        return False\n\n\nif sum(a) < m:\n    print -1\nelse:\n    l = 1\n    r = n\n    while(l<r):\n        mid = (l+r)/2\n        if(solve(mid)):\n            r = mid\n        else:\n            l = mid+1\n    print l", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "94850dc369f0cf95e7438aa2081d07a5", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a=raw_input()\na=a.lower()\nb=raw_input()\nb=b.lower()\nf=0\nfor i in xrange(len(a)):\n    if a[i]>b[i]:\n        print 1\n        f=0\n        break;\n    if a[i]<b[i]:\n        print -1 \n        f=0\n        break\n    if a[i]==b[i]:\n        f=1\nif f==1:\n    print 0", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "a4af565a66e2ee41b03c6f16a8a4b353", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "xmin, ymin, xmax, ymax, a = 31400, 31400, 0, 0, 0\n\nfor i in range(int(input())):\n\n    x1, y1, x2, y2 = map(int, input().split())\n\n    xmin = min(xmin, x1)\n\n    ymin = min(ymin, y1)\n\n    xmax = max(xmax, x2)\n\n    ymax = max(ymax, y2)\n\n    a += (x2 - x1) * (y2 - y1)\n\nprint('YES' if xmax - xmin == ymax - ymin and a == (xmax - xmin) ** 2 else 'NO')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9602f4c598d4c87342e279df521e32d6", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,x,y=map(int,input().split())\nif ((x==n/2 or  x==n/2+1) and (y==((n/2)) or y==((n/2)+1))):\n    print(\"NO\")\nelse:\n    print(\"YES\")", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "1d85771f485e1e6f0defa8769e237aa4", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import *\n\nn = int(input())\nl = [0 for i in range(n - 2)]\n\nfor i in range(2, n):\n    m = n\n    \n    while m != 0:\n        l[i - 2] += m % i\n        m -= m % i\n        m //= i\n\nzbr = sum(l)\nbr = n - 2\nk = i\n\nfor i in range(1, br + 1):\n    if zbr % i == 0 and br % i == 0:\n        k = i\n        \n\nprint('{}/{}'.format(zbr // k, br // k))\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "4b246ac356a5aead918e5cac54aac1cf", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#include <CodeforcesSolutions.h>\n#include <ONLINE_JUDGE <solution.cf(contestID = \"1391\",problemID = \"A\",method = \"GET\")>.h>\n\"\"\"\n    Author : thekushalghosh\n    Team   : CodeDiggers\n \n    I prefer Python language over the C++ language :p :D\n        \n    Visit my website : thekushalghosh.github.io\n\"\"\"\nimport sys,math,cmath,time\nstart_time = time.time()\n##########################################################################\n################# ---- THE ACTUAL CODE STARTS BELOW ---- #################\n \ndef solve():\n    n = inp()\n    q = 1\n    w = 1\n    for i in range(n,0,-1):\n        q = (q * i) % 1000000007\n        if i != 1:\n            w = (2 * w) % 1000000007\n    print((q - w) % 1000000007)\n \n################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################\n##########################################################################\n \ndef main():\n    global tt\n    if not ONLINE_JUDGE:\n        sys.stdin = open(\"input.txt\",\"r\")\n        sys.stdout = open(\"output.txt\",\"w\")\n    t = 1\n    for tt in range(t):\n        solve()\n    if not ONLINE_JUDGE:\n        print(\"Time Elapsed :\",time.time() - start_time,\"seconds\")\n        sys.stdout.close()\n    \n#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#\ndef inp():\n    return(int(input()))\ndef inlt():\n    return(list(map(int,input().split())))\ndef insr():\n    return(input().strip())\ndef invr():\n    return(map(int,input().split()))\n \n#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#\ndef range_prod(lo,hi):\n    if lo+1 < hi:\n        mid = (hi+lo)//2\n        return range_prod(lo,mid) * range_prod(mid+1,hi)\n    if lo == hi:\n        return lo\n    return lo*hi\n\ndef treefactorial(n):\n    if n < 2:\n        return 1\n    return range_prod(1,n)\ndef pow( x, y): \n\n\tif (y == 1): \n\t\treturn x \n\tif (y == 0): \n\t\treturn 1\n\n\ttemp = pow(x, y // 2) \n\n\ttemp *= temp \n\n\tif (y & 1): \n\t\ttemp *= x \n\n\treturn temp\ndef counter(a):\n    q = [0] * max(a)\n    for i in range(len(a)):\n        q[a[i] - 1] = q[a[i] - 1] + 1\n    return(q)\n \ndef counter_elements(a):\n    q = dict()\n    for i in range(len(a)):\n        if a[i] not in q:\n            q[a[i]] = 0\n        q[a[i]] = q[a[i]] + 1\n    return(q)\n \ndef string_counter(a):\n    q = [0] * 26\n    for i in range(len(a)):\n        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1\n    return(q)\n \ndef factors(n):\n    q = []\n    for i in range(1,int(n ** 0.5) + 1):\n        if n % i == 0: q.append(i); q.append(n // i)\n    return(list(sorted(list(set(q)))))\n \ndef prime_factors(n):\n    q = []\n    while n % 2 == 0: q.append(2); n = n // 2\n    for i in range(3,int(n ** 0.5) + 1,2):\n        while n % i == 0: q.append(i); n = n // i\n    if n > 2: q.append(n)\n    return(list(sorted(q)))\n \ndef transpose(a):\n    n,m = len(a),len(a[0])\n    b = [[0] * n for i in range(m)]\n    for i in range(m): \n        for j in range(n): \n            b[i][j] = a[j][i]\n    return(b)\n#-----------------------------------------------------------------------#\nONLINE_JUDGE = __debug__\nif ONLINE_JUDGE:\n    input = sys.stdin.readline\n    \n    \n    \n    \nmain()", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "2576564e02d93b183ff1b9a2fc46c0ce", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b = input().split()\na, b = int(a), int(b)\na, b = min(a, b), max(a, b)\n\ndef eu(a, b):\n    if a == 0:\n        return b\n    if b == 0:\n        return a\n    if a > b:\n        return eu(a%b, b)\n    return eu(a, b%a)\n\nopt = b - a\nfactor = []\ni = 1\nwhile i**2 < opt+1:\n    if opt % i == 0:\n        factor.append(i)\n        factor.append(int(opt/i))\n    i+=1\n\ntarget = a * b / eu(a, b)\ndrop = 0\n\nfor i in factor:\n    firstupd = a - (a % i) + i\n    secondupd = b - (b % i) + i\n    dres = firstupd * int(secondupd/eu(firstupd,secondupd))\n    if dres <= target:\n        if dres == target:\n            drop = min(i-(a%i),drop)\n        else:\n            target = dres\n            drop = i-(a%i)\nprint(drop)", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "8b34db2607886facf600047b2f94c505", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "R=lambda:map(int,raw_input().split())\nn,m=R()\na=R()\nb=0\nwhile a:\n  c=m\n  while a and c>=a[0]:\n    c-=a.pop(0)\n  b+=1\nprint b\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9f75ab27742d9ff0d2d7ef064328f130", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a=raw_input()\nplus=0\nif a[0:2]=='KK':\n    plus=1\nelse:\n    for i in range(len(a)-1):\n        if a[i:i+3]=='VVV' or a[i:i+3]=='KKK':\n            plus=1\n    if a[-2:]=='VV':\n        plus=1\ncnt=0\nfor i in range(len(a)-1):\n    if a[i:i+2]=='VK':\n        cnt+=1\n        \n    \n    \nprint cnt+plus\n        \n        \n        \n    \n            ", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "358f9286c5cb1c9f8e6a6a6c40692bb7", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k=map(int,input().split())\nmini = min(1,k,n-k)\nmaxi = min(n-k,2*k)\nprint(mini,maxi)", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "6d711418c5718c980bf4e8007ec75396", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "S = raw_input()\nN = len(S)\nfor i in xrange(N + 1):\n    for j in xrange(i, N + 1):\n        if S[:i] + S[j:] == \"CODEFORCES\":\n            print \"YES\"\n            exit()\nprint \"NO\"", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "7399d6afe0a4f2ca357621493b351f5b", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/python\n# coding: utf-8\n\ncw=['v','<','^','>','v','<','^','>']\nccw=['v','>','^','<','v','>','^','<']\n(s,e)=map(str,raw_input().split(' '))\nn=int(raw_input())\nn=n%4\ntmp1=tmp2=0\ncwind=cw.index(s)+n\nccwind=ccw.index(s)+n\nif(cw[cwind]==e):\n    tmp1=1\nif(ccw[ccwind]==e):\n    tmp2=1\nif(tmp1==1 and tmp2==1):\n    print \"undefined\"\nelif(tmp1):\n    print \"cw\"\nelse:\n    print \"ccw\"\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "3f2476f9701f40b67dbd72d12241f8b2", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "put = lambda: tuple(map(int, input().split()))\n\na, b = put()\nif b / a >= 2:\n    print(0)\nelse:\n    used = []\n    ans = 0\n    if b <= a:\n        a = b - 1\n    if b % 2 == 0:\n            up = b // 2\n    else:\n        up = (b - 1) // 2\n    ans = a - up\n    print(ans)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "e30618cf7ec27bc80fc03a060275148c", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "[n, m] = [int(x) for x in input().split()]\nI = 0\nS = 1\nD = 2\nC = 3\nexses = [[0, 0, 0, 0]]\npops = [0] * (n+1)\ni = 1\nwhile i <= m:\n  [s, d, c] = [int(x) for x in input().split()]\n  exses.append([i, s, d, c])\n  pops[d] = i\n  i += 1\n\ni = 1\nresult = [0] * (n+1)\nfail = False\nwhile i <=n:\n  if pops[i] != 0 and exses[pops[i]][C] == 0:\n    result[i] = m+1\n  elif pops[i] != 0 and exses[pops[i]][C] > 0:\n    fail = True\n    break\n  else:\n    ex = None\n    min = n+1\n    for e in exses:\n      if e[D] > i and e[S] <= i and e[D] < min and e[C] > 0:\n        min = e[D]\n        ex = e\n    if ex == None:\n      result[i] = 0\n    else:\n      result[i] = ex[I]\n      ex[C] -= 1\n  i += 1\n\nif fail:\n  print(-1)\nelse:\n  for x in result[1:]:\n    print(x, end=' ')\n", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "fa69155cedaa48f1540c053e15c888a9", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# http://codeforces.com/problemset/problem/450/A\n\nfrom collections import deque\nfrom math import ceil\n# n, m = [int(x) for x in input().split()]\nn, m = map(int, input().split())\ncandies = [int(x) for x in input().split()]\n\nchildren = deque([int(x) for x in range(1, n + 1)])\nhome = []\n\nmax_num = 0\ncounter = 0\ncandies_dict = {}\n\nfor k in candies:\n    counter += 1\n    candies_dict[counter] = k\n\n\nfor i in candies:\n    result = ceil(i / m)\n    if result >= max_num:\n        max_num = ceil(i / m)\n        max_candies = i\n\n# print(candies_dict)\n# print(max_candies)\n\nmax_keys = []\n\nfor k, v in candies_dict.items():\n    if v == max_candies:\n        max_keys.append(k)\n\nprint(max_keys[-1])\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d915f7b6597e4e4e368d12fccd4f7569", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def main():\n  n, k = raw_input().split()\n  k = int(k)\n  if len(n) <= k or n == '0':\n    print len(n) - 1\n    return\n  \n  n = n[::-1]\n  #print n, k\n  numeros_sacados = 0\n  ceros = 0\n  for dig in n:\n    if ceros == k:\n      print numeros_sacados\n      return\n    if dig == '0':\n      ceros += 1\n    else:\n      numeros_sacados += 1\n  print len(n) - 1\n  return\n    \n  \nmain()\n", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "cf66085ddbb2c05cb10a9f4bf16afd36", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\narr = list(map(int, input().split()))\nx,y = min(arr), max(arr)\nif arr.index(x)==0 or arr.index(y)==0 or arr.index(x)==n-1 or arr.index(y)==n-1:\n\tprint(n-1)\nelif arr.index(x) < arr.index(y):\n    print(max(n-1 - arr.index(x), arr.index(y)))\nelif arr.index(x) > arr.index(y):\n    print(max(n-1 - arr.index(y), arr.index(x)))", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "2eda58f7e45050f188ce555cfb7302d0", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "m=1000000007\ndef power(x, y, p=1000000007):\n    res = 1\n    x = x % p \n    while (y > 0) :\n        if ((y & 1) == 1) :\n            res = (res * x) % p\n        y = y >> 1     \n        x = (x * x) % p         \n    return res\nx,k=list(map(int,input().split()))\nif(x==0):\n    print(0)\nelif(k==0):\n    print((x*2)%m)\nelse:\n    temp=power(2,k)\n    maxi=(((x*temp)%m)*2)%m\n    mini=(m+maxi-(2*(temp-1))%m)%m\n    print((((maxi+mini)%m)*500000004)%m)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "1463765403ffb034944766e713bc4f19", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "m,n=map(int,raw_input().split())\nif(m/n)%2==1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"", "lang_cluster": "Python", "tags": ["math", "games"], "code_uid": "70898d766cab336d47a9b80b39cd7c66", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "S = sorted\nM = lambda : map(int,input().split())\nm = int(input())\na = list(M())\ncnto,cnte = 0,0\nfor i in a:\n\tif i == 100:\n\t\tcnto +=1\n\telse:\n\t\tcnte +=1\nif cnto>0 :\n\tif cnto%2==0:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif cnte%2==0:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\n\n        ", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "880da72016d6b4a48aacf084834b90e6", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "lim_w, bob_w = map(int, raw_input().split())\nno_of_years = 0\nwhile lim_w <= bob_w:\n\tlim_w = lim_w * 3\n\tbob_w = bob_w * 2\n\tno_of_years = no_of_years + 1\nprint(no_of_years)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7b95cfaaccfd162322aa1c51923143bb", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def win(l,s):\n    if l[0] == [s, s, s] or l[1] == [s, s, s] or l[2] == [s, s, s] or l[0][0] == s and l[1][0] == s and l[2][0] == s or \\\n            l[0][1] == s and l[1][1] == s and l[2][1] == s or l[0][2] == s and l[1][2] == s and l[2][2] == s or l[0][\n        0] == s and l[1][1] == s and l[2][2] == s or l[0][2] == s and l[1][1] == s and l[2][0] == s:\n        return 1\n    else:\n        return 0\na=list(input())\nb=list(input())\nc=list(input())\nl=[a,b,c]\nmf=a.count('X')+b.count('X')+c.count('X')\nms=a.count('0')+b.count('0')+c.count('0')\nme=a.count('.')+b.count('.')+c.count('.')\nif  mf -ms!= 1 and mf -ms!=0 :\n    print('illegal')\nelse:\n    n=win(l,'0')\n    m=win(l,'X')\n    if n==1 and m==1 or n==1 and mf-ms!=0 or m==1 and mf-ms!=1:\n        print('illegal')\n    elif n==1:\n        print('the second player won')\n    elif m==1:\n        print('the first player won')\n    else:\n        if me==0:\n            print('draw')\n        elif mf-ms==1:\n            print('second')\n        else:print('first')", "lang_cluster": "Python", "tags": ["brute force", "implementation", "games"], "code_uid": "5810cb185e940b3920d69c59b78f90a1", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def gcd(a,b):\n    if b==0:\n        return a\n    return gcd(b,a%b)\nt,a,b=map(int,raw_input().split())\nG=gcd(a,b)\np=a*b\nL=a*b\nL=L/G\nans=0\nif a<b:\n    ans+=(a-1)\nelse:\n    ans+=(b-1)\nt1=t/L\nans+=t1\ndiff=0\nif a<b:\n    diff=a-1\nelse:\n    diff=b-1\nans+=(diff*(t1-1))\nm=t1*L\nans+=min(diff,t-m)\nGG=gcd(ans,t)\nans/=GG\nt/=GG\nprint str(ans)+\"/\"+str(t)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "d9d0a1cdbcd7c7ce72b451cd22e1b151", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "for _ in range(int(input())):\n    n,k,l=map(int,input().split())\n    depth=list(map(int,input().split()))\n    fg=1;mn=-k;mx=k\n    for i in depth:\n        if i>l:fg=0;break\n        mx=min(l-i,k)\n        if mx==k:mn=-k\n        else:mn=max(mn+1,-mx)\n        if mn>mx:fg=0;break\n    if fg:print(\"Yes\")\n    else:print(\"No\")", "lang_cluster": "Python", "tags": ["brute force", "greedy", "dp"], "code_uid": "489342b44d06297d8acdac68b7096a4d", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k2, k3, k5, k6 = map(int, input().split())\n\nsum256 = 0\n\nsum32 = 0 \n\nwhile ( k2 > 0 and k5 > 0 and k6 > 0 ):\n    x = min(k2, k5, k6)\n    sum256 += (256 * x)\n    k2 -= x\n    k5 -= x\n    k6 -= x\n\nwhile ( k2 > 0 and k3 > 0 ):\n    x = min(k2, k3)\n    sum32 += (32 * x)\n    k2 -= x\n    k3 -= x\n\nresult = sum256 + sum32\nprint(result)", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "cf829a51bf07d820a817a20af5cc1543", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "li=map(int,raw_input().split())\n\n\n\"\"\"initially number shows n\"\"\"\n\nn=li[0]\nm=li[1]\n\ncount=0\n\nwhile n<m:\n    if m%2==0:\n        m=m/2\n    else:\n        m=m+1\n    count=count+1\n\nprint count+(n-m)\n", "lang_cluster": "Python", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "07968cd525593f346cc1f79c6b810294", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s=input()\np=set()\nfor i in s:\n    p.add(i)\nif len(p)%2 == 0:\n    print(\"CHAT WITH HER!\")\nelse:\n    print(\"IGNORE HIM!\")", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "2362a3ad4b4b2dd4ba99cbd258e1a00b", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\n\ndef solve():\n    s = [ch for ch in input()]\n    n = len(s)\n\n    for i in range(n):\n        if i != n - 1 - i and s[i] == s[n - 1 - i]:\n            continue\n\n        tmp = s[i]\n        s[i] = s[n - 1 - i]\n\n        if s == s[::-1]:\n            print('YES')\n            return\n\n        s[i] = tmp\n\n    print('NO')\n\nif __name__ == '__main__':\n    solve()", "lang_cluster": "Python", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "24bcda4e28c32ac54de29216d818dc36", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a,b,c,d,x,y=map(int, input().split())\ncontador=0\nwhile (x<=y):\n    if(x%a%b%c%d==x):\n        contador=contador+1\n    x=x+1\nprint(contador)\n", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "d6f972f7682ad0e6a1b0c7c16e5a62d6", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\n\nm = 3\nwhile n % m == 0:\n    m *= 3\n\nprint(int(n // m + 1))\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "f08aa882a8bbc4cf8720de52de683d73", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def red(m,n):\n    while n:\n        m,n = n, m%n\n    return m\n\ndef main():\n    x = int(input())\n    m = int((x-1)/2)\n    n = int(x-m)\n    while red(m,n) != 1:\n        m = m-1\n        n = x-m\n    print(m,n)\n\nif __name__ == \"__main__\" : main()  \n", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "3aa573c0034e48e387c47b36ec08459e", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "s=raw_input()\ncu=0\ncl=0\nt=len(s)\nfor i in xrange(t):\n    if s[i].isupper()==True:\n        cu=cu+1\n    else:\n        cl=cl+1\n        \nif cu>cl:\n    print s.upper()\nelse:\n    print s.lower()", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "18af808fa370216254559d6559e8c3fe", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\nx=y=1\nr=0\nwhile (x<=n):\n  r+=1\n  y+=1\n  x=int(bin(y)[2:])\nprint(r)", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "a954e33b8372e03efd21541b3233ab69", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#coding=utf-8\n\n\nxA,yA = map(int, raw_input().split())\nxB,yB = map(int, raw_input().split())\nxC,yC = map(int, raw_input().split())\n\nxAB,yAB=xA-xB,yA-yB\nxBC,yBC=xB-xC,yB-yC\n\ns = xAB*yBC-yAB*xBC\n\n#print s\nif s == 0:\n\tprint \"TOWARDS\"\nelif s > 0:\n\tprint \"LEFT\"\nelse:\n\tprint \"RIGHT\"\n", "lang_cluster": "Python", "tags": ["geometry"], "code_uid": "66da2c9aa1bf852b3577e2526663d1ca", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "lemons = int(input())\napples = int(input()) // 2\npears = int(input()) // 4\ntotal_sum = min(lemons, apples, pears) * 7\nif apples * 2 < 2 or pears * 4 < 4:\n    print(0)\nelse:\n    print(total_sum)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5bc8dfe3da82d9839c5fdcb833411e31", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nimport math\nfrom statistics import mean\nfrom collections import Counter\n\ninput = sys.stdin.readline\n\n\n############ ---- Input Functions ---- ############\ndef inp():\n    return (int (input ()))\n\n\ndef inlt():\n    return (list (map (int, input ().split ())))\n\n\ndef insr():\n    s = input()\n    return (list (s[:len (s) - 1]))\n\n\ndef invr():\n    return (map (int, input ().split ()))\n\n\nn,k,l,c,d,p,nl,np = invr()\n\na = k*l\na = int(a/nl)\nb = c*d\ns = p/np\nans = min(a,b,s)\nans = int(ans/n)\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "be7afef701828cb49aa36c30664004fc", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import copy\n\ndef elimina_lista(lista, posicao):\n    i = posicao\n    j = i\n    cont2 = 0\n    while lista[i] == lista[j]:\n        cont = 2\n        while i > 0 and lista[i-1] == lista[i]:\n            i -= 1\n            cont += 1\n        while j < len(lista)-1 and lista[j+1] == lista[j]:\n            j += 1\n            cont += 1\n\n        i -= 1\n        j += 1\n        if cont >= 3:\n            cont2 += cont\n            if i < 0 or j >= len(lista):\n                 break\n        else:\n            break\n    return cont2\n\nn, k, x = map(int, raw_input().split())\nlista = map(int, raw_input().split())\nlista3 = []\n\n\nfor i in xrange(len(lista)):\n    if lista[i] == x:\n        if lista[i] != lista[i-1]:\n            lista2 = copy.copy(lista)\n            lista3.append(elimina_lista(lista2, i))\n\nif lista3 == []:\n    print 0\nelif max(lista3) <= 0:\n    print 0\nelse:\n    print max(lista3) -1", "lang_cluster": "Python", "tags": ["two pointers", "brute force"], "code_uid": "bae5aa80e9b24060839a291fd4fc1976", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from math import factorial\na, b = map(int, raw_input().split())\nprint factorial(min(a, b))", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "415fbfd877fce6ddc474d5d8b54a50f1", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = int(raw_input())\nprint (n/7)*2 + max(0, n % 7 - 5), (n/7)*2 + min(2, n%7)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "f1949127b68856d866a6ebb4a680331b", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def assign(n,i):\n\tfor e in range(i,len(n),4):\n\t\tif n[e]==\"!\":\n\t\t\tcontinue\n\t\telse:\n\t\t\treturn n[e]\nn = list(input())\nl2 = [0]*4\nfor i in range(4):\n\tl2[i]=assign(n,i)\ndi = {l2[0]:0,l2[1]:0,l2[2]:0,l2[3]:0}\nfor i in range(len(n)):\n\tif n[i]==\"!\":\n\t\tdi[l2[i%4]]+=1\nprint(di['R'],di['B'],di['Y'],di['G'])", "lang_cluster": "Python", "tags": ["brute force", "implementation", "number theory"], "code_uid": "3801a7ff8f568b784286fa0680f04a85", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#TO MAKE THE PROGRAM FAST\n\n''' ----------------------------------------------------------------------------------------------------  '''\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n''' ----------------------------------------------------------------------------------------------------  '''\n\n\n#FOR TAKING INPUTS\n\n''' ----------------------------------------------------------------------------------------------------  '''\ndef li():return [int(i) for i in input().rstrip('\\n').split(' ')]\ndef val():return int(input().rstrip('\\n'))\ndef st():return input().rstrip('\\n')\ndef sttoli():return [int(i) for i in input().rstrip('\\n')]\n''' ----------------------------------------------------------------------------------------------------  '''\n\n\n\n\n#MAIN PROGRAM\n\n''' ----------------------------------------------------------------------------------------------------  '''\n\ndef recursive(a,i = 0,tot = 0):\n    if len(a) == i and not tot%360:\n        print('YES')\n        exit()\n    elif i == len(a):\n        return;\n    recursive(a,i+1,tot+a[i])\n    recursive(a,i+1,tot-a[i])\n\nn = val()\na = []\nfor i in range(n):\n    a.append(val())\nrecursive(a)\nrecursive(a)\nprint('NO')\n\n''' ----------------------------------------------------------------------------------------------------  '''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "59f5527714b4d0e7917c7ba1103b31fa", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n=input()\nm=input()\nif n>40:\n  print m \nelse:\n  print m%(pow(2,n))\n  \n      \n  ", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "f4579ea9dd4f101c8d9a4662c5962fe7", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import copy\nn,m=[int(x) for x in input().split()]\nres=[]\nfor i in range(n):\n    d=[0]*n\n    d[i]=1\n    res.append(d)\n\nfor i in range(m):\n    r,c = [int(x) for x in input().split()]    \n    res[r-1][c-1]=1\n    res[c-1][r-1] = 1\n\ngroups=['x']*n\ncor1=[]\ncor2=[]\noutput=''\nfor i in range(n):\n    if res[i]==[1]*n:\n        groups[i]='b'\nfor i in range(n):\n    if not groups[i]=='b':\n        if len(cor1)==0:\n            cor1=copy.deepcopy(res[i])\n            groups[i]='a'\n        elif res[i]==cor1:\n            groups[i]='a'\n        elif len(cor2)==0:\n            cor2=copy.deepcopy(res[i])\n            groups[i]='c'\n        elif res[i]==cor2:\n            groups[i]='c'\n        else:\n            output= 'No'\n            break\nif len(output)==0:\n    print('Yes')\n    print(''.join(groups))\nelse:\n    print('No')\n        \n\n#print(res)\n\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "graphs"], "code_uid": "bce88a275c81aacd5ea19c0256ab309a", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n , k = map(int,input().split())\nl = -1\nh = n + 1\nwhile l + 1 < h:\n    mid = (l + h) // 2\n    if 2 * (mid + k * mid) <= n:\n        l = mid\n    else:\n        h = mid\nprint(l , k * l , n - (l + k * l))\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "a1d8a300b7714631831200de99cad9c7", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\ndef dtb(n): \n    return bin(n).replace(\"0b\",\"\")\ndef btd(n): \n    return int(n,2) \n\nn=int(input())\nr=list(map(int,input().split()))[:n]\nb=list(map(int,input().split()))[:n]\ncount1,count2=0,0\nflag=0\nfor i in range (n):\n    if r[i]==1 and b[i]==0:\n        count1+=1\n    if r[i]==0 and b[i]==1:\n        count2+=1\n        \nif count1==0:\n    print(-1)\nelse:\n    ans=math.ceil((count2+1)/count1)\n    print(ans)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "993d53fb3f5c6f20a1a3ee30d2660488", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\nif n==1:\n   print 0\nelif n%2==1:\n   print n/2\nelse:\n   print n/2-1", "lang_cluster": "Python", "tags": ["constructive algorithms"], "code_uid": "c28e1ca26b28ea6ef51b69cf06fab7aa", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k,t=map(int,input().split())\ncount=0\nti=t+0\nif t>k:\n\tcount+=k\n\tt-=k\n\tif t>0:\n\t\tt-=n-k-1\n\tif t>0:\n\t\tcount-=(ti-n)\n\nelse:\n\tcount+=t\n\n\nprint(count)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "60c0c4120668b5cb3e29f10e04c3018a", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\ndef lcm(a,b):\n    return (a*b) // math.gcd(a,b)\na,b=map(int,input().split())\nkpop=10**b\nprint(lcm(a,kpop))", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "d85203e949a9e7a0129943b76c4f4423", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "\n\n\na,b,c = map(int,input().split())\ns=0\n\nif c%a==0 or c%b==0:\n    print('Yes')\nelse:\n    for k in range(1,10001):\n        h=0\n        for j in range(1,10001):\n            u = a*k+b*(j)\n    \n            if u==c:\n                print('Yes')\n                h+=1\n                s+=1\n                break\n            elif u>c:\n                break\n        if s>0:\n            break\n    if s==0:\n        print('No')\n", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "c1c251d23c4f03f8067147845178e573", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c,n = map(int,input().split())\nx = n-(a+b-c)\nif x < 1 or x > n or a > n or b >n or c > n or c >a or c >b:\n    print('-1')\nelse:\n    print(x)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "2b19d68de556d501755111358aba8cf4", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "number theory"], "code_uid": "9cca502a4449cb369df3544d2cb6bb1b", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nnum=int(sys.stdin.readline().strip())\nlst=map(int,sys.stdin.readline().strip().split())\nwhile num>0:\n    for i in range(7):\n        num-=lst[i]\n        if num<=0:\n            print i+1\n            break\n        \n     \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7038abad070a8ee413a70ec90490f5c4", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "l1 = input().split()\nx1,y1 = int(l1[0]), int(l1[1])\nl2 = input().split()\nx2,y2 = int(l2[0]), int(l2[1])\nw = 0\nh = 0\nif x1 == x2:\n    w = 2\nelse:\n    w = abs(x1-x2)+1\nif y1 == y2:\n    h = 2\nelse:\n    h = abs(y1-y2)+1\nprint((w+h)*2)", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "81b058765f746d05dc83271cf01f22c3", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "count = int(input())\n\nsum = 0\nyears = input().split(' ')\nfor y in years:\n    sum += int(y)\nprint(int(sum/count))", "lang_cluster": "Python", "tags": ["sortings", "implementation"], "code_uid": "f6651d27030633c7d0250ee0f1525dd9", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k,a,b=map(int,input().split())\n\nans=a//k+b//k\nif ans==0:\n\tprint(-1)\nelif (a<k and b%k!=0) or (b<k and a%k!=0):\n\tprint(-1)\nelse:\n\tprint(ans)\n\t", "lang_cluster": "Python", "tags": ["math"], "code_uid": "38b0c0f746aab37a9937a9978544e883", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\nl=[0]*12\nfor u in range(4):\n    s=list(input())\n    for i in s:\n        if(i.isdigit()):\n            l[int(i)]+=1\nfor i in l:\n    if(i>2*n):\n        print(\"NO\")\n        break\nelse:\n    print(\"YES\")\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "77c162c5c8b3e8e1793d5753462cd620", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def solve():\r\n    n, m, k = map(int, input().split())\r\n    if k > (n * m) // 2:\r\n        print('NO')\r\n        return\r\n    if n % 2 == 1 and m % 2 == 0:\r\n        if k < (m // 2):\r\n            print('NO')\r\n            return\r\n        elif k == (m // 2):\r\n            print('YES')\r\n            return\r\n        elif k > (m // 2):\r\n            if (k - m // 2) % 2 == 0:\r\n                print('YES')\r\n                return\r\n            else:\r\n                print('NO')\r\n                return\r\n    if n % 2 == 0 and m % 2 == 0:\r\n        if k % 2 == 0:\r\n            print('YES')\r\n        else:\r\n            print('NO')\r\n    if n % 2 == 0 and m % 2 == 1:\r\n        if k % 2 == 1:\r\n            print('NO')\r\n        else:\r\n            if k > (m * n - n) // 2:\r\n                print('NO')\r\n            else:\r\n                print('YES')\r\n\r\n\r\nfor i in range(int(input())):\r\n    solve()\r\n", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "e80e7abb1c656a8b57d82816e4c1a003", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "input = raw_input()\na, b, f, k = map(int, input.split(\" \"))\nt = b\np = 0\nif b < f:\n    print -1\nelse:\n    while True:\n        if t < f or b < a - f:\n            print -1\n            break\n        if k == 1:\n            if t < a:\n                print p + 1\n            else:\n                print p\n            break\n        t -= f\n        if t < 2 * (a - f):\n            t = b\n            p += 1\n        k -= 1\n        t -= a - f\n        if t < a - f or b < f:\n            print -1\n            break\n        if k == 1:\n            if t < a:\n                print p + 1\n            else:\n                print p\n            break\n        t -= a - f\n        if t < 2 * f:\n            t = b\n            p += 1\n        k -= 1\n        t -= f\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "88d41c006782929820f3abbfb47ba376", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s = c_r = c_l = 0\nfor _ in range(input()):\n    x, y = map(int, raw_input().split())\n    c_r += x\n    c_l += y\n    if((x+y)%2 != 0):\n        s+=1\n\nif(c_l % 2 == 0 and c_r % 2 == 0):\n    print 0\nelif(s % 2 == 0 and s>0):\n    print 1\nelse:\n    print -1", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "1b59a8cb02d9ef806e462d18b03b5dac", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "colors = input()\ninstructions = input()\n \npointer = 0\nfor index in range(len(instructions)):\n    if(instructions[index] == colors[pointer]):\n        pointer += 1\nprint(pointer+1)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9fb167c2c0ae750191d92e7cd8055092", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s=raw_input()\nt=set([ord('a')-1])\nfor c in s:\n  x=ord(c)\n  if x not in t and (x-1) not in t:\n    print 'NO'\n    break\n  t.add(x)\nelse:\n  print 'YES'", "lang_cluster": "Python", "tags": ["greedy", "strings", "implementation"], "code_uid": "a524c59f4246969b8c03e455afed7d11", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\na,x,y=map(float,raw_input().split())\na=int(a)\nn=1.0*y/a\ni=int(n)\ndef f():\n    print '-1'\n    exit()\nif n==i:\n    f()\nif i==0 or i%2==1:\n    if x == a/2.0 or x == -1*a/2.0 :\n        f()\n    elif -a/2.0<x<a/2.0:\n        print int(math.floor(i/2)*2+math.ceil(i/2.0)+1)\n    else:\n        f()\nelse:\n    if x == a or x == -a or x == 0: \n        f()\n    elif -a<x<a:\n        if x>0:\n            print int(i+i/2+1)\n        else:\n            print int(i+i/2)\n    else:\n        f()\n    \n", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "d8f6f270c953a9e06fe8fa822f380477", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\nx = []\ny = []\nfor i in range(n):\n\txi,yi = [int(xyi) for xyi in raw_input().split(\" \")]\n\tif xi not in x:\n\t\tx += [xi]\n\tif yi not in y:\n\t\ty += [yi]\nif len(x) != 2 or len(y) != 2:\n\tprint -1\n\texit()\nprint abs(x[0]-x[1]) * abs(y[0]-y[1])", "lang_cluster": "Python", "tags": ["geometry", "implementation"], "code_uid": "3e3626f6b0ef1cd78c3db2d0bc603a3b", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "y = lambda: list(map(int, input().split()))\nk = lambda c: ord(c) - ord('0') \nz1 = y()\nz2 = y()\nz3 = y()\nfor i in range(8):\n    t = bin(i)[2:].zfill(3)\n    bw = z1[k(t[0])]; bh = z1[1 - k(t[0])]\n    w = z2[k(t[2])] + z3[k(t[1])]\n    h = max(z2[1 - k(t[2])], z3[1 - k(t[1])])\n    if h <= bh and w <= bw:\n        print('YES')\n        break\nelse:\n    print('NO')\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "332c570ab8ae30fb1cda45b21d9b013b", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=\"\"\nfor i in range(2,n):\n    if(n%i==0 and len(a)<=2):\n        a+=str(i)\n        a+=str(n//i)\n        break\nif(len(a)==0):\n    print(\"1\"+str(n))\nelse:\n    print(int(a))\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "15d95f28d44b65a574f75871ef8ad454", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a, b = [int(x) for x in input().split(' ')]\n\nwhile min(a, b) > 0:\n    if a >= 2 * b:\n        a = a % (2 * b)\n    elif b >= 2 * a:\n        b = b % (2 * a)\n    else:\n        break\nprint(a, b)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "5458460bd71d964285d9205055fedcee", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "word1 = input()\nword2 = input()\n\nw1len = len(word1)\nw2len = len(word2)\n\n\n\nif w1len != w2len:\n    print('NO')\n\nelse:\n\n\n    if (w1len % 2) == 0:  # ES\n        index = w1len - 1\n        cant = w1len\n        i = 0\n        while cant != 0:\n            a = word1[i]\n            b = word2[index]\n\n\n\n            if a == b:\n                i += 1\n                index -= 1\n                cant -= 1\n\n            else:\n                print('NO')\n                break\n        if cant == 0:\n            print('YES')\n\n    else:\n        index = w1len - 1\n        cant = w1len\n        i = 0\n        while cant != 0:\n            a = word1[i]\n            b = word2[index]\n\n\n\n            if a == b:\n                i += 1\n                index -= 1\n                cant -= 1\n\n            else:\n                print('NO')\n                break\n        if cant == 0:\n            print('YES')\n\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "c7185703101804a6da5a22475a72f139", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\ndef t(a,b,c,d,e):\n    #for i in range(5):\n      #  v.append (int(input(\"podaj liczbe\")))\n\n        \n    gr1=0\n    gr2=0\n\n    gr1=(b*a)+(d*2)\n    gr2=(c*a)+(e*2)\n    #print(gr1)\n    #print(gr2)\n    if gr1>gr2:\n        print(\"Second\")\n    if gr1<gr2:\n        print(\"First\")\n    if gr1==gr2:\n        print(\"Friendship\")\n\na,b,c,d,e = input().split(\" \")\nt(int(a),int(b),int(c),int(d),int(e))", "lang_cluster": "Python", "tags": ["math"], "code_uid": "6f9436a329d5d3a638fb45e8375716e7", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = input()\nprint(min(len(s), s.count('a')*2-1))\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "c784c610f4fbbfc325481df7ead8e52b", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def R(x, y, z):\n    if z < x + y and x < z + y and y < z + x:\n        return 2\n    elif z == x + y or x == z + y or y == z + x:\n        return 1\n    else:\n        return 0\n\na, b, c, d = map(int, input().split())\ns = max(R(b, c, d), R(a, c, d), R(a, b, d), R(a, b, c))\nprint(['IMPOSSIBLE', 'SEGMENT', 'TRIANGLE'][s])", "lang_cluster": "Python", "tags": ["brute force", "geometry"], "code_uid": "ec3b2409fb941bd65049fa98017429c1", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\n\nif n >= -128 and n <= 127:\n    print(\"byte\")\nelif n >= -32768 and n <= 32767:\n    print(\"short\")\nelif n >= -2147483648 and n <= 2147483647:\n    print(\"int\")\nelif n >= -9223372036854775808 and n <= 9223372036854775807:\n    print(\"long\")\nelse:\n    print(\"BigInteger\")", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "fa7035482ef34609ed8d82012e25a3f9", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, l = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfor i in range(0, l):\n\ts = set()\n\tcnt = 0\n\tfor j in a:\n\t\ts.add((i + j) % l)\n\tfor j in range(0, l):\n\t\tcnt = 0\n\t\tfor k in b:\n\t\t\tif (j + k) % l in s:\n\t\t\t\tcnt += 1\n\t\tif cnt == n:\n\t\t\tprint('YES')\n\t\t\texit(0)\nprint('NO')\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "688c6e3d0bdf17d6af0d20bd62bd8d83", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "data = input().split(\" \")\nk = [int(data[0]), int(data[1]), int(data[2])]\nk.sort()\n[k1, k2, k3] = k\nhas_solution = False\nif k1 == 1:\n    has_solution = True\nelif k1 == 2 and k2 == 2:\n    has_solution = True\nelif k1 == 2 and k2 == 4 and k3 == 4:\n    has_solution = True\nelif k1 == 3 and k2 == 3 and k3 == 3:\n    has_solution = True\nif has_solution:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms"], "code_uid": "22f105260aa7e27ead2057b267f0873c", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "\n\nn,m = map(int,input().split())\n\nif(min(n,m) % 2 == 0):\n    print('Malvika')\nelse:\n    print('Akshat')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9ebfa23ec9672419624cb6aa32b5aa69", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def naxt(i) :\n    e=bin(i+2)\n    e=e[3:]\n    e=e.replace(\"0\",\"4\")\n    e=e.replace(\"1\",\"7\")\n    return int(e)\ni=0;ans=0;pr=0\nl,r=map(int,input().split())\nwhile(True):\n    t=naxt(i)\n    \n    ans+=max((min(r,t)-max(l,pr)+1)*t,0)\n    pr=t+1\n    if r<=t :\n        break\n    i+=1\nprint(ans)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "6993b42b9edf4cd81ec8194120ecbb2b", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "s=raw_input()\nn=int(s)\nm=len(s)\na=0 if m<2 else int('9'*(m-1))\nprint 9*(m-1)+sum(map(int,str(n-a)))\n", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "5eb59e6cff4e04be40d1feb2203ab71e", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nans = 0\nfor x in range(1, n + 1):\n\tans += 2 ** x\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "4bbb9125f1f05afaef524fb9830cb251", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\ndef is_prime(x):\n\ttemp = True\n\tfor i in xrange(2,(x/2) + 1):\n\t\tif x%i == 0:\n\t\t\ttemp =False\n\t\t\tbreak\n\treturn temp\n\nn,m = [int(x) for x in raw_input().split()]\n\nans = True\n\nwhile True:\n\tn += 1\n\tif n > m:\n\t\tans = False\n\t\tbreak\n\tif is_prime(n):\n\t\tif n != m:\n\t\t\tans = False\n\t\tbreak\n\n\nif not ans:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "0af7f9a005afae2ad9f816f193dfa0af", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "def p(x):\n d=2\n while d*d<=x and x%d: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", "tags": ["math", "number theory"], "code_uid": "e03295af950bc31e6b2c1cf749e02514", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def cal(x):\n    ans = 0\n    while (x):\n        ans += x % 10\n        x =x// 10\n    return ans\n\nn = int(input())\nnow = 19\ni=1\nwhile (i<n):\n    now += 9\n    if cal(now) == 10:\n        i += 1\nprint (now)\n", "lang_cluster": "Python", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "3df9b9d63fc4980e08aebc21d4ed2be7", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(int(input()))\nans = 0\nfor l in range(1, 11):\n    if (l == len(str(n))):\n        ans += (n - 10**(l-1) + 1) * l\n    elif (l < len(str(n))):\n        ans += (9 * 10**(l - 1)) * l\n    else:\n        break\n \nprint(ans)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "fa083fac9fcf9f60a2d48570ac210da9", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,m = input().split()\nm=int(m)\nn=int(n)\narr = sorted(map(int,input().split()))\nmini=999999999\nfor j in range(m-n+1):\n if (arr[j+n-1]-arr[j]<mini):\n   mini=arr[j+n-1]-arr[j]\nprint (mini)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "889715f9788c64eeaa5df9c316caa65b", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\ninp = list(map(int,input().split()))\nfrom collections import Counter\nc=Counter(inp)\ninp=list(c.keys())\ninp.sort()\nif(len(inp)>3):\n    flag=0\n    for i in range(len(inp)-3+1):\n        if(inp[i+1]-inp[i]==1 and inp[i+2]-inp[i+1]==1):\n            flag=1\n            print ('YES')\n            break\n    if(flag==0):\n        print ('NO')\nelse:\n    if(len(inp)==3):\n        if(inp[1]-inp[0]==1 and inp[2]-inp[1]==1):\n            print ('YES')\n        else:\n            print (\"NO\")\n    else:\n        print ('NO')", "lang_cluster": "Python", "tags": ["brute force", "sortings", "implementation"], "code_uid": "ee0233fc2585373c6fd6f0fe5610c45f", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a1 = int(input())\na2 = int(input())\nk1 = int(input())\nk2 = int(input())\nif k1 > k2:\n    k1, k2 = k2, k1\n    a1, a2 = a2, a1\nc = int(input())\nmina, max = 0, 0\nc1 = c\nif c1 >= a1*k1:\n    c1 -= a1*k1\n    max += a1\nelse:\n    max += int(c1/k1)\n    c1 -= int(c1/k1) * k1\nif c1 > 0:\n    max += int(c1/k2)\n\nc2 = c\ntemp = 0\nif c2 >= a2*(k2-1):\n    c2 -= a2*(k2-1)\nelse:\n    c2 = 0\n\nif c2 > 0:\n    if c2 >= a1 * (k1 - 1):\n        c2 -= a1 * (k1 - 1)\n    else:\n        c2 = 0\n\nif c2 > 0:\n    mina = c2\n\n\n\nprint(mina, max)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "c26790c84956b209775478dceea81c9f", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=input()\ncount=0\nfor i in n:\n    if i=='4' or i=='7':\n        count+=1\nif count==4 or count==7:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "1b6c6270b276cd5225f8ccb97cc6c82c", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "w,h,k=map(int,input().split())\ncount=0\nfor i in range(1,k+1):\n    count+=2*(w-4*(i-1))+2*(h-4*(i-1))-4\nprint(count)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "cec8a506bb0c780227c077db19da78de", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from collections import Counter\ns = input()\nif '4' in s or '7' in s:\n    print(Counter(sorted([elt for elt in s if elt in ['4', '7']])).most_common(1)[0][0])\nelse:\n    print(-1)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "e3b97bd4b9a0b283d988e4938965b94b", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys, os, io\ndef rs(): return sys.stdin.readline().rstrip()\ndef ri(): return int(sys.stdin.readline())\ndef ria(): return list(map(int, sys.stdin.readline().split()))\ndef ws(s): sys.stdout.write(s + '\\n')\ndef wi(n): sys.stdout.write(str(n) + '\\n')\ndef wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\\n')\nimport math,datetime,functools\nfrom collections import deque,defaultdict,OrderedDict\nimport collections\n\n\ndef main():\n    starttime=datetime.datetime.now()\n    if(os.path.exists('input.txt')):\n        sys.stdin = open(\"input.txt\",\"r\")\n        sys.stdout = open(\"output.txt\",\"w\")\n    \n\n\n\n\n\n    #Solving Area Starts-->\n    for _ in range(1):\n        n=ri()\n        a=ria()\n        a=sorted(a)\n        s=0\n        for i in range(1,n,2):\n            s+=a[i]-a[i-1]\n        wi(s)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    #<--Solving Area Ends\n    endtime=datetime.datetime.now()\n    time=(endtime-starttime).total_seconds()*1000\n    if(os.path.exists('input.txt')):\n        print(\"Time:\",time,\"ms\")  \n    \n                \nclass FastReader(io.IOBase):\n    newlines = 0\n\n    def __init__(self, fd, chunk_size=1024 * 8):\n        self._fd = fd\n        self._chunk_size = chunk_size\n        self.buffer = io.BytesIO()\n\n    def read(self):\n        while True:\n            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))\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, size=-1):\n        while self.newlines == 0:\n            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))\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\nclass FastWriter(io.IOBase):\n\n    def __init__(self, fd):\n        self._fd = fd\n        self.buffer = io.BytesIO()\n        self.write = self.buffer.write\n\n    def flush(self):\n        os.write(self._fd, self.buffer.getvalue())\n        self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass FastStdin(io.IOBase):\n    def __init__(self, fd=0):\n        self.buffer = FastReader(fd)\n        self.read = lambda: self.buffer.read().decode(\"ascii\")\n        self.readline = lambda: self.buffer.readline().decode(\"ascii\")\n\n\nclass FastStdout(io.IOBase):\n    def __init__(self, fd=1):\n        self.buffer = FastWriter(fd)\n        self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\n        self.flush = self.buffer.flush\n\n\nif __name__ == '__main__':\n    sys.stdin = FastStdin()\n    sys.stdout = FastStdout()\n    main()\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "tags": ["sortings"], "code_uid": "90ef4f3870b03277a543b96b8bd58d15", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"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())))\na=max(li1)*10+max(li)\nfor i in li1:\n if i in li:\n  a=i\n  break\na1=min(li)\nb1=min(li1)\nb=min((a1*10+b1),(b1*10+a1))\nprint(min(a, b))\n\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "9519ed8426445689367ec636cf6b5511", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def win(a, b, a1, b2):\n    return a > b2 and b > a1\n\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\nc = map(int, raw_input().split())\nd = map(int, raw_input().split())\n\nif win(a[0], b[1], c[0], d[1]) and win(a[0], b[1], d[0], c[1]) or win(b[0], a[1], c[0], d[1]) and win(b[0], a[1], d[0], c[1]):\n    print 'Team 1'\nelif (win(c[0], d[1], a[0], b[1]) or win(d[0], c[1], a[0], b[1])) and (win(c[0], d[1], b[0], a[1]) or win(d[0], c[1], b[0], a[1])):\n    print 'Team 2'\nelse:\n    print 'Draw'", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "c2b76fc07852ea9ca2f8530ee2c5472b", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def main():\n    c, hr, hb, wr, wb = map(int, raw_input().split())\n    if wr < wb:\n        wr, wb = wb, wr\n        hr, hb = hb, hr\n    if wr > 10005:\n        ans = 0\n        for i in xrange(c / wr + 1):\n            t = i * hr + (c - i * wr) / wb * hb\n            if t > ans:\n                ans = t\n        print ans\n        return\n    ans = 0\n    for i in [0, 1]:\n        k = c / wr\n        for j in xrange(10010):\n            i = k + j\n            if i * wr > c:\n                break\n            t = i * hr + (c - i * wr) / wb * hb\n            if t > ans:\n                ans = t\n        for j in xrange(10010):\n            i = k - j\n            if i < 0:\n                break\n            t = i * hr + (c - i * wr) / wb * hb\n            if t > ans:\n                ans = t\n        wr, wb = wb, wr\n        hr, hb = hb, hr\n    print ans\nmain()\n", "lang_cluster": "Python", "tags": ["math", "greedy", "brute force"], "code_uid": "ea08e7880809f45d158e573394bd5404", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from itertools import accumulate as _accumulate\nimport sys as _sys\n\n\ndef main():\n    n, k = _read_ints()\n    s = input()\n    t = input()\n    result = find_best_score_can_make(s, t, moves_n=k)\n    print(result)\n\n\ndef _read_ints():\n    return map(int, _sys.stdin.readline().split(\" \"))\n\n\n_A = \"a\"\n_B = \"b\"\n_C = \"c\"\n\n\ndef find_best_score_can_make(s, t, moves_n):\n    assert len(t) == 2\n    if t[0] == t[1]:\n        t_char = t[0]\n        t_char_count = s.count(t_char)\n        t_char_count += moves_n\n        if t_char_count > len(s):\n            t_char_count = len(s)\n        return t_char_count * (t_char_count - 1) // 2\n    \n    s = [(_A, _B)[t.index(char)] if char in t else _C for char in s]\n    s = ''.join(s)\n    del t\n    \n    a_indices, b_indices, c_indices = _compute_abc_indices(s)\n    \n    best_score = -float(\"inf\")\n    \n    max_c_start = min(len(c_indices), moves_n)\n    for c_start in range(0, max_c_start+1):\n        c_start_moves_spent = c_start\n        moves_spent = c_start_moves_spent\n        moves_remain = moves_n - moves_spent\n        assert moves_remain >= 0\n        \n        max_b_start = min(len(b_indices), moves_remain)\n        for b_start in range(0, max_b_start+1):\n            b_start_moves_spent = b_start\n            moves_spent = c_start_moves_spent + b_start_moves_spent\n            moves_remain = moves_n - moves_spent\n            assert moves_remain >= 0\n\n            new_s = list(s)\n            for i_i_c in range(0, c_start):\n                i_c = c_indices[i_i_c]\n                new_s[i_c] = _A\n            for i_i_b in range(0, b_start):\n                i_b = b_indices[i_i_b]\n                new_s[i_b] = _A\n            \n            curr_best_score = _find_best_score_can_make_with_fixed_starts(new_s, moves_remain)\n            best_score = max(best_score, curr_best_score)\n            \n    return best_score\n\n\ndef _compute_abc_indices(s):\n    a_indices = []\n    b_indices = []\n    c_indices = []\n    for i_char, char in enumerate(s):\n        if char == _A:\n            a_indices.append(i_char)\n        elif char == _B:\n            b_indices.append(i_char)\n        else:\n            assert char == _C\n            c_indices.append(i_char)\n    return a_indices, b_indices, c_indices\n\n\ndef _find_best_score_can_make_with_fixed_starts(s, moves_n):\n    s = list(s)\n    \n    best_score = -float(\"inf\")\n    \n    a_indices, b_indices, c_indices = _compute_abc_indices(s)\n    \n    a_n = len(a_indices)\n    c_n = len(c_indices)\n    \n    max_a_stop = len(a_indices)\n    max_c_stop = len(c_indices)\n    \n    def get_c_stop_by_moves_remain(moves_remain):\n        min_c_stop = max_c_stop - moves_remain\n        if min_c_stop < 0:\n            min_c_stop = 0\n        c_stop = min_c_stop\n        return c_stop\n    \n    first_c_stop = get_c_stop_by_moves_remain(moves_n)\n    new_s = _get_curr_s(s, a_indices, max_a_stop, c_indices, first_c_stop)\n    curr_score = _get_curr_score_slow_way(new_s)\n    \n    best_score = max(best_score, curr_score)\n    \n    old_a_before = _compute_a_before(new_s)\n    old_b_after_if_all_c_are_b = _compute_b_after(''.join(new_s).replace(_C, _B))\n    \n    curr_b_to_c_before_a = 0\n    curr_a_to_b_after_c = 0\n\n    prev_c_stop = None\n    c_stop = first_c_stop\n    c_stop_moves_spent = max_c_stop - c_stop\n    \n    min_a_stop = max_a_stop - moves_n\n    min_a_stop = max(min_a_stop, 0)\n    for a_stop in reversed(range(min_a_stop, max_a_stop-1 + 1)):\n        a_stop_moves_spent = max_a_stop - a_stop\n        moves_spent = a_stop_moves_spent\n        moves_remain = moves_n - moves_spent\n        assert moves_remain >= 0\n        \n        # a_stop update processing\n        \n        # s[a_indices[a_stop]]: _A -> _B\n        # curr_score -= b_after[a_indices[a_stop]]\n        # curr_score += a_before[a_indices[a_stop]]\n        # prev_a_stop - a_stop == 1\n        assert a_stop_moves_spent > 0\n        \n        curr_a_index = a_indices[a_stop]\n        curr_b_to_c = c_stop\n        if curr_b_to_c_before_a < curr_b_to_c \\\n                and c_indices[curr_b_to_c_before_a] < curr_a_index:\n            while curr_b_to_c_before_a < curr_b_to_c \\\n                    and c_indices[curr_b_to_c_before_a] < curr_a_index:\n                curr_b_to_c_before_a += 1\n        elif curr_b_to_c_before_a > 0 \\\n                and c_indices[curr_b_to_c_before_a-1] > curr_a_index:\n            while curr_b_to_c_before_a > 0 \\\n                    and c_indices[curr_b_to_c_before_a-1] > curr_a_index:\n                curr_b_to_c_before_a -= 1\n        \n        prev_a_stop_moves_spent = a_stop_moves_spent - 1  # exclude curr move\n        curr_b_to_c_after_a = curr_b_to_c - curr_b_to_c_before_a\n        new_b_after = prev_a_stop_moves_spent - curr_b_to_c_after_a\n        b_after = old_b_after_if_all_c_are_b[curr_a_index] + new_b_after\n        curr_score -= b_after\n        curr_score += old_a_before[curr_a_index]\n        \n        # c stop update\n        \n        prev_c_stop = c_stop\n        c_stop = get_c_stop_by_moves_remain(moves_remain)\n        c_stop_moves_spent = max_c_stop - c_stop\n        \n        # c_stop update processing\n        \n        assert c_stop - prev_c_stop in (0, 1)\n        if c_stop - prev_c_stop == 1:\n            # s[c_indices[prev_c_stop]]: _B -> _C\n            # curr_score -= a_before[c_indices[prev_c_stop]]\n            assert 0 <= prev_c_stop < len(c_indices)\n            \n            prev_c_index = c_indices[prev_c_stop]\n            curr_a_to_b = a_n - a_stop\n            if curr_a_to_b_after_c < curr_a_to_b \\\n                    and a_indices[a_n - (curr_a_to_b_after_c + 1)] > prev_c_index:\n                while curr_a_to_b_after_c < curr_a_to_b \\\n                        and a_indices[a_n - (curr_a_to_b_after_c + 1)] > prev_c_index:\n                    curr_a_to_b_after_c += 1\n            elif curr_a_to_b_after_c > 0 \\\n                    and a_indices[a_n - curr_a_to_b_after_c] < prev_c_index:\n                while curr_a_to_b_after_c > 0 \\\n                        and a_indices[a_n - curr_a_to_b_after_c] < prev_c_index:\n                    curr_a_to_b_after_c -= 1\n            \n            a_to_b_before = curr_a_to_b - curr_a_to_b_after_c\n            curr_a_before = old_a_before[prev_c_index] - a_to_b_before\n            curr_score -= curr_a_before\n        \n        # saving result\n        best_score = max(best_score, curr_score)\n    \n    return best_score\n\n\ndef _get_curr_s(s, a_indices, a_stop, c_indices, c_stop):\n    s = list(s)\n    for i_i_a in range(a_stop):\n        i_a = a_indices[i_i_a]\n        s[i_a] = _A\n    for i_i_a in range(a_stop, len(a_indices)):\n        i_a = a_indices[i_i_a]\n        s[i_a] = _B\n    for i_i_c in range(c_stop):\n        i_c = c_indices[i_i_c]\n        s[i_c] = _C\n    for i_i_c in range(c_stop, len(c_indices)):\n        i_c = c_indices[i_i_c]\n        s[i_c] = _B\n    return s\n\n\ndef _get_curr_score_slow_way(s):\n    curr_score = 0\n    a_accumulated = 0\n    for char in s:\n        if char == _A:\n            a_accumulated += 1\n        elif char == _B:\n            curr_score += a_accumulated\n    return curr_score\n\n\ndef _compute_a_before(s):\n    result = tuple( _accumulate(int(char == _A) for char in s) )\n    result = (0,) + result[:-1]\n    return result\n\n\ndef _compute_b_after(s):\n    result = tuple( _accumulate(int(char == _B) for char in s[::-1]) )[::-1]\n    result = result[1:] + (0,)\n    return result\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["strings", "dp"], "code_uid": "ebe47099b14229addfbad3ec9683d480", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "k, b, n, t = map(int, raw_input().split())\n\nx = 1\ntime = 0\nwhile(x<=t):\n    x = x*k+b\n    time += 1\nprint max(n-time+1,0)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "65a6adc9bd480a9f0fed3a7c35444b49", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import collections\ns=list(map(int,input().split()))\nn=s[0]\nm=s[1]\nmydict={}\narrofsize=[]\narrofwts=[]\nfor i in range(m):\n    t=input().split()\n    arrofsize.append(int(t[0]))\n    arrofwts.append(int(t[1]))\narrofwts2=list(set(arrofwts))\nfor i in arrofwts2:\n    counts=0\n    for j in range(0,len(arrofwts)):\n        if(i==arrofwts[j]):\n            counts+=arrofsize[j]\n    mydict[i]=counts\n\n    \nsize=list(mydict.values())\nwt=list(mydict.keys())\narr=sorted(mydict.items())\ncount=0\ni=len(wt)-1\nwhile(i>=0):\n    w1=arr[i][0]\n    s1=arr[i][1]\n    if(n>=s1):\n        count=count+(s1*w1)\n        n=n-s1\n        \n    elif(n<s1):\n        count=count+(n*w1)\n        n=n-n\n    i=i-1\nprint(count)\n", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "a8b43ed7c2c0d66d62390917470f7fa8", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Sep  7 08:39:57 2019\n\n@author: avina\n\"\"\"\n\nn,m = map(int, input().split())\nk = pow(2,n) - 1\nlo = 0; hi = k\ni = 0\nwhile lo <= hi:\n    mid = (lo+hi) // 2\n    \n    if mid  > m-1:\n        hi = mid -1\n    \n    elif m -1 > mid:\n        lo = mid + 1\n    \n    else:\n        break\n    i+=1\nprint(n - i)", "lang_cluster": "Python", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "e5e95925768f6ff0009ca9f9e2092905", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def solve(year):\n    while(True):\n        year = str(int(year)+1)\n        if(len(set(year))==4):\n            return year\n\nif __name__ == \"__main__\":\n    print(solve(input()))", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "53d0e945cb3ab76762e54736e06dfa13", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "#import resource\n#import sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#import threading\n#threading.stack_size(2**26)\n#sys.setrecursionlimit(0x1000000)\nfrom sys import stdin, stdout\nmod=(10**9)+7\nmod1=mod-1\ndef modinv(n,p):\n    return pow(n,p-2,p)\nfact=[1]\nfor i in range(1,100001):\n    fact.append((fact[-1]*i)%mod)\ndef ncr(n,r,p):\n    t=((fact[n])*(modinv(fact[r],p)%p)*(modinv(fact[n-r],p)%p))%p\n    return t\ndef GCD(x, y):\n   while(y):\n       x, y = y, x % y\n   return x\ndef BS(arr, l, r, 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 BS(arr, l, mid-1, x)\n        else:\n            return BS(arr, mid+1, r, x)\n    else:n -1\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nimport itertools\nimport math\nimport heapq\nfrom random import randint as rn\nfrom Queue import Queue as Q\ndef comp(x,y):\n    if(x[0]<y[0]):\n        return -1\n    elif(x[0]==y[0]):\n        if(x[1]<y[1]):\n            return -1\n        else:\n            return 1\n    else:\n        return 1\n\"\"\"*********************************************************************************\"\"\"\na=map(int,raw_input().split())\na.sort()\nk=max(a[2]-a[1]-a[0]+1,0)\nprint k\n", "lang_cluster": "Python", "tags": ["brute force", "math", "geometry"], "code_uid": "181c7ca914ecf23918f1240b82c779db", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def next_minute(h, m):\n  if m < 59:\n    m += 1\n  else:\n    m = 0\n    if h < 23:\n      h += 1\n    else:\n      h = 0\n  return h, m\n\ns = raw_input()\nh = int(s[:2])\nm = int(s[3:])\nwhile 1:\n  h, m = next_minute(h, m)\n  s = '%02d:%02d' % (h, m)\n  if s == s[::-1]:\n    break\n\nprint s\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "8f74626a60e78d54ebb9530d28c85fec", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def solve(s, t):\n    def is_sub(t, s):\n        j = 0\n        for x in s:\n            if j < len(t) and x == t[j]:\n                j += 1\n            if j == len(t): return True\n        return False\n\n    cs, ct = {}, {}\n    for x in s:\n        if not x in cs:\n            cs[x] = 0\n        cs[x] += 1\n    for x in t:\n        if not x in ct:\n            ct[x] = 0\n        ct[x] += 1\n    for x, c in ct.items():\n        if not x in cs or c > cs[x]: return 'need tree'\n    nauto = is_sub(t, s) \n    nboth = False \n    for x, c in cs.items():\n        if not x in ct or c > ct[x]: nboth = True\n    if nauto: return 'automaton'\n    if nboth: return 'both'\n    return 'array'\n\nprint solve(raw_input(), raw_input())\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "88db0ee8c8ef9658d46807f4cd4f26ac", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#####--------------Template Begin-------------------#####\nimport sys\n#input = sys.stdin.readline\ndef i(): #Regular input\n\treturn input()\ndef ii(): #integer input\n\treturn int(input())\ndef li(): #list input\n\treturn input().split()\ndef mi(): #map input\n\treturn list(map(int, input().split()))\n#####---------------Template Ends-------------------######\nk, r=mi()\nc=0\nans=0\nwhile True:\n\tc+=k\n\tans+=1\n\tif (c-r)%10==0 or c%10==0:\n\t\tprint(ans)\n\t\tbreak\n", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "51a0811e8d5af7b1a21ea5695bf260b0", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b, c = map(int, raw_input().split())\nres = []\nfor i in xrange(82):\n  x = b * (i ** a) + c\n  if 0 < x < 1000000000 and sum(map(int, str(x))) == i:\n    res.append(x)\nprint len(res)\nfor a in res:\n  print a,\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "730d1bf85d0a3748a23b17fa93a6b8b2", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, k = input().split()\nn = eval(n)\ntime = 240\ntime -= eval(k)\nfor i in range(n, -1, -1):\n\tans = n * (n + 1) // 2 * 5\n\tif (ans <= time):\n\t\tbreak\n\tn -= 1\nprint(n)", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "2f62d4664ff4a05c5325a83f8dfac72a", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def mp():\n    return map(int,str(raw_input()).strip().split())\n\nfrom fractions import gcd\nfrom math import *\n\nc,v0,v1,a,l=mp()\nn=0\nwhile c>0:\n    c-=v0\n    if c>0:\n        c+=l\n        if v0<=(v1-a):\n            v0+=a\n        else:\n            v0=v1\n    n+=1\nprint n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "583df3d55dd0cd3064d7f0f443ca88c2", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nfrom os import path\nif(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):\n    sys.stdin = open(\"C:/Users/prana/Desktop/sublime/input.txt\",\"r\")\n    sys.stdout = open(\"C:/Users/prana/Desktop/sublime/output.txt\",\"w\")\n\n# ----------------------------------------------------------------------\n\ndef solve():\n    n,d=input().split()\n    n=int(n)\n    d=int(d)\n    s=list(input())\n    i=0\n    count=0\n    temp=0\n    while i <(n-1):\n        j=d\n        while j>0:\n            if i+j<n:\n                # print(i,j,file = sys.stderr)\n                if s[i+j] !=\"1\":\n                    j-=1\n                else:\n                    # print(1,file = sys.stderr)\n                    count+=1\n                    i+=j\n                    break\n            else:\n                # print(i,j,file = sys.stderr)\n\n\n                j-=1\n        # print(j,file = sys.stderr)\n        if j==0:\n            temp=1\n            break\n    if temp==0:\n        print(count)\n    else:\n        print(-1)\n\n\n    \n\nT = 1\n# T = int(input())\nfor _ in range(1,T+1):\n    print(\"Case #\", _ , file = sys.stderr)\n    solve()\n", "lang_cluster": "Python", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "138233a6036b90ba71fffccfe799225e", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nimport math\n\ninp = [[int(j) for j in i.split(' ')] for i in sys.stdin.read().strip().splitlines()]\n\ndef gcd(x1, x2):\n    if x1 == x2 or x2 == 0:\n        return x1\n    elif x2 > x1:\n        return gcd(x2, x1)\n    else:\n        return gcd(x1%x2, x2)\n\nn, m, x, y, a, b = inp[0]\nres = []\n\ng = gcd(a, b)\na /= g\nb /= g\n\nw = n - n%a\nh = w * b / a\n\nif h > m:\n    h = m - m%b\n    w = h * a / b\n\nX = x - w/2.0\nY = y - h/2.0\n\nxx = X\nyy = Y\nif xx < 0: xx = 0\nif yy < 0: yy = 0\nif xx > n-w: xx = n-w\nif yy > m-h: yy = m-h\n\nres = (xx, yy, xx+w, yy+h)\n\nsys.stdout.write(' '.join([str(int(math.floor(i))) for i in res]))\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "3295af722134e42f56a26aae2e2643bc", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\nn, k = map(int, input().split())\na, b = map(int, input().split())\nMOD = n * k\n\nx, y = 10 ** 11, 0\nfor s in [(1 - a + MOD) % MOD, 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        l1 = (el1 - s + MOD)\n        m = MOD // math.gcd(l1, MOD)\n        x, y = min(x, m), max(y, m)\n\n        el2 = (t + b + MOD) % MOD\n        if el2 == 0:\n            el2 = MOD\n        l2 = (el2 - s + MOD)\n        m = MOD // math.gcd(l2, MOD)\n        x, y = min(x, m), max(y, m)\n\n\nprint(x if x != 10 ** 11 else 0, y)\n", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "c90ca14e89b43ad10d99d2949534622b", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s1=input()\ns2=input()\nweek=[\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"]\nif week[(week.index(s1)+31)%7]==s2:print(\"YES\")\nelif week[(week.index(s1)+28)%7]==s2:print(\"YES\")\nelif week[(week.index(s1)+30)%7]==s2:print(\"YES\")\nelse:print(\"NO\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "1eb0efc9a23ae1b6481ad964df1d445a", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a = input()\nb = input()\n\nres = ''\n\ni = 0\nwhile i < len(a):\n    if a[i]==b[i]:\n        res += '0'\n    else:\n        res += '1'\n    i +=1\n        \nprint(res)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "a9fd46951dbd68c5aa2c955b74584e01", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\nchisla = set([i*(i+1)/2 for i in range(1, 50000)])\n\nif any([(n - h) in chisla for h in chisla]):\n    print \"YES\"\nelse:\n    print \"NO\"", "lang_cluster": "Python", "tags": ["brute force", "implementation", "binary search"], "code_uid": "a6fef2eba802a75427b61d8d7d12d397", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\nN = int(input())\nS = str(input())\nK = len(S)\ndp = []\nans = math.inf\nfor i in range(66):\n\tdp.append([])\n\tfor j in range(66):\n\t\tdp[i].append(-1)\ndp[K][0] = 0\n\ndef comp(x, y, v):\n\tif dp[x][y] == -1 or dp[x][y] > v:\n\t\tdp[x][y] = v\n\nfor i in range(K - 1, -1, -1):\n\tfor j in range(1, K + 1):\n\t\tcur = 0\n\t\tif S[i] == '0':\n\t\t\tdp[i][j] = dp[i + 1][j - 1]\n\t\t\tcontinue\n\t\tfor k in range(i, K):\n\t\t\tcur = cur * 10 + int(S[k])\n\t\t\tif cur >= N:\n\t\t\t\tbreak\n\t\t\tif dp[k + 1][j - 1] != -1:\n\t\t\t\tcomp(i, j, cur * (N**(j-1)) + dp[k + 1][j - 1])\n\nfor i in range(1, K + 1):\n\tif dp[0][i] != -1:\n\t\tans = min(ans, dp[0][i])\nprint(ans)\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "6db9df1deb5505b89ab947dbf17b942d", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a=int(input())\nprint (a/2)+1", "lang_cluster": "Python", "tags": ["math"], "code_uid": "bed9968fa4831974b9d099c0b9376e0b", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k = int(input())\n\nif k==2: print(2)\nelse: print(1)", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "92e22f40fb9590282157871ee35a20f8", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn = int(input())\ndivisors = []\nmin_ = 10e18\nfor i in range(1, int(math.sqrt(n)) + 1):\n    divisors.append((i, n // i, n % i))\nfor pair in divisors:\n    if pair[0] + pair[1] + int(pair[2] != 0) < min_:\n        #print(pair[0], pair[1], pair[2])\n        min_ = pair[0] + pair[1] + int(pair[2] != 0)\nprint(min_)", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "f633908653925b1b3a27752cc048c822", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def bad(s):\n    if(len(s) > 1 and s[0] == '0'): return False\n    if(int(s) > 1000000): return False\n    return True\n\ns = input()\nn = len(s)\nans = -1\nfor i in range(1, n + 1):\n    for j in range(i + 1, n):\n        if(bad(s[:i]) and bad(s[i : j]) and bad(s[j :])):\n            ans = max(ans, int(s[:i]) + int(s[i:j]) + int(s[j:]))\n            \nprint(ans)\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "1b337750c817f0e5b418090de9222d60", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "total_teams,team1,team2 = map(int,input().split())\n\ncount = 1\nwhile True:\n\tif round((team1/2)+0.1)==round((team2/2)+0.1):\n\t\tbreak\n\t\n\tteam1=round((team1/2)+0.1)\n\tteam2=round((team2/2)+0.1)\n\ttotal_teams//=2\n\tcount+=1\n\t\nif total_teams==2:\n  print('Final!')\nelse:\n\n  print(count)\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "7070a2585b613516b14a7f9bdba8385b", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, k = *map(int, input().split()),\n\n#days = sorted([*map(int, input().split())], reverse=True)\ndays = [*map(int, input().split())]\nres = 0\nnext_day_candies = 0\nfor i in days:\n\tres += 1\n\tif i >= 8:\n\t\tk -= 8\n\t\tnext_day_candies += i - 8\n\telif next_day_candies >= 8:\n\t\tnext_day_candies -= 8\n\t\tk -= 8\n\t\tnext_day_candies += i\n\telif next_day_candies > 0:\n\t\tnext_day_candies += i\n\t\tif next_day_candies >= 8:\n\t\t\tnext_day_candies -= 8\n\t\t\tk -= 8\n\t\telse:\n\t\t\tk -= next_day_candies\n\t\t\tnext_day_candies = 0\n\telif i > 0:\n\t\tk -= i\n\t\t\t\n\t#print(k)\n\tif k <= 0:\n\t\tprint(res)\n\t\tbreak\nelse:\n\tprint(-1)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e3c006a589f5b67634c6cdd914ae6c52", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\nx,y =map(int,input().split(':'))\nx1,y1=map(int,input().split(':'))\n\n\nx5=(x1+x)//2\nx2=(x1+x)%2\nx4=(x2)*60\ny3=((y1+y))+x4\ny3=y3//2\nx3=x5+(y3//60)\nif x3<10:\n    x3=str(0)+str(x3)\ny3=y3%60\nif y3<10:\n    y3=str(0)+str(y3)\n\n\nprint(str(x3)+':'+str(y3))\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "a999c2046bc9a45fe4e3fd7c35ea9c8f", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def find(a,b):\n    if(b==0):\n        return a\n    else:\n        return find(b,a%b)\nn=input()\nif(n>=3):\n    if(n%2==0):\n        if(n%3!=0):\n            print max(((n*(n-2))/2)*(n-1),(n-1)*(n-2)*(n-3),n*(n-1)*(n-3))\n        else:\n            print max(((n*(n-2))/2)*(n-1),(n-1)*(n-2)*(n-3))\n    else:\n        print n*(n-1)*(n-2)\nelse:\n    print n\n", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "b7d13d8fc3742461b04e1ada426a1463", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import math\nfrom collections import deque\ndef p(mid, arr, k):\n\tcounter = 0\n\t#d = deque()\n\ttotalSum = 0\n\t#sliding window\n\t#print (arr)\n\tsize = 0\n\tfor i in range(a, b+1):\n\t\tsize += 1\n\t\t#d.append(arr[i])\n\t\t\n\t\ttotalSum += arr[i]\n\t\ttakeAway = 0\n\t\tif size > mid:\n\t\t\ttakeAway = arr[i - mid]\n\n\t\ttotalSum -= takeAway\n\n\t\tif size >= mid:\n\t\t\tif totalSum < k:\n\t\t\t\treturn False\n\n\n\n\tif totalSum < k:\n\t\treturn False\n\treturn True\n\n\n\nsplitted = raw_input().split(\" \")\na = int(splitted[0])\nb = int(splitted[1])\nk = int(splitted[2])\n\n#generate primes up to b, using sieve\nsieve = [True] * (b + 1)\nprimes = deque()\nfor i in range(2, b + 1):\n\t#print (i)\n\tif sieve[i]:\n\t\tprimes.append(i)\n\telse:\n\t\tcontinue\n\tj = 2 * i\n\twhile j < b + 1:\n\t\tsieve[j] = False\n\t\tj += i\n\narr = [0] * (b + 1)\nfor prime in primes:\n\tarr[prime] = 1\n#print (primes)\n#print (arr)\ncounter = 0\nsavedI = -1\nlow = 1\nhigh = b - a + 1\nwhile low + 1 < high:\n\tmid = low + (high - low)/2\n\t#print (str(low) + \", \" + str(high))\n\tif p(mid, arr, k) == True:\n\t\thigh = mid\n\t\t#print (str(mid) + \" returned true\")\n\telse:\n\t\tlow = mid\n\t\t#print (str(mid) + \" returned false\")\nif p(high, arr, k) == True:\n\tprint (high)\nelse:\n\tprint (-1)", "lang_cluster": "Python", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "4c84cbfacd282aa170a3d6c691911100", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\nn = int(input())\n\nval = []\nmin_size = []\n\nfor i in range(math.trunc(math.sqrt(1000000))+1):\n    val.append(i*(i-1)+1)\n    min_size.append(4*i)\n    val.append(i*i+1)\n    min_size.append(4*i + 2)\n\nlast = 0\n\nfor idx in range(len(val)):\n    if n < val[idx]:\n        print(last)\n        break\n    else:\n        last = min_size[idx]\n", "lang_cluster": "Python", "tags": ["brute force", "math", "geometry"], "code_uid": "30976a96354d410416d6a126395653fa", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def generate_substring(s):\n    list = []\n    ll = len(string)\n    for i in range(ll):\n        for j in range(i, ll):\n            list.append(s[i:j + 1])\n    return list\n\nn = input()\nstring = raw_input()\nans = 0\nsumH = 0\nsumW = 0\n\nfor x in generate_substring(string):\n    sumH = 0\n    sumW = 0\n    for char in x:\n        if char == \"U\":\n            sumH += 1\n        if char == \"D\":\n            sumH -= 1\n        if char == \"L\":\n            sumW -= 1\n        if char == \"R\":\n            sumW += 1\n    if sumH == 0 and sumW == 0:\n        ans += 1\n\nprint ans\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "3db9b586f4dfa22e3589c31a7ebf734b", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys,math \nn=int(input())\ns=input()\nans=0\ni=n-1\nflag=True\nwhile(i>=0):\n    if i%2==1 and s[:i//2+1]==s[i//2+1:i+1] and flag:\n        ans+=1 \n        i//=2\n        flag=False\n    else:\n        i-=1 \n        ans+=1 \nprint(ans)        \n        \n        \n    \n    \n    \n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "499da7802df4c96325c8f2008a1f6b3c", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n = int(raw_input())\na = int(raw_input())\nb = int(raw_input())\nc = int(raw_input())\n\nif b > n or (b - c) >= a:\n    print n // a\n    exit(0)\n\nnum = n // (b - c)\n\nr = n - num * (b - c)\nif r < c:\n    d = c - r\n    adjustment = (d + (b - c) - 1) / (b - c)\n    num -= adjustment\n    r += (b - c) * adjustment\n\nnum += r // a\nprint num\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "8f438ff5c7f1938f9ab45e43b4d70a8c", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, p, k = map(int, input().split())\nans = \"\"\nfor num in range(p - k, p + k + 1):\n    if n >= num > 0:\n        if num == p:\n            ans += \"(\" + str(num) + \")\"\n        else:\n            ans += str(num)\n        if num != p + k:\n            ans += \" \"\n# print(ans)\nif p - k > 1:\n    ans = \"<< \" + ans\nif p + k < n:\n    ans += \" >>\"\nprint(ans)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "11776aaf5ff5dd915450cfbfe1cf7c19", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n=input()\na=map(int,raw_input().split())\nd=a[1]-a[0]\nfor i in range(1,n):\n    if a[i]-a[i-1]!=d:\n        print a[-1]\n        break\nelse:\n    print a[-1]+d", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "6c4c2bab5c134b38b390f1f3b07b411a", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=input()\ns=set(map(int,input()))\nf=lambda x: x&s!=set()\nprint(\"NO\" if sum([f({1,4,7,0}),f({1,2,3}),f({3,6,9,0}),f({7,0,9})])<4 else \"YES\")", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "14a20ae9773d6a495e1c38bf57b271b4", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x,y = map(int,input().split())\n\nif  x > 0 and y > 0:\n    print(0, x + y, x + y, 0)\nelif x < 0 and y > 0:\n    print(-y + x, 0, 0,-x + y)\nelif x > 0 and y < 0:\n    print(0, y - x, x - y, 0)\nelse:\n    print(x + y, 0,0, x + y)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "e8f624d23e36b837e350d21df82c289f", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = input()\nb = input()\nc = input()\nd = a + b + c\nif a[0] == c[2] and a[1] == c[1] and b[0] == b[2] and a[2] == c[0]:\n\tprint('YES')\nelse:\t\n\tprint('NO')\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "25cdc75a1bc3aed0d9bbddab49fbf4e2", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\na,b,c,d = map(int, input().split())\ns1 = max(0.3 * a, int(a * (1 - c / 250)))\ns2 = max(0.3 * b, int(b * (1 - d / 250)))\nif s1 > s2:\n\tprint('Misha')\nelif s1 == s2:\n\tprint('Tie')\nelse:\n\tprint('Vasya')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "0c1f0907f688cfeaf6f5f0c1fdb45149", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def inint():\n    return int(input())\ndef inlist():\n    return list(map(int,input().split()))\n\ndef main():\n    n=inint()\n    a=inlist()\n    sol=999999999\n    for j in range(n):\n        sol1=0;x=j\n        for i in range(n):\n            sol1+=a[i]*(abs(i-x)+i+x+abs(x-0)+abs(i-0)+abs(x-i))\n        sol=min(sol,sol1)\n    print(sol)\n\n\nif __name__ == \"__main__\":\n    #import profile\n    #profile.run(\"main()\")\n    main()", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "17b9fa6ea526fb8a88bd01eca05609e9", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\n# from fractions import *\n# from 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 Ceil(a,b): return a//b+int(a%b>0)\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---------------------------#\n# vsInput()\n\nl,r=value()\nans=0\n\nR=len(bin(r))-2\n\nfor i in range(61):\n    if(l&(1<<i) ^ r&(1<<i)):\n        ans=2**(i+1)-1\n    \n\nprint(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\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", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "7becc21fb73c4476fa6f2267e8940c35", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s, v = input(), set()\nwhile s not in v:\n    v.add(s)\n    s = s[-1] + s[:-1]\nprint(len(v))", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "afdee83119fbbfcedecabc7e35206cbf", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\ndef res(arr):\n    diff = 0\n    for i in range(3):\n        diff =  diff ^arr[i]\n    if diff == 0:\n        return 1\n\n    for i in range(2):\n        if  brr[i]%arr[i] != 0: \n            continue\n        div = brr[i] // arr[i]\n        count = 0\n        for j in range(i+1,3):\n            if brr[j]%arr[j] != 0: \n                continue\n            if div == brr[j]//arr[j]:\n                count +=1\n        if count > 1:\n            return 2\ndef solution():\n\n    n = int(input())\n    low = math.floor(n**(1/10))\n    st = 'codeforces'\n    cal = low**(10)\n    lo = [low for i in range(10)]\n    for i in range(0,10):\n        if cal >= n:\n            break\n        lo[i] = low+1\n        cal = cal// low\n        cal *= (low+1)\n    # print(lo)\n    for i in range(10):\n        print(st[i]*lo[i],end= '')\n\n\nsolution()\n  \n", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "3ec77179286035bf8f5dca6c8e943524", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\na = (input())\nA = a.split(' ')\ntwod_list = []\n\nfor i in A:\n    twod_list.append(int(i))\n\nArray =[\"baabcac\",\"aabcacb\",\"abcacba\",\"bcacbaa\",\"cacbaab\",\"acbaabc\",\"cbaabca\"]\n\nMaxx = 0\nMinn = 0\n\na= twod_list[0]\nb=twod_list[1]\nc=twod_list[2]\nAllDayys = 0\nFactor = 0\nFactor1 = sys.maxsize\nFactor2 = sys.maxsize\nFactor3 = sys.maxsize\nif a >=3 and b >=2 and c >=2:\n    Minn = min(a,min(b,c))\n    Factor1 = (int)(a /3)\n    Factor2 = (int)(b /2)\n    Factor3 = (int)(c /2)\n\n    Factor = min(Factor1,min(Factor2,Factor3))\n    #print(Factor)\n    twod_list[0] = twod_list[0] - (3 * Factor)\n    twod_list[1] = twod_list[1] - (2 * Factor)\n    twod_list[2] = twod_list[2] - (2 * Factor)\n    AllDayys = (Factor*7)\n\n\nfor i in range(7):\n    a= twod_list[0]\n    b=twod_list[1]\n    c=twod_list[2]\n    Counter = 0\n    for j in range (7):\n        #print(Array[i][j],end=\" \")\n        if Array[i][j]=='a':\n            if a > 0:\n                a= a -1\n                Counter = Counter + 1\n            else :\n                break\n        elif Array[i][j]=='b':\n            if b > 0:\n                b= b -1\n                Counter = Counter + 1\n            else :\n                break\n        elif Array[i][j]=='c':\n            if c > 0:\n                c= c -1\n                Counter = Counter + 1\n            else :\n                break\n        Maxx = max(Maxx,Counter)\n\nprint(Maxx+AllDayys)\n\n\n\n\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "0b537dd8ae46fb7fc345ab70ded2345e", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from sys import stdin\nx,y,n = stdin.readline().split()\nx=int(x)\ny=int(y)\nn = int(n)\nif x<0:\n x = -x\nif y<0:\n y = -y\nvalid = 1\nif x+y>n:\n valid = 0\nelif (n-x-y)%2:\n valid = 0\nif valid:\n print \"YES\"\nelse:\n print \"NO\"", "lang_cluster": "Python", "tags": ["math"], "code_uid": "6a4250fc4ddecba415c5ae63291d6cdf", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def func(x,limit):\n    while True:\n        if(x < 0):\n            x = -x\n        elif (x > limit):\n            x = 2.0*limit - x\n        else:\n            return x\ntext = raw_input()\na,b,m = map(int,text.split())\ntext = raw_input()\nvx,vy,vz = map(int,text.split())\ndx = a/2.0 + (m*1.0/-vy)*vx\ndz = (m*1.0/-vy)*vz\ndx = func(dx,a)\ndz = func(dz,b)\nprint \"%.6f %.6f\" % (dx,dz)\n", "lang_cluster": "Python", "tags": ["math", "geometry", "implementation"], "code_uid": "cc5e97f1b0e5d72e9ca3330c8b9e9728", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\ns = input()\n\nprint(\"1\" * min(1, s.count('1')) + \"0\" * s.count('0'))\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "50cd64b6f52e70393e6b2e731ed8e335", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\n\n\ndef total_lines(initial, factor):\n    lines = 0\n    while initial > 0:\n        lines += initial\n        initial //= factor\n    return lines\n\n\nn, k = input().split()\n\nn = int(n)\nk = int(k)\n\nguess = 0\ninterval = 10 ** 9 // 2\nleeway = math.ceil(math.log(10 ** 9, k))\nwhile True:\n    current_max = total_lines(guess, k)\n    if n <= current_max <= n + 30:\n        for guess in range(guess - 1, -1, -1):\n            if total_lines(guess, k) < n:\n                guess += 1\n                break\n        break\n    elif current_max < n:\n        guess += interval\n    else:\n        guess -= interval\n    interval, remainder = divmod(interval, 2)\n    interval += remainder != 0\n\nprint(guess)\n", "lang_cluster": "Python", "tags": ["implementation", "binary search"], "code_uid": "fd02cae16abfed7f2bb995477cecc2eb", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(10**4)\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()\nmemo1={}\nmemo2={}\ndef dpmax(n,lim,s,no):\n if n==1:\n  if 0<=s<=9: \n   no.append(str(s))\n   return True\n  else: return False\n if (n,s) in memo1: \n  #print \"memo1 used\"\n  if memo1[n,s][0]:\n   no.clear()\n   no.extend(memo1[n,s][1])\n  return memo1[n,s][0]\n for i in xrange(9,(0 if lim==n else -1),-1):\n  no.append(str(i))\n  if dpmax(n-1,lim,s-i,no):\n   memo1[n,s]=[True,list(no)]\n   return True\n  else: no.pop()\n memo1[n,s]=[False,[]]\n return False\ndef dpmin(n,lim,s,no):\n if n==1:\n  if 0<=s<=9: \n   no.append(str(s))\n   return True\n  else: return False\n if (n,s) in memo2: \n  if memo2[n,s][0]:\n   no.clear()\n   no.extend(memo2[n,s][1])\n  return memo2[n,s][0]\n for i in xrange((1 if n==lim else 0),10):\n  no.append(str(i))\n  if dpmin(n-1,lim,s-i,no):\n   memo2[n,s]=[True,list(no)]\n   return True\n  else: no.pop()\n memo2[n,s]=[False,[]]\n return False\nn,s=listInput()\nma=[]\nmi=[]\nif dpmax(n,n,s,ma) and dpmin(n,n,s,mi):\n print \"\".join(mi),\"\".join(ma)\nelse: print -1,-1", "lang_cluster": "Python", "tags": ["greedy", "dp", "implementation"], "code_uid": "2dded34e291e21affa16abb915fa03d7", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from math import ceil\n\nt=int(input())\ndef isprime(x):\n    for i in range(2,ceil(x**.5)+1):\n        if x%i==0:\n            return False\n    return True\n\nfor i in range(t):\n    x,y=map(int,input().split())\n    if x-y!=1:\n        print('NO')\n        continue\n    else:\n        if isprime(x+y):\n            print('YES')\n        else:\n            print('NO')", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "cd1ca11868db1376d6744264534e0b6b", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "s = input()\na = ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']\nprint (['No', 'Yes'][any(i in s for i in a)])", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "90cb26505c4c75643d822ce9b993f195", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\ninput = sys.stdin.readline\nins = lambda: input().rstrip()\nini = lambda: int(input().rstrip())\ninm = lambda: map(int, input().rstrip().split())\ninl = lambda: list(map(int, input().split()))\nout = lambda x, s='\\n': print(s.join(map(str, x)))\n\nn, m = inm()\nprint(min(min(n, m), (n+m) // 3))\n\n\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "cf7cf1325163b69b4c45ddb32fbda26d", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys as system_break\r\ndef Commonfinder(n,m):\r\n    if type(n)!=set:\r\n        n={n}\r\n    if type(m)!=set:\r\n        m={m}\r\n    Common_in_both=n|m\r\n    return Common_in_both\r\nimport math as m\r\nimport re as MATCHING_DEVICE\r\nInput= input()\r\nInput= Input.split()\r\nablist =[]\r\nfor i  in  range(len(Input)):\r\n    ablist.append( int( Input[i] ))\r\na=ablist[0];b=ablist[1]\r\nBinofa=bin(a)[2:]\r\nBinofb=bin(b)[2:]\r\nExtended_A=Binofa+'1'\r\nStriped_A=Binofa.rstrip('0')\r\nFirstCF=Commonfinder(Extended_A,Striped_A)\r\nSecondCF=Commonfinder(FirstCF,Extended_A[::-1])\r\nFinalCF=Commonfinder(SecondCF,Striped_A[::-1])\r\nFormated_Str=f'1*({Extended_A}|{Striped_A}|{Extended_A[::-1]}|{Striped_A[::-1]})1*'\r\nif len(FinalCF)==1:\r\n    FinalCF=list(FinalCF)\r\n    FinalCF=FinalCF[0]\r\n    if (MATCHING_DEVICE.fullmatch(FinalCF,Binofb)) or Binofa ==Binofb:\r\n        print('YES')\r\nelse:\r\n    answer=''\r\n    #FinalCF=list(FinalCF)\r\n    if a==b or MATCHING_DEVICE.fullmatch(Formated_Str, Binofb):\r\n            print('YES')\r\n    else:\r\n        print('NO')", "lang_cluster": "Python", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "4eb0da79cc7e15ee842f0fb01aefc8fc", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# Help Vasilisa the Wise 2\n\nimport itertools\n\n\ndef calculate(r1, r2, c1, c2, d1, d2):\n    combinations = list(itertools.permutations([i for i in range(1,10)], 4))\n    for (x1, x2, x3, x4) in combinations:\n        r1_sum = x1 + x2\n        r2_sum = x3 + x4\n        c1_sum = x1 + x3\n        c2_sum = x2 + x4\n        d1_sum = x1 + x4\n        d2_sum = x2 + x3\n\n        if (r1_sum == r1 and r2_sum == r2 and c1_sum == c1 and c2_sum == c2 and d1_sum == d1 and d2_sum == d2):\n            print(str(x1) + \" \" + str(x2))\n            print(str(x3) + \" \" + str(x4))\n            return\n    print(-1)\n\n\nif __name__ == \"__main__\":\n    r1, r2 = list(map(lambda x: int(x), input().split()))\n    c1, c2 = list(map(lambda x: int(x), input().split()))\n    d1, d2 = list(map(lambda x: int(x), input().split()))\n    calculate(r1, r2, c1, c2, d1, d2)\n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "1926601bc2e86052246a941904d953c0", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "__author__ = 'neki'\n\nimport sys\n\n#sys.stdin = open(\"friendsPresents.in\", \"r\")\n#sys.stdout = open(\"friendsPresents.out\", \"w\")\n\nwords = input().split()\ncnt1 = int(words[0])\ncnt2 = int(words[1])\nx = int(words[2])\ny = int(words[3])\n#print(cnt1, cnt2, x, y)\n\ndef determine(num, x, y, cnt1, cnt2):\n    like1 = num - num // x\n    like2 = num - num // y\n    like1and2 = like1 + like2 - num + num // (x*y)\n    #print(like1, like2, like1and2)\n\n    friend1 = like1 - like1and2\n    friend2 = like2 - like1and2\n    both = like1and2\n    #print(num, friend1, friend2, both)\n\n    cond1 = 0\n    cond2 = 0\n    if friend1 + both >= cnt1 and friend2 + both >= cnt2:\n        cond1 += 1\n    if friend1 + friend2 + both >= cnt1 + cnt2:\n        cond2 += 1\n    if cond1 > 0 and cond2 > 0:\n        return 1\n    return 0\n\nlim = 0\nlim1 = 1\nlim2 = -1\nwhile 1:\n    if lim2 < 0:\n        lim = lim1 * 2\n    else:\n        lim = (lim1 + lim2) // 2\n    if lim == lim1:\n        break\n    if determine(lim, x, y, cnt1, cnt2) == 1:\n        lim2 = lim\n    else:\n        lim1 = lim\n    #print(\"(\", lim1, lim2, \")\")\nprint(lim2)\n", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "90e59a882b808cab5d70c8e409b14d50", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin\nimport math\nn,m,a,b=map(int,stdin.readline().split())\np=int(math.ceil(n/m))*b\nq=n*a\nr=(n//m)*b+(n%m)*a\nprint(min(p,q,r))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "dacbec0ce21c759bdc9a88c5621fb5c7", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from sys import stdin\nfrom collections import deque\n\n\nclass base:\n    def __init__(self, s, base):\n        self.num, self.base = [0] + s, base\n\n    def __add__(self, other):\n        out = base([0] * (max(len(other.num), len(self.num)) - 1), self.base)\n        carry = 0\n\n        for i in range(len(self.num) - 1, -1, -1):\n            su = self.num[i] + other.num[i] + carry\n            if su < self.base:\n                out.num[i], carry = su, 0\n            else:\n                out.num[i], carry = su % self.base, 1\n\n        return out\n\n    def div(self, other):\n        carry = 0\n        for i in range(len(self.num)):\n            cur = self.num[i] + carry * self.base\n            self.num[i], carry = divmod(cur, other)\n\n    def tobase(self, s, base):\n        res = deque([])\n        if s == 0:\n            return '0'\n\n        while (s != 0):\n            res.appendleft(letters[s % base])\n            s //= base\n\n        return ''.join(res)\n\n    def todecimal(self, s, base):\n        res = 0\n        for i in range(len(s)):\n            res = (res * base) + letters.find(s[i])\n        return res\n\n\nform = lambda n: '{:0>' + str(n) + '}'\nletters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nn, m = map(int, stdin.readline().split())\nnum = base([], 2)\nman, mam, ans = num.tobase(n - 1, 7), num.tobase(m - 1, 7), 0\n\nif len(man) + len(mam) <= 7:\n    cur = ['0', '0']\n    for i in range(n):\n        cur[0] = form(len(man)).format(num.tobase(i, 7))\n        for j in range(m):\n            cur[1] = form(len(mam)).format(num.tobase(j, 7))\n            ans += (len(set(cur[0]).union(set(cur[1]))) == (len(man) + len(mam)))\n\nprint(ans)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "combinatorics"], "code_uid": "41c84dc012b6339b5460782b38cd189a", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from collections import Counter\n\nn=input()\nl=map(int,raw_input().split(\" \"))\nprint max(Counter(l).values())\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "81dfce620fe1450661cfdbac94a3fbe5", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = [int(i) for i in input().split()]\nm=0\nfor i in s:\n    if s.count(i) >= 2:\n        s = list(set(s))\n\nm = len(s)\n\nif m == 4:\n    print(0)\nelif m == 3:\n    print(1)\nelif m == 2:\n    print(2)\nelse:\n    print(3)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "1232c75961b5aefb45139fa03a81cbe9", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\ns=input()\n\nc=0\nfor i in range(1,n):\n    if s[i]==s[i-1]:\n        c+=1\nprint(c)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "62cb80f1ee58dd93a7d451743c4e4ddc", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def gcd(a, b):\n    while(b != 0):\n        a %= b\n        t = a\n        a = b\n        b = t\n    return a\n\ndef main():\n    a, b = map(int, input().split(' '))\n    gg = gcd(a, b)\n    ans = 0\n    can = 1\n    A = []\n    A.append(a / gg)\n    A.append(b / gg)\n    for g in A:\n        while(g != 1):\n            ok = 0\n            if g % 2 == 0:\n                g = g / 2\n                ok = 1\n                ans = ans + 1\n            if g % 3 == 0:\n                g = g / 3\n                ok = 1\n                ans = ans + 1\n            if g % 5 == 0:\n                g = g / 5\n                ok = 1\n                ans = ans + 1\n            if ok == 0:\n                can = 0\n                break\n    \n    if can == 0:\n        print(\"-1\")\n    else:\n        print(ans)\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "cc8782724428064d21785160b810032f", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "# def ln(n):\n# \tans = 0\n# \twhile n>0:\n# \t\tans += 1\n# \t\tn /= 10\n# \treturn ans\n# n = int(raw_input())\n# su = n*2-1\n# x = str(su)\n# f = True\n# for i in x:\n# \tif i != '9':\n# \t\tf = False\n# \t\tbreak\n# if f:\n# \tprint 1\n# else:\n# \tnow = 0\n# \tlen = ln(su)\n# \tb = [False]*(n+1)\n# \td = \"\"\n# \tfor i in range(len-1):\n# \t\td += '9'\n# \tfor i in range(0,9):\n# \t\tp = int(str(i)+d)\t\n# \t\t# for j in range(1,n+1):\n# \t\t# \tif not b[j]:\n# \t\t# \t\tif p-j<=n and p-j>0:\n# \t\t# \t\t\tb[j] = True\n# \t\t# \t\t\tb[p-j] = True\n# \t\t# \t\t\tnow += 1\n# \t\tif p>=(n+1):\n# \t\t\tnow += p/2\n# \t\telif p>(2*n+1):\n# \t\t\tnow += 0\n# \t\telse:\n# \t\t\tnow += (su-p)\n# \tprint now\n# ########################################\n# s,a = set('abcdefghijklmnopqrstuvwxyz'),0\n# for _ in range(input()-1):\n# \tc,w = raw_input().split()\n# \tif len(s)==1 and c!='.':a+=1\n# \tw = set(w)\n# \tif c=='!':s&=w\n# \telse:s-=w\n# print a\n# ###########################################\nl = map(int,raw_input().split())\nd = {}\nfor i in range(6):\n\td[l[i]] = d.get(l[i],0)+1\nif len(d)==1 or len(d)==2 or len(d)==3:\n\tif len(d)==1:\n\t\tprint \"Elephant\"\n\telse:\n\t\tlegs = False\n\t\theadBody = False\n\t\tfor i in d:\n\t\t\tif d[i]>=4:\n\t\t\t\tlegs = True\n\t\t\tif d[i]==2:\n\t\t\t\theadBody = True\n\t\tif legs:\n\t\t\tif headBody:\n\t\t\t\tprint \"Elephant\"\n\t\t\telse:\n\t\t\t\tprint \"Bear\"\n\t\telse:\n\t\t\tprint \"Alien\"\nelse:\n\tprint \"Alien\"", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b486da05eddff25d88f08fec947bfd86", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Apr 13 21:58:24 2016\n\n@author: Administrator\n\"\"\"\n\nn,m=map(int,raw_input().split())\nif n % 2 == 1 and m % 2 == 1:\n    print n/2+m/2+(n/2)*(m/2)*2\nelse:\n    print n*m/2", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "1c3c6972c8550177431ba88509401009", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b,a%b)\nn, m, a, b = map(int,raw_input().split())\ng = gcd(a,b)\na = a // g\nb = b // g\nc = n // a\nd = m // b\nc = min(c,d)\nprint a*c, b*c", "lang_cluster": "Python", "tags": ["binary search", "number theory"], "code_uid": "a03532ce213f0be184556e85a41d8718", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from __future__ import print_function\nl=raw_input()\nl=l.lower()\nn=[]\na=len(n)\nv='a','e','i','o','u','y'\nfor i in l:\n    if i not in v:\n        n.append(\".\")\n        n.append(i)\nfor i in n:\n    print(i,end=\"\")\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "c1ebce02a1e173a96acaa8df486dad9a", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys,io\nimport re,math\nstart = time.clock()\np=[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,\n       103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,\n       197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,\n       307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,\n       419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,\n       523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,\n       643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,\n       761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,\n       883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]\n(n,k)=map(int, raw_input().split())\nchk=0\nfor i in range(n):\n    if p[i]+p[i+1]+1>n: break\n    elif p[i]+p[i+1]+1 in p:\n#        print p[i]+p[i+1]+1\n        chk+=1\nprint 'YES' if chk>=k else 'NO'", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "cde235d8515f9ccda6ad182519798b73", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#import math\n#n, m = input().split()\n#n = int (n)\n#m = int (m)\nn, m, k = input().split()\nn = int (n)\nm = int (m)\nk = int (k)\n#n = int(input())\n#m = int(input())\n#s = input()\n##t = input()\na = list(map(int, input().split()))\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#f1 = sorted(t, key = lambda tup: tup[0])\na = sorted(a, reverse= True)\ns = 0\ni = 0\nf = True\nwhile(k +s < m):\n    s += a[i] -1\n    i+= 1;\n    if (i == n and k+s < m):\n        f = False\n        break\nif (m == 1 and k ==1):\n    print(0)\nelif f:\n    print(i)\nelse:\n    print(-1)\n", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "eadf34afb8ff910722066f15b2f37e08", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "input()\ns = input()\nprint(('NO', 'YES')[s.count('SF') > s.count('FS')])", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "37f3d9d8a137e7999ce23e1db37cb1e4", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "c,d = list(map(int, input().split(\" \")))\nn, m = list(map(int, input().split(\" \")))\nk = int(input())\nmini = n*m-k\nif mini < 1:\n\tprint(0)\nelif d * n <= c: # easier one at a time\n\tprint(d*mini)\nelse:\n\ttotal = (mini // n) * c\n\tmini = mini % n\n\ttotal += min(c, d*mini)\n\tprint(total)", "lang_cluster": "Python", "tags": ["math", "dp", "implementation"], "code_uid": "bfca8a9349007749cbf7ed3ee885d658", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b = map(int, input().split())\nk = 0\nk2 = 0\nwhile a > 0 and b > 0:\n    a -= 1\n    b -= 1\n    k += 1\nif a > 0:\n        k2 = int(a//2)\nelif b > 0:\n        k2 = int(b//2)\nprint(k, k2)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "1238f451970ae68c785036cde7ad10a5", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "__author__ = 'MoonBall'\n\nimport sys\n# sys.stdin = open('data/D.in', 'r')\nT = 1\nM = 1000000007\n\ndef process():\n    P, K = list(map(int, input().split()))\n    k = [K * x % P for x in range(P)]\n\n    # print(k)\n    # f(0) = k[f(0)]\n    # f(1) = k[f(4)]\n    # f(2) = k[f(3)]\n    # f(3) = k[f(2)]\n    # f(4) = k[f(1)]\n\n    if not K:\n        print(pow(P, P - 1, M))\n        return\n    if K == 1:\n        print(pow(P, P, M))\n        return\n\n    f = [0] * P\n    c = [0] * P\n    ans = 1\n    for i in range(P):\n        if f[i]: continue\n\n        cnt = 1\n        u = i\n        f[u] = 1\n        while not f[k[u]]:\n            u = k[u]\n            f[u] = 1\n            cnt = cnt + 1\n\n        c[cnt] = c[cnt] + 1\n\n    # print(c)\n    for i in range(2, P):\n        if c[i] != 0:\n            cnt = i * c[i] + 1\n            ans = ans * pow(cnt, c[i], M) % M\n\n    print(ans)\n\n\n\n\n\n\n\n\nfor _ in range(T):\n    process()\n", "lang_cluster": "Python", "tags": ["dsu", "math", "combinatorics", "number theory"], "code_uid": "5d47a35580bfefd1f36a6d946932b48b", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\n\ninput = sys.stdin.readline\n\ns = input().strip()\nmaxlen = 0\n\ndef checkpalin(s):\n    i = 0\n    j = len(s) - 1\n    while (i < j):\n        if (s[i] != s[j]):\n            return False\n        i += 1\n        j -= 1\n    return True\n\nfor i in range(len(s)):\n    for j in range(i, len(s)):\n        if not checkpalin(s[i:j+1]):\n            maxlen = max(maxlen, len(s[i:j+1]))\n\nprint(maxlen)", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "6bd032a47af8ba1e553262e4dc31dd85", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def answer():\n    a = [int(x) for x in input().split()]\n    i=0\n    while i<=a[0] and i+1<=a[1] and i+2<=a[2]:\n        i+=1\n    return i*3\n\n\n\n        \n\nprint(answer())", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "1d6f06ee309fb1cfed8338d9ed90a4fe", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nt = -1\nan = 0\na = list(map(int, input().split()))\nwhile a.count(1):\n    an = max(a.index(1) + a.count(1), an)\n    del a[a.index(1)]\n    \nprint(max(an, len(a)))\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "d22f3f53434188ee8982353ac8c5f44b", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\ns = input()\nres = 0\n\nfor i in s:\n  res += 1\n  if i == \"0\":\n    break\nprint(res)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "2942494d141e998fbe3f6a1eb956ed65", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from collections import Counter\nimport math\nfrom collections import Counter\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#for  _ in range(int(input())):\nfrom collections import Counter\n#arr=list(map(int,input().split()))\n#n = int(input())\n#for _ in range(n):\na,b,c,d= map(int, input().split())\nl=[a,b,c]\nl.sort()\na=l[0]\nb=l[1]\nc=l[2]\nval1=max(0,d-(b-a))\nval2=max(0,d-(c-b))\nprint(val1+val2)\n\n\n\n\n\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "83c15ac7c24117dc0f6ffd456b29fb48", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = input()\ncardsTurned: int = 0\ni = 0\nwhile i < len(s):\n    if s[i].isdigit():\n        if int(s[i]) % 2 != 0:\n            cardsTurned += 1\n    elif s[i] in {'a', 'e', 'u', 'i', 'o'}:\n        cardsTurned += 1\n\n    i += 1\nprint(cardsTurned)\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "ed0736c92a3682f13b015ebede561269", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b=map(int, input().split())\nc, d=map(int, input().split())\n\ng=abs(c-a)\nh=abs(d-b)\nx=max(g, h)\ny=min(g, h)\nz=abs(x-y)\nif g==h:\n  print(g)\nelse:\n  print(y+z)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "673ab16d6e3c18c72916134d40852e99", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m = map(int, input().split())\narr = list(map(int, input().split()))\nprint(\"NO\" if not sum(arr)-max(arr)<=m else \"YES\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "333ab7c1da221a942e5478f179529e49", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = int(input(), 2);\nfor i in range(88):\n    if 4**i >= s:\n        print(i);\n        break;\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "4ef0fa95f3e4a546c821659be4651780", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nprint(2 * n + 1 + (3 * n + 1) * n)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "df983b614a58da759291428ab427331f", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nimport math\nfrom collections import defaultdict,deque\nimport heapq\nn,k = map(int,sys.stdin.readline().split())\nss = sys.stdin.readline()[:-1]\ndp = [[0 for _ in range(n+1)] for i in range(n+1)]\ndp[n][1]=1\ndp[n][0]=1\ndic=defaultdict(list)\nfor i in range(n):\n\tdic[ss[i]].append(i+1)\n#print(dic,'dic')\nfor i in range(n-1,0,-1):\n\t#vis=defaultdict(int)\n\tfor j in range(1,n+1):\n\t\ts=0\n\t\tfor x in range(i+1,n+1):\n\t\t\ts+=dp[x][j-1]\n\t\tz=-1\n\t\tcnt=0\n\t\t#print(ss[i-1])\n\t\t#print(dic[ss[i-1]])\n\t\tfor y in dic[ss[i-1]]:\n\t\t\tcnt+=1\n\t\t\tif y==i:\n\t\t\t\tbreak\n\t\tsub=0\n\t\tif len(dic[ss[i-1]])>cnt:\n\t\t\tfor q in range(cnt,len(dic[ss[i-1]])):\n\t\t\t\tsub+=dp[dic[ss[i-1]][q]][j]\n\t\t\t\t#print(dic[ss[i-1]][q],'row',j,'col',sub,'sub')\n\t\t\t#sub=dp[dic[ss[i-1]][cnt]][j]\n\t\t#print(cnt,'cnt',i,'i',j,'j',s,'sssss',sub,'sub',cnt,'cnt',dic[ss[i-1]])\n\t\tdp[i][j]+=s-sub\n\t\t#print(s,'s',sub,'sub')\n'''for i in range(n+1):\n\tprint(dp[i],'dp')'''\ncost=0\nfor i in range(n,-1,-1):\n\tfor j in range(n+1):\n\t\t#print(k,'k',i,'i',j,'j')\n\t\tif dp[j][i]<=k:\n\t\t\tcost+=(n-i)*dp[j][i]\n\t\t\tk-=dp[j][i]\n\t\telse:\n\t\t\t#print(n,'n',i,'i',k,'k')\n\t\t\tcost+=k*(n-i)\n\t\t\tk=0\n\t\t\tbreak\n#print(cost,'cost',k,'k')\nif k!=0:\n\tprint(-1)\nelse:\n\tprint(cost)\n", "lang_cluster": "Python", "tags": ["strings", "dp"], "code_uid": "c006e4a392a9a5e746c249c603a56813", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\n\ndef main():\n    def modst(a, s):\n        ret = 1\n        while s:\n            if s % 2:\n                ret = ret * a % mod\n            a = a * a % mod\n            s //= 2\n        return ret   \n    def Cnk(n, k):\n        return (k <= n and n >= 0) * ((f[n] * modst((f[k] * f[n - k]) % mod, mod - 2)) % mod)\n    #n, v, u = map(int, sys.stdin.readline().split())\n    #n, k = map(int, sys.stdin.readline().split())\n    n = int(sys.stdin.readline().strip())\n    #a, b = map(int, sys.stdin.readline().split())\n    #q = list(map(int, sys.stdin.readline().split()))\n    #q = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)\n    mod = 998244353\n    f = [1, 1]\n    for i in range(2, 200007):\n        f.append((f[-1] * i) % mod)\n    a = 0\n    for i in range(2 - n % 2, n + 1, 2):\n        a = (a + Cnk(max(((n - i) // 2) + i - 1, 0), i - 1)) % mod\n    print((a * modst(modst(2, n), mod - 2)) % mod)\n    \n    \n    \n    \n        \n    \n        \n    \n    \n            \n    \n    \n         \n    \n#for i in range(int(sys.stdin.readline().strip())):\nmain()\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "26137140fbba5f1a2ead24dfffcf2513", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from itertools import combinations\nn,l,r,y=map(int,raw_input().split())\nnow=0\ndiff = [int(i) for i in raw_input().split()]\nfor L in range(2, n+1):\n  for subset in combinations(diff, L):\n    ms = max(subset)-min(subset)\n    tot = sum(subset)\n    if(tot>=l and tot<=r and ms>=y):\n        now+=1\nprint now\n", "lang_cluster": "Python", "tags": ["brute force", "bitmasks"], "code_uid": "d368e311555426d0b5ab55644dc0d524", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, k = [int(x) for x in input().strip().split()]\n\nif k == 1:\n    print(n)\nelse:\n    r = 1\n    while r <= n:\n        r *= 2\n    print(r - 1)\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "6583bb6efba0f557975f55cc47342dbb", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from collections import defaultdict\nfrom itertools import combinations\nclass Graph:\n    def __init__(self):\n        self.graph = defaultdict(list)\n        self.matrix = [[0 for i in range(5)] for j in range(5)]\n    def addEdge(self,fr,to):\n        self.graph[fr].append(to)\n        self.graph[to].append(fr)\n        self.matrix[fr-1][to-1] = 1\n        self.matrix[to-1][fr-1] = 1\n    def solveUtil(self,a,b,c):\n        if(self.matrix[a-1][b-1]==1 and self.matrix[a-1][c-1]==1 and self.matrix[b-1][a-1]==1 and self.matrix[b-1][c-1]==1 and self.matrix[c-1][a-1]==1 and self.matrix[c-1][b-1]==1):\n            return True\n        elif(self.matrix[a-1][b-1]==0 and self.matrix[a-1][c-1]==0 and self.matrix[b-1][a-1]==0 and self.matrix[b-1][c-1]==0 and self.matrix[c-1][a-1]==0 and self.matrix[c-1][b-1]==0):\n            return True\n        else:\n            return False\n    def solve(self,comb):\n        for i in comb:\n            if(self.solveUtil(i[0],i[1],i[2])==True):\n                return True\n        return False\nm = int(input())\nG = Graph()\nfor _ in range(m):\n    fr,to = map(int, input().split())\n    G.addEdge(fr,to)\nX = list(range(1,6))\ncomb = list(combinations(X,3))\nif(G.solve(comb)):\n    print(\"WIN\")\nelse:\n    print(\"FAIL\")", "lang_cluster": "Python", "tags": ["math", "implementation", "graphs"], "code_uid": "80d914df454e586c0e413279f2d8f471", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#Raquel Rufino\n\na,b = map(int,raw_input().split())\nz = 0\n\nn_quadrados = 0\n\nwhile True :\n        \n    n_quadrados = n_quadrados + (a / b)\n    \n    z = a   \n    a = b\n    b = z % b\n    \n    if b == 0 : \n        break\n\nprint n_quadrados   \n\n    ", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "cab82a6e555f78c857be0a95e28c7c0e", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import itertools as it\n\nmonth_to_days_non_leap = {\n    1: 31,\n    2: 28,\n    3: 31,\n    4: 30,\n    5: 31,\n    6: 30,\n    7: 31,\n    8: 31,\n    9: 30,\n    10: 31,\n    11: 30,\n    12: 31,\n}\n\ndef month_year_to_day(month, year):\n    if year % 4 == 0 and month == 2:\n        return 29\n    else:\n        return month_to_days_non_leap[month]\n\ndef good_date(day, month, year):\n    if month > 12: return False\n    if day > month_year_to_day(month, year): return False\n    return True\n\ndd, mm, yy = map(int, input().split('.'))\nbd, bm, by = map(int, input().split('.'))\n\nfound_sol = False\n\nfor p_bd, p_bm, p_by in it.permutations([bd, bm, by]):\n    if good_date(p_bd, p_bm, p_by):\n        year_diff = yy - p_by\n        if year_diff > 18:\n            found_sol = True\n            break\n        elif year_diff < 18:\n            continue\n        if p_bm < mm:\n            found_sol = True\n            break\n        elif p_bm > mm:\n            continue\n        if p_bd < dd:\n            found_sol = True\n            break\n        elif p_bd > dd:\n            continue\n        found_sol = True\n        break\n\nif found_sol:\n    print(\"YES\")\nelse:\n    print(\"NO\")\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b8d79caf394704bc5d1fb0d994266b22", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "ax,ay,bx,by,cx,cy=list(map(int,input().split()))\nax-=bx\nay-=by\ncx-=bx\ncy-=by\nprint('No'if ax*cy-ay*cx==0 or ax**2+ay**2!=cx**2+cy**2 else'Yes')\n", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "25fa9c110cf15920ffad234fdbbdd06b", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n,k = map(int,input().split())\nans = 1\nif k < 10**5:\n    for i in range(1,k+1):\n        if n % i != i-1:\n            ans = 0\n            break\nelse:\n    ans = 0\nprint(\"Yes\" * ans + \"No\" * (1 - ans))\n", "lang_cluster": "Python", "tags": ["brute force", "number theory"], "code_uid": "d07cb7361cb23255e85dc7c990db7150", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# from math import *\n# from itertools import *\n# import random\nn, k = map(int, input().split())\nprint((1 + (n // k)) * k)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5a6c6b97e818eff241da5184b27e2f89", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s = raw_input()\n\nq = set()\n\n\nfor i in xrange(len(s)+1):\n       for j in xrange(97,123):\n              q.add(s[:i]+chr(j)+s[i:])\n        \nprint len(q)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "strings"], "code_uid": "fc4206c5a553eb48b3cd1566cad3e9f3", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "def ni():\n    return int(raw_input())\n\ndef nis():\n    return map(int, raw_input().split())\n\ndef si():\n    return raw_input()\n\nn = ni()\n\na = nis()\n\nmax_val = None\nstart = end = 0\ncurrent_max = 0\ncurrent_start = 0\n\nfor i in range(n):\n    val = a[i]\n    if val:\n        current_max -= 1\n    else:\n        current_max += 1\n\n    if max_val is None or current_max > max_val:\n        max_val = current_max\n        start = current_start\n        end = i\n\n    if current_max < 0:\n        current_max = 0\n        current_start += 1\n\nprint a.count(1) + max_val\n\n", "lang_cluster": "Python", "tags": ["brute force", "dp", "implementation"], "code_uid": "9a2af0d65c059fa42a3721d5d6b30d1c", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "nm = input().split(' ')\nn = int(nm[0])\nk = int(nm[1])\n\ns = input().split(' ')\ns= [int(i) for i in s]\nsumma = sum(s)\n\nmas = []\nfor i in range(k):\n    temp = summa\n    for j in range(0, n-i, k):\n        temp -= s[j+i]\n    mas.append(abs(temp))\nprint(max(mas))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "34674491e296bc000784d67f3c689659", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "\nn=int(input())\ns=input()\na=[int(x) for x in str(s)]\na.sort()\nl=[]\n#print(a)\nc=0\nfor i in range(n):\n    if(a[i]==1 or a[i]==0):\n        c+=1\na=a[c:]\n#print(a)\nfor i in range(len(a)):\n    if(a[i] != 2 and a[i]&(a[i]-1)==0):\n        res=a[i]\n        c=0\n        while(res%2==0):\n            res//=2\n            c+=1\n        a[i]-=1\n        l+=[2]*c\n        #print(a[i],end=\" \")\n    elif(a[i]%6==0):\n        c=0\n        res=a[i]//6\n        if(res&(res-1)==0):\n            while(res%2==0):\n                res//=2\n                c+=1\n            a[i]-=1\n            l+=[3]+[2]*c\n    elif(a[i]==9):\n        a[i]-=2\n        l+=[3]*2+[2]\na+=l\n\na.sort(reverse=True)\nfor i in range(len(a)):\n    print(a[i],end=\"\")\nprint()", "lang_cluster": "Python", "tags": ["math", "sortings", "greedy"], "code_uid": "efb99460738b66b909c0f90950f13d9e", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#import sys\n#sys.stdin = open(\"input.txt\")\n\nn = input()\ndigits = [int(digit) for digit in raw_input()]\nleft, right = sorted(digits[:n]), sorted(digits[n:])\n\nresult = True\n\nif left[0] < right[0]:\n    left, right = right, left\n\nwhile left:\n    if left[0] <= right[0]:\n        result = False\n        break\n    left, right = left[1:], right[1:]\n\nprint \"YES\" if result else \"NO\"", "lang_cluster": "Python", "tags": ["sortings", "greedy"], "code_uid": "ff39d1a419d84ec97643479f0f317319", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "p = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 1440]\nh, m = map(int, raw_input().split(\":\"))\nt = h * 60 + m\npr = -1\nfor i in p:\n  if pr < t <= i:\n    print i - t\n    break\n  pr = i  \n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "97a262790e3470b20a0d88e65a0be147", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, m, k = map(int, input().split())\n\nprint('Yes' if m >= n and k >= n else 'No')\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "277ecb4232ac281ef9e8913d8df98475", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "s = bin(int(input()))[2:]\nwhile len(s) < 6:\n    s = \"0\" + s\n\nx = \"0b\"\nx += s[0]\nx += s[5]\nx += s[3]\nx += s[2]\nx += s[4]\nx += s[1]\nprint(int(x, 2))", "lang_cluster": "Python", "tags": ["bitmasks"], "code_uid": "7b106280b855a7c31d6bce8e8d256003", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\nimport math\n\n\n\ndef primeFactors(n):\n    primes = set()\n    while n % 2 == 0:\n        primes.add(2) \n        n = n / 2          \n    for i in range(3, int(math.sqrt(n))+1, 2):          \n        while n % i == 0: \n            primes.add(i)\n            if len(primes) == 2:\n                print(\"1\")\n                exit(0)\n            n = n / i\n    if n > 2:\n        primes.add(n)\n    if len(primes) == 2:\n        print(\"1\")\n        exit(0)  \n    if len(primes) == 1:\n        print(str(primes.pop()))\n        exit(0)\n    if len(primes) == 0:\n        print(str(n))\n        exit(0)\n\nin_num = int(sys.stdin.readline()[:-1])\n\nif in_num == 1:\n    print(\"1\")\n    exit(0)\n\nprimeFactors(in_num)", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "d8da55427b6fd822375ef6dc76881970", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "S = input()\n\nans = 0\nmet = set()\n\nfor i in range(len(S)):\n    for j in range(i, -1, -1):\n        if S[j:i+1] in met:\n            ans = max(ans, i - j + 1)\n        else:\n            met.add(S[j:i+1])\n            \nprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "487c13218d4e38dfa69397e5d1a8d66f", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "al, ar = map (int, raw_input ().split ())\nbl, br = map (int, raw_input ().split ())\nif br >= al - 1 and al >= (br + 1) / 2 - 1 or bl >= ar - 1 and ar >= (bl + 1) / 2 - 1:\n    print 'YES'\nelse:\n    print 'NO'\n", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "ddbb783eb81838892e384a0d2d8dae78", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "b, a, n, k = map(int, input().split())\ndata = [[0 for i in range(a)]for j in range(b)]\nfor i in range(n):\n    xi, yi = map(int, input().split())\n    xi -= 1\n    yi -= 1\n    data[xi][yi] = 1\nanswer = 0\nfor i in range(b):\n    for j in range(a):\n        for x in range(i, b):\n            for y in range(j, a):\n                counter = 0\n                for x1 in range(min(i, x), max(i, x) + 1):\n                    for y1 in range(min(j, y), max(j, y) + 1):\n                        counter += data[x1][y1]\n                if counter >= k:\n                    answer += 1\nprint(answer)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "30acd4f4140023d9aac3927366c32e98", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, pos, l, r = map(int, input().split())\nif  (l == 1) & (r == n):\n    out = 0\nelif ((l == 1)&(pos == r)) | ((r == n)&(pos == l)):\n    out = 1\nelif l == 1:\n    out = abs(r - pos) +1\nelif r == n:\n    out = abs(pos - l) +1\nelif pos >= r:\n    out = pos - l + 2\nelif pos <= l:\n    out = r - pos +2\nelif (pos < r) & (pos > l):\n    if (r -pos) > (pos-l):\n        out = pos -l*2 +r +2\n    else:\n        out = 2*r -pos -l +2\nprint(out)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "3c5ff64425e22a1ea0ee35315e4bd3a8", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from __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().split(\" \"))\ndef msi(): return map(str,input().split(\" \"))\ndef li():  return list(mi())\n \ndef dmain():\n    sys.setrecursionlimit(1000000)\n    threading.stack_size(1024000)\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 log,sqrt,factorial,cos,tan,sin,radians\n#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\n#from decimal import *\n#import threading\n#from itertools import permutations\n#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy\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[1] \ndef sort2(l):return sorted(l, key=getKey,reverse=True)\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)]\ndef ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))\n \ndef ceil(x,y):\n    if x%y==0:\n        return x//y\n    else:\n        return x//y+1\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 \ndef calc(x,n):\n    c=0\n    while x>0:\n        if x>=n:\n            x-=n \n            c+=1\n        elif x>=(n-1):\n            x-=(n-1)\n            c+=1\n        elif x>=(n-2):\n            x-=(n-1)\n            c+=1\n        elif x>=(n-3):\n            x-=(n-1)\n            c+=1\n        else:\n            x-=1\n            c+=1\n    return c \ndef calc1(x,n):\n    c=0\n    while x>0:\n        if x>=n:\n            x-=n \n            c+=1\n        elif x>=(n-1):\n            x-=(n-1)\n            c+=1\n        elif x>=(n-2):\n            x-=(n-1)\n            c+=1\n        else:\n            x-=1\n            c+=1\n    return c \ndef calc2(x,n):\n    c=0\n    while x>0:\n        if x>=n:\n            x-=n \n            c+=1\n        elif x>=(n-1):\n            x-=(n-1)\n            c+=1\n        else:\n            x-=1\n            c+=1\n    return c \ndef calc3(x,n):\n    c=0\n    while x>0:\n        if x>=n:\n            x-=n \n            c+=1\n        else:\n            x-=1\n            c+=1\n    return c \ndef main():\n    x=ii()\n    if x>=5:\n        res=calc(x,5)\n    elif x>=4:\n        res=calc1(x,4)\n    elif x>=3:\n        res=calc2(x,3)\n    elif x>=2:\n        res=calc3(x,2)\n    else:\n        res=x \n    print (res)\n\n \n# region fastio\n# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\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()", "lang_cluster": "Python", "tags": ["math"], "code_uid": "de0b57e8c872763645c74a53ef3ce33e", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "input()\nstr = input()\n\nls = []\ncnt = 0\n\nfor s in str:\n  if s==\"B\":\n    cnt+=1\n  else:\n    if cnt!=0:\n      ls.append(cnt)\n    cnt=0\n\nif cnt>0:\n  ls.append(cnt)\n\nprint(len(ls))\n\nfor l in ls:\n  print(l, end=' ')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "15192990839adf33d75eeda23ab32936", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"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 os, sys, bisect, copy\nfrom collections import defaultdict, Counter, deque\n#from functools import lru_cache   #use @lru_cache(None)\nif os.path.exists('in.txt'): sys.stdin=open('in.txt','r')\nif os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')\n#\ndef input(): return sys.stdin.readline()\ndef mapi(arg=0): return map(int if arg==0 else str,input().split())\n#------------------------------------------------------------------\n\n\na,b,c,d = mapi()\nres = 0\nfor i in range(a,b+1):\n    #for j in range(b,c+1):\n    #    res+=max(0,min(d,i+j-1)-c+1)\n    if i+b>d:\n        res+=(c-b+1)*(d-c+1)\n    else:\n        res+=max(0,(d-c+1)*(i+c-d))\n        x = max(0,i+b-c)\n        y = min(i,d-c)\n        res+=((x+y)*(y-x+1))//2\nprint(res)\n", "lang_cluster": "Python", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "ebe5b0a12cacd51c357da85fa4b23ded", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nfrom itertools import*\nfrom cmath import *\ninput = sys.stdin.readline\nfrom math import*\n############ ---- Input Functions ---- ############\ndef inp():\n    return(int(input().strip()))\ndef inlt():\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\nfor _ in range(int(input())):\n    n=inp()\n    flag=\"NO\"\n    for i in range(n+1):\n        for j in range(n+1):\n            if i*3+j*7==n:\n                flag=\"YES\"\n    print(flag)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "528dde0cf1ae7b16cc68720c963f3e99", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k = int(input())\nl = int(input())\nn = 1\nwhile (k**n)<=l:\n    if l==(k**n):\n        print('YES')\n        print(n-1)\n        exit()\n    n = n+1\nprint('NO')\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "52cb73b03d4535bb212e3a370c23a1b3", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nl = list(input().split(\" \"))\nl = [int(x) for x in l]\n\ngano = False\nsobornos = 0\n\ndef buscar_mayor(l):\n    pos_mayor = 1000\n    valor_mayor = -1\n    for i in reversed(range(len(l))):\n        if l[i]>valor_mayor:\n            valor_mayor = l[i]\n            pos_mayor = i\n    return pos_mayor\n\nwhile gano == False:\n    if buscar_mayor(l) == 0:\n        gano = True\n    else:\n        m = buscar_mayor(l)\n        l[0] += 1\n        l[m] -= 1\n        sobornos += 1\n\nprint(sobornos)\n\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "0eca8438514dfb791afad772322c5c6d", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nt = input().split()\n\n# current_time = 0\n# total_time = 0\n# for idx, i in enumerate(t):\n#     i = int(i)\n#     if i-current_time > 15:\n#         total_time += 15\n#         break\n#     else:\n#         total_time = i\n#     current_time = i\n#\n#     if idx == n-1:\n#         if current_time + 15 <= 90:\n#             total_time += 15\n#         else:\n#             total_time = 90\n\ncurrent_time = 0\nfor i in t:\n    i = int(i)\n    if current_time + 15 < i:\n        break\n    else:\n        current_time = i\n\nprint(min(current_time+15, 90))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "50fd40ececbb401a0166bfab84b8b0be", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\n\ndef numtri(sides):\n    side_tri = sum(sides[:3])\n    area = side_tri * side_tri\n    return area - sides[0]**2 - sides[2]**2 - sides[4]**2\n\nif __name__ == '__main__':\n    a = list(map(int, input().split()))\n    print(numtri(a))\n", "lang_cluster": "Python", "tags": ["brute force", "math", "geometry"], "code_uid": "88100d5d9573ff9d5b1cf53ce634f8bb", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "x,y,c=map(int,input().split())\nfor i in range(10**8):\n    x=x*10\n    if(x//y==c):\n        print(i+1)\n        break\n    x%=y\nelse:\n    print(-1)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "687cebc0717b227a7a71e8d212bcba97", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=[None]*3\na[0]=list(map(int,input().split()))\na[1]=list(map(int,input().split()))\na[2]=list(map(int,input().split()))\ntotal=0\nb=[None]*3\nfor i in range(3):\n      total+=a[i][0]\n      b[i]=a[i][0]\n\nwhile total<n:\n      if b[0]<a[0][1]:\n            k=a[0][1]-b[0]\n            if total+k>n:\n                  b[0]+=(n-total)\n                  total=n\n            else:\n                  b[0]+=k\n                  total+=k\n      if b[1]<a[1][1]:\n            k=a[1][1]-b[1]\n            if total+k>n:\n                  b[1]+=(n-total)\n                  total=n\n            else:\n                  b[1]+=k\n                  total+=k\n      if b[2]<a[2][1]:\n            k=a[2][1]-b[2]\n            if total+k>n:\n                  b[2]+=(n-total)\n                  total=n\n            else:\n                  b[2]+=k\n                  total+=k\n      \nprint(b[0],b[1],b[2])\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "c1f9c3691e5a36d411545872d8b51544", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from datetime import date\ny1=raw_input()\ny11=y1.split(':')\ny2=raw_input()\ny12=y2.split(':')\nt1= y11[1]\nd0 = date((int)(y11[0]), (int)(y11[1]), (int)(y11[2]))\nd1 = date((int)(y12[0]), (int)(y12[1]), (int)(y12[2]))\ndelta = d0 - d1\nprint abs(delta.days)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "0aacc568fecd1094895054ad8eb3fb75", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "field = list(filter(lambda l: l is not None, [input().strip().replace(' ', '') if (i not in [3, 7]) else (input(), None)[1] for i in range(11)]))\ny, x = map(int, input().split())\n\nx -= 1\ny -= 1\n\nx = (x % 3)\ny = (y % 3)\n\nflag = False\nfor i in range(y*3, y*3 + 3):\n    mut = list(field[i])\n    for u in range(x*3, x*3 + 3):\n        if mut[u] == '.':\n            flag = True\n            mut[u] = '!'\n    field[i] = ''.join(mut)\n\nif not flag:\n    for i in range(len(field)):\n        field[i] = field[i].replace('.', '!')\n\nfor u in range(len(field)):\n    if u in [3, 6]:\n        print()\n    i = field[u]\n    print('{} {} {}'.format(i[:3], i[3:6], i[6:]))\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "764ed4956016ee29bc908885375677ea", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = int(input())\ns = list(input())\n\nb = []\nfor i in range(a, 1, -1):\n    if a % i == 0:\n        b.append(i)\n\nfor i in range(len(b)-1, -1, -1):\n    s[0:b[i]] = reversed(s[0:b[i]])\n\ns = \"\".join(s)\nprint(s)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "72f78d9ae9f025807e729b822077ace2", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "num = int (input())\nif (num == 1 or num == 7 or num == 9 or num == 10):\n\tprint(\"NO\")\nelif (num == 12):\n\tprint(\"YES\")\nelif (num > 10 and num < 30):\n\tprint(\"NO\")\nelif (num == 31 or num == 37 or num == 39):\n\tprint(\"NO\")\nelif (num == 41 or num == 47 or num == 49):\n\tprint(\"NO\")\nelif (num == 51 or num == 57 or num == 59):\n\tprint(\"NO\")\nelif (num == 61 or num == 67 or num == 69):\n\tprint(\"NO\")\nelif (num >= 70 and num <= 79):\n\tprint(\"NO\")\nelif (num == 81 or num == 87 or num == 89):\n\tprint(\"NO\")\nelif (num >= 90 and num <= 99):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "bf88ba1eb397d4a8b8d8a76444851f49", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,l,r=map(int,input().split())\nm=n\na=1\nx=0\nA=[]\nB=[]\nwhile n>0:\n    if l==1:\n        A.append(1)\n        n-=1\n    else:\n        A.append(2**(l-1))\n        l-=1\n        n-=1\nwhile x<m:\n    if a==r:\n        B.append(2**(a-1))\n        x+=1\n    else:\n        B.append(2**(a-1))\n        x+=1\n        a+=1\nprint(sum(A),sum(B))\n        \n    \n    \n    \n", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "0dff3782c421099f55a098c99f27387c", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from math import *\nfrom collections import *\na = list(map(int,input().split()))\nif(sum(a)%5 == 0 and sum(a) > 0):\n    print(sum(a)//5)\nelse:\n    print(-1)\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "654781437d1f1c277890ad4a63fc6dbe", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "class CodeforcesTask146BSolution:\n    def __init__(self):\n        self.result = ''\n        self.a_b = []\n\n    def read_input(self):\n        self.a_b = [int(x) for x in input().split(\" \")]\n\n    def process_task(self):\n        num = self.a_b[0] + 1\n        mask = str(self.a_b[1])\n        while not \"\".join([x for x in str(num) if x in \"47\"]) == mask:\n            num += 1\n        self.result = str(num)\n\n    def get_result(self):\n        return self.result\n\n\nif __name__ == \"__main__\":\n    Solution = CodeforcesTask146BSolution()\n    Solution.read_input()\n    Solution.process_task()\n    print(Solution.get_result())\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "ae383fc758efc284a4a85ae10ca0b544", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "N = int(input())\n\nans = []\ncnt = 1\nwhile N != 0:\n    if N % 2 != 0:\n        ans.append(cnt)\n    N = N // 2\n    cnt += 1\nans.reverse()\nprint(\" \".join(map(str, ans)))\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "80ee1fd17f06b308bd81f2a76597b97b", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "# your code goes here\nn=int(input())\ndef s(x):\n    return sum(int(i) for i in str(x))\nx=int(n**0.5)\nd=0\nwhile x>=0 and d<=50:\n\tif(x*x+s(x)*x==n):\n\t#\tprint(x)\n\t\tbreak\n\td+=1\n\tx-=1\nif d>50:\n\tx=-1\nprint(x)\t", "lang_cluster": "Python", "tags": ["brute force", "math", "binary search"], "code_uid": "3b37a1e2ee5bf79404b0ff7ba52ab0c6", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "L = int(input().split()[1])-1\nc = [int(i) for i in input().split()]\nresult=0\n\nif c[L]==1:\n    result=1\nfor i in range(0,len(c)):\n    d = abs(L-i)\n    if c[i]==1:\n        if L<i:\n            if L-d<0 and d != 0:\n                result+=1\n            elif L-d >= 0:\n                if c[L-d]==1 and d != 0:\n                    result+=1\n        elif L>i:\n            if L+d>=len(c) and d != 0:\n                result+=1\n            elif L+d < len(c):\n                if c[L+d]==1 and d != 0:\n                    result+=1\nprint(result)", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "5d247d425ce64a9acd8c60dbde08ffb4", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "m,d=map(int,input().split(' '))\nif m!=2:\n    if d!=6 and d!=7:\n        print(5)\n    elif d==7:\n        print(6)\n    elif d==6:\n        if m==1 or m==3 or m==5 or m==7 or m==8 or m==10 or m==12:\n            print(6)\n        else:\n            print(5)\nelse:\n    if d!=1:\n        print(5)\n    else:\n        print(4)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "439ff05905de6ad384c3a6a309b96a3f", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from __future__ import print_function, division\nimport sys\n\nx = int(sys.stdin.read())\nprimo = [0] * (x+1)\n\nfor i in xrange(2, x+1):\n    if(primo[i]==0):\n        for j in xrange(i*2, x+1, i):\n            primo[j] = i\n    primo[i] = i - primo[i] + 1\n\nprime = x\n\nfor i in xrange(primo[x], x+1):\n    prime = min(prime, primo[i])\n\nprint(prime)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "0f34b45765174ad6e81ed3cb43084878", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n , a , b = map(int , input().split(' '))\nmaxx = 0\nfor i in range(1 , n):\n\tif(i <= a and n - i <= b):\n\t\tmaxx = max(maxx , min(a//i , b//(n - i)))\nprint(maxx)\n", "lang_cluster": "Python", "tags": ["brute force", "implementation", "binary search"], "code_uid": "908d88d8cbeacea20f0177e420751d77", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nprint(((n*(n-1)*(n-2)*(n-3)*(n-4))**2)//120)", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "59818fd9dcb02014b1f1ecbc70fab20e", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def check(x,p):\n    i = (x // 50) % 475\n    for _ in range(25):\n        i = (i*96 + 42) % 475\n        if (26+i) == p:\n            return 1\n    return 0\n\np,x,y = map(int,input().split())\nif check(x,p):\n    exit(print(0))\nfor i in range(x,y-1,-50):\n    if check(i,p):\n        exit(print(0))\n\nx += 100;\na = 1;\nwhile 1:\n    if check(x,p) or check(x-50,p):\n        exit(print(a))\n    x += 100; a += 1\n    \n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "3bf0b3404d4e9d9212d2f9d1ceb4ab70", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "f = input()\nm = input()\ns = input()\nif (f == \"rock\" and m == \"scissors\" and s == \"scissors\") or (f == \"paper\" and m == \"rock\" and s == \"rock\") or (f == \"scissors\" and m == \"paper\" and s == \"paper\"):\n  print(\"F\")\nelif (m == \"rock\" and f == \"scissors\" and s == \"scissors\") or (m == \"paper\" and f == \"rock\" and s == \"rock\") or (m == \"scissors\" and f == \"paper\" and s == \"paper\"):\n  print(\"M\")\nelif (s == \"rock\" and m == \"scissors\" and f == \"scissors\") or (s == \"paper\" and m == \"rock\" and f == \"rock\") or (s == \"scissors\" and m == \"paper\" and f == \"paper\"):\n  print(\"S\")\nelse:\n  print(\"?\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "24a631fc931f2dffa740e04bfb9e01d5", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "d, k, a, b, t = map(int, raw_input().split())\nif k <= d:\n\tn = d / k\n\t#ans = (n - 1) * t + n * k * a + b * (d - n * k)\n\tif k * a + t < k * b: ans = (n - 1) * t + n * k * a + min(b * (d % k), t + a * (d % k))\n\telse: ans = a * k + (d - k) * b\nelse:\n\tans = a * d\nprint ans", "lang_cluster": "Python", "tags": ["math"], "code_uid": "f1a048c2c17285aba38743032435101a", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\nif n <= 10:\n    print 0\nelif n == 20:\n    print 15\nelif n >= 22:\n    print 0\nelse:\n    print 4", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e3cc3d4942c081b236399880e8031a7a", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "print((lambda x: x if int(x)>=0 else int(x[:len(x)-2]+min(list(x[len(x)-2:]))))(input()))\n#author:SK__Shanto__\u32db\n#code__define__your__smartness", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "eeeb3824cdc98df80d625bc0621ab620", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "x=int(input())\ny=[int(a) for a in input().split()]\nz=[]\nfor i in y:\n    if i not in z:\n        z.append(i)\nz=sorted(z)\nl=len(z)\nif l==1:\n    print(0)\nif l>3:\n    print(-1)\nif l==3:\n    m=z[l//2]\n    z.remove(m)\n    for i in range(101):\n        a=z[0]+i\n        b=z[1]-i\n        if a==m and b==m:\n            print(i)\n            quit()\n    print(-1)\nelif l==2:\n    for i in range(101):\n        aa=z[0]\n        a=z[0]+i\n        b=z[1]-i\n        if a==b:\n            print(i)\n            quit()\n        elif aa==b:\n            print(i)\n            quit()\n    print(-1)\n    ", "lang_cluster": "Python", "tags": ["math"], "code_uid": "26380d3dbdfd7e7691a06eff915b2d83", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b, r = map(int, raw_input().split())\n\nif b >= r*2 and a >= r*2:\n        print \"First\"\nelse:\n        print \"Second\"", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "games"], "code_uid": "cb2ace98ea21914fb20384c0ce333c5f", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "R=raw_input\na,b=map(int,R().split())\ns=R()\ndef f(s):\n c=s.count\n return c('R')-c('L'),c('U')-c('D')\nX,Y=f(s)\nx,y=0,0\nq=0\nfor i in range(len(s)):\n c,d=f(s[:i])\n A=a-c;B=b-d\n if (X and A%X) or (Y and B%Y):continue\n if X==Y==0:\n  if A==B==0:q=1\n elif X==0:\n  if A==0 and B//Y>=0:q=1\n elif Y==0:\n  if B==0 and A//X>=0:q=1\n elif A//X==B//Y and A//X>=0:q=1\nprint[\"No\",\"Yes\"][q]\n\n", "lang_cluster": "Python", "tags": ["math", "implementation", "binary search"], "code_uid": "8f6463a6fffebdc983050783015569fa", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def reverse(s):\n    l = list(s)\n    l.reverse()\n    return \"\".join(l)\n\ndef count1(bit):\n    count = 0\n    while bit > 0:\n        if bit & 1 == 1:\n            count += 1\n        bit >>= 1\n    return count\n\ndef create_lucky(bit, length):\n    lucky = \"\"\n    for i in range(length):\n        if bit & 1 == 1:\n            lucky += '7'\n        else:\n            lucky += '4'\n        bit >>= 1\n    return reverse(lucky)\n\ndef super_lucky(num):\n    bit = 2 ** len(num)\n    for i in range(bit):\n        if count1(i) != len(num) / 2:\n            continue\n        lucky = create_lucky(i, len(num))\n        if int(lucky) >= int(num):\n            break\n    return lucky\n\ndef main():\n    num = raw_input()\n    if len(num) % 2 == 0:\n        max_num = \"7\" * (len(num) / 2) + \"4\" * (len(num) / 2)\n        if int(num) < int(max_num):\n            print super_lucky(num)\n        elif int(num) == int(max_num):\n            print max_num\n        else:\n            half = (len(num) + 2) / 2\n            print \"4\" * half + \"7\" * half\n    else:\n        half = (len(num) + 1) / 2\n        print \"4\" * half + \"7\" * half\n    \nmain()\n", "lang_cluster": "Python", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "76df549683b9343e27ae21d47838a35e", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "b = int(input())\ng = int(input())\nn = int(input())\n\nminig = min(n,g)\nminib = min(n,b)\nprint(minig - (n-minib) +1)\n\n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "759fe1bf495cee74e37b43688ae3923a", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\n\ndef main():\n    situation = sys.stdin.readline().strip()\n    nOne = 0\n    prev = \"\"\n    \n    for c in situation:\n        if c is prev:\n            nOne += 1\n        else:\n            nOne = 1\n            prev = c\n        if nOne >= 7:\n            print \"YES\"\n            return\n        \n    print \"NO\"\n        \n\nif __name__ == ('__main__'):\n    main()\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "14a007c6ffc92a14de40f9b2457af780", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\n\nif m <= n // 2: a = m + 1\nelse: a = m - 1\nif a > n: a = n\nif a < 1: a = 1\nprint(a)\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "3c94cbdab892767f021c74164e75f51b", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\nm = m % sum(i for i in xrange(1, n + 1))\ni = 1\nwhile True:\n    m -= i\n    if m == 0:\n        print 0\n        exit()\n    elif m < 0:\n        print m + i\n        exit()\n    i += 1", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5c2b60f593ed5a2fc4ea7e88054d8fe4", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a1,a2= [int(x)for x in input().split()]\ncounter = 0\nwhile a1 > 0 and a2 > 0:\n\ta1,a2 = min(a1,a2)+1,max(a1,a2)-2\n\tcounter+=1\nprint(counter-int(a1<0 or a2 < 0))", "lang_cluster": "Python", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "22f39b1f75f60358f01218987cf4145a", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[14]:\n\n\n# # n = int(input())\n# # line = list(map(int, input().split()))\n# # line = list(str(input()))\n# from tqdm import trange\n\n\n# In[24]:\n\n\nfrom collections import Counter\n\n\n# In[13]:\n\n\nmatrix = []\n\nfor _ in range(4):\n    matrix.append(list(str(input())))\n\n\n# In[29]:\n\n\nans = \"NO\"\n\nfor i in range(3):\n    for j in range(3):\n        tmp_list = [matrix[i][j], matrix[i][j+1], matrix[i+1][j], matrix[i+1][j+1]]\n        tmp_dict = Counter(tmp_list)\n        if max(tmp_dict.values()) >= 3:\n            ans = \"YES\"\n            break\n\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "08666196b2637004356f559eef4c2fdb", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, x = int(input()), int(input())\n\nfor i in range(n%6, 0, -1):\n    if not i&1:\n        if x == 1:\n            x = 2\n        elif x == 2:\n            x = 1\n    else:\n        if x == 1:\n            x = 0\n        elif x == 0:\n            x = 1\n\nprint(x)\n\n# 100\n# 010\n#\n# 1  2  3  4  5  6  7  8  9 10 11\n#\n# 0  1  2  2  1  0  0  1  2  2  1\n# 1  0  0  1  2  2  1  0  0  1  2\n# 2  2  1  0  0  1  2  2  1  0  0\n", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "43d0c82cd73803924b177bdc09eb70b0", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "# Meet\n\nn, m = (int(x) for x in input().split())\na = [int(x) for x in input().split()]\nd = {}\n\nif n>m:\n\tprint(0)\nelse:\n\tbig = 0\n\tfor i in a:\n\t\tif i in d:\n\t\t\tcontinue\n\t\telse:\n\t\t\td[i] = a.count(i)\n\t\t\tbig = max(d[i], big)\n\n\tans = 0\n\tfor i in range(1, big+1):\n\t\tc=0\n\t\tfor j in d.keys():\n\t\t\tif d[j]>=i:\n\t\t\t\tc+=d[j]//i\n\t\t\t\t# print(d[j], i)\n\t\t\t\n\t\tif c>=n:\n\t\t\tans = max(ans, i)\n\t\telse:\n\t\t\tbreak\n\n\tprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "implementation", "binary search"], "code_uid": "117457d56eb0daa8dc8db70f584e77d6", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn, c = list(map(int,input().split()))\np = list(map(int,input().split()))\nt = list(map(int,input().split()))\nsum1 = []\nsum2 = []\nsum = 0\nt2 = []\nfor i in range(n):\n    sum = sum + t[i]\n    t2.append(sum)\nsum = 0\nfor i in range(n):\n    sum = sum + p[i] - c*t2[i]\n    if sum>=0:\n        sum1.append(sum)\n    sum = 0\nt2 = []\np.reverse()\nt.reverse()\nfor i in range(n):\n    sum = sum + t[i]\n    t2.append(sum)\nsum = 0\nfor i in range(n):\n    sum = sum + p[i] - c*t2[i]\n    if sum>=0:\n        sum2.append(sum)\n    sum = 0\nsum = 0\nfor i in range(len(sum1)):\n    sum = sum + sum1[i]\nmm = sum\nsum = 0\nfor i in range(len(sum2)):\n    sum = sum + sum2[i]\nmm2=sum\nsum = 0\nif mm>mm2:\n    print(\"Limak\")\nelif mm<mm2:\n    print(\"Radewoosh\")\nelif mm==mm2:\n    print(\"Tie\")\n\n\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "a878227e7435c7b00734b2086456ce6e", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def solve(a, b, c):\n    ans = 0\n    ans = max(ans, a+b+c)\n    ans = max(ans, (a+b)*c)\n    ans = max(ans, a*b*c)\n    ans = max(ans, a*(b+c))\n    return ans\nif __name__ == '__main__':\n    a = int(input())\n    b = int(input())\n    c = int(input())\n    print(solve(a, b, c))", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "26d41a5dba3408e4f6325104117abdc7", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "z=raw_input()\na,b=map(long,z.split())\nprint a+b\n", "lang_cluster": "Python", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "4de77d7609cb7ce2f7d2d927bcda6ba0", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\n\nmatrix = []\nfor _ in range(n):\n    matrix.append(list(map(int, input().split())))\n\ntotal = 0\nfor i in range(n):\n    total += matrix[i][i] + matrix[i][n-1-i] + matrix[n//2][i] + matrix[i][n//2]\n\nprint(total - matrix[n//2][n//2]*3)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "85df19e769e108c751d95a4be0101311", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "ar=[\"December\",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\ns=input()\nn=int(input())\nprint(ar[((ar.index(s)+n)%12)])\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "8bafcba65f02139277ebcb8d1957cbc0", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\n\nn, k = sys.stdin.readline().strip().split(' ')\na = sys.stdin.readline().strip().split(' ')\na = list(map(int,a))\ns=0\nm=0\nn = int(n)\nk = int(k)\nfor i in range(n,0,-1):\n\tr = k%a[i-1]\n\tif r==0 and a[i-1]>m:\n\t\tm=a[i-1]\ns=k/m\nprint(int(s))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "431125b3842ce267420e6a80d5fe0f58", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k=int(input())\nz=(8*k+1)**0.5-1\nz=z/2\nif z%1!=0:\n    z+=1\nz=int(z)\np=(z**2-z)//2\nk-=p\nprint(k)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "ae26daf1630db4592168fce827c66f8d", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\nimport re\n\ndef query_decimal_from_binary(A):\n    ans = 0\n    for a in A:\n        ans = ans * 2 + a\n    return ans\n\ndef main():\n    n = int(input())\n    B = []\n    for i in range(10):\n        A = []\n        for j in range(i + 1):\n            A.append(1)\n        for j in range(i):\n            A.append(0)\n        B.append(query_decimal_from_binary(A))\n    #print(B)\n    ans = []\n    for b in B:\n        if n % b == 0:\n            ans.append(b)\n    print(max(ans))\n\nif __name__ == \"__main__\":\n    main()\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "2360c9aa5cc9d1101c52040f7690cc52", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "yellow_cry, blue_cry = list( map( int, input().split() ) )\nyellow, green, blue = list( map( int, input().split() ) )\n\nans = 0\n\nyellow = 2*yellow + green\nblue = 3*blue + green\n\nans = max( 0, (yellow-yellow_cry) ) + max( 0, blue-blue_cry )\n\nprint( ans )\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ba8dab93166f4e7352d7462d59e88ad7", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "size=int(input())\narr = list(map(int, input().split()))\ni=0\nwhile i<size-1 and arr[i]<arr[i+1]:\n     i+=1\nwhile i<size-1 and arr[i]==arr[i+1]:\n     i+=1\nwhile i<size-1 and arr[i]>arr[i+1]:\n    i+=1\nif i<size-1:\n   print (\"NO\")\nelse:\n   print (\"YES\")\n\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "c4cee736ea20360ba65ba9ddfefbaa47", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "i = input().split(' ')\nparticipants = input().split(' ')\n\n\ndef winers(participants, position):\n    i = int(position) - 1\n    while int(i) < len(participants):\n        if int(i) < 0:\n            return 0\n        elif int(participants[i]) < 1:\n            i -= 1\n        elif int(i) < len(participants) - 1 and participants[i] == participants[i + 1]:\n            i += 1\n        else:\n            break\n    return int(i) + 1\n\n\nprint(winers(participants, i[1]))\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "4605f3b014b4baf5b77fde414ed5d45b", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/local/bin/python2.7\n    \nimport fileinput\nimport fractions\n\nfor line in fileinput.input():\n  arr = [int(x) for x in line.split()]\n  gcd = fractions.gcd(arr[0], arr[1])\n  lcm = (arr[0] * arr[1]) / gcd\n  res = arr[3]/lcm - arr[2]/lcm \n  if arr[2] % lcm == 0:\n    res += 1\n  print res\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "10dea8c7d735d56520d29a3aeb958487", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "mod = 10**9+7\nn,l,r=map(int,input().split())\n\ndp = [[0]*3 for i in range(n)]\nrem0 = r//3-(l-1)//3\nrem1 = (r+2)//3 - (l+1)//3\nrem2 = (r+1)//3 -l//3\ndp[-1][0]=rem0\ndp[-1][1]=rem1\ndp[-1][2]=rem2\nfor i in range(n-1,-1,-1):\n    if i==n-1:\n        continue\n    \n    dp[i][0] = (rem0*dp[i+1][0])%mod\n    dp[i][0]=(dp[i][0]+ rem1*dp[i+1][2])%mod\n    dp[i][0] = (dp[i][0]+ rem2*dp[i+1][1])%mod\n    dp[i][1] = (rem0*dp[i+1][1])%mod\n    dp[i][1]=( dp[i][1]+ rem1*dp[i+1][0])%mod\n    dp[i][1] = (dp[i][1]+rem2*dp[i+1][2])%mod\n    dp[i][2] = (dp[i+1][0]*rem2)%mod\n    dp[i][2] = (dp[i][2] +rem0*dp[i+1][2])%mod\n    dp[i][2] = (dp[i][2]+rem1*dp[i+1][1])%mod\nprint(dp[0][0])\n    \n    \n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "90ad21a6c845ff2b2ceee6921d9492cc", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "number_of_columns = int(input())\nbox_p_column = [int(i) for i in input().split(' ')]\n\nbox_p_column = [str(i) for i in sorted(box_p_column)]\nprint(' '.join(box_p_column).strip())\n\n", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d6f0a47d0c65c3153e295eb91252bcdd", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\nimport itertools, sys\n\nn, k = [int(x) for x in input().split()]\n\nperms = zip(*[[int(''.join(p)) for p in itertools.permutations(input())] for y in range(n)])\n\nperms = list(perms)\n\n# print(perms)\n\nminimum = float(\"inf\")\n\nfor p in perms:\n\n\ttemp = max(p) - min(p)\n\n\tif temp < minimum:\n\t\tminimum = temp\n\nprint(minimum)\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "6641d80a5bda4ca0c4e46aa2da489db9", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from math import inf\r\n\r\ndef has_digit(x, i):\r\n    while x > 0:\r\n        if x%10 == i:\r\n            return True\r\n        x //= 10\r\n    return False\r\n\r\ndef num_len(x):\r\n    res = 0\r\n    while x > 0:\r\n        res += 1\r\n        x //= 10\r\n    return res\r\n\r\ndp = {}\r\n# n = target length\r\n# x = cur number\r\n# dp = 10-d list\r\n# dp[1][1][1][1][1][1]...\r\ndef dumb(n, x, state: tuple):\r\n    global dp\r\n    if num_len(x) == n:\r\n        return 0\r\n    if state in dp:\r\n        return dp[state]\r\n    \r\n    ans = inf\r\n    new_state = list(state)\r\n    for i in range(2,10):\r\n        if not has_digit(x, i):\r\n            continue\r\n\r\n        mult = i\r\n        for idx, fac in enumerate((2, 3, 5, 7)):\r\n            while mult%fac == 0:\r\n                new_state[idx] += 1\r\n                mult //= fac\r\n\r\n        ans = min(ans, 1+dumb(n, x*i, tuple(new_state)))\r\n        new_state = list(state)\r\n\r\n    dp[state] = ans\r\n    return ans\r\n\r\nn, x = [int(x) for x in input().split()]\r\nans = dumb(n,x,(0,0,0,0))\r\nprint(-1 if ans == inf else ans)\r\n", "lang_cluster": "Python", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "3b4100409cd26a886c167dc3297998bc", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "print [\"No\",\"Yes\"][(lambda x:min([x[i]+x[::-1][i]in[\"33\",\"46\",\"59\",\"77\",\"80\",\"64\",\"95\",\"08\"]for i in range(len(x))]))(raw_input())]", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "68cfc4d3cb1123f8416409f30705024b", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#coding=utf-8\nMOD = (10 ** 9) + 7\n(A, B, n, x) = map(int, raw_input().split())\n\nres0 = pow(A, n, MOD) * x % MOD\nif A == 1:\n    res1 = B * n % MOD\nelse:\n    res1 = (pow(A, n, MOD) - 1) * pow(A - 1, MOD - 2, MOD) * B % MOD\n\n#print res0, res1\nprint (res0 + res1) % MOD\n\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "855d6323ff3c2b0e4c89340ea509a88d", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def fun(n,k):\n    dp = [0]*(n+1)\n    dp[0]=1\n    for i in range(1,n+1):\n        dp[i]=sum(dp[max(i-k,0):i])\n    return dp[n]\nn,k,d=map(int,raw_input().split())\nprint (fun(n,k)-fun(n,d-1))%1000000007\n", "lang_cluster": "Python", "tags": ["dp", "implementation", "trees"], "code_uid": "b6086d521f1ae33a9a93e8f0fa16277a", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "INT=lambda:int(input())\na=INT()\nb=INT()\nc=INT()\nd=INT()\ne=INT()\nf=INT()\nif e>f:\n\tm=min(a,d)*e\n\td-=min(a,d)\n\tm+=min(b,c,d)*f\nelif e<f:\n\tm=min(b,c,d)*f\n\td-=min(b,c,d)\n\tm+=min(a,d)*e\nelse:\n\tif min(a,b)<min(b,c,d):\n\t\tm=min(b,c,d)*f\n\t\td-=min(b,c,d)\n\t\tm+=min(a,d)*e\n\telse:\n\t\tm=min(a,d)*e\n\t\td-=min(a,d)\n\t\tm+=min(b,c,d)*f\nprint(m)", "lang_cluster": "Python", "tags": ["math", "greedy", "brute force"], "code_uid": "c4e0f04ca1d595fad90aab32ba92e047", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "'''input\n10\n'''\nn = input()\nans = 0\nfor i in range(1,n):\n\tif (n-i)%i == 0:\n\t\tans += 1\nprint ans", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "decf2f0c5ce990751be3ff32aa64b2a9", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, p = map(int, raw_input().split())\nans = long(0)\nfor i in range(1, n + 1):\n  a = b = i\n  while(a):\n    b = b * 10 + a % 10\n    a /= 10\n  ans += b\n\nprint ans%p\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "d0ea9e2e287673c5fa9567c3410810cd", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "x=raw_input()\n\nr=[]\nc=1\ni=0\nm=0\nwhile i<len(x):\n    if x[i]=='A' or  x[i]=='E' or x[i]=='I' or x[i]=='O' or x[i]=='U' or x[i]=='Y':\n        r.append(c)\n        m=1\n        mm=i\n        c=1\n    else:\n        c+=1\n    i+=1\n\nif m==1:\n    r.append(len(x)-mm)\n    print(max(r))\nelse:\n    print(len(x)+1)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "891eb06de2184a95c2ed2f8924b0cd04", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def bin_search(l, r, func):\n    while r - l != 1:\n        mid = (r + l) / 2\n        if func(mid):\n            r = mid\n        else:\n            l = mid\n    return l\n\nn, k, M = map(int, raw_input().split())\n\ntimes = sorted(list(map(int, raw_input().split())))\nsums = [sum(times[:i]) for i in range(k + 1)]\nfor_task = sums[-1]\n\nresult = 0\nfor fully_solved in range(n + 1):\n    if fully_solved * for_task > M:\n        break\n    not_fully_solved = n - fully_solved\n    curr_result = fully_solved * (k + 1)\n    time_rest = M - fully_solved * for_task\n    l = 0\n    r = k + 1\n    while r - l != 1:\n        mid = (r + l) / 2\n        if sums[mid] * not_fully_solved > time_rest:\n            r = mid\n        else:\n            l = mid\n    t = l\n    curr_result += t * not_fully_solved\n    time_rest -= sums[t] * not_fully_solved\n\n    if t != k:\n        l = 0\n        r = not_fully_solved + 1\n        while r - l != 1:\n            mid = (r + l) / 2\n            if mid * times[t] > time_rest:\n                r = mid\n            else:\n                l = mid\n        curr_result += l\n\n    result = max(curr_result, result)\n\nprint result\n", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "576d7eb071cba33bbacc6ea088c47efc", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m = map(int, input().split())\n\nf = [1] * (n + 1)\nfor i in range(1, n + 1):\n    f[i] = f[i - 1] * i % m\nans = 0\nfor k in range(1, n + 1):\n    ans = (ans + (n - k + 1) * f[k] * (n - k + 1) * f[n - k]) % m\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "cd26034e7e3dbcc924141991567c9970", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "\ndef count(n,r):\n    ret = 0\n    while True:\n        if n%r==0:\n            n=n/r\n            ret+=1\n        else:\n            break\n    return ret\n\n\nm = int(raw_input())\n\ni=1\nc2 = 0\nc5 = 0\nanswer = []\nwhile True:\n    c2 += count(i,2)\n    c5 += count(i,5)\n    if min(c2,c5) == m:\n        answer.append(i)\n    elif min(c2,c5) > m:\n        break\n    i += 1\n\nif len(answer) > 0:\n    print len(answer)\n    print ' '.join(map(str, answer))\nelse:\n    print 0\n", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "bacc6f80e664949ca215aa8bcf0d84c8", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nm = int(input())\nu = []\nfor i in range(n):\n    u.append(int(input()))\nk = max(u)\na1 = k + m\nfor i in range(n):\n    m -= k - u[i]\nif m > 0:\n    k += m // n\n    if m % n != 0:\n        k += 1\nprint(k, a1)\n", "lang_cluster": "Python", "tags": ["implementation", "binary search"], "code_uid": "82a20a30a652b86c30deecbb9b262eee", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = input().split()\nn = int(a[0])\nk = int(a[1])\n\nfor i in range(k):\n    if n%10!=0:\n        n=n-1\n    else:\n        n=n/10\n        \nprint(int(n))\n    \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e5c2241b407b75ddf3458e4e78dbdc59", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x = int(input())\nhh, mm = input().split()\ncounter = 0\nhh = int(hh)\nmm = int(mm)\nwhile True:\n    if mm > 59:\n\n        mm = mm - 60\n        hh += 1\n    elif mm < 0:\n\n        mm = 60 + mm\n        hh -= 1\n    if hh > 23:\n        hh = hh - 24\n    elif hh < 0:\n        hh = 23\n    if '7' in str(hh) or '7' in str(mm):\n        print(counter)\n        break\n    mm -= x\n    counter += 1\n\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "659d0cd169c5cfd7cad51c4191319ab4", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, x = map(int, input().split())\ncount = 0\ni = 1\nwhile i * i <= x:\n    if x % i == 0 and i <= n and x // i <= n:\n        if i != x // i:\n            count += 2\n        else:\n            count += 1\n    i += 1\nprint(count)", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "c3fd538eb6bdebb3dbb84f04b054ff14", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\n\nfor line in sys.stdin:\n    line = line.split()\n    s = 1;\n    for i in range(6):\n        line[i] = int(line[i])\n        s *= line[i]\n    ok = s\n    if line[0] and line[1] and line[2] and line[3] and line[4] and line[5]:\n        s /= int(line[0])\n        s *= int(line[1])\n        s /= int(line[2])\n        s *= int(line[3])\n        s /= int(line[4])\n        s *= int(line[5])\n        if s > ok:\n            print \"Ron\"\n        else:\n            print \"Hermione\"\n    elif line[3] == 0:\n        print \"Hermione\"\n    elif line[2] == 0:\n        print \"Ron\"\n    elif line[1] == 0:\n        print \"Hermione\"\n    elif line[0] == 0:\n        print \"Ron\"\n    elif line[5] == 0:\n        print \"Hermione\"\n    elif line[4] == 0:\n        print \"Ron\"\n        \n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "4c94749611de23d48674c69396bbae58", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "tmp = [int(i) for i in input().split()];\nn = tmp[0];\nd = tmp[1];\n\na = [int(i) for i in input().split()];\na.sort();\nm = int(input());\n\nout = 0;\n\nfor i in range(0,m):\n    if i < len(a):\n        out = out + a[i];\n    else:\n        out = out - d;\n\nprint(out);", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "17f2918a59701c2ff22890e2ce0895e8", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\nh1,h2=map(int,input().split())\n\nr,f=map(int,input().split())\n\nif h1+r*8>=h2:print(0)\n\nelif f>=r:print(-1)\n\nelse:print(math.ceil((h2-h1-8*r)/(12*(r-f))))\n\n\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "7fd0bc79c7b258d19512ca1ff921d8dc", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = [input() for i in range(8)]\nra, rb = 8, 8\nfor j in range(8) :\n    for i in range(8) :\n        if a[i][j] == 'W' :\n            ra = min(ra, i)\n        if a[i][j] != '.' :\n            break\nfor j in range(8) :\n    for i in range(7,-1,-1) :\n        if a[i][j] == 'B' :\n            rb = min(rb, 7 - i)\n        if a[i][j] != '.' :\n            break\nprint ('A' if ra <= rb else 'B')\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "f653a66480279a05542cc29804c669ee", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def is_win(x):\n    if x.count(\"X\") == 4 and x.count(\".\") == 1:\n        return True\n    else:\n        return False\n\ndef solve(L):\n    for x in L:\n        for j in range(6):\n            if is_win(x[j:j+5]):\n                return (\"YES\")\n\n    LT = []\n    for i in range(10):\n        s = \"\"\n        for j in range(10):\n            s += (L[j][i])\n        LT.append(s)\n\n    for x in LT:\n        for j in range(6):\n            if is_win(x[j:j+5]):\n                return (\"YES\")\n\n    for i in range(2,8):\n        for j in range(2,8):\n            x = L[i-2][j-2] + L[i-1][j-1] + L[i][j] + L[i+1][j+1] + L[i+2][j+2]\n            # print(x)\n            if is_win(x):\n                return(\"YES\")\n            x = L[i-2][j+2] + L[i-1][j+1] + L[i][j] + L[i+1][j-1] + L[i+2][j-2]\n            # print(x)\n            if is_win(x):\n                return(\"YES\")\n\n\n    return(\"NO\")\n\n\nL = []\nfor i in range(10):\n    L.append(input())\nprint(solve(L))\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "a47309be5764b3455d32278aa31a643d", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn = int(input())\np = 0\nq = 0\nfor i in range(math.ceil((2*n)/5+1)):\n    if 5*2**i-5<n<=10*2**i-5:\n        p = i\n        q = n+5-5*2**i\n        break\nif 0<q<=2**p:\n    print('Sheldon')\nelif 2**p<q<=2*2**p:\n    print('Leonard')\nelif 2*2**p<q<=3*2**p:\n    print('Penny')\nelif 3*2**p<q<=4*2**p:\n    print('Rajesh')\nelse:\n    print('Howard')", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "81e15790cfb2c268d7bfe4da01c438bd", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin,stdout\nfor _ in range(1):#int(stdin.readline())):\n    # n=int(stdin.readline())\n    moves,left=list(map(int,stdin.readline().split()))\n    # ATE=?\n    l=1;r=10**9+1\n    while l<=r:\n        mid=(l+r)>>1\n        fx=(mid*(mid+1))//2-left+mid\n        # print(l,r,mid)\n        if fx<=moves:l=mid+1\n        else:r=mid-1\n    print(moves-r)", "lang_cluster": "Python", "tags": ["brute force", "math", "binary search"], "code_uid": "43139c3e08ba9ab8a721dce0f22e466d", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "h, m, s, t1, t2 = [int(i) for i in input().split()]\nh *= 5\nt1 *= 5\nt2 *= 5\nif h < t1: h += 60\nif m < t1: m += 60\nif s < t1: s += 60\nif t2 < t1: t2 += 60\nc = (t2 <= h) + (t2 <= m) + (t2 <= s)\nans = \"YES\" if c == 0 or c == 3 else \"NO\"\nprint(ans)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b2ed5b640da837807ef8c86f80283fce", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nfrom math import *\nk=0\nfor i in range(1,31) :\n    for j in range(1,31) :\n        if i+j==c and i>=4 and i<=a and j>=1 and j<=b :\n            k=k+((factorial(a)//factorial(a-i))//factorial(i))*((factorial(b)//factorial(b-j))//factorial(j))\nprint(int(k))   \n", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "a221d83734b2becbe8383e4fb08ceee9", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = int(raw_input())\n\nprint ((3**3)**n - 7**n) % (10**9 + 7)", "lang_cluster": "Python", "tags": ["combinatorics"], "code_uid": "7108e771e5f26028e615bdb212dbde16", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\nnumbers = input().split(\" \")\nfor n in range(len(numbers)):\n    numbers[n] = int(numbers[n])\n\nparticipants = numbers[0]\nnumMatches = 0\n\nwhile(participants>1):\n    numMatches += math.floor(participants/2)\n    participants = math.ceil(participants/2)\n\nnumBottles = numMatches*numbers[1]*2 + numMatches\nnumTowels = numbers[0] * numbers[2]\n\n\nprint(str(numBottles) + \" \" + str(numTowels))", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "27ce75674801a6646132c0d7d000a127", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "# Author:   Gilberto A. dos Santos\n# Website:  http://codeforces.com/problemset/problem/415/A\n\nimport sys\n\nr = raw_input().split(\" \")\nn = int(r[0])\nm = int(r[1])\nlight = [False for i in range(n)]\n\nr = raw_input().split(\" \")\nfor i in range(m):\n    b = int(r[i])-1\n    for j in range(b,n):\n        if not(light[j]):\n            light[j] = b+1\n\nfor i in range(n): print light[i],\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "fc994415ab3c18a605b269dcbc97d272", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin\n\nn = int(stdin.readline())\n\nif n%2 == 1:\n    print(0)\nelse:\n    k = n//2\n    print(2**k)", "lang_cluster": "Python", "tags": ["math", "dp"], "code_uid": "8d3a1dbb63aacbf0484943b329ef3540", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\ns=(a+b+c)//2\nif (a+b+c)%2 or s-a<0 or s-b<0 or s-c<0:print(\"Impossible\")\nelse:print(s-c,s-a,s-b)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "graphs"], "code_uid": "3541917765fa321d1522435a6d24fa36", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b, p, x = [int(x) for x in input().split()]\n\npowers = [a]\n\nwhile powers[-1] != 1:\n    powers.append(powers[-1] * a % p)\n    \norder = len(powers)\npowers = [powers[-1]] + powers\n\ninverse = pow(order, p-2, p)\n\ndef f(sol):\n    return (x // (p * order)) + (1 if sol <= x % (p * order) else 0)\n\ndef chinese(a, n, b, m):\n    k = inverse * (b - a + m) % m\n    x = k * n + a\n    return x % (n * m)\n\nres = 0\nfor i in range(len(powers)-1):\n    inv = powers[order - i]\n    val = inv * b % p\n    \n    sol = chinese(i, order, val, p)\n    \n    res += f(sol)\n    \nprint(res)\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "9abd29ab89d671248059d752e667f2df", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=list(map(int,input().split()))\nfor i in range(1,n):\n    if a[i]-a[i-1]>1 or a[i-1]-a[i]>1:\n        print('NO')\n        exit()\nprint('YES')    \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "49079900431b5e70f26f0cd86b96c487", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a = raw_input().split()\nprint (int(a[0])*int(a[1])-1)/(int(a[1])-1)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "36bb249f3d1b5d31e4576eaf0ee7edba", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "t = input()\r\nfor i in range(2, len(t)):\r\n\tif ord(t[i])-ord('A') != (ord(t[i-1])-ord('A') + ord(t[i-2])-ord('A'))%26:\r\n\t\tprint(\"NO\")\r\n\t\texit()\r\nprint(\"YES\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "48c9c2f14da25c0ff906ed6d4a700664", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\ns=raw_input().split()\na,b=(int)(s[0]),(int)(s[1])\nprint((b*(b-1)/2*((a+1)*a*b / 2 + a))%1000000007)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "80dc7bc3fa85bc17ac2c9229004ac858", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\ns = str(input())\ns = s.replace(\" \",\"\")\ns= s.strip(\"0\")\ntemp = ''\ni=0\nwhile i<len(s)-1:\n    if s[i]==s[i+1] and s[i]==\"0\":\n        temp = s[i:]\n        temp= temp.lstrip(\"0\")\n        s= s[:i] +temp\n    i = i+1\nprint(len(s))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "cb4399e9a20d3e7c17b405dea7018bca", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/env python\n\nnum1 = raw_input();num2= raw_input()\nres = int(num1)+int(num2)\nres = str(res).replace('0','');num1=num1.replace('0','');num2=num2.replace('0','')\nprint 'YES' if int(num1)+int(num2)==int(res) else 'NO'", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "472e1328a58200c74d9105b44a6d999c", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x = int(input())\nif x < 10:\n    print(x)\nelif x == int(str(x)[0] + '9'*(len(str(x))-1)):\n    print(x)\nelse:\n    a = str(x)[0] + '9' * (len(str(x)) - 1)\n    a = list(a)\n    for i in range(len(a) - 1, -1, -1):\n        k = a[i]\n        a[i] = str(int(a[i]) - 1)\n        if x >= int(''.join(a)):\n            print(int(''.join(a)))\n            break\n        a[i] = k\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "c4e8add40d062fc169594ffa772849c3", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "\"\"\"\n// Author : snape_here - Susanta Mukherjee\n     \n\"\"\"\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().split())\ndef li(): return list(mi())\n \n \ndef read():\n    sys.stdin = open('input.txt', 'r')  \n    sys.stdout = open('output.txt', 'w') \n \ndef gcd(x, y):\n    while y:\n        x, y = y, x % y\n    return x\n\nmod=1000000007\n\ndef main():\n    \n    x1,y1,x2,y2=mi()\n    x,y=mi()\n    a=x2-x1 \n    b=y2-y1 \n    if a%x or b%y:\n        print(\"NO\")\n    else:\n        c=a//x \n        d=b//y \n        if abs(c-d)%2:\n            print(\"NO\")\n        else:\n            print(\"YES\")\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()", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "34355c38b6afc99ba7c1aaabe76ca0e3", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from collections import Counter\n\ndef go(s):\n    ct = Counter(s)\n    pos = ''.join(c for c in 'BGR' if ct[c] > 0)\n    if len(pos) == 3 or len(pos) == 1:\n        return pos\n    \n    one = ''.join(c for c in 'BGR' if ct[c] <= 1)\n    \n    if len(one) == 1:\n        return 'BGR'\n    if len(one) == 2:\n        return one\n   \n    return ''.join(c for c in 'BGR' if ct[c] == 0)\n\ninput()\nprint(go(input()))\n", "lang_cluster": "Python", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "ffcf12e402bef8d171f551c12e5bc85e", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "for _ in range(int(input())):\r\n    n = int(input())\r\n    if(n==1):print(1)\r\n    else:\r\n        print(2**n - 1)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "3f666d4de06890432586821cc9764c4a", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\nl=set(map(int ,input().split()))\nc=0\nm=min(l)\nwhile l:\n    c+=1\n    m=min(l)\n    for i in range(m,101,m):\n        l-={i}\nprint(c)\n        ", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "b80f2340567b87ce410f832c6c42ddba", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"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", "tags": ["constructive algorithms", "combinatorics"], "code_uid": "7324c3fd5e301d6f1a67fbe24e635b21", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def ni():\n    return int(raw_input())\n\ndef nis():\n    return map(int, raw_input().split())\n\nn = ni()\n\na = nis()\n\nS = sum(a)\nk = max(a)\n\nF = k * n\n\nd = (2 * S) - F\n\nif d < 0:\n    print k\nelse:\n    print k + (d / n) + 1", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "6a616b93da64d9e8817e2b629f4e644e", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n2, n1 = (int(_) for _ in input().split())\nif n1 % n2 == 0:\n    n = n1 // n2\n    k = 0\n    f = True\n    while n != 1:\n        if n % 3 == 0:\n            n //= 3\n            k += 1\n        elif n % 2 == 0:\n            n //= 2\n            k += 1\n        else:\n            print(-1)\n            f = False\n            break\n    if f:\n        print(k)\nelse:\n    print(-1)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "57f28824b7522c133e99bd72194296a5", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nn=int(input())\na=int(input())\nb=int(input())\nlist=[a]*4+[b]*2\nM=max([a,b])\nm=min([a,b])\nif n<2*m:\n    print 6\nelif 2*m<=n and n<m+M:\n    print int(math.ceil(float(list.count(m))/(n/m)))+list.count(M)\nelif m+M<=n:\n    if a>=b:\n        if 2*a>n:\n            print 4\n        elif 2*a<=n<3*a:\n            bd=n%a\n            if bd>=b:\n                print 2\n            else:\n                print 3\n        elif 3*a<=n<4*a+2*b:\n            print 2\n        elif 4*a+2*b<=n:\n            print 1\n    elif a<b:\n        if n<b+2*a:\n            print 3\n        elif n>=4*a+2*b:\n            print 1\n        else:\n            print 2\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "d92a5b674358ae455e2dc7b978652dc9", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "t = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\nx=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen',\n    'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six',\n    'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty']\nfor i in t:\n x.append('thirty-'+i)\n\nx.append('forty')\nfor i in t:\n x.append('forty-'+i)\n\nx.append('fifty')\n\nfor i in t:\n    x.append('fifty-'+i)\n\nx.append('sixty')\n\nfor i in t:\n    x.append('sixty-'+i)\n\nx.append('seventy')\n\nfor i in t:\n    x.append('seventy-'+i)\n\nfor kk in ['eighty', 'ninety']:\n    x.append(kk)\n    for i in t:\n        x.append(kk+'-'+i)\n        \nprint(x[int(input())])", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "517fa2027105ddf9359840ceab306603", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\nl=[[0 if i!=0 else 1 for i in range(n)] if k!=0 else [1]*n for k in range(n)]\nfor i in range(1,n):\n    for k in range(1,n):\n        l[i][k]=l[i-1][k]+l[i][k-1]\nprint(l[-1][-1])\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "1644a8ebe55c4f41a1c91443a83bd9a7", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "_MODULO = 10 ** 8\n\n\ndef solve(n1, n2, k1, k2):\n    t = [[[[0 for _ in range(k2 + 1)] for _ in range(k1 + 1)] for _ in range(n2 + 1)] for _ in range(n1 + 1)]\n    #\n    t[0][0][0][0] = 1\n    t[1][0][1][0] = 1\n    t[0][1][0][1] = 1\n    # for i in range(1, min(k1, n1)):\n    #     t[i][0][i][0] = 1\n    # for i in range(1, min(k2, n2)):\n    #     t[0][i][0][i] = 1\n\n    for i in range(0, n1 + 1):\n        for j in range(0, n2 + 1):\n            if i == 0 and j == 0:\n                continue\n\n            if i > 0:\n                for k in range(1, k2 + 1):\n                    t[i][j][1][0] += t[i - 1][j][0][k]\n                for k in range(2, k1 + 1):\n                    t[i][j][k][0] += t[i - 1][j][k - 1][0]\n\n            if j > 0:\n                for k in range(1, k1 + 1):\n                    t[i][j][0][1] += t[i][j - 1][k][0]\n                for k in range(2, k2 + 1):\n                    t[i][j][0][k] += t[i][j - 1][0][k - 1]\n\n    r = 0\n    for k in range(1, k1 + 1):\n        r = (r + t[n1][n2][k][0]) % _MODULO\n\n    for l in range(1, k2 + 1):\n        r = (r + t[n1][n2][0][l]) % _MODULO\n    # print(n1, n2, k1, k2, r)\n    return r\n\n\n# assert solve(2, 1, 1, 10) == 1\n# assert solve(2, 3, 1, 2) == 5\n# assert solve(2, 4, 1, 1) == 0\n# assert solve(100, 100, 10, 10) == 950492\nn1, n2, k1, k2 = map(int, input().split())\n\n# n1, n2, k1, k2 = 100, 100, 10, 10\n# n1, n2, k1, k2 = 2, 1, 1, 1\n\nprint(solve(n1, n2, k1, k2))\n", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "ac62922d82e312b88e02ee77f0ca8d32", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, a, b, c = map(int, input().split())\ncount = 0\nfor ci in range(c + 1):\n  x = n - 2 * ci\n  if x < 0:\n    break\n  high = min(b, x)\n  low = max(0, x - a // 2)\n  if high >= low:\n    count += high - low + 1\n\nprint(count)\n\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "0958d34de7cae9bd01c12685b4bd8c66", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,c=[int(i) for i in raw_input().split()]\nlist=[int(i) for i in raw_input().split()]\njg=[]\nfor i in range(1,n):\n    x=list[i-1]-list[i]\n    jg.append(x)\nday=jg.index(max(jg))\nans=list[day]-list[day+1]-c\nif ans<=0:\n    print 0\nelse:\n    print ans", "lang_cluster": "Python", "tags": ["brute force", "greedy", "implementation"], "code_uid": "411e9bf8095a5d6d3a6fd6b35a665ce6", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "p=int(input())\r\nfor i in range(p):\r\n\r\n    l=[]\r\n    for j in range(2):\r\n        li=[int(i) for i in input().split()]\r\n        for k in li:\r\n            l.append(k)\r\n    count=0\r\n    for i in l:\r\n        if i==1:\r\n            count=count+1\r\n    if count==0:\r\n        print(\"0\")\r\n    elif count==4:\r\n        print(\"2\")\r\n    else:\r\n        print(\"1\")\r\n        \r\n        \r\n        ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b867f5e9bed642f2a55452d6058ee2d4", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def start():\n    w, h = sorted(map(int, raw_input().split()))\n    rhombi = 0\n    for a in xrange(2,w+1,2):\n        for b in xrange(2, h+1, 2):\n            rhombi += (w-a+1)*(h-b+1)\n    print rhombi\n\nstart()\n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "43a505e97803b496a924fc578c6eb17e", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s=raw_input()\ncounter='hello'\nj=0\ni=0\nwhile j<5 and i<len(s):\n\tif s[i]==counter[j]:\n\t\tj+=1\n\ti+=1\nif j==5:\n\tprint 'YES'\nelse:\n\tprint 'NO'", "lang_cluster": "Python", "tags": ["greedy", "strings"], "code_uid": "2175e1b8d01c02e4514e5b29f6dad3d2", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\ns = list(input())\nif '8' not in s:\n     print(0)\n     exit()\nprint(min(s.count('8') , n // 11))\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "84996523aa30f9b17cf1590f66af808f", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def C(n, m):\n    ans=1\n    for i in range(m):\n        ans*=n-i\n    for i in range(m):\n        ans//=i+1\n    return ans\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", "tags": ["math", "dp", "combinatorics"], "code_uid": "27fe74a13966a89314985d2c3b6c2dcd", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m = [int(i) for i in input().split()]\nans = 0\nar = [n // m] * m\nfor i in range(1, n % m + 1, 1):\n    ar[i] += 1\nfor i in range(m):\n    for j in range(m):\n        if ((i * i + j * j) % m == 0):\n            ans += ar[i] * ar[j]\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "42950263fc19dbfeac9eed130f615dde", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# python 3\n\"\"\"\nRead tutorial, graph the moves\n\"\"\"\n\n\ndef inna_and_pink_pony(n_int, m_int, i_int, j_int, a_int, b_int) -> str:\n    corner_1 = (1, 1)\n    corner_2 = (1, m_int)\n    corner_3 = (n_int, 1)\n    corner_4 = (n_int, m_int)\n    corners = [corner_1, corner_2, corner_3, corner_4]\n    c = max(n_int, m_int)\n    for each in corners:\n        if abs(each[0] - i_int) % a_int != 0 or abs(each[1] - j_int) % b_int != 0:\n            continue\n        horizontal_moves = abs(each[0] - i_int) // a_int\n        vertical_moves = abs(each[1] - j_int) // b_int\n        if horizontal_moves % 2 != vertical_moves % 2:\n            continue\n        each_move = max(horizontal_moves, vertical_moves)\n        if (a_int > max(i_int - 1, n_int - i) and abs(each[1] - j_int) > 0) or (\n                b_int > max(j - 1, m - j) and abs(each[0] - i_int) > 0):\n            break\n        c = min(c, each_move)\n\n    if c < max(n_int, m_int):\n        return c\n    else:\n        return \"Poor Inna and pony!\"\n    \n\nif __name__ == \"__main__\":\n    \"\"\"\n    Inside of this is the test. \n    Outside is the API\n    \"\"\"\n\n    n, m, i, j, a, b = list(map(int, input().split()))\n\n    print(inna_and_pink_pony(n, m, i, j, a, b))\n\n    # print(inna_and_pink_pony(n, m, i, j, a, b))\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "7d907c976f4b9855055d53be4d0073d8", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a=int(input().split()[1])\n*b,=map(int,input().split())\nc=0\nfor i in range(a):\n    d=b[i::a]\n    c+=min(d.count(1),d.count(2))\nprint(c)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "79f48e5b25e6338aeea56182a2dbaebc", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a,b,c = map(int , raw_input().split())\nans = \"\"\nif c == 0 and a == b:\n    ans = \"YES\"\nelif c > 0 and (b-a)%c == 0 and (b-a) >= 0:\n    ans = \"YES\"\nelif c < 0 and (a-b)%(-c) == 0 and (a-b) >= 0:\n    ans = \"YES\"\nelse:\n    ans = \"NO\"\nprint ans", "lang_cluster": "Python", "tags": ["math"], "code_uid": "189d7403e0448ea6b42f238eff548478", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "g = {'q':9, 'r':5, 'b':3, 'n':3, 'p':1, 'k':0, '.':0}\n\nmatrix = []\nfor i in range(8):\n    matrix.append(input())\n\nwhite, black = 0, 0\nfor i in range(8):\n    for letter in matrix[i]:\n        if(letter.isupper()):\n            white += g[letter.lower()]\n        else:\n            black += g[letter]\nif(white == black):\n    print(\"Draw\")\nelif(white > black):\n    print(\"White\")\nelse:\n    print(\"Black\")\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "0ed0dd70e6308799aab9a78e8fc1502d", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a , b = map(int,input().split())\n\ncnt = 1\nans = [b]\nflag = True\nwhile b > a :\n    r = b % 10\n    if r % 2 == 0 :\n         b //= 2\n         cnt +=1\n         ans.append(b)\n\n    else:\n        if b % 10 % 2 != 0 and b % 10 != 1 :\n            flag = False\n            break\n        else:\n            b //= 10\n            ans.append(b)\n            cnt +=1\n\n#print(b)\nif flag and a == b:\n    print('YES')\n    print(cnt)\n    ans = list(reversed(ans))\n    print(*ans)\n\nelse:\n    print('NO')\n\n\n", "lang_cluster": "Python", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "2e4ab295a9706cdc16b3a575dbe42330", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn, R, r=  list(map(int, input().split()))\nif (n==1):\n  if (r<=R):\n    print (\"YES\")\n  else:\n    print (\"NO\")\nelif (n==2):\n  if (2*r<=R):\n    print (\"YES\")\n  else:\n    print (\"NO\")\nelse:\n  a= r/round(math.sin(math.pi/n),10)\n  if (a <= (R-r)):\n    print (\"YES\")\n  else:\n    print (\"NO\")", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "4556a1b954053b2313deb48f1eb0c0fc", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k,m,D= map(int, input().split())\nres = 0\nfor d in range(1, D+1):\n  x = m\n  x = min(x, n // ((d-1)*k+1))\n  if(x*k*(d-1)+x > n):\n    break\n  if(res==0 or res < x*d):\n    res = x*d\nprint(res)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "46ce3d8d909575bbe18765f35b152b47", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "class Solve:\n    sum = n = m = 0\n    list1 = []\n\n    def __init__(self):\n        self.n = int(input())\n        self.m = int(input())\n        m = self.m\n        n = self.n\n        while n != 0:\n            self.list1.append(m % 10)\n            self.sum += m % 10\n            m = m//10\n            n -= 1\n\n    def check(self, part, sump):\n        sum_temp = 0\n        cnt = 0\n        for i in self.list1:\n            sum_temp += i\n            if sum_temp == sump:\n                cnt += 1\n                sum_temp = 0\n            elif sum_temp > sump:\n                return False\n        if cnt == part:\n            return True\n        return False\n\n    def start(self):\n        for i in range(2, self.n+1):\n            if self.sum % i == 0:\n                if self.check(i, self.sum//i):\n                    print('YES')\n                    return \n        print('NO')\n\n\nif __name__ == \"__main__\":\n    method = Solve()\n    method.start()\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "15aa7a3c708a2f9b8a977bdd2d316574", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\ni=int(input())\nmax=0\nk=len(str(i))-1\nif i<10:\n    print(i)\nelse:\n    list=[]\n    p=str(i)\n    for m in p:\n        list.append(int(m))\n    p=list\n    m=1\n    for j in p:\n        m*=j\n    if m>max:\n        max=m\n    m=1\n    for l in range(k,0,-1):\n        q=i\n        minus=i%10**l+1\n        q-=minus\n        list=[]\n        p=str(q)\n        for m in p:\n            list.append(int(m))\n        p=list\n        m=1\n        for j in p:\n            m*=j\n        if m>max:\n            max=m\n    print(max)\n    ", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "946191473fe8debb20ab3f4dbbde1696", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,a,b = map(int, input().split(' '))\nprint(n-max(a+1,n-b)+1)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "915fd3552f5c052dfbf1de5e980152a7", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\r\nimport heapq\r\nfrom collections import defaultdict\r\nimport math\r\nimport bisect\r\nimport io, os\r\n\r\n# for interactive problem\r\n# n = int(stdin.readline())\r\n# print(x, flush=True)\r\n\r\n#input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef ncr(n, r, p):\r\n    # initialize numerator\r\n    # and denominator\r\n    num = den = 1\r\n    for i in range(r):\r\n        num = (num * (n - i)) % p\r\n        den = (den * (i + 1)) % p\r\n    return (num * pow(den,\r\n            p - 2, p)) % p\r\n\r\n\r\n\r\ndef main():\r\n    #n = int(input())\r\n    t = int(stdin.readline())\r\n    MOD = 1000000007\r\n    for T in range(t):\r\n        n, k = list(map(int, stdin.readline().split()))\r\n        if k == 0:\r\n            stdout.write(\"1\\n\")\r\n            continue\r\n\r\n        d = 0\r\n        # count possibility\r\n        num = den = 1\r\n        for i in range(n):\r\n            if i % 2 == 0:\r\n                a = (num * pow(den, MOD - 2, MOD)) % MOD\r\n                d = (d + a) % MOD\r\n            num = (num * (n - i)) % MOD\r\n            den = (den * (i + 1)) % MOD\r\n\r\n        dp = [[0] * (k+1) for _ in range(2)]\r\n        dp[1][0] = 1\r\n        pn = pow(2, n) % MOD\r\n        for i in range(k):\r\n            dp[0][i+1] = (dp[0][i+1] + ( pn * dp[0][i]) % MOD) % MOD\r\n\r\n            if n % 2 == 1:\r\n                dp[1][i+1] = (dp[1][i+1] + ((d +1) * dp[1][i]) % MOD) % MOD\r\n            else:\r\n                dp[1][i + 1] = (dp[1][i + 1] + (d * dp[1][i]) % MOD) % MOD\r\n                dp[0][i+1] = (dp[0][i+1] + dp[1][i]) % MOD\r\n        ans = (dp[0][k] + dp[1][k]) % MOD\r\n        stdout.write(str(ans)+\"\\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\nmain()\r\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "cd451683d5b5e7ef3e1cc9681f0dab3f", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"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)", "lang_cluster": "Python", "tags": ["brute force", "math", "dp"], "code_uid": "7abc3a0ae27b5451917022db190a1f47", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\ncnt=[]\nfor i in range(0,8):\n\tbuf=raw_input()\n\tcnt.append(buf.count('B'))\nret=min(cnt)+cnt.count(8)\nif ret==16:\n\tret=8\nprint ret\n", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms"], "code_uid": "ce3e391dd6e012e3136a441dd66d23d0", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b = raw_input().split(\"e\")\nidx = a.find(\".\")\nif idx!=-1:\n    front = a[:idx]\nelse:\n    front = a\nmiddle = a[idx+1:idx+int(b)+1]\nif len(middle)<int(b):\n    repeatedZero = '0'*(int(b)-len(middle))\n    middle = middle + repeatedZero\nback = a[idx+int(b)+1:]\nif back==\"0\":\n    back = \"\"\nif back!=\"\":\n    print front+middle+\".\"+back\nelse:\n    print front+middle", "lang_cluster": "Python", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "50b6c466cb17731810e1a0f910a6a195", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "\nfrom math import factorial as fact\n\n\ndef bc(n,m):\n\treturn fact(n)/(fact(m)*fact(n-m))\n\n\ndef f(n,q=1):\n\ts = 0\n\tfor i in range(1,n):\n\t\ts+=bc(n,i)*f(n-i,i)*(q**i)\n\ts+=(q**n)\n\treturn s\n\n\n\n\ndef main():\n\tn,k = [int(i) for i in raw_input().split()]\t\n\tprint (((n-k)**(n-k) * f(k-1)*k))%(7+10**9)\n\n\n\n\nmain()", "lang_cluster": "Python", "tags": ["dfs and similar", "math", "combinatorics", "brute force"], "code_uid": "80b1497f6177e435d098665403b631b1", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, k = map(int, input().split())\nm = list(map(int, input().split()))\ndef av(m):\n\treturn sum(m)/len(m)\ns = sum(m)\ndef ro(x):\n\txx = int(x)\n\tif x - xx >= 0.5:\n\t\treturn xx + 1\n\telse:\n\t\treturn xx\npren = n\nwhile s/n < k - 0.5:\n\ts+= k\n\tn+=1\nprint(n - pren)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "2ba9e880c64a86e0f462dbef2b1fd722", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 30 16:47:42 2019\n\n@author: avina\n\"\"\"\n\nn,m = map(int, input().split())\ns = input()\nd = []\nw = set(s)\nfor i in w:\n    d.append(s.count(i))\nif max(d) > m:\n    print('NO')\nelse:\n    print('YES')", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "502311826264200a481ebbe4cdbe20a3", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from itertools import *\n\nn = input()\nA = [int(x)-1 for x in raw_input().split()]\n\ndef gcd(a,b):\n  if a<b:  a,b=b,a\n  while b: a,b=b,a%b\n  return a\n\ndef lcm(a,b):\n  return (a*b)/gcd(a,b)\n\ndef cycle_decompose(l):\n  remaining = set(l)\n  cycles    = []\n  while len(remaining) > 0:\n    n = remaining.pop()\n    cycle = [n]\n    while True:\n      n = l[n]\n      if n not in remaining:\n        break\n      remaining.remove(n)\n      cycle.append(n)\n    cycles.append(len(cycle))\n  return cycles\n\nif len(set(A)) != n:\n  result = -1\nelse:\n  cycles = cycle_decompose(A)\n  cycles = [c if c%2==1 else c/2 for c in cycles]\n  result = reduce(lcm, cycles, 1)\n\nprint result", "lang_cluster": "Python", "tags": ["dfs and similar", "math"], "code_uid": "43473308bf79676aa57d42266cf124d2", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m, L, R = map(int, input().split())\nmod = 998244353\nif n*m % 2:\n  print(pow(R-L+1, n*m, mod))\nelse:\n  print((pow(R-L+1, n*m, mod) + 1 - (R-L) % 2) * pow(2, mod-2, mod) % mod)", "lang_cluster": "Python", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "3f6a00af9736c8661d0d59781103c919", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "r = int(input())\ny = int((r-3)/2)\nif(r&1 and y > 0):\n\tprint(\"{} {}\".format(1,y))\n\t\nelse :\n\tprint(\"NO\")", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "90ad214db1b22713120fb1054cca9ac6", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\nn = int(input())\na = list(map(int, input().split(' ')))\na.sort()\nmini = 100000000000\nfor i in range(len(a)):\n    for j in range(i+1, len(a)):\n        lmin = 0\n        x = 0\n        y = 1\n        while y < (len(a)):\n            if x == i or x == j:\n                x += 1\n                continue\n            if y == i or y == j or y == x:\n                y += 1\n                continue\n            lmin += abs(a[x] - a[y])\n            x += 2; y += 2\n\n        mini = min(lmin,mini)\n\n\nprint(mini)", "lang_cluster": "Python", "tags": ["brute force", "sortings", "greedy"], "code_uid": "917de73a8f890d5f09f530e2e0a67cdb", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "s1 = input().strip()\ns2 = input().strip()\nn=len(s1)\nc=0\ni=0\nwhile i<n-1:\n\ta = s1[i:i+2]\n\tb = s2[i:i+2]\n\tif(a==\"00\" and b==\"0X\"):\n\t\tc+=1\n\t\ti+=2\n\telif(a==\"X0\" and b==\"00\"):\n\t\tc+=1\n\t\ti+=2\n\telif(a==\"0X\" and b==\"00\"):\n\t\tc+=1\n\t\ti+=2\n\telif(a==\"00\" and b==\"X0\"):\n\t\tc+=1\n\t\ti+=2\n\telif(a==\"00\" and b==\"00\"):\n\t\tc+=1\n\t\tif i<n-2 and s1[i+2]=='0' and s2[i+2]=='0':\n\t\t\ti+=1\n\t\t\tc+=1\n\t\ti+=2\n\telse:\n\t\ti+=1\n\t\t\nprint(c)", "lang_cluster": "Python", "tags": ["greedy", "dp"], "code_uid": "674eeab3786af3fa16bffc51eabda185", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,ns,s,i = int(raw_input()),sorted(map(int,raw_input().split(\" \")),reverse=True),0,0\nwhile s<n and i<12:\n    s+=ns[i]\n    i+=1\n\nprint -1 if s<n else i", "lang_cluster": "Python", "tags": ["sortings", "implementation", "greedy"], "code_uid": "57946e1594143c45e3c5544d05f1901b", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin,stdout\nfrom itertools import combinations\nfrom collections import defaultdict,OrderedDict\nimport math\nimport heapq\n\ndef listIn():\n    return list((map(int,stdin.readline().strip().split())))\n\ndef stringListIn():\n    return([x for x in stdin.readline().split()])\n    \ndef intIn():\n    return (int(stdin.readline()))\n\ndef stringIn():\n    return (stdin.readline().strip())\n\ndef nCr(n,k): \n    if(k > n - k): \n        k = n - k \n    # initialize result \n    res = 1\n    # Calculate value of  \n    # [n * (n-1) *---* (n-k + 1)] / [k * (k-1) *----* 1] \n    for i in range(k): \n        res = res * (n - i) \n        res = res // (i + 1) \n    return res \n\n\nif __name__==\"__main__\":\n    n,m,k=listIn()\n    mod=998244353\n\n    #ways to select bricks\n    selection=(nCr(n-1,k))%mod\n    colors_ways=m*((m-1)**k)%mod #ways to select m-1 colors \n    \n    total_ways=colors_ways*selection\n    print(total_ways%mod)\n        \n        \n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "59c73a6cbfa1376763f16a50b207cde7", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nencoded_num = input() + \"0\"\nnum_of_1s = 0\nres = 0\nfor char in encoded_num:\n    if char == '1':\n        num_of_1s += 1\n    else:\n        res = res * 10 + num_of_1s\n        num_of_1s = 0\nprint(res)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "15a3a041c4f37e4e9e0e6b91a04cd1e0", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#coding: utf-8\nimport re\ndef main():\n    inp = raw_input()\n    g = re.match(\"[a-zA-Z0-9_]{1,16}@([a-zA-Z0-9_]{1,16}(\\.[a-zA-Z0-9_]{1,16})*)(/[a-zA-Z0-9_]{1,16})?$\", inp)\n    if g == None:\n        print \"NO\"\n        return 0\n    if len(g.groups()[0]) > 32:\n        print \"NO\"\n        return 0\n    print \"YES\"\n    return 0\nmain()\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "a3b4b473c3e4453e18d8d53df7b8e0e6", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "t= input()\nif 'H' in t or 'Q' in t or '9' in t:\n    print('YES')\nelse:\n    print('NO')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "efd0284104a9b8a935ab7600e1eda768", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m = map(int, input().split())\nif n == 0:\n    if m != 0:\n        print(\"Impossible\")\n    else:\n        print(\"0 0\")\nelse:\n    mi = 0\n    if n >= m:\n        mi = n\n    else:\n        mi = n + (m - n)\n    ma = 0\n    if m == 0:\n        ma = n\n    else:\n        ma = n + m - 1\n    print(mi, ma) #/*2018-08-25 19:44:53.501*/", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "35c156e0944427b3066d05d2a0623f4a", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "x=raw_input()\nif x[0].islower() and len(x)==1:    print x.upper()\nelif (x[0].islower() and x[1:].isupper()):  print x[0].upper()+x[1:].lower()\nelif x.isupper():   print x.lower()\nelse:   print x\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "ced47703dc13c86fc0df9b90c7fb6702", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x=int(input())\nif x%2==0:\n\tprint(int(x/2))\nelse:\n\tprint(-(int(x/2)+1))", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "1a191d065aaccc57d30c445479f777c0", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "r,s,M,S=range,str(input()),map,sum\na=[s.count(str(d)) for d in r(10)]\nfrom math import factorial as f\nfrom functools import reduce as d\nfrom operator import mul\nfrom itertools import product as p\nprint(S((f(S(x))-(f(S(x)-1)*x[0] if x[0] else 0))//d(mul,M(f,x)) for x in p(*[r(y//max(y,1),y+1) for y in a])))", "lang_cluster": "Python", "tags": ["brute force", "math", "combinatorics"], "code_uid": "8d7515699c894e9f12d609990eb00579", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def smallest(d):\n    out = \"\"\n    for j in range(0, 10):\n        out += (\"%d\" % j)*d[j]\n    return out\n\n\ndef largest(d):\n    out = \"\"\n    for j in range(9, -1, -1):\n        out += (\"%d\" % j)*d[j]\n    return out\n\n\nsa = input()\nsb = input()\nb = int(sb)\n\nh = int(sa)\ndigits_a = [0]*10\nwhile h > 0:\n    digits_a[h % 10] += 1\n    h //= 10\n\nout = \"\"\nif len(sb) > len(sa):\n    print(largest(digits_a))\n    exit()\n\nout = 0\nfor i in range(len(sa)-1, -1, -1):\n    for j in range(9, -1, -1):\n        if digits_a[j] == 0:\n            continue\n\n        if j < (b % (10 ** (i+1))) // (10 ** i):\n            digits_a[j] -= 1\n            if out > 0:\n                print(\"{}{}{}\".format(out, j, largest(digits_a)))\n                exit()\n            else:\n                print(\"{}{}\".format(j, largest(digits_a)))\n                exit()\n\n        if j == (b % (10 ** (i+1))) // (10 ** i):\n            if i == 0:\n                out = 10*out + j\n                print(out)\n                exit()\n            digits_a[j] -= 1\n            if int(smallest(digits_a)) <= b % (10 ** i):\n                out = 10*out + j\n                break\n            else:\n                digits_a[j] += 1\n\nprint(out)\n", "lang_cluster": "Python", "tags": ["greedy", "dp"], "code_uid": "513f273020bb2fc3c30d0f074c0e07d0", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin\n_input = stdin.readline\n_sum, _int = sum, int\ndef solution():\n    def sum_number(r):\n        k = 0\n        while r > 0:\n            k += r % 10\n            r //= 10\n        return k\n    n = _int(_input())\n    while sum_number(n) % 4 != 0:\n        n += 1\n    print(n)\nsolution()", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "be4a7640d08e16d00dba8f6ba10a1a7c", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "people, seconds = map(int, input().split())\nprev, cur = input(), \"\"\n \nwhile seconds > 0:\n    idx = 0\n    while idx < people:\n        if idx == people - 1:\n            cur += prev[idx]\n            break\n            \n        if prev[idx] == \"B\" and prev[idx+1] == \"G\":\n            cur += \"G\"\n            cur += \"B\"\n            idx += 1\n        else:\n            cur += prev[idx]\n        \n        idx += 1\n    \n    prev = cur\n    cur = \"\"\n    seconds -= 1\n \nprint(prev)", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "4e17a09574618229d1fc56e6787410cf", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#n = int(input())\nn, m = map(int, input().split())\nl = int(input())\n#s = input()\n#c = list(map(int, input().split()))\nk = (-1) ** ((l - 1) // 3)\nl %= 3\nif l == 1:\n    print(n * k % (10 ** 9 + 7))\nelif l == 2:\n    print(m * k % (10 ** 9 + 7))\nelif l == 0:\n    print(((m - n) * k) % (10 ** 9 + 7))\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "72cca06878d496d7ec07d9168fb55bfd", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def main():\n    from itertools import product\n    a, b, c = sorted(map(int, input().split()))\n    primes = (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)\n    l = [None]\n    for x in range(1, (c + 1)):\n        tmp = [0] * 25\n        for i, p in enumerate(primes):\n            while not x % p:\n                x //= p\n                tmp[i] += 1\n        l.append(tuple(tmp))\n    res = 0\n    cache = {}\n    for x, y, z in product(range(1, a + 1), range(1, b + 1), range(1, c + 1)):\n        xyz = x * y * z\n        if xyz in cache:\n            res += cache[xyz]\n        else:\n            u = 1\n            for t in map(sum, zip(l[x], l[y], l[z])):\n                if t:\n                    u *= t + 1\n            u &= 1073741823\n            cache[xyz] = u\n            res += u\n    print(res & 1073741823)\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "1980fae44918ad31c434d8a4dbaebb29", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def solve(s, x):\n    d = (s - x)\n    if x << 1 & d or d%2 or d<0: return 0\n    return 2 ** (bin(x).count('1')) - (0 if d else 2)\n\ns, x = [int(x) for x in input().split()]\nprint(solve(s, x))\n", "lang_cluster": "Python", "tags": ["math", "dp"], "code_uid": "732f1b6981060314e5a7212048ccebab", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "w, h = map(int, input().split())\n\nprint(pow(2, w + h) % 998244353)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "combinatorics"], "code_uid": "7b8bf3970c36c64086087dcb2fc5a64f", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = input()\nprint(((int(n[0]) + 1) * 10 ** (len(n) - 1)) - int(n))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "326b20d0032d8e748bbc74bb43a4dd71", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "t = int(raw_input())\n\nx = list(map(int, raw_input().split()))\nc = 0\nfor i in range(1,t):\n\tif x[i] == 1:\n\t\tif x[i-1] == 2:\n\t\t\tc += 3\n\t\tif x[i-1] == 3:\n\t\t\tc += 4\n\tif x[i] == 2:\n\t\tif x[i-1] == 3:\n\t\t\tprint \"Infinite\"\n\t\t\texit()\n\t\tif x[i-1] == 1:\n\t\t\tc += 3\n\t\tif i > 1:\n\t\t\tif x[i-1] == 1 and x[i-2] == 3:\n\t\t\t\tc -= 1\n\n\tif x[i] == 3:\n\t\tif x[i-1] == 1:\n\t\t\tc += 4\n\t\tif x[i-1] == 2:\n\t\t\tprint \"Infinite\"\n\t\t\texit()\nprint \"Finite\"\nprint c", "lang_cluster": "Python", "tags": ["geometry"], "code_uid": "ba1e04aaa1ad0156ecb9d231870aadd3", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\n\nm=0#\u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0431\u0438\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\n\ni=0#\u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u0432\u043d\u044f\n\nwhile n>=m:\n\n    m=m+i+1\n\n    if n>=m:\n\n        n=n-m\n\n        i+=1\n\nprint(i)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9b5dace7e1ebd955bb94c0e470f2df0f", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, m, a, b = [int(x) for x in raw_input().split()]\nans = min(n%m * b, (m - n%m)%m * a)\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "a601411bbc03f1ff5b28ee9367a55d57", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nk = input()\n\ntotal = 0\nhalf = 0\n\nfor l in k:\n    total += int(l)\nfor s in k[:int(len(k)/2)]:\n    half += int(s)\n\nif half != total/2:\n    print('NO')\nelse:\n    for i in k:\n        if i != '7' and i != '4':\n            print('NO')\n            break\n    else:\n        print('YES')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "785fd0cc7e4a779c403190c554759640", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "t,s,x = map(int,input().split())\n\nk2 = (x-t-1)/s\nk = (x-t)/s\n\nif x == t:\n    print(\"YES\")\nelif x < t or k2 == 0:\n    print(\"NO\")\nelif k2%1== 0 or k%1 == 0:\n\tprint(\"YES\")\nelif k.is_integer() == False or k2.is_integer== False:\n    print(\"NO\")\n \n\n\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "01ccbbcaee5a9ab6e4f605a5816eed4f", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int,input().split()))\n\ncount=ans=0\n\nif(n>=2 and a[0]==1 and a[1]==2):\n\tcount+=1\n\nfor i in range(1,n-1):\n\tif(a[i-1]+1==a[i] and a[i+1]-1==a[i]):\n\t\tcount+=1\n\telse:\n\t\tans=max(ans,count)\n\t\tcount=0\n\nif(n>=2 and a[-1]==1000 and a[-2]==999):\n\tcount+=1\n\nans=max(count,ans)\nprint(ans)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "ef5fbe01bd96ceb2cc0f3c54b5ebf0cd", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a=int(input())\nx=input()\nr=0\nfor i in x:\n\tif r!=0 and i=='-':\n\t\tr-=1\n\telif i=='+':\n\t\tr+=1\nprint(r)\n#author:SK__Shanto__\u32db\n#code__define__your__smartness", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "2730a1448dea18e8164ab47e4788dc99", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "q = [str(i*i) for i in range(1, 44722)]\nq.reverse()\nn = input()\nans = ''\nfor i in q:\n  cont = 0\n  pos = 0\n  for j in i:\n    x = pos\n    for k in n[x::]:\n      pos+=1\n      if(k == j):\n        cont+=1\n        break\n  if(cont == len(i)):\n    ans = str(len(n) - cont)\n    break\nif(ans == ''):\n  print('-1')\nelse:\n  print(ans)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "cf24f800595e5f2725f4ae6210dc5c7c", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "data = [int(info) for info in input().split(' ')]\n\nif data[0] == data[2] and data[1] == data[3]:\n\ttime = data[1] - data[0] + 1\n\tif data[4] >= data[0] and data[4] <= data[1]:\n\t\ttime -= 1\n\nelif (((data[2] < data[0]) and (data[2] < data[1])) and ((data[3] < data[0]) and (data[3] < data[1]))) or (((data[1] < data[2]) and (data[0] < data[2])) and ((data[0] < data[3]) and (data[0] < data[3]))):\n\t#import code\n\t#code.interact(local=locals())\n\t#print('bine pa')\n\ttime = 0\nelse:\n\tif data[0] < data[2]:\n\t\tif data[1] < data[3]:\n\t\t\ttime = data[1] - data[2] + 1\n\t\t\tif data[4] <= data[1] and data[4] >= data[2]:\n\t\t\t\ttime -= 1\n\t\telse:\n\t\t\ttime = data[3] - data[2] + 1\n\t\t\tif data[4] <= data[3] and data[4] >= data[2]:\n\t\t\t\ttime -= 1\n\n\telse:\n\t\tif data[1] > data[3]:\n\t\t\ttime = data[3] - data[0] + 1\n\t\t\t#import code\n\t\t\t#code.interact(local=locals())\n\t\t\tif data[4] <= data[3] and data[4] >= data[0]:\n\t\t\t\ttime -= 1\n\t\telse:\n\t\t\ttime = data[1] - data[0] + 1\n\t\t\tif data[4] >= data[0] and data[4] <= data[1]:\n\t\t\t\ttime -= 1\nprint(time)\t\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "e75dc50c8f545d9038967f6c8af8e8ec", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input()\ndef isprime(n):\n    for i in range(2,int(n**.5)+1):\n        if n%i==0: return 0\n    return 1\nl=[]\nfor i in range(2,1300):\n    if(isprime(i)==1):l.append(i)\nind=0\nif n!=1: print n\nwhile n>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", "tags": ["greedy"], "code_uid": "a631f5466882e7468b069f7188edb470", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "lista = list(map(int, input().split()))\nlista1 = list(range(lista[0], lista[1]+1))\nlista2 = list(range(lista[2], lista[3]+1))\nj = i = 0\nresp = \"NO\"\n\nwhile True:\n\tif j == lista[3] - lista[2] +1  or i == lista[1] - lista[0]+1:\n\t\tbreak\n\tif lista1[i] / lista2[j] == lista[4]:\n\t\tresp = \"YES\"\n\t\tbreak\n\telif lista1[i] / lista2[j] < lista[4]:\n\t\ti += 1\n\telif lista1[i] / lista2[j] > lista[4]:\n\t\tj += 1\n\nprint (resp)", "lang_cluster": "Python", "tags": ["two pointers", "brute force"], "code_uid": "6d4b317623696d30dc4dfbc23c1c0f79", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\nm = str(n)\ng = len(m)\nl = [int(m[0])-1]+[9]*(g-1)\nh = 0\nless = 0\nwhile(h<len(l)):\n    less = less + l[h]\n    h = h + 1\na = n - less\nr = []\ni = 0\nwhile(a<n):\n    j = 0\n    s = str(a)\n    c = a\n    while j<len(s):\n        c = c + int(s[j])\n        j = j + 1\n    if(c==n):\n        i +=1\n        r = r + [a]\n    a = a + 1\nif(i==0):\n    print(0)\nelse:\n    print(i)\n    j = 0\n    while(j<len(r)):\n        print(r[j])\n        j = j + 1\n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "3d9b561821b9d49b6ba48d5bbb08b2e1", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def isSquare(x, p):\n  return (pow(x, p - 1, p) - 1) % p == 0 and all(((pow(x, i, p) - 1) % p != 0 for i in xrange(1, p - 1)))\np = input()\ncount = 0\nfor x in xrange(1, p):\n  if isSquare(x, p):\n    count += 1\nprint count", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "2a5d3e4a8909878ff819aec506f29e4b", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\nst=\"\"\nfor i in range(1,1000):\n    st=st+str(i)\nprint(st[n-1] )\n\n    ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "21396af87304a95563d5b4b4a9eebdfd", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "l = input()\nm = 0\nn = 0\nfor i in range(1, len(l)):\n\tm += 1\n\tif l[i] != l[i-1]:\n\t\tm = 0\n\t\tn += 1\n\telif m == 5:\n\t\tm = 0\n\t\tn += 1\nprint(n+1)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "9f6066c7e407451131ebd26c2dd06e59", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# Python3 code to find largest prime \n# factor of number \nfrom collections import Counter\nimport math \n  \n# A function to print all prime factors of  \n# a given number n \ndef primeFactors(n): \n      \n    # Print the number of two's that divide n\n    list=[]\n    while n % 2 == 0: \n        \n        list.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(math.sqrt(n))+1,2): \n          \n        # while i divides n , print i ad divide n \n        while n % i== 0: \n            \n            list.append(i)\n            n = n / i \n              \n    # Condition if n is a prime \n    # number greater than 2 \n    if n > 2: \n        \n        list.append(n)\n    return list\n\n  \n  \n#write your main here\n#find the count of maximum factor in the b\nn,b=map(int,input().split())\n\nm_fact=primeFactors(b)\n#counter = Counter(m_fact)\n#print(counter)\nll=[]\n#print(m_fact)\nfor fact in m_fact:\n    #print(fact)\n    div=0\n    bb=b\n    while (bb%fact)==0:\n        div+=1\n        bb=int(bb//fact)\n    #print(div)\n    #print(div)\n\n    t_count=int(0)\n    num=n\n    #print(num)\n    while num>=fact:\n        t_count+=int(num//fact)\n        num=(num//fact)\n        #print(num)\n    #print(t_count)\n\n    ll.append(t_count//div)\n    #print(ll)\nprint(min(ll))", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "843c56481ab76363747fb1c6f803cc68", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "N = int(input())\r\n \r\nfor i in range(N):\r\n    \r\n    key = int(input())\r\n    arr = [int(i) for i in input().split()]\r\n    if (arr[key-1] ==0) or (arr[arr[key-1]-1]==0):\r\n        print(\"NO\")          \r\n    else:\r\n        print(\"YES\")", "lang_cluster": "Python", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "31fb2d99adca01c7467c4688194d7c76", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def gogo(n, m): \n    return n + ((n-1)//(m-1))\n\n\ndef main():\n    pairs, bought = map(int, input().split())\n    print(gogo(pairs, bought))\n\n\nmain()\n\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "bfa17fde86ca6c500cecdd3dab5415f2", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "#n=input()\nboo = [0]*10\nn,m = map(int,raw_input().split())\narr_n = map(int,raw_input().split())\narr_m = map(int,raw_input().split())\nfor i in arr_m:\n\tboo[i] +=1\nres=[]\nf=100\nfor j in range(n):\n\tif boo[arr_n[j]]==1:\n\t\tboo[arr_n[j]]-=1\n\t\tf=min(100,j)\n\t\tres.append(arr_n[j])\nif len(res)>0:\n\tfor i in range(f-1):\n\t\tif boo[arr_n[i]]==1:\n\t\t\tprint j,\n\tfor k in res:\n\t\tprint k,\n\tprint\nelse:\n\tprint", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "331ad0b5d6e6805761c3c383a70e314b", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a=int(input())\ns=input().split()\nm=0\nfor i in s:\n\tv=0\n\tfor j in i:\n\t\tif ord(j)>64 and ord(j)<91:\n\t\t\tv=v+1\n\tif v>m:\n\t\t\tm=v\nprint(m)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "2fb10196245ac0c0b8030c0cd869c5a9", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n = input()\nwhile (n % 10 == 0) :\n\tn /= 10\n\nn = str(n)\nit = 0;\nwhile it < len(n) : \n\tif n[ it ] != n[ len(n) - it - 1] :\n\t\tprint \"NO\"\n\t\texit()\n\tit += 1;\n\nprint \"YES\"", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "c2a9618d893e256099a29be138c41b8f", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,m=map(int,input().split())\n\na=[]\nans=0\nfor i in range(n):\n\ta.append(list(input()))\n\nate=[]\n\nfor i in range(n):\n\tfor j in range(m):\n\t\tif i+1<n:\n\t\t\tif a[i][j]=='W' and a[i+1][j]=='P' and (i,j) not in ate:\n\t\t\t\ta[i+1][j]='.'\n\t\t\t\tate.append((i,j))\n\t\t\t\tans+=1\n\t\tif j+1<m:\n\t\t\tif a[i][j]=='W' and a[i][j+1]=='P' and (i,j) not in ate:\n\t\t\t\ta[i][j+1]='.'\n\t\t\t\tans+=1\n\t\t\t\tate.append((i,j))\nfor i in range(n-1,-1,-1):\n\tfor j in range(m-1,-1,-1):\n\t\tif i>=1:\n\t\t\tif a[i][j]=='W' and a[i-1][j]=='P' and (i,j) not in ate:\n\t\t\t\ta[i-1][j]='.'\n\t\t\t\tans+=1\n\t\t\t\tate.append((i,j))\n\t\tif j>=1:\n\t\t\tif a[i][j]=='W' and a[i][j-1]=='P' and (i,j) not in ate:\n\t\t\t\ta[i][j-1]='.'\n\t\t\t\tans+=1\n\t\t\t\tate.append((i,j))\nprint(ans)\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "80843d8263b7cb7a7497c15f9ae01ecd", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import re\nimport sys\nimport time\n\ndef read(t=None):\n\tstring = raw_input()\n\treturn string if t is None else [t(x) for x in string.split()]\n\ndef solve():\n\tminc = 10000000000000000\n\tn, a, b, c = read(int)\n\tfor i in range(0, 5):\n\t\tfor j in range(0, 5):\n\t\t\tfor k in range(0, 5):\n\t\t\t\tcost = i * a + j * b + k * c\n\t\t\t\tnum = n + i + 2 * j + 3 * k\n\t\t\t\tif num % 4 == 0:\n\t\t\t\t\tminc = min(minc, cost)\n\tprint minc\n\t\t\t\t\n\nif __name__ == \"__main__\":\n\tsolve()", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "ed503395c68ac8de2e5853dd21db85d1", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/bin/env python\n\nfrom typing import List\nfrom math import sqrt\n\nMOD = 998244353\n\n\ndef sieve(n) -> List[bool]:\n    is_prime = [True] * (n + 1)\n    is_prime[0] = is_prime[1] = False\n    for i in range(4, n + 1, 2):\n        is_prime[i] = False\n    \n    for i in range(3, int(sqrt(n)) + 2, 2):\n        if is_prime[i]:\n            for j in range(i * i, n, 2 * i):\n                is_prime[j] = False\n    \n    return is_prime\n\n\ndef main():\n    n, m = map(int, input().split())\n    is_prime = sieve(n)\n\n    unambiguous = 0\n    last = 1\n    primes_acc = 1\n\n    for i in range(1, n + 1):\n        if primes_acc > m:\n            break\n\n        if is_prime[i]:\n            primes_acc *= i\n\n        last *= m // primes_acc\n        unambiguous = (unambiguous + last) % MOD\n\n    \n    if m != 1:\n        all = pow(m, n + 1, MOD) - 1\n        all = (all * pow(m - 1, MOD - 2, MOD) - 1 + MOD) % MOD\n    else:\n        all = n % MOD\n\n    ans = (all - unambiguous + MOD) % MOD\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    main()\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "f62fa553ce31f380fcc59493c49fb6eb", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/usr/bin/env python\np, d = raw_input().split()\np = int(p)\nd = int(d)\ni = 0\nj = 0\nbest = p\nwhile True:\n\twhile j < len(str(p)) and p >= 0 and str(p)[-(j+1)] != '9':\n\t\ti += 10**j\n\t\tp -= 10**j\n\tif i > d or p < 0 or j >= len(str(p)) or str(p)[-(j+1)] != '9':\n\t\tbreak\n\tbest = p\n\tj += 1\nprint best", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7f5a112d5ff4968feacac80a4dc30bae", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def xc2(x):\n    t=x*(x-1)/2\n    return t\nn,m=raw_input().split()\nn=int(n)\nm=int(m)\nq=n/m\nr=n%m\nmax=xc2(n-m+1)\nmin=(m-r)*xc2(q)+r*xc2(q+1)\nprint min,max\n", "lang_cluster": "Python", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "0a4dacd4f8c3af109150427ef7f5b2a1", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import atexit\nimport io\nimport sys\nimport math\n\n# Buffering IO\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO()\nsys.stdout = _OUTPUT_BUFFER\n\n@atexit.register\ndef write():\n    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\n    \n\ndef main():\n    n = int(input())\n    ss = 0\n    \n    k = 1\n    while n>1:\n        ss += k * (n // 2)\n        n = math.ceil(n/2)\n        k*=2\n    \n    print(ss)\n\n    \nif __name__ == '__main__':\n    main()\n        ", "lang_cluster": "Python", "tags": ["math", "dp", "bitmasks", "graphs", "implementation"], "code_uid": "1aa50eda0df1b1cad76b3406435402c6", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "'''\nCreated on Jan 1, 2013\n\n@author: Evan\n'''\nline0 = raw_input()\nline1 = raw_input()\nline2 = raw_input()\nl0 = line0.split(\" \")\nl1 = line1.split(\" \")\nl2 = line2.split(\" \")\nl0[0] = int(l0[0])\nl0[1] = int(l0[1])\nl0[2] = int(l0[2])\nl1[0] = int(l1[0])\nl1[1] = int(l1[1])\nl1[2] = int(l1[2])\nl2[0] = int(l2[0])\nl2[1] = int(l2[1])\nl2[2] = int(l2[2])\n\nnum = (l0[1] + l0[2] + l1[2] + l1[0] + l2[0] + l2[1])/2\n\nl0[0] = num - l0[1] - l0[2]\nl1[1] = num - l1[0] - l1[2]\nl2[2] = num - l2[0] - l2[1]\n\nprint l0[0], l0[1], l0[2]\nprint l1[0], l1[1], l1[2]\nprint l2[0], l2[1], l2[2]", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "b8c3f09758a10c7752bc274aaa33224f", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def f(x):    \n    x+=1\n    while not x % 10:\n        x //=10\n    return x\n        \nprevious = set()\n\nn = int(input())\nwhile n not in previous:\n    previous.add(n)\n    n = f(n)\n    \nprint(len(previous))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "87807144a21d31696051967aa976d835", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "m,b=map(int,input().split())\nans=0\nfor x in range(0,m*b+1,m):\n    y=b-x//m\n    t=(x+y)*(x+1)*(y+1)//2\n    ans=max(ans,t)\nprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "03adfade9a24e5f7285bbd26b44c3dc7", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = int(raw_input())\n\nstring = str(raw_input())\n\ncont = 0\ni = 0\nwhile(i < (n - 1)):\n    if(string[i] + string[i + 1] == 'RU' or string[i] + string[i + 1] == 'UR'):\n        cont += 1\n        i += 1\n    i += 1\n\nprint(len(string) - cont)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "bdaeaca25317cf0b4611327305857504", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def f():v=raw_input();return 60*int(v[:2])+int(v[-2:])\nx=f()-f()\nprint\"%02d:%02d\"%(x/60%24,x%60)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b96b64a6b71e2f6ffccccd4bc860d01c", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import atexit\nimport io\nimport sys\n\n\nbuffer = io.BytesIO()\nsys.stdout = buffer\n\n\n@atexit.register\ndef write():\n    sys.__stdout__.write(buffer.getvalue())\n\n\nfor i in range(5):\n    row_lst = raw_input().split()\n    if '1' in row_lst:\n        print(abs(i - 2) + abs(row_lst.index('1') - 2))\n        break\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ce57ecb53e18405be8fb41fbdd775ca3", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn = int(input().strip())\n\nis_prime = [False, False] + [True] * (n - 1)\nprime_list = list()\nalmost_prime = list()\n\nfor i in range(n + 1):\n    if is_prime[i]:\n        prime_list.append(i)\n        for j in range(i * 2, n + 1, i):\n            is_prime[j] = False\n\ndef find_factors(n):\n    if n < 2:\n        return set()\n    elif n == 2:\n        return set([2]) \n    else:\n        for item in prime_list:\n            if n % item == 0:\n                return set([item]).union(find_factors(n/item))\n    return set() \n\ncount = 0\nfor i in range(n + 1):\n    if not is_prime[i]:\n        num_factors = len(find_factors(i))\n        if num_factors == 2:\n            count += 1\n\nprint(count)\n\n\n", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "a69909dc18e9b2282781e1fc76efacef", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def main():\n    n=input()\n    d=[1,2]\n    s=[3]\n    dic=[]\n    c=0\n    for i in xrange(n):\n        dic.append(input())\n    for i in xrange(n):\n        if  dic[i]==d[0]:\n            d[1],s[0]=s[0],d[1]\n        elif dic[i]==d[1]:\n            d[0],s[0]=s[0],d[0]\n        else:\n            c=1 \n            print \"NO\"\n            break \n    if c==0:\n        print \"YES\"\n    \n            \n            \nif __name__ == '__main__':\n    main()", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "06197a7f94210888fb8a5a069d3d9d8c", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a = [len(map(str,raw_input()[2::])), 'A']\nb = [len(map(str,raw_input()[2::])),'B']\nc = [len(map(str,raw_input()[2::])),'C']\nd = [len(map(str,raw_input()[2::])),'D']\n\nans = None\n\nl = list(sorted([a, b, c, d]))\n\nif l[0][0] * 2 <= l[1][0] and l[2][0] * 2 > l[3][0]:\n    ans = l[0][1]\nelif l[2][0] * 2 <= l[3][0] and l[0][0] * 2 > l[1][0]:\n    ans = l[3][1]\nelse:\n    ans = 'C'\n\nprint(ans)\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "75409bb858770a708bf547decdda48a3", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def neighbors(point):\n    neighs = [point]\n    p = (max(0, point[0]-1),point[1])\n    if p not in neighs: neighs.append(p)\n    p = (min(2, point[0]+1),point[1])\n    if p not in neighs: neighs.append(p)\n    p = (point[0],max(0,point[1]-1))\n    if p not in neighs: neighs.append(p)\n    p = (point[0],min(2,point[1]+1))\n    if p not in neighs: neighs.append(p)\n    return neighs \n\ndef start():\n    lights = [[1,1,1],[1,1,1],[1,1,1]]\n    grid = []\n    grid.append(map(int, raw_input().split()))\n    grid.append(map(int, raw_input().split()))\n    grid.append(map(int, raw_input().split()))\n    for x in xrange(3):\n        for y in xrange(3):\n            if grid[x][y]%2 != 0:\n                for p in neighbors((x,y)):\n                    lights[p[0]][p[1]] = (lights[p[0]][p[1]]+1)%2\n    print '\\n'.join(''.join(map(str, l)) for l in lights)\n\nstart()\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d9dac7e5180025f5b4243387adbefc66", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\ndone=0\nh,e=map(int,raw_input().split())\nans=0\nif h==50 and e==1125899906842624:\n    ans=2251799813685246\n    done=1\ne=pow(2,h)-1+e\ntemp=1\nch=0\nwhile e!=1 and done==0:\n    ansh=int(math.log(e,2))\n    if (e/2)%2==0:\n        if e%2==1:\n            ans+=1\n        else:\n            ans+=pow(2,h-ansh+1)\n    else:\n        if e%2==0:\n            ans+=1\n        else:\n            ans+=pow(2,h-ansh+1)\n    e/=2\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "implementation", "trees"], "code_uid": "c89b98d8f2de7a597a20445d3eeb04d8", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = input()\nif 'week' in n:\n\tif '5' in n:\n\t\tprint(53)\n\telif '6' in n:\n\t\tprint(53)\n\telse:\n\t\tprint(52)\nelse:\n\tif '30' in n:\n\t\tprint(11)\n\telif '31' in n:\n\t\tprint(7)\n\telse:\n\t\tprint(12)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "c0b36e53c2b656d800d05b68654b60b1", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nrows = [0, 1, 0, 1]\nseats = [\"f\", \"e\", \"d\", \"a\", \"b\", \"c\"]\ns = input()\na, b = int(s[:-1]), s[-1]\nprint((a - 1) // 4 * 16 + rows[a % 4 - 1] * 7 + seats.index(b) + 1)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "b332753ba91c1b18078f3d0963564d1d", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,x = input().split()\nn,x=int(n),int(x)\nl = list(map(int , input().split()))\nl.sort()\nif l[0]>x:\n\tprint(x)\nelif l[0]==x:\n\tprint(x+1)\nelse:\n\tc=0\n\tfor i in range(x):\n\t\tif i not in l:\n\t\t\tc+=1\n\tif x in l:\n\t\tc+=1\n\tprint(c)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "fa4e8943b867f706bcd2fb03b61b0a83", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\npf = {}\n\nn = int(input())\nif n == 1:\n  print('1 0')\n  exit()\n\ncare = 0\nwhile(True):\n  done = True\n  for i in range(2, n):\n    if n % i == 0:\n      while(n % i == 0):\n        n /= i\n        n = int(n)\n        pf[i] = pf.get(i, 0) + 1\n        care = max(care, pf[i])\n      done = False\n      break\n  if done:\n    if n != 1: pf[n] = pf.get(n, 0) + 1\n    break\n\ntwo = 1\ntwo_count = 0\nwhile(True):\n  if two >= care:\n    break\n  two *= 2\n  two_count += 1\n\nans = 0\nfor x in pf.items():\n  if x[1] != two:\n    ans = 1\n    break\n\nfirst_ans = 1\nfor x in pf.items():\n  first_ans *= x[0]\nprint(f'{first_ans} {ans + two_count}')", "lang_cluster": "Python", "tags": ["math", "greedy", "number theory"], "code_uid": "c2100b6c2aa0574537a489dcfdc3886d", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#      *\n#     * *\n#    *   *\n#   *  *  *  Author:Aditya Joshi\n#  *       *\n# *         *\nn = int(input())\ns = input()\nz = []\ns = 'A'+s+'B'\nfor i in range(len(s)):\n    if s[i].isupper():\n        z.append(i)\nl = []\nfor i in range(len(z)-1):\n    t = len(set(s[z[i]+1: z[i + 1]]))\n    # print(s[z[i]+1: z[i + 1]])\n    # print(t)\n    l.append(t)\n# print(z)\nprint(max(l))\n", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "a688e7ab4de4ba35e0cf0ca298c0e7e4", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "x,y,m=map(long,raw_input().split())\nif (x>=m)|(y>=m):\n    print 0\nelif (x<=0)&(y<=0):\n    print -1\nelse:\n    if (x<y):x,y=y,x\n    t=0\n    while (x<m):\n        u=max(1,(x-y)/x-1)\n        x,y,t=y+u*x,x,t+u\n        if (x<y):x,y=y,x\n    print t\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "195ec50b146d42fc7173abe95da22925", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def func(h, n, m):\n    if 2 * n > h or 3 * m > h:\n        return False\n    om = (h + 3) // 6\n    em = m - om\n    an = h // 2\n    rn = an - em\n    return rn >= n\n\nn, m = map(int, raw_input().split())\n\nans = None\nlow, high = 0, 10000000\nwhile low <= high:\n    mid = (low + high) // 2\n    if func(mid, n, m):\n        ans, high = mid, mid - 1\n    else:\n        low = mid + 1\n\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "b88fd4f6ec48d7269c03e9acb88e793a", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, k = raw_input().strip().split()\nk = int(k)\n\ndef findMax(s, fro, mx):\n    to = fro + min(mx+1, len(s)-fro)\n    M, idx = s[fro], fro\n    for i in xrange(fro+1, to):\n        if s[i] > M:\n            M, idx = s[i], i\n    return idx\n\ni = 0\nwhile k > 0 and i < len(a):\n    j = findMax(a, i, k)\n    k -= (j-i)\n    a = a[:i] + a[j] + a[i:j]+ a[j+1:]\n    i += 1\nprint a", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "052b5a8d372f72114ee75a072b4731a2", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = {0: 0, 1: 0}\nfor i in range(4):\n    a, b, c, d = input().split()\n    if a == c and b != d: s[0] += 1\n    if b == d and a != c: s[1] += 1\n    for q in [(a, b), (c, d)]: s[q] = s.get(q, 0) + 1\nprint('YES' if all(i == 2 for i in s.values()) else 'NO')", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "43ad5d3c6352602939e7a03d0b156ddf", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,m,k,x,y=map(int, raw_input().split())\nt=[0 for i in range(n)]\nlen=0\nfor i in range(n):t[i]+=1; len+=1\nfor i in range(n-2,0,-1): t[i]+=1; len+=1\nlen*=m\nmd=k%len\nti=k/len\nc=[[0 for i in range(m)] for j in range(n)]\nfor i in range(n):\n    for j in range(m):\n        c[i][j]=t[i]*ti\nwhile md > 0:\n    for i in range(n):\n        for j in range(m):\n            if(md==0): break\n            else: c[i][j]+=1; md-=1;\n    for i in range(n-2,0,-1):\n        for j in range(m):\n            if (md==0): break\n            else: c[i][j]+=1; md-=1;\nprint max([max(c[i]) for i in range(n)]), min([min(c[i]) for i in range(n)]), c[x - 1][y - 1];", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "8f2f6224da9bf1f4f6711f678e6e5fe1", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def int3(c):\n    a = []\n    while c:\n        a.append(c%3)\n        c = c/3\n    if not a:\n        a.append(0)\n    return a\n\ndef untor(c1, c2):\n    c3 = []\n    for i, j in zip(c1, c2):\n        if j < i:\n            c3.append(3+j-i)\n        else:\n            c3.append(j-i)\n    if len(c2) > len(c1):\n        c3 += c2[len(c1):]\n    else:\n        c3 += [ (3-i)%3 for i in c1[len(c2):] ]\n    c3.reverse()\n    s = ''\n    for i in c3:\n        s += str(i)\n    return s\n\nc1, c2 = tuple(raw_input().split())\nc1 = int(c1)\nc2 = int(c2)\nprint int(untor(int3(c1), int3(c2)), 3)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "ff1d4d00ce12180f17a006c6b17e43fa", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x1, y1, x2, y2 = map(int, input().split())\nif (x1 > x2 or y1 > y2) and x1 + y1 > max(x2, y2):\n\tprint(\"Vasiliy\")\nelse:\n\tprint(\"Polycarp\")\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation", "games"], "code_uid": "d2ef760ef34e8097365e8dc2adae51b8", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a1,a2,a3=map(int,input().split())\nb1,b2,b3=map(int,input().split())\nn=int(input())\ntotal_medals=b1+b2+b3\ntotal_cups=a1+a2+a3\nif(total_medals%10==0):\n    x=total_medals/10\n    n=n-x\nelse:\n    n-=(total_medals//10+1)\nif(total_cups%5==0):\n    x=total_cups/5\n    n=n-x\nelse:\n    n-=(total_cups//5+1)\nif(n>=0):\n    print('YES')\nelse:\n    print('NO')\n\n    \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ae2c9bddd99bade8b23c9b0d5b3d000b", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "ss=int(input())\ns=str(ss)\ncount=0\nx=len(s)\nfor i in range(1,x):\n    if(s[i]==\"1\"):\n        count+=1\nif(x-count>6):\n    print(\"yes\")\nelse:\n    print(\"no\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7ed8b0a1fb8034001d614570d87e24a6", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "s=input().strip()\nl=[]\nn=int(input())\nfor x in range(n):\n    l.append(input().strip())\n\npresent=False\nfor i in range(n):\n    for j in range(n):\n        if s in l[i]+l[j] or s in l[j]+l[i]:\n            present=True\n\nif present:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "25b9fb37eef13af44478b55206498c57", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/python3\n\nx1, y1, x2, y2 = [int(i) for i in input().split()]\n\ndx = x2 - x1 + 1\ndy = (y2 - y1) // 2 + 1\n\nif dx%2 == 1:\n\tans = dy * (dx//2 + 1) + (dy-1) * (dx//2)\nelse:\n\tans = dx*dy\n\nprint(ans)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "bdb060a0503db2108568c9995df29c5a", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s=input()\nl=len(s)\nif l>=5:\n    A=0\n    a=0\n    d=0\n    for i in s:\n        if A>0 and a>0 and d>0:\n            break\n        if i>='a' and i<='z':\n            a=a+1\n        elif i>='A' and i<='Z':\n            A+=1\n        try:\n            k=int(i)\n            d=d+1\n        except:\n            pass\n    if A>0 and a>0 and d>0:\n        print('Correct')\n    else:\n        print('Too weak')\nelse:\n    print('Too weak')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "47964f4c568294070cebdafc18b1c63f", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from math import *\nstring=raw_input()\n#numbers = ['0','1','2','3','4','5','6','7','8','9']\nextracts=[]\nfor i in range(len(string)):\n\tif string[i] !='+':\n\t\textracts.append(int(string[i]))\nextracts.sort()\nfinal = []\ni = 0\ns=\"\"\nif len(extracts)>1:\n\tfor x in extracts:\n\t\ts+=str(x)\n\t\t# print(\"i = \",i)\n\t\tif i!=len(extracts)-1:\n\t\t\ts+=\"+\"\n\t\ti+=1\nelse:\n\tfor x in extracts:\n\t\ts+=str(x)\n#s.join(final)\nprint(s)\n\n", "lang_cluster": "Python", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "784d3f3a6c03e46d7bc5d53941ba0b45", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nif n == 1:\n    r = 5\nif n > 1:\n    r = 25\nprint(r)\n          ", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "9481afd6db6481de57b8331832c27ad0", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# cook your dish here\nfrom sys import stdin,stdout\nfrom collections import Counter\nfrom itertools import permutations\nimport bisect\nimport math\nI=lambda: map(int,stdin.readline().split())\nI1=lambda: stdin.readline()\n\nl,r=I()\na=[]\ni,j,x=1,1,1 \nwhile i<2000000001:\n    j,x=1,1 \n    while x<2000000001:\n        x=i*j \n        a.append(x)\n        j*=3 \n    i*=2 \nans=bisect.bisect(sorted(a),r)-bisect.bisect_left(sorted(a),l)\nprint(ans)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "bd32ee20df3c58721e9f036c886489d5", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"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)\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            Aij = Ai[j] + 1j * ((Ai[j] * 65536.0) % mod)\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", "tags": ["math", "matrices", "dp"], "code_uid": "ffc4925ed29194aa9aa07b149c9634e7", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "info = raw_input()\nn = int(info.split(\" \")[0])\nm = int(info.split(\" \")[1])\nk = int(info.split(\" \")[2])\n\nif k > (n+m-2):\n\tprint -1\nelse:\n\tif m >= n:\n\t\tif k <= m-1:\n\t\t\tcut_area1 = n*int(m/(k+1))\t#cut along m side\n\t\t\tcut_area2 = m*int(n/(k+1))  #cut along n side\n\t\t\tif cut_area1 > cut_area2:\n\t\t\t\tprint cut_area1\n\t\t\telse:\n\t\t\t\tprint cut_area2\n\t\telse:\n\t\t\tremainder = k-(m-1)\t\t# case where all of the cuts on major side have been used \n\t\t\tprint int(n/(remainder+1))\n\telse:\n\t\tif k <= n-1:\n\t\t\tcut_area1 = int(n/(k+1))*m\t#cut along n side\n\t\t\tcut_area2 = int(m/(k+1))*n  #cut along m side\n\t\t\tif cut_area1 > cut_area2:\n\t\t\t\tprint cut_area1\n\t\t\telse:\n\t\t\t\tprint cut_area2\n\t\telse:\n\t\t\tremainder = k-(n-1)\n\t\t\tprint int(m/(remainder+1))\n", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "0f49ccc847d33a2c97919d55963cba1c", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\nxo,yo,ax,ay,bx,by=map(int,input().split())\norx,ory=xo,yo\nxs,ys,t=map(int,input().split())\ncur=abs(xo-xs)+abs(yo-ys)\nsort=[cur]\nwhile True:\n    x,y=xo,yo\n    xo,yo=ax*xo+bx,ay*yo+by\n    cur=abs(xo-xs)+abs(yo-ys)\n    if cur>sort[-1]:\n        break\n    else:\n        sort.append(cur)\ndpoint=0\ncopyx,copyy=x,y\nmina=abs(x-xs)+abs(y-ys)\nif mina<=t:\n    dpoint+=1\ntime=0\ncopy=time\nwhile time<t and (x,y)!=(orx,ory):\n    a,b=x,y\n    x,y=(x-bx)//ax,(y-by)//ay\n    time+=abs(x-a)+abs(y-b)\n    if (time+min(mina,abs(x-xs)+abs(y-ys)))<=t:\n        dpoint+=1\n    #print(x,y,a,b,time,dpoint)\nif time+min(mina,(abs(x-xs)+abs(y-ys)))<t:\n    mina=abs(x-xs)+abs(y-ys)\n    while time<t:\n        a,b=ax*copyx+bx,ay*copyy+by\n        time+=abs(a-copyx)+abs(b-copyy)\n        copyx,copyy=a,b\n        x,y=a,b\n        if (time+min(mina,(abs(a-xs)+(b-ys))))<=t:\n            #print(time+min(mina,(abs(a-xs)+(b-xs))),a,b,copyx,copyy,dpoint)\n            dpoint+=1\nprint(dpoint)\n        \n    \n\n    \n", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "implementation", "greedy", "geometry"], "code_uid": "d162a7bb7c61a54e21b30823911ebc7c", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\nleap = \"312931303130313130313031\"\nstr2 = \"312831303130313130313031\"\nstr2 = str2+str2+leap+str2+str2\nstrings = ''.join(str(x) for x in a)\nif strings in str2:\n    print(\"YES\")\nelse:\n    print(\"NO\")\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d0d0faf1c3184115479be32d6bee2b3b", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=''\na=input()\nfor i in a:\n    if(i==\">\"):\n        n=n+'1000'\n    if(i==\"<\"):\n        n=n+'1001'\n    if(i==\"+\"):\n        n=n+'1010'\n    if(i==\"-\"):\n        n=n+'1011'\n    if(i==\".\"):\n        n=n+'1100'\n    \n    if(i==\",\"):\n        n=n+'1101'\n    \n    if(i==\"[\"):\n        n=n+'1110'\n        \n    if(i==\"]\"):\n        n=n+'1111'\n        \nx=int(n, 2)\nprint(x%1000003)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "6021bf415014448794639ac98eb17ed4", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nk=input()\nl=input()\nm=input()\nn=input()\nd=input()\nl1=[]\nc=1\nz1=k\nz2=l\nz3=m\nz4=n\nwhile c!=0:\n    if z1<=d:\n        l1.append(z1)\n    if z2<=d:\n        l1.append(z2)\n    if z3<=d:\n        l1.append(z3)\n    if z4<=d:\n        l1.append(z4)\n    z1+=k\n    z2+=l\n    z3+=m\n    z4+=n\n    if z1>d and z2>d and z3>d and z4>d:\n        c=0\nl1=set(l1)\nprint len(l1)\n   ", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "e37ce9c50befc5e954af78d4110c5d16", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nsys.setrecursionlimit(1500)\n\ns1 = \"What are you doing at the end of the world? Are you busy? Will you save us?\"\na = \"What are you doing while sending \\\"\"\nb = \"\\\"? Are you busy? Will you send \\\"\"\nc = \"\\\"?\"\nans = \"\"\n\n\ndef solve(n, k):\n    if n == 0:\n        if k >= len(s1):\n            return \".\"\n        else:\n            return s1[k]\n    if k < len(a):\n        return a[k]\n    k -= len(a)\n    prev_len = (2 ** (n - 1) - 1) * (len(a) + len(b) + len(c)) + (2 ** (n - 1)) * len(s1)\n    if k < prev_len:\n        return solve(n - 1, k)\n    k -= prev_len\n    if k < len(b):\n        return b[k]\n    k -= len(b)\n    if k < prev_len:\n        return solve(n - 1, k)\n    k -= prev_len\n    if k < len(c):\n        return c[k]\n    else:\n        return \".\"\n\n\nfor _ in range(int(input())):\n    n, k = list(map(int, input().split()))\n    k -= 1\n    if n > 65:\n        m = n - 65\n        if k < len(a) * m:\n            ans += a[k % len(a)]\n            continue\n        k -= len(a) * m\n        n = n - m\n    ans += solve(n, k)\n\nprint(ans)\n", "lang_cluster": "Python", "tags": ["dfs and similar", "binary search"], "code_uid": "aba673e31fba54d8d9e5c42d059a516b", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def getsum(x): \n\treturn int((x * (x + 1)) / 2) \n\n\ndef countJumps(n): \n\t\n\t \n\tn = abs(n) \n\n\t \n\tans = 0\n\n\t\n\twhile (getsum(ans) < n or\n\t\t(getsum(ans) - n) & 1): \n\t\tans += 1\n\n\t\n\treturn ans \n\n \nif __name__ == '__main__': \n\tn = int(input())\n\n\tprint(countJumps(n))", "lang_cluster": "Python", "tags": ["math"], "code_uid": "2bc6154c3c8ef963ff434077268a3c41", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "# cf 177 B1 1000\nn = int(input())\n\nsum_ = 0\n\nwhile n != 1:\n    sum_ += n\n    max_ = 0\n    for i in range(2, n + 1):\n        if n % i == 0:\n            max_ = max(max_, n // i)\n    n = max_\n    assert n != 0\n\nprint(sum_ + 1)\n", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "7e42fdd6916f07ea7e0e8995a7934ac8", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "t,s,q=map(int,input().split())\nres=0\nwhile s<t:s*=q;res+=1\nprint(res)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "075c28eaa1bdc66e9693240308b15533", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "a = raw_input()\nprint (ord(a[-1]) - ord('0')) % 2", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "6adbc53449cbff97224a66ed1dd27a55", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n=input()\no=[(n>3 and (n-2)/3),(n>3 and (n-3)/3),0,(n>3 and (n-4)/3)]\nh=['|D|)','|.|','..|','|.|)']\ns='+'+'-'*24+'+'\nprint s\nfor r in range(4):\n  print '|'+('O.' if n>r else '#.')+'O.'*o[r]+('..' if 2==r else '#.')*(10-o[r])+h[r]\nprint s", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "51dda47ecb85072b3def3afedea07353", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def rt(p):\n    a = (p[0] - p[2]) ** 2 + (p[1] - p[3]) ** 2\n    b = (p[0] - p[4]) ** 2 + (p[1] - p[5]) ** 2\n    c = (p[2] - p[4]) ** 2 + (p[3] - p[5]) ** 2\n    return a and b and c and (a + b == c or a + c == b or b + c == a)\ndef f(p):\n    if rt(p):\n        return 'RIGHT'\n    for i in range(6):\n        p[i] -= 1\n        if rt(p):\n            return 'ALMOST'\n        p[i] += 2\n        if rt(p):\n            return 'ALMOST'\n        p[i] -= 1\n    return 'NEITHER'\nprint(f(list(map(int, input().split()))))", "lang_cluster": "Python", "tags": ["brute force", "geometry"], "code_uid": "9786864081e305377adf192938ccafd2", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "b = int(input())\ncnt, j = 0, 1\nwhile j * j <= b:\n    if b % j == 0:\n        cnt += 1\n        if (j * j != b):\n            cnt += 1\n    j += 1\nprint(cnt)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "0791d05c4412cd64a6574190be06eba5", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "t=int(input())\nfor ti in range(t):\n    n,k,d=map(int,input().split())\n    inlist=[int(i) for i in input().split()]\n    a=[]\n    for i in range(n-d+1):\n        se=set(inlist[i:i+d])\n        a.append(len(se))\n    print(min(a))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d844e4db1b4dfa93a7d6281b09adef8c", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#author : SanskarxRawat\nn,k=map(int,input().strip().split())\nprint(3*n+min(n-k,k-1))", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "71980504bbc1123462f26dc3e44fd076", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "h,m=map(int,raw_input().split(':'))\nh%=12\nm/=60.\nprint 360.*(h+m)/12,360.*m", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "e61d68c0646ab84e433d01c747ef7aa1", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def reach_max(n, k):\n    return n * k + 1 - n * (n + 1) // 2\n\n\nn, k = map(int, input().split())\n\nif n == 1:\n    print(0)\n    exit()\n\nlo, hi = 1, k - 1\n\nif n > reach_max(hi, k):\n    print(-1)\n    exit()\n\n\nwhile lo < hi:\n    mid = (lo + hi) // 2\n    if reach_max(mid, k) < n:\n        lo = mid + 1\n    else:\n        hi = mid\n\nprint(lo)\n", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "d288840bc9e8c4692ed1b5713d587df0", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b, c = map(int, input().split())\nx = (a * c * b) ** .5\nprint(4 * int(x / a + x / b + x / c))", "lang_cluster": "Python", "tags": ["brute force", "math", "geometry"], "code_uid": "df69e1532ce13cf3008476293707cf80", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "number_sizes = (6, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n\ndef lines_in_number(number, total_previous_number):\n    total = 0\n\n    while number > 0:\n        number, remainder = divmod(number, 10)\n\n        if total_previous_number > 0 and total == 0 and remainder > 0:\n            # If last digit - use total previous number instead\n            total = total_previous_number + number_sizes[remainder] - number_sizes[remainder - 1]\n            break\n\n        total += number_sizes[remainder]\n\n    return total\n\n\ndef calculate_total_lines(start, stop):\n    total = 0\n    total_previous_number = 0\n\n    for number in xrange(start, stop + 1):\n        lines = lines_in_number(number, total_previous_number)\n        total_previous_number = lines\n\n        total += lines\n\n    return total\n\n\nif __name__ == '__main__':\n    user_input = raw_input()\n    parsed_input = user_input.split()\n    parsed_input = map(int, parsed_input)\n\n    start = parsed_input[0]\n    stop = parsed_input[1]\n\n    print calculate_total_lines(start, stop)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d87c7063b80d6e9126bc3eaa004eb0f6", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "__author__ = 'myduomilia'\n\nn, t = list(map(int, input().split()))\narr = list(map(int, input().split()))\ns = sum(arr)\nans = 0\n\nif s + (len(arr) - 1) * 10 > t:\n    print(-1)\nelse:\n    print((t - s) // 5)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "7839b462979f317f3f02850efbf73dbb", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = input()\nn = list(n)\nspace = 1\n\ns = []\ni = 0\nfor _ in range(0,len(n), 1):\n    if i == len(n):\n        break\n    elif i + 2 < len(n) and n[i] == 'W' and n[i+1] == 'U' and n[i+2] == 'B':\n        i += 3\n        if space == 0:\n            s.append(\" \")\n        space = 1\n    else:\n        s.append(n[i])\n        i += 1\n        space = 0\nans = \"\"\nfor i in range(0, len(s)):\n    ans = ans + s[i]\n\nprint(ans)\n", "lang_cluster": "Python", "tags": ["strings"], "code_uid": "b74d1efc8dc7c743f39b0603ef78ded1", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "A_count = 0\nB_count = 0\nC_count = 0\nfor i in range(3):\n    line = input()\n    if line[0] == 'A':\n        if line[1] == \">\":\n            A_count +=1\n        else:\n            if line[2] == 'B':\n                B_count +=1\n            else:\n                C_count +=1\n    elif line[0] == 'C':\n        if line[1] == '>':\n            C_count += 1\n        else:\n            if line[2] == 'B':\n                B_count +=1\n            else:\n                A_count +=1\n    else:\n        if line[1] == '>':\n            B_count += 1\n        else:\n            if line[2] == 'C':\n                C_count +=1\n            else:\n                A_count +=1\n\nif A_count > B_count > C_count:\n    print('CBA')\nelif A_count > C_count > B_count:\n    print('BCA')\nelif B_count > C_count > A_count:\n    print('ACB')\nelif B_count > A_count > C_count:\n    print('CAB')\nelif C_count > A_count > B_count :\n    print('BAC')\nelif C_count > B_count > A_count:\n    print('ABC')\nelse:\n    print('Impossible')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b53bd98c0393d9a846a6b9da72bcb933", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b = raw_input().strip().split()\nx = int(a);\ny = int(b);\nif( y==1 and x==0):\n    print('Yes')\nelif( (y-1)>=1 and (x-y+1)/2 >= 0 and (x-y-1)%2 == 0):\n    print('Yes')\nelse:\n    print('No')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "f63fd4a230f6f451ee9efabc44fe0aca", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "l,r,a=map(int,raw_input().split())\nif l>=r+a:\n\tprint 2*(r+a)\nelif r>=l+a:\n\tprint 2*(l+a)\nelif l>=r:\n\ttemp=(a+r-l)/2\n\tprint 2*(l+temp)\nelse:\n\ttemp=(a+l-r)/2\n\tprint 2*(r+temp)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "3200812582549ebfcef9d5a1a4db46e0", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, k = list(map(int, input().split()))\nif k >= n // 2:\n    print(n * (n - 1) // 2)\nelse:\n    print(k * (2 * n - 3) - 2 *(k - 1) *(k))", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "7a1b99a1cb7a4b8d7d4c55381bbd8e11", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\ninput= lambda:sys.stdin.readline()\nMOD = 1000000007\nii = lambda: int(input())\nsi = lambda: input()\ndgl = lambda: list(map(int, input()))\nf = lambda: list(map(int, input().split()))\nil = lambda: list(map(int, input().split()))\nls = lambda: list(input())\nv1, v2 = f()\nt, d = f()\nlf, lb = [0]*t, [0]*t\nlf[0]=v1\nlb[-1]=v2\nsff,sfb=[0]*t,[0]*t\nsff[0],sfb[-1]=v1,v2\nfor i in range(1,t):\n    lf[i]=lf[i-1]+d\n    lb[t-i-1]=lb[t-i]+d\n    sff[i]=sff[i-1]+lf[i]\n    sfb[t-i-1]=sfb[t-i]+lb[t-i-1]\nmx=0\nfor i in range(t-1):\n    if abs(lf[i]-lb[i+1])<=d:\n        mx=max(mx,sff[i]+sfb[i+1])\nprint(mx)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "dp"], "code_uid": "f76db4b0fbfcc9dc4c42f58a86f5577e", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "flores = map(int, raw_input().split(' '))\n\nflag = False\n\nif (flores[0] == 0 or flores[1] == 0 or flores[2] == 0):\n  flag = True\n\na = flores[0]/3\nb = flores[1]/3\nc = flores[2]/3\n\nsoma = a + b + c\n\nar = flores[0]%3\nbr = flores[1]%3\ncr = flores[2]%3\n\nif (ar + br + cr == 6):\n  soma += 2\nelif (((ar + br + cr > 3 and ar + br + cr < 6) or (ar == 1 and br == 1 and cr == 1)) and (flag != True) ):\n  soma += 1\n\nprint soma\n", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "1b2b4fd19c68504620a6df2f4e29dc12", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n1,n2 = map(int,input().split());\n\nif(n2-n1)>10:\n    print (0);\nelse:\n    result=1;\n    for i in range(n1+1,n2+1):\n        result*=i;\n    print (result%10);\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "4bb6d998e8198797a581394fc09daf1d", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import os\nimport sys\nimport math\nimport heapq\nfrom decimal import *\nfrom io import BytesIO, IOBase\nfrom collections import defaultdict, deque\n\ndef r():\n    return int(input())\ndef rm():\n    return map(int,input().split())\ndef rl():\n    return list(map(int,input().split()))\n\nn,m,a=rm()\nb=rl()\nc=rl()\nini=a\nb.sort()\nc.sort(reverse=True)\nshares=0\nshares = a//b[0]\na = a%b[0]\na = a + shares*c[0]\nprint(max(ini,a))", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "76126aba35c140dcccfd92780f7c4055", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def sol():\n\n    N = int(input())\n    count = 1\n\n    if N == 1:\n        print(1)\n        return\n\n    while N > 3:\n        N = N//2\n        count += 1\n\n    count += 1\n\n    print(count)\n\n# main\n#for t in range(100):\nsol()\n", "lang_cluster": "Python", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "b36e86a4ac509f349315f5505b93fdae", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\nif (n == 1) :\n print (\"Washington\")\nelif (n == 2):\n print (\"Adams\")\nelif (n == 3):\n print (\"Jefferson\")\nelif (n == 4):\n print (\"Madison\")\nelif (n == 5):\n print (\"Monroe\")\nelif (n == 6):\n print (\"Adams\")\nelif (n == 7):\n print (\"Jackson\")\nelif (n == 8):\n print (\"Van Buren\")\nelif (n == 9):\n print(\"Harrison\")\nelif (n == 10):\n print(\"Tyler\")\nelif (n == 11):\n print(\"Polk\")\nelif (n == 12):\n print(\"Taylor\")\nelif (n == 13):\n print(\"Fillmore\")\nelif (n == 14):\n print(\"Pierce\")\nelif (n == 15):\n print(\"Buchanan\")\nelif (n == 16):\n print (\"Lincoln\")\nelif (n == 17):\n print (\"Johnson\")\nelif (n == 18):\n print (\"Grant\")\nelif (n == 19):\n print (\"Hayes\")\nelif (n == 20):\n print (\"Garfield\")\nelif (n == 21):\n print (\"Arthur\")\nelif (n == 22):\n print (\"Cleveland\")\nelif (n == 23):\n print (\"Harrison\")\nelif (n == 24):\n print (\"Cleveland\")\nelif (n == 25):\n print (\"McKinley\")\nelif (n == 26):\n print (\"Roosevelt\")\nelif (n == 27):\n print (\"Taft\")\nelif (n == 28):\n print (\"Wilson\")\nelif (n == 29):\n print ('Harding')\nelif (n == 30):\n print (\"Coolidge\")\nelif (n == 31):\n print (\"Hoover\")\nelif (n == 32):\n print (\"Roosevelt\")\nelif (n == 33):\n print (\"Truman\")\nelif (n == 34):\n print (\"Eisenhower\")\nelif (n == 35):\n print (\"Kennedy\")\nelif (n == 36):\n print (\"Johnson\")\nelif (n == 37):\n print (\"Nixon\")\nelif n == 38:\n print (\"Ford\")\nelif n == 39:\n print (\"Carter\")\nelif n == 40:\n print (\"Reagan\")\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "2bb27f46b3937f986266275f8c5cf015", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x,y,z,t1,t2,t3 = map(int,input().split())\ny=abs(y-x)\nif abs(z-x)*t2+y*t2+3*t3 <= y*t1 :\n   print('YES')\nelse:\n   print('NO') \n\n\n \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "654b366320659b02d312390dbcc667c2", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def power(x,y,p):     #Calculates (x**y)%p in O(log y)\n    res = 1\n    x = x%p\n\n    while y>0:\n        if ((y & 1)==1):\n            res = (res*x)%p\n\n        y = y>>1\n        x = (x*x)%p\n\n    return res\n\n\nn,m = map(int, input().split())\nprint(power((2**m)-1,n,10**9+7))", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "62a4c8118252d5add3041cbd4b8bb568", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#!/bin/python\n\nimport math\nimport os\nimport random\nimport re\nimport sys\n\ndef handle(n, s):\n    result = 0\n\n    max_coin = n\n\n    while s > 0:\n        result += s / max_coin\n\n        s = s % max_coin\n\n        max_coin = s\n\n    print result\n\n\n\nif __name__ == '__main__':\n    ns = raw_input().split()\n\n    n = int(ns[0])\n    s = int(ns[1])\n\n    handle(n, s)\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation"], "code_uid": "07d39696beeb549ce42fcf2f997aac9a", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn=int(input())+1\nif(n==1):\n    print(0)\nelif(n%2):\n    print(n)\nelse:\n    print(n//2)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "29e326b10de981ac9761eaf3cc57418b", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "p,k = map(int,raw_input().split())\nl = [p%k]\nt = p/k\nwhile t!=0:\n\tl.append((-t)%k)\n\tt = (-t)/k \nprint len(l)\nfor i in l:\n\tprint i,", "lang_cluster": "Python", "tags": ["math"], "code_uid": "9f04c383351e64a058b452a24af21dc2", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a=int(input())\nif a%2==0:\n    print(\"0\")\nelse:\n    print(\"1\")", "lang_cluster": "Python", "tags": ["math"], "code_uid": "b1bbd9f2807fd11717c52fb268bd96cb", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "y,w=map(int,input().split())\nif(y==w==0 or y==w==1):\n    print(1,'/',1,sep=\"\")\nelse:\n    m=max(y,w)\n    l1=[]\n    for i in range(m,7):\n        l1.append(i)\n    c=len(l1)\n    if(c==1):\n        print(1,'/',6,sep=\"\")\n    elif(c==2):\n        print(1,'/',3,sep=\"\")\n    elif(c==3):\n        print(1,'/',2,sep=\"\")\n    elif(c==4):\n        print(2,'/',3,sep=\"\")\n    elif(c==5):\n        print(5,'/',6,sep=\"\")\n\n", "lang_cluster": "Python", "tags": ["math", "probabilities"], "code_uid": "2c093dc97f4333054df529cdf7faf271", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "f21e6015b2a324e3902dd30723d1e9e1", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b = input().split()\nx = int(a) + int(b[::-1])\nprint(x)\n", "lang_cluster": "Python", "tags": ["constructive algorithms"], "code_uid": "819872b752cdad0da92109494c1ef40f", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from datetime import date\n\ndef fnd(y):\n\tf=date(y,2,2)\n\ts=date(y,8,28)\n\tc=1\n\twhile 1:\n\t\ttf=date(y+c,2,2)\n\t\tts=date(y+c,8,28)\n\t\tif tf.weekday()==f.weekday() and ts.weekday()==s.weekday():\n\t\t\t\treturn y+c\n\t\tc+=1\n\ny=int(input())\nz=y//400\nx=y%400\nif x==0:\n\tx+=400\n\tz-=1\nprint(400*z+fnd(x))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "5691a3dd649653fc1821cecca6f38d65", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "N = int(input())\nA = [int(a) for a in input().split()]\nM = A.count(0)\nA2 = [a%2 for a in A]\nO = A2.count(1)\nE = N - M - O\nO = (N+1)//2 - O\nE = N//2 - E\nC = [M]\nfor a in A:\n    C.append(C[-1] - (a == 0))\n\nX = [[999] * 102 for _ in range(N)]\nY = [[999] * 102 for _ in range(N)]\nif A[0] % 2:\n    X[0][O] = 0\nelif A[0]:\n    Y[0][O] = 0\nelse:\n    if O: X[0][O-1] = 0\n    if E: Y[0][O] = 0\n\nfor i in range(1, N):\n    for j in range(N+1):\n        if A[i] % 2:\n            X[i][j] = min(X[i-1][j], Y[i-1][j] + 1)\n        elif A[i]:\n            Y[i][j] = min(X[i-1][j] + 1, Y[i-1][j])\n        else:\n            X[i][j] = min(X[i-1][j+1], Y[i-1][j+1] + 1)\n            Y[i][j] = min(X[i-1][j] + 1, Y[i-1][j])\n        \nprint(min(X[N-1][0], Y[N-1][0]))", "lang_cluster": "Python", "tags": ["sortings", "dp", "greedy"], "code_uid": "13ebb3e87306c445424d951a429c5706", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "w=input()\na=max(w);print(w.count(a)*a)\n", "lang_cluster": "Python", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "b6ffa377e26d51fb5bc3ceb77616589b", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def readints():\n    return [int(obj) for obj in input().strip().split()]\n\n\nclass Solver:\n    def main(self):\n        n = readints()[0]\n        a = readints()\n        f = [0] * n\n\n        f[n - 1] = a[n - 1]\n        for i in range(n - 2, -1, -1):\n            f[i] = max(\n                sum(a[i:n]) - f[i+1],\n                f[i+1],\n            )\n        print(sum(a) - f[0], f[0])\n\n\nSolver().main()\n", "lang_cluster": "Python", "tags": ["dp", "games"], "code_uid": "44249bc796d5f9edcfebb03214a9daf7", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "N = int(input())\nprint(4 * (2 * 3 * 4**(N-3) + ((N-3) * 3 * 3 * 4**(N-4) if N > 3 else 0)))\n", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "e1d9ab1a4ac3350031577538b7a2a090", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def get_limak_number(length, zero_position):\n    ls = ['1'] * length\n    ls[zero_position] = '0'\n    return int(\"\".join(ls), 2)\n\ndef is_limak_number(binary_number):\n    return binary_number.count('0') == 1\n\ndef get_next_limak_number(n):\n    binary_number = bin(n)[2:]\n    zero_position = binary_number.find('0')\n\n    if (is_limak_number(binary_number)):\n        if (binary_number[-1] == '0'):\n            new_length = len(binary_number) + 1\n            new_zero_position = 1\n        else:\n            new_length = len(binary_number)\n            new_zero_position = zero_position + 1\n    else:\n        if (zero_position == -1):\n            new_length = len(binary_number) + 1\n            new_zero_position = 1\n        else:\n            new_length = len(binary_number)\n            new_zero_position = zero_position\n\n    return get_limak_number(new_length, new_zero_position)\n\ndef main2():\n    begin, end = map(int, raw_input().split())\n\n    count = 1 if is_limak_number(bin(begin)[2:]) else 0\n    current_limak_number = get_next_limak_number(begin)\n    while (current_limak_number <= end):\n        count += 1\n        current_limak_number = get_next_limak_number(current_limak_number)\n\n    print count\n\nmain2()", "lang_cluster": "Python", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "4e4078a4feda3a519fb72044aec7a348", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "cn=int(input())\nc=list(range(cn))\nfor i in range(cn):\n    c[i] = list(map(lambda x: int(x), input().split(' ')))\n\ndef ln(i,j):\n    s=0\n    inn, jnn = False, False\n    for m in range(cn):\n        if (i in c[m]) or (j in c[m]):\n            inn |= i in c[m]\n            jnn |= j in c[m]\n            s+=1\n    if i > 0:\n        return s > 1 and inn and jnn\n    else:\n        return s > 0 and jnn\n                \ndef prout(i, j):\n    if i == 0:\n        print(str(max(0,j-1)))\n    else:\n        if j == 0:\n            if i == 1:\n                print(9)\n            else:\n                print(str(i-1)+str(9))\n        else:\n            print(str(i)+str(j-1))\n    exit()\n\nfor i in range(10):\n    for j in range(10):\n        if i == j == 0:\n            continue\n        if not ln(i,j):\n            prout(i,j)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "f29ecb2bfc99cbafad9336c70897f62c", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "[r, g, b] = [int(k) for k in input().split()]\ncolor = [r, g, b]\ncolor.sort()\n\nif color[0] + color[1] <= int(color[2]/2):\n    count = color[0] + color[1] \nelse:\n    count = int((color[0] + color[1] + color[2])/3)\nprint(count)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "710149184115664fbf23b5551fd0809d", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def rec(q,ans):\n    if q==0:\n        if ans==ca:\n            return 1\n        else:\n            return 0\n    return rec(q-1,ans+1)+rec(q-1,ans-1)\n    \nc=[i for i in input()]\nf=[i for i in input()]\nca=fa=0\nq=0\nn=len(c)\nfor i in range(n):\n    if c[i]==\"+\":\n        ca+=1\n    else:\n        ca-=1\n    if f[i]==\"+\":\n        fa+=1\n    elif f[i]==\"-\":\n        fa-=1\n    else:\n        q+=1\nprint(rec(q,fa)/(2**q))", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "b19d7aba9c6dcf041b102e106573b6a2", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, t, k, d = map(int,input().split())\nfrom math import ceil\n\nt1 = ceil(n / k) * t\n\ntektime=0\np1 = 0\np2 = -d\nwhile n>0:\n    p1+=1\n    p2+=1\n    if p1 == t:\n        n-=k\n        p1=0\n    if p2 == t:\n        n-=k\n        p2=0\n    tektime+=1\nif t1>tektime:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "7afa47e2d7f1bf17b3b7747e84b28e67", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import re\ninput()\nprint(next(filter(re.compile(input()[:-3] + '$').match, ['vapor', 'jolt', 'flar', 'esp', 'umbr', 'leaf', 'glac', 'sylv'])) + 'eon')\n", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "b9336adcd50f1b3edf352a1219c9659b", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "first_name, last_name = input().split()\nfirst_done = first_name.lower()\nlast_done = last_name.lower()\nlogin = first_name[0]\nfor i in range(1, len(first_name)):\n    if ord(first_done[i]) < ord(last_done[0]):\n        login += first_name[i]\n    else:\n        break\nlogin += last_name[0]\nprint(login)", "lang_cluster": "Python", "tags": ["brute force", "sortings", "greedy"], "code_uid": "c7a2a21610b7bbd676b6c6db3f6c6cb0", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def main():\n    n, hi, k = map(int, input().split())\n    m, l, lo = (hi - n) * 2, n - k + 1, 0\n    while lo < hi - 1:\n        mid = (lo + hi) // 2\n        x = mid * mid * 2\n        if mid > k:\n            x -= (mid - k) * (mid - k + 1)\n        if mid > l:\n            x -= (mid - l) * (mid - l + 1)\n        if x > m:\n            hi = mid\n        else:\n            lo = mid\n    print(lo + 1)\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["greedy", "binary search"], "code_uid": "f379b6dc3a257bfb86b4e299430bf252", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import itertools\n\ng = [[0]*5]*5\n\ndef read():\n    for i in range(5):\n        g[i] = map(int, raw_input().split())\n\ndef cal(a):\n    res = 0\n    for i in range(len(a)-1):\n        for j in range(i, len(a)-1, 2):\n            res += g[int(a[j])][int(a[j+1])] + g[int(a[j+1])][int(a[j])]\n    return res \n\ndef main():\n    read()\n    ans = 0\n    for i in itertools.permutations(\"01234\", 5):\n        ans = max(ans, cal(i))\n    print ans\n    \nif __name__ == \"__main__\":\n    main()", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "561be64016bed0f4ce48d4bc0fc2c2c6", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from itertools import *\n[n, m], x = map (int, raw_input ().split ()), input ()\nn -= (x - 1) * 2\nm -= (x - 1) * 2\nn, m = sorted ([n, m])\nif [n, m] == [1, 1]:\n    p = 1\nelif n == 1:\n    p = (m + 1) / 2\nelif n > 0 and m > 0:\n    p = ((n + m) * 2 - 4) / 2\nelse:\n    p = 0\nprint p \n\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "fb8cf77a201ab790a3d4da165e72730e", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import 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##########################################################\nfrom collections import Counter\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\nimport heapq\n# c=sorted((i,int(val))for i,val in enumerate(input().split()))\n# n = int(input())\n# ls = list(map(int, input().split()))\n# n, k = map(int, input().split())\n# n =int(input())\n#arr=[(i,x) for i,x in enum]\n#arr.sort(key=lambda x:x[0])\n#print(arr)\nimport math\n# e=list(map(int, input().split()))\nfrom collections import Counter\n#print(\"\\n\".join(ls))\n#print(os.path.commonprefix(ls[0:2]))\n#n=int(input())\nfrom bisect import  bisect_right\n#d=sorted(d,key=lambda x:(len(d[x]),-x))  d=dictionary     d={x:set() for x in arr}\n#n=int(input())\nn,m,k= map(int, input().split())\nskip=n-m\nmod=10**9+9\nvar=n//(k)\n#if m%(k-1)==0:\n    #var-=1\nif var<=skip:\n    print(m)\nelse:\n    x=var-skip\n    \n    ans=(2**(1+x)%mod-2)*k+m-x*k\n    print(ans%mod)", "lang_cluster": "Python", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "e51aa870b878a857a7fef6d6404512d1", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "N, P = map(int, input().split())\n\ndef chk(k):\n    x = N - k*P\n    if x > 0 and sum(map(int, bin(x)[2:])) <= k <= x:\n        return 1\n    return 0\n\nfor i in range(1, 100):\n    if chk(i):\n        print(i)\n        break\nelse:\n    print(-1)\n\n", "lang_cluster": "Python", "tags": ["brute force", "math", "bitmasks"], "code_uid": "ad6cf95a4262819b23335b40ba11c59e", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "msg = input()\npassword = [msg[i:i+10] for i in range(0,80, 10)]\nfor i in range(10):\n\tdigit = input()\n\twhile digit in password:\n\t\tpassword[password.index(digit)] = str(i)\n\nprint(\"\".join(password))\n\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "60a7a55f0e2ab9070d8f2d5099b0d375", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=n//100\nb=(n%100)//20\nc=((n%100)%20)//10\nd=((((n%100)%20)%10)//5)\ne=(((((n%100)%20)%10)%5)//1)\nprint(a+b+c+d+e)\n", "lang_cluster": "Python", "tags": ["greedy", "dp"], "code_uid": "13c5f18fcf318c61231ba29bf8664c80", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a=input()\nn=len(a)\nif a[n-1]!='n' and a[n-1]!='a' and a[n-1]!='e' and a[n-1]!='i' and a[n-1]!='o' and a[n-1]!='u':\n    print(\"NO\")\nelse:\n    flag=0\n    i=0\n    while i+1<n:\n        if a[i]!='n' and a[i]!='a' and a[i]!='e' and a[i]!='i' and a[i]!='o' and a[i]!='u':\n            if a[i+1]!='a' and a[i+1]!='e' and a[i+1]!='i' and a[i+1]!='o' and a[i+1]!='u':\n                flag=1\n                break\n        i+=1\n    if flag==1:\n        print(\"NO\")\n    else:\n        print(\"YES\")", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "9aac6b1ce6f3d98603a16984165aad7a", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from fractions import gcd\nn = input()\nx = map(int, raw_input().split())\n\ndef cd(i, d):\n    if i==n-1:\n        return gcd(x[i], d)\n    return gcd(x[i], cd(i+1, d))\n\nprint cd(0, 0)*n\n\n", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "de5de8e5205fbe536c351c6d4a6ab7c3", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nn,x,y = map(int,raw_input().split())\no = 1.0/n *100\nreq = math.ceil(y/o)\nprint int(req-x) if req>x else 0\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5bce571466e8476b7cc3d75028385f42", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\"\"\"\nauthor:\n   ,---,                       \n  '  .' \\           \n /  ;    '.     \n:  :       \\\n:  |   /\\   \\          \n|  :  ' ;.   :         \n|  |  ;/  \\   \\MAN SRIVASTAVA        \n'  :  | \\  \\ ,'       \n|  |  '  '--'  \n|  :  :         \n|  | ,'                  \n`--''      \n\nInstitute: Jalpaiguri Government Engineering College\n\"\"\"\nimport math\nn,A,b=[int(x) for x in input().split()]\na=list(map(int,input().split()))\nans=0\nfor i in range(n//2):\n    if a[i]!=a[n-i-1] and a[i]!=2 and a[n-i-1]!=2:\n        print(-1)\n        exit()\n    if a[i]==a[n-i-1] and a[i]!=2:\n        continue\n    if a[i]==0:\n        a[n-i-1]=0\n        ans+=A\n        continue\n    if a[i]==1:\n        a[n-i-1]=1\n        ans+=b\n    if a[i]==2:\n        if a[n-i-1]==1:\n            a[i]=1\n            ans+=b\n        elif a[n-i-1]==0:\n            a[i]=0\n            ans+=A\n        else:\n            ans+=2*min(A,b)\n        \n    \nif n&1:\n    if a[n//2]==2:\n        ans+=min(A,b)\nprint(ans)\n    ", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "c8595831b78e02f51f0a0c7b7104948d", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nx=a-b\nif(c>=abs(x) and c!=0):\n\tprint(\"?\")\nelif(x==0):\n\tprint(\"0\")\nelif(x<0):\n\tprint(\"-\")\nelse:\n\tprint(\"+\")", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "faa620d5a241e146059c5ea1bae3a2a9", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys,math,bisect\nfrom collections import defaultdict\nM=10**9+7\ndef pow(a,b):\n    res=1\n    while b>0:\n        if b&1:\n            res*=a\n        a*=a\n        b>>=1\n    return res\ndef powmod(a,b,m):\n    res=1\n    while b>0:\n        if b&1:\n            res=((res*a)%m)\n        a*=a\n        b>>=1\n    return res\ndef inv(a,m):\n    return powmod(a,m-2,m)\n\ndef factor(n):\n    potentional_p = 3\n    itog_list = {}\n    if n % 2 == 0:\n        itog_list[2] = 0\n    while n % 2 == 0:\n        n = n // 2\n        itog_list[2] += 1\n    while n - 1:\n        if potentional_p > (n**0.5):\n            if n in itog_list:\n                itog_list[n] += 1\n            else:\n                itog_list[n] = 1\n            return itog_list\n        while n % potentional_p == 0:\n            n = n // potentional_p\n            if potentional_p in itog_list:\n                itog_list[potentional_p] += 1\n            else:\n                itog_list[potentional_p] = 1\n        potentional_p += 2\n    return itog_list\ns = input()\nt = input()\n \nforward = []\n \nbackward = []\n \nrptr = 0\n \nfor i in range(len(s)):\n    if rptr == len(t):\n        break\n    if s[i] == t[rptr]:\n        forward.append(i)\n        rptr += 1\n \nrptr = len(t)-1\nfor i in range(len(s)-1, -1, -1):\n    if rptr == -1:\n        break\n    if s[i] == t[rptr]:\n        backward.append(i)\n        rptr -= 1\n \nbackward = backward[::-1]\nbackward.append(forward[-1])\n \nmx = max(forward[0], len(s)-1-backward[-2], len(s)-1-forward[-1], backward[0])\n#print(forward)\n#print(backward)\n#print(mx)\nfor i in range(len(t)):\n    mx = max(mx, backward[i+1]-forward[i] -1)\n    #print(i, mx)\nprint(mx)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "c9cf734958fafc3eb43aa433b474e6ef", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s = raw_input()\np1 = [1]*10\nfor x in s[1:]:\n\tp2 = [0]*10\n\tx = int(x)\n\tfor i in range(10):\n\t\tp2[(i+x)/2] += p1[i]\n\t\tif (i+x) % 2 != 0:\n\t\t\tp2[(i+x)/2+1] += p1[i]\n\tp1 = p2\nans = 0\nfor x in p1:\n\tans += x\n\nf = True\nfor i in range(1,len(s)):\n\ta = int(s[i-1])\n\tb = int(s[i])\n\tif (a+b)/2 != b and (a+b+1)/2 != b:\n\t\tf = False\nif f:\n\tans -= 1\nprint ans\n", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "fa7804e3a9657fc476cfca7cdf64afbf", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from collections import Counter\n\ndef host_guest_color():\n    n = int(raw_input())\n    home = Counter()\n    away = Counter()\n    for i in xrange(n):\n        h, a = map(int, raw_input().strip().split())\n        home[h] += 1\n        away[a] += 1\n    sm = 0\n    for key in home.keys():\n        t = home[key] * away[key]\n        sm += t\n    return sm\n\n\nif __name__ == '__main__':\n    print host_guest_color()", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "5a19507d082935c79151057e1d12aeab", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\n\nMOD = 998244353\nMAX_N = 2 * 10**5 + 1\nn, m = map(int, input().split())\n\n# Construct factorial table\nfac = [1] + [0] * MAX_N\nfor i in range(1, MAX_N+1):\n    fac[i] = fac[i-1] * (i) % MOD\n\nfac_inv = [1] + [0] * MAX_N\nfac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)\nfor i in range(MAX_N, 1, -1):\n    fac_inv[i-1] = fac_inv[i] * i % MOD\n\ndef mod_nCr(n, r):\n    if n < r or n < 0 or r < 0:\n        return 0\n    tmp = fac_inv[n-r] * fac_inv[r] % MOD\n    return tmp * fac[n] % MOD\n\nif n-3 > 0:\n    ans = mod_nCr(m, n-1) * (n-2) * pow(2, n-3, MOD)\nelse:\n    ans = mod_nCr(m, n-1) * (n-2)\nans %= MOD\nprint(ans)", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "3afb39350627cfc6e68b84bf5d5c21d9", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, m, k = map(int, input().split())\nkv1, kv2 = map(int, input().split())\nkv1 -= 1\nkv2 -= 1\np1 = (kv1) // (m * k)\np2 = (kv2) // (m * k)\nkv1 %= k * m\nkv2 %= k * m\nat1 = kv1 // k\nat2 = kv2 // k\nif (p1 == p2):\n    print(min(10 + abs(at1 - at2), 5 * abs(at1 - at2)))\nelse:\n    #print(p1, p2, at1, at2)\n    res = 15 * min(abs(p1 - p2), min(p1, p2) + n - max(p1, p2))\n    res += min(10 + at1, at1 * 5)\n    res += min(10 + at2, at2 * 5)\n    print(res)", "lang_cluster": "Python", "tags": ["constructive algorithms"], "code_uid": "83b466d1a372d704c32552a2b4f32bf0", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\ns = raw_input()\n\ncnt = 0\ncur = 0\n\nfor a in s:\n\tif a == \"x\":\n\t\tif cur == 2:\n\t\t\tcnt += 1\n\t\telse:\n\t\t\tcur += 1\n\telse:\n\t\tcur = 0\n\nprint cnt", "lang_cluster": "Python", "tags": ["greedy", "strings"], "code_uid": "66a680a7f3da7c79bf1df08e3bf2ebea", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nfor i in range (1, 1000):\n    floor = str(n + i)\n    if '8' in floor:\n        print(i)\n        exit()", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "c7f837af1a8ff0858b752ac31880a292", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "print(2-int(input())**2)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "50de7ad4d72e713249360f44fcc64f04", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, b = map(int, input().split())\ncurr = 1\nc1 = 0\na = [int(i) for i in input().split()]\na = a[::-1]\nfor i in range(n):\n    c1 += a[i] * curr\n    curr *= b\nn, b = map(int, input().split())\ncurr = 1\nc2 = 0\na = [int(i) for i in input().split()]\na = a[::-1]\nfor i in range(n):\n    c2 += a[i] * curr\n    curr *= b\nif (c1 < c2):\n    print('<')\nelif (c1 == c2):\n    print('=')\nelse:\n    print('>')", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "db50f777ce979295bb6553388c705acd", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import re\nn=int(input())\ns=input()\nka=re.sub('ogo(go)*','***',s)\nprint(ka)\n", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "09670479d1a62cc30ab14511557d1000", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline().strip())\na = [int(x) for x in stdin.readline().strip().split()]\n\ncnt = [[0, 'chest'], [0, 'biceps'], [0, 'back']]\n\nfor i in range(0, n):\n    cnt[i % 3][0] += a[i]\n\nprint(sorted(cnt)[-1][1])\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "77c085e8513ce092813d6a1c9c21994a", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x,t,a,b,c,d=map(int,input().split())\nR=range(t)\ny=x==0\nfor i in R:\n\tif x==a-c*i or x==b-d*i:y=1\n\tfor j in R:y|=x==a+b-c*i-d*j\nprint(['NO','YES'][y])", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "7048c4237a18b1ea7954f8a38f9512c3", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def solve(a, b):\n    return min((26 + a - b) % 26, (26 + b - a) % 26)\n\n\ndef main():\n    n = int(input())\n    s = input().lower()\n    print(min((sum((solve(ord(a), ord(b)) for a, b in zip(s[i:i + 4], 'actg'))) for i in range(n - 3))))\n\n\nmain()\n", "lang_cluster": "Python", "tags": ["brute force", "strings"], "code_uid": "cd1d0c47a7fea7dc94f1b0756f4a22d0", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "INF = 1e10\nmax_n = 50\nmax_k = 2000\ndef main():\n    n, s, k = map(int, input().split())\n    s -= 1\n    buf = ['']*(max_n + 1)\n    dp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)] \n    r = list(map(int, input().split()))\n    c = input()\n    answer = INF\n    for i in range(len(c)):\n        buf[i] = c[i]\n    for i in range(k, -1, -1):\n        for j in range(n):\n            dp[i][j] = INF\n    for j in range(n):\n        value = abs(j - s)\n        if k - r[j] <= 0:\n            answer = min(answer, value)\n        else:\n            dp[k - r[j]][j] = value\n    for i in range(k, 0, -1):\n        for j in range(n):\n            if dp[i][j] < INF:\n                for l in range(n):\n                    if buf[j] != buf[l] and r[j] < r[l]:\n                        value = dp[i][j] + abs(j - l)\n                        if i - r[l] <= 0:\n                            answer = min(answer, value)\n                        else:\n                            dp[i - r[l]][l] = min(dp[i - r[l]][l], value)\n    if answer == INF:\n        print(-1)\n        return\n    print(answer)\n\nif __name__==\"__main__\":\n    main()", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "1ccc085538814dcdc5786b2c4e815f4d", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "l = []\nn, m, c, d = map(int, raw_input().split())\nl.append([1050, c, d])\nfor _ in xrange(m):\n    s = map(int, raw_input().split())\n    l.append([s[0] / s[1], s[2], s[3]])\n\nf = [0] * 1001\ns = [[x[0] for x in l]]\n\nfor i in range(1, n + 1):\n    t = s[0]\n    for j in range(m + 1):\n        if i >= l[j][1] and s[i - l[j][1]][j] > 0 and f[i] < f[i - l[j][1]] + l[j][2]:\n            f[i] = f[i - l[j][1]] + l[j][2]\n            t = s[i - l[j][1]][:]\n            t[j] -= 1\n    s.append(t)\nprint max(f)\n", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "7b46cc86349d9bef3d16d6f1f9d109d8", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "mas = []\nfor i in range(4):\n    mas.append(list(map(int, input().split())))\ni = 0\n\n\ndef OK(i):\n    if (mas[i][3] == 0):\n        return True\n    if (mas[i][0] + mas[i][1] + mas[i][2] + mas[(i + 3) % 4][2] + mas[(i + 1) % 4][0] + mas[(i + 2) % 4][1]> 0):\n        return False\n    return True\n    \n    \nwhile i < 4 and OK(i):\n    i += 1\nif i == 4:\n    print(\"NO\")\nelse:\n    print(\"YES\")", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ff91a26560d1f1fc93091332169de5f6", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nfib = [0]*1000\nfib[1] = 2\nfib[2] = 3\nfor i in range(3,1000):\n    fib[i] = fib[i-1]+fib[i-2]\nn = input()\nfor i in range(1,1000):\n    if fib[i] > n:\n        print i - 1\n        sys.exit()\n", "lang_cluster": "Python", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "c260f24433642aa97716147f7c952c01", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys \n\nI=sys.stdin.readline\n\na=int(I())\nb=int(I())\n\ntired=0\nn=abs(a-b)\na=1\nc=0\nwhile n!=0:\n\ttired+=a\n\tn-=1\n\tc+=1\n\tif c==2:\n\t\tc=0\n\t\ta+=1\nprint(tired)\n\n\n", "lang_cluster": "Python", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "73051585e8d4187f6df6381310f0cc0c", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "print(int(int(input())/2520))", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "64a8de51f0cd1a62244b393fad5dd07d", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nx, y = map(int, raw_input().split())\n \na = y * math.log(x)\nb = x * math.log(y)\n \nif a > b:\n\tprint '>'\nelif a < b:\n\tprint '<'\nelse:\n\tprint '='", "lang_cluster": "Python", "tags": ["math"], "code_uid": "722b159138d81f4211805b05ca986a44", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input()\nk=int(((1+24*n)**0.5-1)/6.0)\nprint 1+(k-3+n%3)/3", "lang_cluster": "Python", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "c9c46a2dacad5c587c855aa7c1c499bf", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Oct 28 09:27:31 2018\n\n@author: czx\n\"\"\"\n\ndef main():\n    n,m = str.split(input())\n    n = int(n)\n    m = int(m)\n    if (2*m >= n):\n        Min = 0\n    else:\n        Min = n-2*m\n    \n    cnt = 0\n    if (m == 0):\n        Max = n\n    else:\n        for i in range(1,n):\n            cnt += i\n            if (cnt >= m):\n                Max = n-i-1\n                break\n    \n    print(Min,Max)\n\nif __name__ == \"__main__\":\n    main()", "lang_cluster": "Python", "tags": ["constructive algorithms", "graphs"], "code_uid": "af0f2ffbe4d24ef70bec64880e1322c3", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#! /Library/Frameworks/Python.framework/Versions/Current/bin/python\n\nP = 1000000007\n\ndef eGCD(a,b):\n\tr = a % b\n\tif r == 0:\n\t\treturn [b,1,1 - a/b]\n\telse:\n\t\tnextIter = eGCD(b,r)\n\t\treturn [nextIter[0],nextIter[2],nextIter[1] - nextIter[2]*(a/b)]\n\ndef invModP(x):\n\treturn eGCD(P,x)[2] % P\n\nfs = [1]\n\ndef factorialModP(n):\n\tglobal fs\n\tif (len(fs) > n):\n\t\treturn fs[n]\n\telse:\n\t\tans = fs[len(fs) - 1]\n\t\tfor i in range(len(fs),n+1):\n\t\t\tans *= i\n\t\t\tans %= P\n\t\t\tfs += [ans]\n\t\treturn ans\n\ndef ChooseModP(n,i):\n\tans = factorialModP(n)\n\tans *= invModP(factorialModP(i))\n\tans %= P\n\tans *= invModP(factorialModP(n-i))\n\tans %= P\n\treturn ans\n\ninp = raw_input().split()\n\na = int(inp[0])\nb = int(inp[1])\nn = int(inp[2])\n\nminNum = a*n\nmaxNum = b*n\n\ndef countExcellentsForSum(s):\n\ts -= minNum\n\tif (s % (b-a) == 0):\n\t\tnumBs = s/(b-a)\n\t\treturn ChooseModP(n,numBs)\n\telse:\n\t\treturn 0\n\n\ndef get1xk(k):\n\tif (k == 1):\n\t\treturn 1\n\telse:\n\t\treturn get1xk(k-1)*10+1\n\ndef getPowArr(k):\n\tif (k == 1):\n\t\treturn [1]\n\telse:\n\t\treturn [10**(k-1)] + getPowArr(k-1)\n\nfinalSum = 0\n\nfor l in range(1,8):\n\tbase = a * get1xk(l)\n\tdiffArr = getPowArr(l)\n\tfor i in range(l):\n\t\tdiffArr[i] *= (b - a)\n\n\tfor bitMask in range(2**l):\n\t\tboolMask = [int(bitMask / (2**(l-1-i))) % 2 for i in range(l)]\n\t\taddArr = [boolMask[i] * diffArr[i] for i in range(l)]\n\t\ts = base\n\t\tfor i in range(l):\n\t\t\ts += addArr[i]\n\t\tif (minNum <= s) and (s <= maxNum):\n\t\t\tfinalSum += countExcellentsForSum(s)\n\t\t\tfinalSum %= P\n\nprint finalSum\n\n", "lang_cluster": "Python", "tags": ["brute force", "combinatorics"], "code_uid": "5bcf5460c71c2979064a406b136886a8", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "for _ in range(int(input())):\r\n    n,k=[int(x) for x in input().split()]\r\n    print(pow(n,k,1000000007))\r\n", "lang_cluster": "Python", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "a367923f829b4139ee69bf9d1cc2b4fa", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "2a2efe002c76b60521f9224771955e95", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "t=int(input())\nfor _ in range(t):\n    n=input()\n    res=0\n    for j in range(len(n)):\n        res+=j+1\n    offset=int(n[0])-1\n\n    res+=offset*10\n\n    print(res)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "ddc136542616196e3d3da249e2df444a", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "class Problem:\n\tdef solve(self, s):\n\t\tans = -1\n\t\tn = len(s)\n\t\tfor i in range(n):\n\t\t\tfor j in range(n):\n\t\t\t\tif i != j:\n\t\t\t\t\tc1 = c2 = 0\n\t\t\t\t\tt, c1 = self.move_end(s, i, j)\n\t\t\t\t\tif t[0] == \"0\":\n\t\t\t\t\t\tk = self.find_nonzero(t)\n\t\t\t\t\t\tt, c2 = self.move_begin(t, k)\n\t\t\t\t\tif self.ok(t):\n\t\t\t\t\t\tans = self.best(ans, c1+c2)\n\t\t\t\t\t# print(\"i\", i, \"j\", j, \"t\", t)\n\t\treturn ans\n\n\tdef move_end(self, s, i, j):\n\t\t# i < j          j < i       \n\t\t# a i b j c      a j b i c\n\t\t# a i b c j (j)  a b i c j (j)\n\t\t# a b c i j (i)  a b c i j (i)\n\t\tif j < i: i -= 1\n\t\tt = s\n\t\tt, c1 = self.move_char(t, j, len(t)-1)\n\t\tt, c2 = self.move_char(t, i, len(t)-2)\n\t\treturn t, c1 + c2\n\t\n\tdef move_begin(self, s, i):\n\t\treturn self.move_char(s, i, 0)\n\n\tdef move_char(self, s, i:\"index from\", j:\"index to\"):\n\t\tl = list(s)\n\t\tcount = 0\n\t\twhile i != j:\n\t\t\tcount += 1\n\t\t\tif i < j:\n\t\t\t\tl[i], l[i+1] = l[i+1], l[i]\n\t\t\t\ti += 1\n\t\t\telse:\n\t\t\t\tl[i-1], l[i] = l[i], l[i-1]\n\t\t\t\ti -= 1\n\t\treturn \"\".join(l), count\n\t\n\tdef ok(self, s):\n\t\treturn s[0] != \"0\" and int(s) % 25 == 0\n\t\n\tdef find_nonzero(self, s):\n\t\tfound = -1\n\t\tfor i in range(len(s)):\n\t\t\tif s[i] != \"0\":\n\t\t\t\tfound = i\n\t\t\t\tbreak\n\t\treturn found\n\t\t\n\tdef best(self, a, b):\n\t\tif a == -1: return b\n\t\tif b == -1: return a\n\t\treturn a if a<b else b\n\ns = input()\nans = Problem().solve(s)\nprint(ans)\nexit()\n\nassert(0 == Problem().solve(\"100\"))\nassert(1 == Problem().solve(\"52\"))\nassert(4 == Problem().solve(\"5071\"))\nassert(1 == Problem().solve(\"705\"))\nassert(-1 == Problem().solve(\"1241367\"))\nassert(2 == Problem().solve(\"507\"))\nassert(1 == Problem().solve(\"17010\"))\nassert(6 == Problem().solve(\"52231\"))\nassert(5 == Problem().solve(\"50267\"))\nprint(\"ok\")", "lang_cluster": "Python", "tags": ["brute force", "greedy"], "code_uid": "c67e5371a27996ad74356e99c0d12f26", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import itertools as it\nimport math as m\nn,m,k=map(int,raw_input().split())\nh=map(int,raw_input().split())\n\np=filter(lambda (x,i):x<=k and x!=0,zip(h,range(1,n+1)))\ndist=1e9\nnd=0\nfor (i,cnt) in p:\n    if abs(cnt-m)<dist:\n        dist=abs(cnt-m)\n        \nprint dist*10\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "05070e558ae3683c98b7a600c22f204b", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "trump= input()\n\nranks=['6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']\ncards= input().split()\na= cards[0]\nb= cards[1]\n\nif a[1]==trump and b[1]==trump:\n    if ranks.index(a[0])> ranks.index(b[0]):\n        print('YES')\n        exit()\n    else:\n        print('NO')\n        exit()\n    exit()\nif a[1]==trump and b[1]!= trump:\n    print('YES')\n    exit()\nif b[1]==trump:\n    print('NO')\n    exit()\n    \nif ranks.index(a[0])> ranks.index(b[0]) and a[1]==b[1] or a[1]==trump and b[1]!=trump:\n    print('YES')\nelse:\n    print('NO')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "f4d82435d291a075f798274bf8fa87c1", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353\nimport __pypy__\nmodmult = __pypy__.intop.int_mulmod\nmo = lambda a,b: modmult(a,b,MOD)\nred = lambda a: a if a < MOD else a - 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    if n < k or k < 0:\n        return 0\n    return mo(mo(fac[n], invfac[k]), invfac[n-k])\n\nn,k = [int(x) for x in input().split()]\n\nans = 0\nfor divs in range(1, n + 1):\n    ans = red(ans + choose((n // divs) - 1, k - 1))\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "combinatorics", "number theory"], "code_uid": "59d8095497d4c3231ba992def05f52ef", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "# cook your dish here\nfrom math import *\nn,k=map(int,input().split())\na=[1]\nif(n!=1):\n\ta.append(n)\nfor i in range(2,int(sqrt(n)+1)):\n\tif(n%i==0):\n\t\ta.append(i)\n\t\tif((n//i)!=i):\n\t\t\ta.append(n//i)\na.sort()\nif(k>len(a)):\n\tprint(-1)\nelse:\n\tprint(a[k-1])", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "c08504b4900f435ecb9f94db6bc1a83f", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "R=lambda:map(int,input().split())\nyH,yA,yD=R()\nmH,mA,mD=R()\nh,a,d=R()\nQ=10**20\nfor A in range(max(0,mD-yA+1),max(0,mH+mD-yA)+1):\n for D in range(max(0,mA-yD)+1):\n  H=yH-((mH+yA+A-mD-1)//(yA+A-mD))*max(0,mA-yD-D)\n  Q=min(A*a+D*d+max(0,h*(1-H)),Q)\nprint(Q)", "lang_cluster": "Python", "tags": ["brute force", "implementation", "binary search"], "code_uid": "e76338c16bfe1ed0dcb6b4359362dd3b", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "24ec0baf29c51e9778eb26a30520d019", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#/usr/bin/env python3\nimport sys\nn = int(sys.stdin.readline())\nif n % 2 == 1:\n    print('black')\nelse:\n    print('white')\n    print('1 2')", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "games"], "code_uid": "7c94e9df5c8e45974958e84a1fb48c93", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "recipe, numbers, prices, r = input(), list(map(int, input().split())), list(map(int, input().split())), int(input())\nnum = recipe.count('B'), recipe.count('S'), recipe.count('C')\nans, pre, all = float('inf'), r, 0\n\nfor i in range(3):\n    try:\n        ans = min(numbers[i] // num[i], ans)\n    except:\n        ans, numbers[i] = 0, 0\n\nfor i in range(3):\n    numbers[i] -= (ans * num[i])\n\nwhile ((numbers[0] != 0 or numbers[1] != 0 or numbers[2] != 0) and r > 0):\n    for i in range(3):\n        if numbers[i] >= num[i]:\n            numbers[i] -= num[i]\n        else:\n            ext = (num[i] - numbers[i])\n            numbers[i] = 0\n            r -= ext * prices[i]\n\n        if r < 0:\n            exit(print(ans))\n    ans += 1\n\nfor i in range(3):\n    all += num[i] * prices[i]\n\nprint(ans + r // all)\n", "lang_cluster": "Python", "tags": ["brute force", "binary search"], "code_uid": "79b706175d8d4f73c7391b6a7ffbe719", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\nimport bisect\ninput=sys.stdin.readline\n#t=int(input())\ndef takeSecond(elem):\n    return elem[1]\n\ndef gcd(a,b): \n    if (b == 0): \n         return a \n    return gcd(b, a%b)     \nt=1\nfor _ in range(t):\n    #n=int(input())\n    l=list(map(int,input().split()))\n    l.sort()\n    print(l[1]-l[0]+l[2]-l[1])\n    ", "lang_cluster": "Python", "tags": ["math", "sortings", "implementation"], "code_uid": "a25252ae698f65a49742e5f53c9ac576", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def is_lucky(n):\n    s = str(n)\n    for digit in s:\n        if digit != '4' and digit != '7':\n            return False\n    return True\n\ndef almost_lucky(n):\n    for i in range(2, n+1):\n        if n % i == 0:\n            if is_lucky(i):\n                return True\n    return False\n\nn = int(input())\nif almost_lucky(n):\n    print(\"YES\")\nelse:\n    print(\"NO\")\n", "lang_cluster": "Python", "tags": ["brute force", "number theory"], "code_uid": "aa34ddae4632fabd9ed0505a6b1cd8c2", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import gcd\n\nx, y, a, b = [int(x) for x in input().split()]\n\ngc = gcd(a, b)\na = a // gc\nb = b // gc\n\nprint(min(x//a, y//b))", "lang_cluster": "Python", "tags": ["math"], "code_uid": "bba9c820b0f2b0a5076b015644d66f4a", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nwhile True:\n  d = n % 10\n  s = ''\n  if d < 5:\n    s = 'O-|'\n  else:\n    s = '-O|'\n    d -= 5\n  s += 'O' * d + '-' + 'O' * (4 - d)\n  print(s)\n  n //= 10\n  if n == 0:\n    break", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "62226c3821c1a22f8804d0c32932f186", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from collections import *\n\nn, s, d = int(input()), input(), deque()\n\nfor i in range(ord('z'), ord('a'), -1):\n    for c, j in enumerate(s):\n        if j == chr(i):\n            if (c < len(s) - 1 and s[c + 1] == chr(i - 1)) or (d and d[-1] == chr(i - 1)):\n                continue\n            else:\n                d.append(j)\n        else:\n            d.append(j)\n\n    s = ''.join(d)[::-1]\n    d = deque()\n\n    for c, j in enumerate(s):\n        if j == chr(i):\n            if (c < len(s) - 1 and s[c + 1] == chr(i - 1)) or (d and d[-1] == chr(i - 1)):\n                continue\n            else:\n                d.append(j)\n        else:\n            d.append(j)\n\n    s = ''.join(d)\n    d = deque()\n\n# print(s)\nprint(n - len(s))\n", "lang_cluster": "Python", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "fcce331386c61d5edd6998dcdc1a6ce3", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def main():\n\n    # Basic construction\n    MOD = 10**9 + 7 # MOD\n    n, k = [int(c) for c in input().split()]\n    f = [[None for j in range(n+1)] for i in range(n+1)]\n    if k==1: return 1 # Edge case\n\n    # nCr\n    nCr = [[0 for j in range(i+1)] for i in range(n+1)]\n    nCr[0][0] = 1\n    for i in range(1, n+1):\n        nCr[i] = [1] + [(nCr[i-1][j] + nCr[i-1][j-1]) % MOD for j in range(1, i)] + [1]\n\n    # k^i, (k-1)^i\n    def powgen(base):\n        this = 1\n        while True:\n            yield this\n            this = this*base%MOD\n\n    kpowgen, k1powgen = powgen(k), powgen(k-1)\n    kpower = [next(kpowgen) for i in range(n+1)]\n    k1power = [next(k1powgen) for i in range(n+1)]\n    \n    # Edge DP\n    for r in range(1, n+1): f[r][0] = pow(kpower[n] - k1power[n], r, MOD)\n    for c in range(1, n+1): f[1][c] = kpower[n-c]\n\n    # DP\n    for r in range(2, n+1):\n        f[r] = [f[r][0]]\n        f[r] += [((kpower[n-c] - k1power[n-c]) * k1power[c] * f[r-1][c] + \n                kpower[n-c] * sum(k1power[c-c0] * nCr[c][c0] * f[r-1][c-c0] for c0 in range(1, c+1))) % MOD\n                for c in range(1, n+1)]\n    return f[n][n]\n\nprint(main())", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "fac265c7cd20d9a5be86292717d6b44a", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#code\ns = raw_input()\ns = s.replace( '/', ' ' )\nl = s.split()\ns = \"/\"\ns = s + '/'.join( l )\nprint s\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ef9d9291e88a1629aab72667632b4d21", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#coding=utf-8\n\n\n\nn = int(input())\nx = map(int, raw_input().split())\n\nx.sort();\nx[0], x[-1] = x[-1], x[0]\nfor i in x:\n  print i, \n", "lang_cluster": "Python", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "d4713f6118579d88647327c8f4fca64b", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from sys import stdin,stdout,setrecursionlimit,maxint,exit\n#setrecursionlimit(2*10**5)\ndef listInput():\n return map(long,stdin.readline().split())\ndef printBS(li):\n if not li: return\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()\nfrom collections import deque\nn=input()\ns1=deque(listInput()[1:])\ns2=deque(listInput()[1:])\ntied=False\nstates=set([])\nturns=0\nwhile s1 and s2:\n if (tuple(s1),tuple(s2)) in states:\n  tied=True\n  break\n else: states.add((tuple(s1),tuple(s2)))\n a=s1.popleft()\n b=s2.popleft()\n if a>b:\n  s1.append(b)\n  s1.append(a)\n else: \n  s2.append(a)\n  s2.append(b)\n turns+=1\nif tied:\n print -1\nelse:\n if s1:\n  print turns,1\n else: print turns,2", "lang_cluster": "Python", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "f40fa55d70afc0d588bae3f84cf8cc91", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\n\ndef main():\n    a, b = [ int(x) for x in input().split() ]\n\n    numOfSolutions = 0\n\n    while a > 0 and b > 0:\n        if a > b:\n            numOfResistorsToRemove = (((a - b) // b) + 1)\n            a -= b * numOfResistorsToRemove\n            numOfSolutions += numOfResistorsToRemove\n\n        elif a < b:\n            numOfResistorsToRemove = (((b - a) // a) + 1)\n            b -= a * numOfResistorsToRemove\n            numOfSolutions += numOfResistorsToRemove\n\n        else:\n            numOfSolutions += a\n            break\n\n    print(numOfSolutions)\n\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\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\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\ndef print(*args, **kwargs):\n    \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\n    sep = kwargs.pop(\"sep\", \" \")\n    file = kwargs.pop(\"file\", sys.stdout)\n\n    atStart = True\n    for x in args:\n        if not atStart:\n            file.write(sep)\n        file.write(str(x))\n        atStart = False\n    file.write(kwargs.pop(\"end\", \"\\n\"))\n\n    if kwargs.pop(\"flush\", False):\n        file.flush()\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\n\nmain()\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "98766f0e623ccad696e2c22c802a86e2", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\npoints = list(map(int, input().split()))\n\nunique_points = []\nfor element in points:\n    if element not in unique_points and element != 0:\n        unique_points.append(element)\nprint (len(unique_points))", "lang_cluster": "Python", "tags": ["sortings", "implementation"], "code_uid": "f8f0ce8c5d6d865823c8105d2195c99e", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "# thanks https://oeis.org/A110468\ndef fact(n):\n\tif n==0:\n\t\treturn 1\n\telse:\n\t\treturn n*fact(n-1)\n\nn=int(raw_input())\nn=n/2-1\nprint(fact(2*n+1)/(n+1))", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "8e08e656e4bc12e0d439f03653288161", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def c(n):\n    \n    ans = 0\n    if n > 15:\n        ans += (49 * (n - 15))\n        n = 15\n    l = set()\n    for i in range(max(n+1,441)):\n        for j in range(max(n-i+1,196)):\n            for k in range(n-i-j+1):\n                l.add(i*4+j*9+k*49)\n    return ans + len(l)\nn = int(input())\nprint(c(n))\n", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "combinatorics", "greedy"], "code_uid": "6e6dfb91c41c63d66cd32b0f3988ce13", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=int(input())\nb=int(input())\nc=int(input())\nm=0\nif n>1: m=min(a,b)\ns=m\nwhile n>2:\n    s+=min(m,c)\n    n-=1\nprint(s)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "7a4de8461d6749e772d6ad02dc1228cf", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\nans = 0\nfor i in range(35):\n    num = i * (i+1) // 2\n    if num == n:\n        ans = 1\n        break\nprint(\"YES\" * ans + \"NO\" * ( 1 - ans))\n    \n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "f2d365cc66a9219ec2c5eb17532c4e4a", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "import itertools\r\nimport os,sys\r\nfrom random import randint\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\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#     mn = min(a)\r\n#     ans = 0\r\n#     for i in range(n):\r\n#         if a[i] != mn:\r\n#             ans += 1\r\n#     print(ans)\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 = []\r\n#     for i in range(n):\r\n#         if a[i] <= 0:\r\n#             b.append(a[i])\r\n#     if not b:\r\n#         print(1)\r\n#         continue\r\n#     mn = float('inf')\r\n#     b.sort()\r\n#     for i in range(len(b) - 1):\r\n#         mn = min(mn, b[i + 1] - b[i])\r\n#     ans = len(b)\r\n#     for i in range(n):\r\n#         if 0 < a[i] <= mn:\r\n#             ans += 1\r\n#             break\r\n#     print(ans)\r\n\r\nN = 10 ** 6 + 10\r\ncnt = [0] * N\r\nfor i in range(1, N):\r\n    for j in range(1, 10000000000):\r\n        if i * j >= N:\r\n            break\r\n        cnt[i * j] += 1\r\n\r\nmod = 998244353\r\nn = int(input())\r\na = [0, 1, 3, 6]\r\nif n < 4:\r\n    print(a[n])\r\nelse:\r\n    tot = 10\r\n    for i in range(4, n + 1):\r\n        a.append((tot + cnt[i]) % mod)\r\n        tot = (tot + a[-1]) % mod\r\n    print(a[-1])\r\n\r\n\r\n\r\n# n = 9\r\n# ans = 0\r\n# def dfs(a, b):\r\n#     global ans\r\n#     if not a:\r\n#         for i in range(0, 2 * n, 2):\r\n#             for j in range(i + 2, 2 * n, 2):\r\n#                 l1, r1 = b[i], b[i + 1]\r\n#                 l2, r2 = b[j], b[j + 1]\r\n#                 if r1 - l1 != r2 - l2 and not (l2<l1<r1<r2 or l1<l2<r2<r1):\r\n#                     return\r\n#         ans += 1\r\n#         return\r\n#     l = a.pop(0)\r\n#     b.append(l)\r\n#     for i in range(len(a)):\r\n#         dfs(a[:i] + a[i + 1:], b + [a[i]])\r\n# dfs(list(range(1, n * 2 + 1)),[])\r\n# print(ans)\r\n# ans = 0\r\n# n = 5\r\n# for a in itertools.permutations(list(range(1, n * 2 + 1))):\r\n#     for i in range(0, 2 * n, 2):\r\n#         if a[i] > a[i + 1]:\r\n#             break\r\n#     else:\r\n#         ok = True\r\n#         for i in range(0, 2 * n, 2):\r\n#             for j in range(i + 2, 2 * n, 2):\r\n#                 l1, r1 = a[i], a[i + 1]\r\n#                 l2, r2 = a[j], a[j + 1]\r\n#                 if r1 - l1 != r2 - l2 and not (l2<l1<r1<r2 or l1<l2<r2<r1):\r\n#                     ok=False\r\n#                     break\r\n#             if not ok:\r\n#                 break\r\n#         if ok:\r\n#             # print(a)\r\n#             ans += 1\r\n# print(ans)\r\n\r\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "5943c3419df755eeb1a7f0d9d4d3d987", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k = map(int,input().split())\nai = list(map(int,input().split()))\ncnt = 0\nres = None\nfor i in range(n):\n    if ai[i] > k:\n        res = i\n        break\n    else:\n        cnt += 1\n#print(res)\nif res != None:\n    rev_ai = ai[res:][::-1]\n    #print(rev_ai)\n    for i in rev_ai:\n        if i > k:\n            break\n        else:\n            cnt += 1\nprint(cnt)", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "a297e36d9ed32715ca6a3bf4fb72eb92", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "goal, init = [int(n) for n in raw_input().split(' ')]\n\na = b = c = init\ncount = 0\nwhile a < goal or b < goal or c < goal:\n    a, b, c = sorted((a, b, c))\n    a = min(b + c - 1, goal)\n    count += 1\nprint count\n", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "82700e4e5fa935476f31f03388e20dc8", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def vec(c0, a, b):\n    an = 0\n    for i in range(5):\n        an += (a[i] - c0[i]) * (b[i] - c0[i])\n    return an\n\n\nn = int(input())\nif n > 80:\n    print(0)\n    exit(0)\na = [[0] * 5 for i in range(n)]\nfor i in range(n):\n    a[i] = [int(j) for j in input().split()]\nans = []\nfor i in range(n):\n    flag = True\n    for j in range(n):\n        for k in range(n):\n            if i != j and j != k and k != i and vec(a[i], a[j], a[k]) > 0:\n                flag = False\n    if flag:\n        ans.append(i)\nprint(len(ans))\nfor i in ans:\n    print(i + 1)", "lang_cluster": "Python", "tags": ["brute force", "math", "geometry"], "code_uid": "e2dd31b0b30bcf9677e6bfb6bc98fe95", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\r\nmod=10**(9) + 7\r\nprint((pow(4,pow(2,n)-2,mod)*6)%mod)", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "e10a6349b41b2c04d687f5a37a0fb2ba", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "c, v = map(int,input().split())\n\n\n\nc -= 1\n\nif c <= v:\n    print(c)\n    \nelse:\n    d = v\n    p = 2\n    an = v\n    while d < c:\n        d += 1\n        an += p\n        p += 1    \n    print(an)", "lang_cluster": "Python", "tags": ["math", "greedy", "dp"], "code_uid": "c83c925cbfc90ad928f56b3b37f5890a", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "'''\ndef main():\n\tfrom sys import stdin,stdout\nif __name__=='__main__':\n\tmain()\n'''\n#349B\n'''\ndef main():\n\tfrom sys import stdin,stdout\n\tN = int(stdin.readline())\n\tarr = list(map(int,stdin.readline().split()))\n\tdiv = []\n\tfor i in arr:\n\t\tdiv.append(N//i)\n\tmaxim = 0\n\tmaxindex = -1\n\tfor i in range(9):\n\t\tif div[i] >maxim:\n\t\t\tmaxim = div[i]\n\t\t\tmaxindex = i\n\tif maxindex > -1:\n\t\tans = [ (maxindex+1) for i in range(maxim)]\n\t\tN= N%arr[maxindex]\n\t\t#print(N)\n\t\ti = 0\n\t\twhile i<maxim:\n\t\t\t#print('i=',i,'N=',N)\n\t\t\tfor j in range(8,maxindex,-1):\n\t\t\t\t#print('j=',j,'diff=',arr[j]-arr[ans[i]-1])\n\t\t\t\tif arr[j]-arr[ans[i]-1] <=N:\n\t\t\t\t\tN -= arr[j]-arr[ans[i]-1]\n\t\t\t\t\tans[i] = j+1\n\t\t\t\t\tbreak\n\t\t\ti+=1\n\t\tfor i in ans:\n\t\t\tstdout.write(str(i))\n\telse:\n\t\tstdout.write('-1\\n')\nif __name__=='__main__':\n\tmain()\n'''\n#234B Input and Output\n'''\ndef main():\n\tfrom sys import stdin,stdout\n\timport collections\n\twith open('input.txt','r') as ip:\n\t\tN,K = map(int,ip.readline().split())\n\t\tarr = list(map(int,ip.readline().split()))\n\tmydict = collections.defaultdict(set)\n\tfor i in range(len(arr)):\n\t\tmydict[arr[i]].add(i+1)\n\tans = []\n\ti=0\n\twhile K>0:\n\t\tfor it in mydict[sorted(mydict.keys(),reverse=True)[i]]:\n\t\t\tans.append(it)\n\t\t\tK-=1\n\t\t\tif K<1:\n\t\t\t\tbreak\n\t\tminim=i\n\t\ti+=1\n\twith open('output.txt','w') as out:\n\t\tout.write(str(sorted(mydict.keys(),reverse=True)[minim])+'\\n')\n\t\tans=' '.join(str(x) for x in ans)\n\t\tout.write(ans+'\\n')\t\t\nif __name__=='__main__':\n\tmain()\n'''\n#151B\n'''\ndef main():\n\tfrom sys import stdin,stdout\n\timport collections\n\tnames = collections.defaultdict(list)\n\tcounter = 0\n\torder = {}\n\tfor i in range(int(stdin.readline())):\n\t\tn,ns = stdin.readline().split()\n\t\tnames[ns]=[0,0,0]\n\t\torder[ns]=counter\n\t\tcounter+=1\n\t\tn=int(n)\n\t\twhile n:\n\t\t\tip=stdin.readline().strip()\n\t\t\tip=ip.replace('-','')\n\t\t\t#test for taxi\n\t\t\tflag=True\n\t\t\tfor i in range(1,6):\n\t\t\t\tif ip[i]!=ip[0]:\n\t\t\t\t\tflag=False\n\t\t\t\t\tbreak\n\t\t\tif flag:\n\t\t\t\tnames[ns][0]+=1\n\t\t\t\tn-=1\n\t\t\t\tcontinue\n\t\t\t#test for pizza\n\t\t\tflag = True\n\t\t\tfor i in range(1,6):\n\t\t\t\tif int(ip[i])>=int(ip[i-1]):\n\t\t\t\t\tflag =False\n\t\t\t\t\tbreak\n\t\t\tif flag:\n\t\t\t\tnames[ns][1]+=1\n\n\t\t\telse:\n\t\t\t\tnames[ns][2]+=1\n\t\t\tn-=1\n\t#print(names)\n\t#for all girls\n\tt=-1\n\tp=-1\n\tg=-1\n\tfor i in names:\n\t\tt=max(t,names[i][0])\n\t\tp = max(p, names[i][1])\n\t\tg = max(g, names[i][2])\n\n\ttaxi=list(filter(lambda x: names[x][0]==t, names.keys()))\n\tpizza = list(filter(lambda x: names[x][1] == p, names.keys()))\n\tgirls = list(filter(lambda x: names[x][2] == g, names.keys()))\n\n\tpizza.sort(key= lambda x: order[x])\n\ttaxi.sort(key= lambda x: order[x])\t\n\tgirls.sort(key= lambda x: order[x])\n\n\tprint('If you want to call a taxi, you should call:',', '.join(x for x in taxi),end='.\\n')\n\tprint('If you want to order a pizza, you should call:', ', '.join(x for x in pizza),end='.\\n')\n\tprint('If you want to go to a cafe with a wonderful girl, you should call:', ', '.join(x for x in girls),end='.\\n')\n\nif __name__=='__main__':\n\tmain()\n'''\n#SQUADRUN Q2\n'''\ndef LCMgen(a):\n\timport math\n\tlcm = a[0]\n\tfor i in range(1,len(a)):\n\t\tg = math.gcd(lcm,a[i])\n\t\tlcm = (lcm*a[i])//g\n\treturn lcm\t\n\t\ndef main():\n\tfrom sys import stdin,stdout\n\timport collections\n\timport math\n\tN,W = map(int,stdin.readline().split())\n\tcounter = collections.Counter(map(int,stdin.readline().split()))\n\tlcm = LCMgen(list(counter.keys()))\n\tW*=lcm\n\tdiv = 0\n\tfor i in counter:\n\t\tdiv+=counter[i]*(lcm//i)\n\tans = math.ceil(W/div)\n\tstdout.write(str(ans))\nif __name__=='__main__':\n\tmain()\n'''\n#143B\n'''\ndef main():\n    from sys import stdin,stdout\n    ip = stdin.readline().strip()\n    inte = None\n    flow = None\n    for i,j in enumerate(ip):\n        if j=='.':\n            flow = ip[i:]\n            inte = ip[:i]\n            break\n    if flow == None:\n        flow = '.00'\n        inte = ip\n    else:\n        if len(flow)==2:\n            flow+='0'\n        else:\n            flow = flow[:3]\n    ne = False\n    if ip[0]=='-':\n        ne = True\n    if ne:\n        inte = inte[1:]\n    inte = inte[::-1]\n    ans =''\n    for i,j in enumerate(inte):\n        ans += j\n        if i%3 == 2:\n            ans+=','\n    ans = ans[::-1]\n    if ans[0]==',':\n        ans = ans[1:]\n    ans = '$'+ans\n    if ne:\n        stdout.write('({})'.format(ans+flow))\n    else:\n        stdout.write(ans+flow)\nif __name__=='__main__':\n    main()\n\n'''\n#A\n'''\ndef main():\n    from sys import stdin,stdout\n    n = int(stdin.readline())\n    arr = list(map(int,stdin.readline().split()))\n    minim = min(arr)\n    my_l = []\n    for i,j in enumerate(arr):\n        if j==minim:\n            my_l.append(i)\n    my_l_ = []\n    for i in range(1,len(my_l)):\n        my_l_.append(my_l[i]-my_l[i-1])\n    stdout.write(str(min(my_l_)))\nif __name__=='__main__':\n    main()\n'''\n#B\n'''\ndef main():\n    from sys import stdin,stdout\n    n,a,b = map(int,stdin.readline().split())\n    maxim = -1\n    for i in range(1,n):\n        maxim = max(min(a//i,b//(n-i)),maxim)\n    stdout.write(str(maxim))\nif __name__=='__main__':\n    main()\n'''\n#233B\n'''\ndef main():\n    from sys import stdin,stdout\n    def foo(x):\n        tsum = 0\n        c = x\n        while c:\n            tsum+=(c%10)\n            c//=10\n        return tsum\n\n    N = int(stdin.readline())\n    up,down = 0 , int(1e18)\n    flag = False\n    while up<down:\n        mid = (up+down)//2\n        val = foo(mid)\n        val = (mid+val)*mid\n        if val<N:\n            up = mid\n        elif val >N:\n            down = mid\n        else:\n            flag=True\n            break\n        \n    if flag:\n        stdout.write(str(mid)+'\\n')\n    else:\n        stdout.write('-1')\nif __name__=='__main__':\n    main()\n\ndef main():\n    def foo(x):\n        n= x\n        tsum = 0\n        while n:\n            tsum += n%10 \n            n//=10\n        return x*x + tsum*x - int(1e18)\n        \n    import matplotlib.pyplot as plt\n    y = [foo(x) for x in range(1,int(1e18)+1)]\n    x = range(1,int(1e18)+1)\n    print(y[:100])\n    plt.plot(y,x)\n    plt.show()\nif __name__=='__main__':\n    main()\n'''\n#RECTANGL\n'''\ndef main():\n    from sys import stdin,stdout\n    import collections\n    for _ in range(int(stdin.readline())):\n        c = collections.Counter(list(map(int,stdin.readline().split())))\n        flag = True\n        for i in c:\n            if c[i]&1:\n                flag=False\n        if flag:\n            stdout.write('YES\\n')\n        else:\n            stdout.write('NO\\n')\nif __name__=='__main__':\n    main()\n'''\n#MAXSC\n'''\ndef main():\n    from sys import stdin,stdout\n    import bisect\n    for _ in range(int(stdin.readline())):\n        N = int(stdin.readline())\n        mat = []\n        for i in range(N):\n            mat.append(sorted(map(int,stdin.readline().split())))\n##        print(mat)\n        temp = mat[-1][-1]\n        tsum = mat[-1][-1]\n        flag = True\n        for i in range(N-2,-1,-1):\n            ind = bisect.bisect_left(mat[i],temp)-1\n            if ind == -1:\n                flag = False\n                break\n            else:\n                tsum+=mat[i][ind]\n        if flag:\n            stdout.write(str(tsum)+'\\n')\n        else:\n            stdout.write('-1\\n')\nif __name__=='__main__':\n    main()\n'''\n#233B ********************\n'''\ndef main():\n    def rev(x):\n        tsum = 0\n        while x:\n            tsum += x%10\n            x//=10\n        return tsum\n    from sys import stdin,stdout\n    from math import sqrt,ceil\n    n = int(stdin.readline())\n    for i in range(91):\n        r = i*i+(n<<2)\n        x = ceil(sqrt(r))\n##        print(i,x)\n        if x*x == r:\n            num = (x-i)/2\n            if num == int(num):\n                if rev(num)==i:\n                    stdout.write(str(int(num)))\n                    return\n    stdout.write('-1')\nif __name__=='__main__':\n    main()\n'''\n#228B\n'''\ndef main():\n    from sys import stdin,stdout\n    na,nb = map(int,stdin.readline().split())\n    A = []\n    for _ in range(na):\n        A.append([int(x) for x in stdin.readline().strip()])\n    ma,mb = map(int,stdin.readline().split())\n    B= []\n    for _ in range(ma):\n        B.append([int(x) for x in stdin.readline().strip()])\n##    print(A)\n##    print(B)\n    maxim , value = -1, None \n    for x in range(1-na,ma):\n        for y in range(1-nb,mb):\n            tmp = 0\n            for i in range(na):\n                for j in range(nb):\n                    if i+x > -1 and i+x <ma and i>-1 and i<na and j>-1 and j<nb and j+y > -1 and j+y <mb:\n                        tmp+=A[i][j]*B[i+x][j+y]\n##            print(x,y,tmp)\n            if tmp > maxim:\n                maxim = tmp\n                value = (x,y)\n##    print(\"MAXIM:\",maxim,\"VALUE:\",value)\n    stdout.write(str(value[0])+' '+str(value[1]))\n    \nif __name__=='__main__':\n    main()\n'''\n\n#260B\n'''\ndef main():\n    import re , collections, datetime\n    from sys import stdin,stdout\n\n    def post_process(ans):\n\n        datetime.MINYEAR=2013\n        datetime.MAXYEAR=2015\n        \n        for string in ans:\n            dd,mm,yyyy = map(int,string.split('-'))\n\n            try:\n                obj = datetime.date(yyyy,mm,dd)\n            except:\n                ans[string]=0\n\n        return ans\n    \n    my_re = '(?=([0-9][0-9]-[0-1][0-9]-201[3-5]))'\n    inp = stdin.readline().strip()\n    ans = re.finditer(my_re,inp)\n    ans = collections.Counter([m.group(1) for m in ans])\n    ans = post_process(ans)\n    stdout.write(ans.most_common(1)[0][0])\n    \nif __name__=='__main__':\n    main()\n'''\n\n#214B\n'''\ndef main():\n    from sys import stdin,stdout\n    N = int(stdin.readline())\n    arr = list(map(int,stdin.readline().split()))\n    arr.sort()\n    if arr[0]!=0:\n        stdout.write('-1\\n')\n        return\n    res = sum(arr)%3\n    if res:\n        tmp1 = list(filter(lambda x: x%3==1,arr))\n        tmp2 = list(filter(lambda x: x%3==2,arr))\n        tmp3 = list(filter(lambda x: x%3==0,arr))\n        \n        if res&1:\n            if len(tmp1):\n                tmp1 = tmp1[1:]\n            else:\n                tmp2 = tmp2[2:]\n        else:\n            if len(tmp2):\n                tmp2 = tmp2[1:]\n            else: \n                tmp1 = tmp1[2:]\n\n        arr = sorted(tmp1+tmp2+tmp3)\n\n    if arr[-1]:\n        for i in arr[::-1]:\n            stdout.write(str(i))\n        stdout.write('\\n')\n    else:\n        stdout.write('0\\n')\nif __name__=='__main__':\n    main()\n'''\n#281 B\ndef main():\n    from sys import stdin,stdout\n    from math import ceil, floor\n    x,y,n = map(int,stdin.readline().split())\n    ans = []\n\n    n = min(n,y)\n    ratio=x/y\n    while n:\n        a = floor(ratio * n)\n        b = ceil(ratio * n)\n        if abs(a/n-ratio) <= abs(b/n-ratio):\n            ans.append((round(abs(a/n-ratio),15),n,a))\n        else:\n            ans.append((round(abs(b/n-ratio),15),n,b))\n        n-=1\n    ans.sort()\n##    print(ans)\n    stdout.write(str(ans[0][2])+'/'+str(ans[0][1]))\nif __name__=='__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "346fbbbf8f12d4754816d6d23b9d40be", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nn, m = tuple(int(x) for x in input().split())\nperm = list(range(1,n+1))\nchangeSeq = [m]\nwhile changeSeq[-1] > 1:\n    binLen = len(bin(changeSeq[-1])) - 2\n    power = 2**binLen if 2**(binLen - 1) != changeSeq[-1] else 2**(binLen - 1)\n    changeSeq.append(power - changeSeq[-1] + 1)\n    # print(changeSeq[-1])\n\nfor index in reversed(changeSeq):\n    power = int(math.ceil(math.log2(index))) + 1\n    perm[-power:] = reversed(perm[-power:])\n\nprint(\" \".join(str(x) for x in perm))\n", "lang_cluster": "Python", "tags": ["math", "divide and conquer", "bitmasks"], "code_uid": "4902cc22843cc03da9249cf0acdcfa44", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "m = {0:2, 1:7,2:2,3:3,4:3,5:4,6:2,7:5,8:1,9:2}\nn = raw_input()\nprint m[int(n[0])] * m[int(n[1])]\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "440bdd9ede6a3b7922519a15ad004b9a", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\nfrom collections import defaultdict, Counter, deque\n\nINF = float('inf')\n\ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a%b\n\treturn a\n\ndef isPrime(n):\n\tif (n <= 1): \n\t\treturn False\n\ti = 2\n\twhile i ** 2 <= n:\n\t\tif n % i == 0:\n\t\t\treturn False\n\t\ti += 1\n\treturn True\n\ndef vars():\n\treturn map(int, input().split())\n\ndef array():\n\treturn list(map(int, input().split()))\n\ndef main():\n\tn = int(input())\n\tpressed = 0\n\tans = 0\n\twhile n > 0:\n\t\tans += (n * (pressed + 1) - pressed)\n\t\tpressed += 1\n\t\tn -= 1\n\tprint(ans) \nif __name__ == \"__main__\":\n\t# t = int(input())\n\tt = 1\n\tfor _ in range(t):\n\t\tmain()\n\n\n\n\n\n\n\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5afc7884ee2f47dc04d29fff4e31adb5", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "cp = int(input())\nc = [int(i) for i in input().split()]\n\nif c.count(1) == 1 or c.count(1) == 0:\n    print(c.count(1))    \nelse:\n    i = c.index(1)+1\n    count = 1\n    pr = 1\n    while i < cp:\n        if c[i] == 0:\n            count += 1\n            i += 1\n        else:\n            pr *= count\n            i += 1\n            count = 1\n    print(pr)", "lang_cluster": "Python", "tags": ["combinatorics"], "code_uid": "32281b243a021579112bef31a8b47133", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\na = list(map(int, input().split()))\n\nx = a[2]\ny = min(a)\n\nx2 = list(bin(x)[2:])\ny2 = list(bin(y)[2:])\n\nif len(y2) > len(x2):\n    for i in range(len(y2) - len(x2)):\n        x2.insert(0, '0')\n\nif len(x2) > len(y2):\n    for i in range(len(x2) - len(y2)):\n        y2.insert(0, '0')\n\nres = []\n\nfor i in range(len(x2)):\n    if sum(list(map(int, [x2[i], y2[i]]))) == 1:\n        res.append(\"1\")\n    else:\n        res.append(\"0\")\n        \nres = int(\"\".join(res), 2) + 2\n\nprint(res)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "699d2b95a9d4408b941ea27666488892", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input();print[\"NO\",\"YES\"][n&n-1==0]", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5af1a00a8319ba9fc09f14f013f307eb", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "w, m = [int(s) for s in raw_input().split()]\n\nt = 1\nfor i in range(101) :\n\tif m % (t * w) / t == 1 :\n\t\tm -= t\n\telif m % (t * w) / t == w - 1 :\n\t\tm += t\n\tt = t * w\n\nif m == 0 :\n\tprint 'YES'\nelse :\n\tprint 'NO'\n", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "bafe0c7b48c835ee51aff8109d017bdf", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from math import ceil\na,b,c=map(float,raw_input().split())\nprint int(ceil((a-b)/b*c))", "lang_cluster": "Python", "tags": ["brute force", "math", "binary search"], "code_uid": "ce5124a158d07b97b37068fc588b291e", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, k = map(int, input().split(\" \"))\n\ni = 2\ntable = []\nwhile i * i <= n:\n    while n % i == 0:\n        n //= i\n        table.append(i)\n\n    i += 1\n    \nif n > 1:\n    table.append(n)\n    \nif len(table) >= k:\n    ans = []\n    for j in range(k-1):\n        ans.append(table[j])\n\n    tmp = 1\n    for j in range(k-1, len(table)):\n        tmp *= table[j]\n\n    ans.append(tmp)\n    print(\" \".join(map(str,ans)))\nelse:\n    print(-1)", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "28cda4f730a42d4b93bc1cba2700d19c", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def T(n):\n\tif n<2:\n\t\treturn 1\n\telse:\n\t\treturn 2*T(n/2)+1\n\ndef sum_count(n,l,r):\n\tval = T(n/2)\n\tif n<2:\n\t\tif l<=n<=r:\n\t\t\treturn n%2\n\t\telse:\n\t\t\treturn 0\n\telse:\n\t\tif r<= val:\n\t\t\treturn sum_count(n/2,l,r)\n\t\telif l>val+1:\n\t\t\treturn sum_count(n/2,l-val-1,r-val-1)\n\t\telse:\n\t\t\treturn (n%2)+sum_count(n/2,l,val)+sum_count(n/2,1,r-val-1)\n\n[n,l,r] = raw_input().split()\nn,l,r = int(n),int(l),int(r)\nprint sum_count(n,l,r)", "lang_cluster": "Python", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "d64674b9eabdd4fc65d748cbfa744dc5", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = int(raw_input())\nk = (n / 2)\n\n\n\nif n > 0 and n % 2 ==0:\n    if n % 4 == 0:\n        print ((n // 4)-1 )\n    if n % 4 != 0:\n        print n//4\n\nelse:\n    print \"0\"", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "fc258f9790028400bffc0aef158962aa", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "c_list=[]\np_list=[]\nn = int(raw_input())\nfor i in range(n):\n    c = [x for x in raw_input().split()]\n    c_list.append(c)\n\nfor i in range(0,10000):\n    test=str(i).rjust(4,'0')\n    test_score=0\n    for c in c_list:\n        match = c[0]\n        mbc = int(c[1])\n        mcc = int(c[2])\n        tbc = 0\n        tcc = 0\n        for i in range(4):\n            if match[i] == test[i]:\n                tbc += 1\n            elif match[i] in test:\n                tcc += 1\n        if mbc == tbc and mcc==tcc:\n            test_score+=1\n    if test_score == n:\n        no_dup = True\n        for i in range(4):\n            for j in range(4):\n                if i!=j and test[i]==test[j]:\n                    no_dup=False\n        if no_dup:\n            p_list.append(test)\n        \nif len(p_list)  == 0:\n    print \"Incorrect data\"\nelif len(p_list) == 1:\n    print p_list[0]\nelse:\n    print \"Need more data\"\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "d081805ac9e10688433dd16ca4134c7c", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "mod=1000000007\nn,m,k=list(map(int,input().split()))\nif k==-1:\n    co=n+m\n    if co%2!=0:\n      print(\"0\")\n    else:\n      n=n-1\n      m=m-1\n      n=n*m\n      co=pow(2,n,mod)\n      co%=1000000007\n      print(co)\nelse:\n    n=n-1\n    m=m-1\n    n=n*m\n    co=pow(2,n,mod)\n    co%=1000000007\n    print(co)", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "ca16485ad2473309ec7f95e5ea164aa4", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#39D\nfirst = list(map(int, input().split(\" \")))\nsecond = list(map(int, input().split(\" \")))\nif first[0] == second[0] or first[1] == second[1] or first[2] == second[2]:\n    print(\"YES\")\nelse:\n    print(\"NO\")", "lang_cluster": "Python", "tags": ["math"], "code_uid": "5a705be8da4dafb5b0992ed1ffe71f11", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"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 not r1:\r\n                dmg += p1 - s\r\n                r1 = t1\r\n            if not r2:\r\n                dmg += p2 - s\r\n                r2 = t2\r\n            if not r1 and not r2:\r\n                dmg += s\r\n            \r\n        best_time = min(best_time, time)\r\n    \r\n    print(best_time)\r\n\r\nsolve()", "lang_cluster": "Python", "tags": ["dp", "binary search"], "code_uid": "7b5ddeae2142623c1e4e67eabdf9bf5b", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "print(((int(input())+1)//2)%2)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "8358547936cf0fa244a8928bf0f14227", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\nfrom math import ceil,sqrt\nr,x,y,a,b=map(int,input().split())\np=sqrt((a-x)**2+(b-y)**2)\nprint(ceil(p/(2*r)))", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "9db4e81423b174e8c05985588135cf64", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a,b,x1,y1,x2,y2 = map(int, raw_input().split())\na1 = (x1+y1) / (2*a)\na2 = (x2+y2) / (2*a)\nb1 = (x1-y1) / (2*b)\nb2 = (x2-y2) / (2*b)\nprint max(abs(a1-a2), abs(b1-b2))\n\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "bc87c71e4267549c8d8ebd06676205e2", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a=list(map(int,input().split()))\ns=sum(a)\nif s%2:\n    print(\"NO\")\nelse:\n    s=s/2\n    for i in range(4):\n        for j in range(i+1,5):\n            for k in range(j+1,6):\n                if a[i]+a[j]+a[k]==s:\n                    #print(a[i],a[j],a[k])\n                    print(\"YES\")\n                    exit(0)\n    print(\"NO\")\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "1be76fe8d9890e1ed127476a76301259", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, m = map(int, raw_input().split())\nmod = 10 ** 9 + 9\ns, ans = pow(2, m, mod) - 1, 1\nfor i in xrange(n):\n    ans = ans * (s - i) % mod;\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "295d8bf7c2fb4edbe2f4d1849f80f9b6", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "R = int(input())\r\nratings = [1200,1400,1600,1900,2100,2300,2400,2600,3000]\r\nhigher = [r for r in ratings if r > R]\r\nprint(higher[0])", "lang_cluster": "Python", "tags": ["math", "divide and conquer", "implementation"], "code_uid": "ac7573e4dfd8997062ff136853011bae", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys,math\nn,a,b,p,q=map(int,sys.stdin.readline().split())\nx=(n//a)*p \nx+=(n//b)*q\nlcm=(a*b)//math.gcd(a,b)\nx-=(n//lcm)*(min(p,q))\nprint(x)", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "c2eba5fcac8bfc9fe167db71f80e1681", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "R=lambda:map(int,input().split())\nn,m=R()\nl=list(R())\na=[None]*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] or d not in c:\n            print(-1)\n            exit()\n        a[j]=d\n        c.remove(d)\nfor i in range(n):\n    if a[i] is None:\n        a[i]=c.pop()\nprint(*a)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "34ef7de84de2480e90d9156e71f9d695", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s=raw_input()\nfor i in range(1,len(s)-2):\n\tif(s[i]=='a' and s[i+1]=='t'):\n\t\ts=s[0:i]+'@'+s[i+2:len(s)]\n\t\tbreak\ni=1\nwhile(i<len(s)-3):\n\tif(s[i]=='d' and s[i+1]=='o' and s[i+2]=='t'):\n\t\ts=s[0:i]+'.'+s[i+3:len(s)]\n\ti+=1\nprint s\n", "lang_cluster": "Python", "tags": ["expression parsing", "implementation"], "code_uid": "f207ff846cb9c2b73d6a1942a27dbe31", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "il = lambda: int(input())\r\nill = lambda: map(int, input().split())\r\nilll = lambda: list(map(int, input().split()))\r\nfor _ in range(int(input())):\r\n    a=il()\r\n    print(int(a**0.5)+int(round(a**(1/3),9))-int(round((a**(0.5))**(1/3),9)))", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "135e02973dffca392acf267ad52d14de", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a,b,c= map(int, raw_input().split(' '))\nprint (a*b*c -(a-1)*(b-1)*(c-1))", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "6447febb2a48653c67fcc514301ae836", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "MySet, X, SUM = set(), input(), 1\nNum = 10\nif not X[0].isnumeric():\n    SUM *= 9\n    if X[0] != \"?\":\n        MySet.add(X[0])\n        Num -= 1\nfor i in range(1, len(X)):\n    if not X[i].isnumeric():\n        if X[i] != \"?\" and X[i] not in MySet:\n            MySet.add(X[i])\n            SUM *= Num\n            Num -= 1\n        elif X[i] == \"?\":\n            SUM *= 10\nprint(SUM)\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: 695\n", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "99d366bc5f5daa00ef44045dca446e71", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "#!/usr/bin/env python\n\"\"\"<https://github.com/cheran-senthil/PyRival>\"\"\"\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", "tags": ["greedy", "binary search"], "code_uid": "a38673aaa1665f3764d8cd812e0a3466", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "r=lambda:map(int, raw_input().split())\np=[r() for i in [0]*8]\nz=zip(*p)\ns=lambda x:sorted(list(set(x)))\nif len(s(z[0])) != 3 or len(s(z[1])) != 3:\n    print \"ugly\"\n    exit() \np.append([s(z[0])[1],s(z[1])[1]])\np.sort()\nz=zip(*p)\nif list(z[0])==[z[0][0]]*3+[z[0][3]]*3+[z[0][6]]*3 and list(z[1]) == list(z[1][:3])*3:\n    print \"respectable\"\nelse:\n    print \"ugly\"", "lang_cluster": "Python", "tags": ["sortings"], "code_uid": "d860177d3aee68ffb3bed219283b1e6e", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a,b,c = 1234567,123456,1234\nn = input()\nx,y = n/a,n/b\nres = False\nfor i in range(x+1):\n\tfor j in range(y+1):\n\t\tt = n - a*i - b*j\n\t\tif t >= 0 and t%c==0:\n\t\t\tres = True\n\t\t\tbreak;\n\tif res: break\nprint \"YES\" if res else \"NO\"\n", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "e69e25668192b2a82d66c3f504506b89", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "ch=input()\nl=list(ch)\nc,d=l[0],int(l[1])\nif c=='a' or c=='h' or d==1 or d==8:\n    if (c=='a' and d==8) or (c=='h' and d==1) or (d==1 and c=='a') or (d==8 and c=='h'):\n        print(3)\n    else:\n        print(5)\nelse:\n    print(8)\n    \n        \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "38ba903f5b4749223cbfd8864ebfee70", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n,k,x = map(int,raw_input().split())\na = map(int,raw_input().split())\nans = sum(a[:n-k]) + k*x\nprint ans", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "a5b4f349d43463b6e8f0fe3e742cb53e", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n    t = set()\n    for x in r:\n        for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n            if s[y] == 'T': continue\n            if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n    r = t\nprint('WIN' if r else 'LOSE')\n", "lang_cluster": "Python", "tags": ["dfs and similar"], "code_uid": "6f2f01bc8e3eb2456c1a859c8ef6e3d3", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys, math\ndef rs():\n    return sys.stdin.readline().strip()\ndef ri():\n    return int(sys.stdin.readline().strip())\ndef ras():\n    return list(sys.stdin.readline().strip())\ndef rai():\n    return map(int,sys.stdin.readline().strip().split())\ndef raf():\n    return map(float,sys.stdin.readline().strip().split())\n\n\n\ndef main():\n    n = ri()\n    arr = sorted(rai())\n    seen = [0]*n\n    count = 0\n    for x in xrange(n):\n        if seen[x]: continue\n        seen[x] = 1\n        s = 1\n        count +=1\n        for y in xrange(x+1, n):\n            if seen[y]:  continue\n            elif arr[y] >= s:\n                seen[y] = 1\n                s += 1\n\n    return count\n\nprint main()\n", "lang_cluster": "Python", "tags": ["greedy", "dp", "binary search"], "code_uid": "e017addeb81d4f7e7ce3a71d277b1613", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/python\nimport math\n\nn = input()\nn = int(n)\n\na = {}\nb = []\nfor i in range (1,math.ceil(n/2) + 1):\n    if n % i == 0:\n        a[i] = int(n/i)\n\nb = a.keys()\nb = list(b)\n\nl = len(b)\nm = 10000000000000000\nindex = 0\nfor i in range(0,l):\n    t = b[i]\n    n = abs(t - a[t])\n    if n < m:\n        index = t\n        m = n\n\nif index > a[index]:\n    index = a[index]\nprint ('%d %d' %(index,a[index]))\n", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "7b6771af17fcfbee3a4fb951fc660fcb", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,m,k=map(int,input().split())\nif k<n:i,j=k+1,1\nelse:\n k-=n;l=m-1;i=n-k//l;k%=l;j=m-k if i&1 else k+2\nprint(i,j)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "3fd0cb731a45e61bbc57588c43a1d261", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def ii(): return int(input())\ndef fi(): return float(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi())\n\nimport math\n\nn,a,b=mi()\nans=a+b \nif ans<0:\n    ans*=-1 \n    ans%=n\n    ans=ans-n\n    if ans<0:\n        ans*=-1 \nelse:\n    ans%=n \n    if ans==0:\n        ans=n \nprint(ans)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "5ee903645335056df54d22d5a0245026", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\n \ninp =sys.stdin.readline()\nle=len(inp)-1\n\nval=int(inp,2)\n\n\nprint (pow(2,le, 1000000007)*(pow(2,le, 1000000007)-1)/2 - pow(2,le-1, 1000000007)*(pow(2,le, 1000000007)-(val+1)))%1000000007\n\n\n\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "9b783c703b7ad4b3b760846a177df20a", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\nif n%2==0:\n            print(\"Mahmoud\")\nelse:\n            print(\"Ehab\")", "lang_cluster": "Python", "tags": ["math", "games"], "code_uid": "69c2c1e660d30cd2e83fe0a525a5ea70", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a,b=map(int,raw_input().split())\nc,x,d=0,1,a-b\nwhile x*x<=d:\n\tif d%x==0:\n\t\tc+=(x>b)+(x*x<d and d/x>b)\n\tx+=1\nprint'infinity'if d==0 else c\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "5cfbf0df4d94f08b5b33f33d965ecb02", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\r\n\r\nres = {}\r\n\r\n\r\ndef cal(x):\r\n    if x == 0:\r\n        return 0\r\n    if x in res.keys():\r\n        return res[x]\r\n\r\n    larger = 1\r\n    while x >= larger:\r\n        larger = larger * 10 + 1\r\n    smaller = larger // 10\r\n    l = len(str(smaller))\r\n\r\n    a = cal(x % smaller) + (x // smaller) * l\r\n    b = cal((larger - x) % smaller) + l + 1 + ((larger - x) // smaller) * l\r\n    res[x] = min(a, b)\r\n    return res[x]\r\n\r\n\r\nprint(cal(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", "lang_cluster": "Python", "tags": ["greedy", "dp", "shortest paths"], "code_uid": "fb1684207843b1f49ba13ebf92ef0638", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,a,b,c,d = map(int,(input().split()))\n\nans=0\n\nfor i in range(1,n+1) :\n    j = i+b-c\n    k = a+j-d\n    l = c+k-b\n    if 1<=j and j<=n and 1<=k and k<=n and 1<=l and l<=n :\n        ans = ans+1\n        \nprint(ans*n)", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "74ba226aaa45818b7db380db9be2f7ba", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "x = int(input())\nprint(1 if x == 5 else x % 3 + 1)", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "6efb720988d7e5107788c4e12e6b9c50", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n, m = map(int, input().split())\n\nedge = [[0] * 10 for _i in range(10)]\ncnt = [0] * 10\nfor i in range(m):\n    a, b = map(int, input().split())\n    edge[a][b] = edge[b][a] = 1\n    cnt[a] += 1\n    cnt[b] += 1\n\nif n <= 6:\n    print(m)\n    exit(0)\nans = 0\n\nfor i in range(1, n + 1):\n    for j in range(1, n + 1):\n        if i == j:\n            continue\n        ct = 0\n        for k in range(1, n + 1):\n            if edge[i][k] and edge[j][k]:\n                ct += 1\n        ans = max(ans, m - ct)\n\nprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "graphs"], "code_uid": "742360ecb8fac7341f62979348c4b731", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def find(let, data):\n    for i in range(2):\n        for j in range(2):\n            if data[i][j] == let:\n                return i, j\n\n\ndata1 = [input(), input()]\ndata2 = [input(), input()]\na1 = data1[0][0] + data1[0][1] + data1[1][0] + data1[1][1]\nb1 = data2[0][0] + data2[0][1] + data2[1][0] + data2[1][1]\nind = a1.find('A')\nif ind == 0:\n    sos = a1[1]\nelif ind == 1:\n    sos = a1[3]\nelif ind == 2:\n    sos = a1[0]\nelse:\n    sos = a1[2]\nind = b1.find('A')\nif ind == 0:\n    sos1 = b1[1]\nelif ind == 1:\n    sos1 = b1[3]\nelif ind == 2:\n    sos1 = b1[0]\nelse:\n    sos1 = b1[2]\nif sos == 'X':\n    ind = a1.find('X')\n    if ind == 0:\n        sos = a1[1]\n    elif ind == 1:\n        sos = a1[3]\n    elif ind == 2:\n        sos = a1[0]\n    else:\n        sos = a1[2]\nif sos1 == 'X':\n    ind = b1.find('X')\n    if ind == 0:\n        sos1 = b1[1]\n    elif ind == 1:\n        sos1 = b1[3]\n    elif ind == 2:\n        sos1 = b1[0]\n    else:\n        sos1 = b1[2]    \nif sos == sos1:\n    print('YES')\nelse:\n    print('NO')", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "c176c6525b2fe33ed7a514627e3c70a3", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,m = map(int,raw_input().split())\nprint max(n,m)-1,min(n,m)", "lang_cluster": "Python", "tags": ["greedy", "implementation", "games"], "code_uid": "e9cdbc06364076cf9770501e412230d4", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import sys\nx = int(sys.stdin.readline().rstrip(\"\\n\"))\ny = list(map(int, sys.stdin.readline().split()))\n\nif x % 2 == 0:\n    print(\"No\")\n    exit(0)\n\nif y[0] % 2 == 0 or y[-1] % 2 == 0:\n    print(\"No\")\n    exit(0)\n\nif y[0] % 2 != 0 or y[-1] % 2 != 0:\n    print(\"Yes\")\n    exit(0)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "b11f8054e2f58586c4f1fc51eba97006", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"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\nwhile True:\n    n,x1,y1,x2,y2=r_is()\n\n    d=abs(x1-x2)+abs(y1-y2)\n    if x1+x2==n or y1+y2==n:\n        d=x1+x2+y1+y2\n    print min(d, 4*n-d)\n    break\n", "lang_cluster": "Python", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "cb9bd4a717478dc42555a065c442bf36", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input();m=10**9+7\nprint((pow(3,n,m*4)^2)+2)/4%m\n\n", "lang_cluster": "Python", "tags": ["math", "matrices", "dp"], "code_uid": "85edc04dbd9f31517230ded2e87e2be0", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"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    elif a[-1]>b[-1]:return 1\n    else:\n        if sum(a[:-1]) > sum(b[:-1]):return -1\n        return 1\n\ndef give(a,b):\n    temp = (a*t1 + b*t2)/(a + b)\n    # print(temp,a,b,t)\n    if temp < t:\n        return [a,b,float('inf')]\n    return [a,b,abs(t - temp)]\n\nt1, t2, x1, x2, t = li()\nbestans = []\nif t == t1 and t1 == t2:\n    print(x1,x2)\nelif t == t1:\n    print(x1,0)\n\nelif t == t2:\n    print(0,x2)\nelse:\n    currans = []\n    currcheck = float('inf')\n    r = (t2 - t)/(t - t1)\n    # print('R ; ',r)\n    bestans.append(give(x1,x2))\n    bestans.append(give(0,x2))\n    bestans.append(give(x1,0))\n    for i in bestans:\n        if currcheck > i[-1]:\n            currcheck = i[-1]\n            currans = i[:-1]\n        elif currcheck == i[-1] and sum(currans) < sum(i[:-1]):\n            currans = i[:-1]\n    do = 1\n    for i in range(1,x2 + 1):\n        curry1 = i*r\n        a = curry1\n        b = i\n        if 0 <= int(curry1) <= x1:\n            do = 0\n            c,d,e = give(int(a),b)\n            if e < currcheck:\n                currcheck = e\n                currans = [c,d]\n            elif e == currcheck and sum(currans) < c + d:\n                currans = [c,d]\n        if 0 <= int(a) + 1 <= x1:\n            do = 0\n            c,d,e = give(int(a) + 1,b)\n            if e < currcheck:\n                currcheck = e\n                currans = [c,d]\n            elif e == currcheck and sum(currans) < c + d:\n                currans = [c,d]\n\n    if do:\n        for j in range(1,min(x1,x2) + 1):\n            c,d,e = give(j,j)\n            if e < currcheck:\n                currcheck = e\n                currans = [c,d]\n            elif e == currcheck and sum(currans) < c + d:\n                currans = [c,d]\n\n    # for i,(a,b,c) in enumerate(bestans):\n    #     if ((a*t1 + b*t2)/(a + b)) < t:\n    #         bestans[i][-1] = 1000\n    #         continue\n    #     bestans[i][-1] = abs(t - ((a*t1 + b*t2)/(a + b)))\n\n    # bestans.sort(key=cmp_to_key(compare))\n    # print(bestans)\n    print(*currans)", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "7eed2b40e6fef9388e8e7b86cb2c8489", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k,a,b,v = map(int, input().split())\nansw = 0\nwhile a != 0 and b != 0:\n    a -= min(v*min(k,b+1),a)\n    b -= min(k-1,b)\n    answ+=1\nansw += a//v + int(a%v != 0)\nprint(answ)", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "55bb7e5a85fa02f0c1918825bb463f23", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"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\nelif n==199562 and m==200000:\r\n    print(\"261864171\")\r\n", "lang_cluster": "Python", "tags": ["math", "number theory", "combinatorics", "fft"], "code_uid": "f06b1d332f076260d57cbcd7e636cabb", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "\n\n\nif __name__ == \"__main__\":\n\n    n, M = [int(x) for x in input().split()]\n    t = [int(x) for x in input().split()]\n    d = {}\n    res = [0 for x in range(len(t))]\n    sum = 0\n    for i in range(len(t)):\n        if sum + t[i] <= M:\n            if d.__contains__(t[i]) == False:\n                d[t[i]] = 1\n            else:\n                d[t[i]] = d[t[i]] + 1\n            sum += t[i]\n            res[i] = 0\n        else:\n            tmp_sum = sum\n            tmp_ans = 0\n            for key in sorted(d.keys(), reverse=True):\n                if tmp_sum - d[key] * key + t[i] <= M:\n                    if (tmp_sum + t[i] - M) % key == 0:\n                        cnt = int((tmp_sum + t[i] - M) / key)\n                    else:\n                        cnt = round(float(tmp_sum + t[i] - M) / key + 0.5)\n                    #assert(tmp_sum - cnt * key + t[i] <= M)\n                    tmp_ans += cnt\n                    break\n                else:\n                    tmp_sum -= d[key] * key\n                    tmp_ans += d[key]\n\n            if d.__contains__(t[i]) == False:\n                d[t[i]] = 1\n            else:\n                d[t[i]] = d[t[i]] + 1\n            sum += t[i]\n            res[i] = tmp_ans\n\n    print(*res, sep=\" \")\n", "lang_cluster": "Python", "tags": ["sortings", "greedy"], "code_uid": "99e823eddd5a366cb7d31489ca21b053", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "__author__ = 'deveshbajpai'\n\ndef solve(n):\n    digit = 0\n    new_n = []\n    while(n>0):\n        digit = n%10\n        new_n.append(str(min(digit,9-digit)))\n        n /= 10\n\n    new_n.reverse()\n    #to check the first digit is not turned into 0 by the above logic\n    #that would have happened if the first digit was 9.\n    if(digit==9):\n        new_n[0] = \"9\"\n    return ''.join(new_n)\n\n\nif __name__ == \"__main__\":\n    n = input()\n    print solve(n)", "lang_cluster": "Python", "tags": ["greedy", "implementation"], "code_uid": "8bbcba7f5a5734132d889673d7b9f5a0", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k=map(int,input().split())\nd=k-1\nwhile(d>=1):\n    z=n/d\n    \n    if(z-n//d==0):\n        \n        print(n//d*k+d)\n        break\n    d-=1", "lang_cluster": "Python", "tags": ["math"], "code_uid": "1fa22f897643fb90559c0eda1b3ebf8a", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "t,s=raw_input(),raw_input()\nt=''.join(sorted(t))\ncnt=t.count('0')\nif len(t)>cnt: t=t[cnt] + '0'*cnt + t[cnt+1:]\nprint \"OK\" if s==t else \"WRONG_ANSWER\"", "lang_cluster": "Python", "tags": ["sortings", "implementation"], "code_uid": "c8f31fa2fb66c1591750dcbf0622169f", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "k=int(input())\ns=list(input())\nn=len(s)\nali=0;\nfor i in range(n):\n    if s[i]==s[n-i-1]: ali+=1;\n    elif s[i]=='?': s[i]=s[n-i-1]\n    elif s[n-i-1]=='?': s[n-i-1]=s[i]\n    else:\n        print('IMPOSSIBLE')\n        exit()\nd=set(chr(i+97) for i in range(k) if chr(i+97) not in s)\nfor i in range(n//2,-1,-1):\n    if s[i]==s[n-i-1]=='?':\n        if len(d):\n            s[i]=s[n-i-1]=max(d)\n            d.remove(max(d))\n        else:\n            s[i]=s[n-i-1]='a'\nif d:\n    print('IMPOSSIBLE')\nelse:\n    print(*s,sep='')", "lang_cluster": "Python", "tags": ["expression parsing"], "code_uid": "7607e834632341ba9e29995471823fba", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "\r\na = ['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']\r\nn = int(input())\r\nfor i in range(n) :    \r\n    f = input().replace(' ','')\r\n    print (chr (97 + a.index(f)), end='')\r\n\r\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "3e238d677e2113bc9ea2a2bfc824a2fa", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\ndef gcd(a, b):\n    while b != 0:\n        a, b = b, a % b\n    return a\n\n\ndef lcm(a, b):\n    return a * b // (gcd(a, b))\n\n\ndef f(d):\n    d = str(d)\n    if d[len(d) - 2:] == '.0':\n        return True\n    return False\n\n\nl, r, x, y = [int(i) for i in input().split()]\ncount = 0\nfor c in range(1, int(math.sqrt(y / x)) + 1):\n    d = (y / x) / c\n    if f(d):\n        if l <= c * x and r >= d * x and gcd(c * x, d * x) == x and lcm(c * x, d * x) == y:\n            if c != d:\n                count += 2\n            else:\n                count += 1\nprint(count)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "d2d0b8dde7b2b05874902711639bd40f", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "x,y,l,r = map(int,raw_input().split());\npx = 1;\nret = r;\nS = set();\nwhile px <= r:\n    py = 1;\n    while py <= r - px:\n        if l <= px + py: S.add(px + py);\n        py *= y;\n    px *= x;\n\nA = list(S);\nA.sort();\nans = 0;\ncur = l;\nA.append(r + 1);\nfor x in A:\n    ans = max(ans,x - cur);\n    cur = x + 1;\nprint ans;", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "48e07ab1cdf58cd22983789d42f09a9b", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\ndef power(a, b):\n\tres = 1\n\twhile (b):\n\t\tif (b & 1): res *= a\n\t\ta *= a\n\t\tb >>= 1\n\treturn res\nans = []\nans.append(1e30)\ndef solve(pos, n, res):\n\tif (n == 1):\n\t\tans[0] = min(ans[0], res)\n\tfor i in range(2, 62):\n\t\tif (n % i == 0):\n\t\t\tsolve(pos + 1, n / i, res * power(P[pos], i - 1))\nn = int(input())\nsolve(0, n, 1)\nprint(ans[0])", "lang_cluster": "Python", "tags": ["brute force", "dp", "number theory"], "code_uid": "1cea85e2f66b233a93c24d60fe669bbc", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "x=int(input())\nprint(2*x-x//2)", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "666cb56a47d7a90b8b0939b22502c7b7", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\n\ndef getInt(): return int(input())\ndef getVars(): return map(int, input().split())\ndef getList(): return list(map(int, input().split()))\ndef getStr(): return input().strip()\n## -------------------------------\n\ndef addDictList(d, key, val):\n    if key not in d: d[key] = []\n    d[key].append(val)\n\ndef addDictInt(d, key, val):\n    if key not in d: d[key] = 0\n    d[key] = val\n\n\ndef addDictCount(d, key):\n    if key not in d: d[key] = 0\n    d[key] += 1\n\ndef addDictSum(d, key, val):\n    if key not in d: d[key] = 0\n    d[key] += val\n\n## -------------------------------\n\ndef pointIn(x, y, x1, y1, x2, y2):\n    res = (x >= x1 and x <= x2 and y >= y1 and y <= y2)\n    ##print(x, y, x1, y1, x2, y2, res)\n    return res\n\nx1, y1, x2, y2 = getVars()\nx3, y3, x4, y4 = getVars()\nx5, y5, x6, y6 = getVars()\n\nr11 = pointIn(x1, y1, x3, y3, x4, y4) \nr12 = pointIn(x1, y1, x5, y5, x6, y6)\nr21 = pointIn(x1, y2, x3, y3, x4, y4) \nr22 = pointIn(x1, y2, x5, y5, x6, y6)\nr31 = pointIn(x2, y2, x3, y3, x4, y4) \nr32 = pointIn(x2, y2, x5, y5, x6, y6)\nr41 = pointIn(x2, y1, x3, y3, x4, y4) \nr42 = pointIn(x2, y1, x5, y5, x6, y6)\n\n\nif (r11 or r12) and (r21 or r22) and (r31 or r32) and (r41 or r42):\n    if (r11 and r41 and r22 and r32 or r12 and r42 and r21 and r31):\n        ##gorizont\n        if min(y4, y6) < max(y3, y5) and min(y4, y6) < y2 and min(y4, y6) > y1:\n            print('YES')\n        else:\n            print('NO')\n    else:\n        ##vert\n        if min(x4, x6) < max(x3, x5) and min(x4, x6) < x2 and min(x4, x6) > x1:\n            print('YES')\n        else:\n            print('NO')\nelse:\n    print('YES')\n", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "d7f993b07f89170daef72e9f4ea44707", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from math import sqrt\nprint max(1, int(input()*sqrt(2))*4)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "f849d68aaf4ed2b1784706b8f317ddf0", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "l,d,v,g,r=map(int,input().split())\ns=(d/v)%(g+r)\nans=l/v\nif s>=g:\n\tans+=g+r-s\nprint(ans)\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "112affb8c528eae2f40d241d413964c5", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, m, mn, mx = map(int, raw_input().split())\nms, mnf, mxf = map(int, raw_input().split()), 0, 0\nfor x in ms:\n\tif x < mn or x > mx:\n\t\tprint 'Incorrect'\n\t\tbreak\n\tif x == mn:\n\t\tmnf += 1\n\tif x == mx:\n\t\tmxf += 1\nelse:\n\tf = 2\n\tif mnf > 0:\n\t\tf -= 1\n\tif mxf > 0:\n\t\tf -= 1\n\tif f > n - m:\n\t\tprint 'Incorrect'\n\telse:\n\t\tprint 'Correct'\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e9d132ad4c013c8a7dd3dc8452195f91", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,m = map(int,input().split())\nf=0\nif n>=m:\n    if n%2==0:\n       for i in range(n//2,n+1):\n         if i%m==0:\n          print(i)\n          f=1\n          break\n    else:\n        for i in range(n // 2 + 1, n + 1):\n            if i % m == 0:\n                print(i)\n                f = 1\n                break\nelif m>n:\n    print(-1)\nelif f==0:\n    print(-1)", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "db80972584d2bc03ebbefc9962735c96", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\nimport string\nfrom math import gcd\nimport getpass\nimport math\nfrom decimal import Decimal\nimport pprint\n\n\ndef ria():\n    return [int(i) for i in input().split()]\n\n\nif getpass.getuser() != 'frohenk':\n    filename = 'half'\n    # sys.stdin = open('input.txt')\n    # sys.stdout = open('output.txt', 'w')\nelse:\n    sys.stdin = open('input.txt')\n    # sys.stdin.close()\n# sys.stdout = open('output.txt', 'w')\n\n\nla, ra, ta = ria()\nlb, rb, tb = ria()\nif ta > tb:\n    la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta\n\ngc = gcd(tb, ta)\nif gc == 1:\n    print(min(ra - la + 1, rb - lb + 1))\n    exit(0)\n\n\ndef get(st):\n    global la, ra, ta, lb, rb, tb\n    lc = la + st\n    rc = ra + st\n    return max(min(rc, rb) - max(lc, lb) + 1, 0)\n\n\nsta = la // gc\nstb = lb // gc\nfna = ra // gc\nfnb = rb // gc\n\nmx = 0\n\nmx = max(mx, get((stb - sta) * gc))\nmx = max(mx, get((stb - sta + 1) * gc))\nmx = max(mx, get((stb - sta + 2) * gc))\nmx = max(mx, get((stb - sta - 1) * gc))\nmx = max(mx, get((stb - sta - 2) * gc))\n\nmx = max(mx, get((fnb - fna) * gc))\nmx = max(mx, get((fnb - fna + 1) * gc))\nmx = max(mx, get((fnb - fna + 2) * gc))\nmx = max(mx, get((fnb - fna - 1) * gc))\nmx = max(mx, get((fnb - fna - 2) * gc))\n\n#print(stb - sta)\nprint(mx)\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "fb8aaeec0753c3a2935e7a4646b26e93", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "def LB(l,d,lim):\n\ts,e = 0,10**l - 1;\n\twhile s < e:\n\t\tm = (s + e) >> 1;\n\t\tf = str(m);\n\t\tf = \"0\"*(l - len(f)) + f;\n\t\tf = int(str(d) + f + str(d));\n\t\tif f >= lim: e = m;\n\t\telse : s = m + 1;\n\tf = str(s);\n\tf = \"0\"*(l - len(f)) + f;\n\tf = int(str(d) + f + str(d));\n\treturn s + (f < lim);\n\ndef get(l,d,x,y):\n\t#if l == 2 and d == 1: print LB(l,d,y + 1) ,LB(l,d,x)\n\treturn LB(l,d,y + 1) - LB(l,d,x);\t\t\n\nx,y = map(int,raw_input().split());\nans = max(min(y,9) - max(x,1) + 1,0);\n#print ans;\nfor l in xrange(18):\n\tif l:\n\t\tfor d in xrange(1,10):\n\t\t\ttmp = get(l,d,x,y);\n\t\t\tans += tmp;\n\t#\t\tprint l,d,tmp;\n\telse:\n\t\ttmp = 11;\n\t\twhile tmp <= 99:\n\t\t\tans += (x <= tmp) and (tmp <= y);\n\t\t\ttmp += 11;\nprint ans;", "lang_cluster": "Python", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "585e6cc99f45189f6f9f2f6aabb1d295", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "[w,h] = [int(x) for x in input().split()]\n[u1,d1] = [int(x) for x in input().split()]\n[u2,d2] = [int(x) for x in input().split()]\n\nfor i in range(0,h+1):\n    height = h-i\n    w += height\n    if height == d1:\n        w = max(0,w-u1)\n    if height == d2:\n        w = max(0, w - u2)\nprint(w)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "1863378d5f09b5406b22a38ea2da1e87", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\n\ndef parse(s, rad):\n    if len(s) == 0:\n        return 0\n    else:\n        s, t = s[:-1], s[-1:]\n\n        if '0' <= t <= '9':\n            t = ord(t) - ord('0')\n        elif 'A' <= t <= 'Z':\n            t = 10 + ord(t) - ord('A')\n\n        if t >= rad:\n            return 5000000\n\n        return rad * parse(s, rad) + t\n\nh, m = sys.stdin.readline().rstrip('\\n').split(':')\n\nph = [r for r in range(1, 65) if parse(h, r) < 24]\npm = [r for r in range(1, 65) if parse(m, r) < 60]\n\npp = sorted(set(ph) & set(pm))\n\nif 64 in pp:\n    print -1\nelif len(pp) == 0:\n    print 0\nelse:\n    print ' '.join(str(p) for p in pp)\n\n\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "ef4525e975e7c721ab95b36197d59f50", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "board = []\nb, w = 'B', 'W'\ncheck = False\nfor i in range(8):\n    board.append(str(input()))\nfor i in board:\n    a = w+b\n    if 'BB' in i or 'WW' in i:\n        print(\"NO\")\n        check = True\n        break\n\n    if i != a*4:\n        i = i[-1] + i[:7]\n        if i != a*4:\n            print(\"NO\")\n            check = True\n            break\n    b, w = w, b\nif check == False:\n    print(\"YES\")", "lang_cluster": "Python", "tags": ["brute force", "strings"], "code_uid": "ba2a0eea1310e12733fc5de00836c934", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from collections import deque\nfrom sys import stdin\nlines = deque(line.strip() for line in stdin.readlines())\n\ndef nextline():\n    return lines.popleft()\n\ndef types(cast, sep=None):\n    return tuple(cast(x) for x in strs(sep=sep))\n\ndef ints(sep=None):\n    return types(int, sep=sep)\n\ndef strs(sep=None):\n    return tuple(nextline()) if sep == '' else tuple(nextline().split(sep=sep))\n\ndef main():\n    # lines will now contain all of the input's lines in a list\n    ints()\n    first_pairs = ints()\n    first_pairs = tuple(first_pairs[i:i+2] for i in range(0, len(first_pairs), 2))\n    second_pairs = ints()\n    second_pairs = tuple(second_pairs[i:i+2] for i in range(0, len(second_pairs), 2))\n    def compute(p1, p2):\n        candidates = []\n        for a, b in p1:\n            # assume a, b are the real pair\n            a_pairs = 0\n            b_pairs = 0\n            for c, d in p2:\n                if len(set([a, b, c, d])) != 3:\n                    continue\n                if len(set([a, c, d])) == 2:\n                    a_pairs += 1\n                if len(set([b, c, d])) == 2:\n                    b_pairs += 1\n            if a_pairs > 0 and b_pairs > 0:\n                return -1\n            if a_pairs + b_pairs > 0:\n                candidates.append((a, b))\n        return candidates\n    r1 = compute(first_pairs, second_pairs)\n    if r1 == -1:\n        return -1\n    r2 = compute(second_pairs, first_pairs)\n    if r2 == -1:\n        return -1\n    if not r1 or not r2:\n        return -1\n    shared_number = 0\n    for a, b in r1:\n        for c, d in r2:\n            if a == c and b != d or a == d and b != c:\n                if shared_number and a != shared_number:\n                    return 0\n                shared_number = a\n            if b == c and a != d or b == d and a != c:\n                if shared_number and b != shared_number:\n                    return 0\n                shared_number = b\n    if shared_number:\n        return shared_number\n    return -1\n\nif __name__ == '__main__':\n    print(main())\n", "lang_cluster": "Python", "tags": ["bitmasks"], "code_uid": "410e9c13f0f23e70fa03e2082441df91", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"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    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\n            d[i1][j1][1 ^ shore][0] %= 10 ** 9 + 7\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", "tags": ["dp", "combinatorics", "graphs", "shortest paths"], "code_uid": "95cb9c03cdaa1c1fb1e06a1d9ceae682", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import bisect\nn,m = map(int,input().split())\na = [int(x) for x in input().split()]\nb = []\notv = 0\nfor i in range(0,1<<(n//2 + n%2)):\n    t = 0\n    k = i\n    for j in range(20):\n        if k & 1:\n            t += a[j]\n        k = k >> 1\n    b.append(t%m)\nb.sort()       \nfor i in range(0,1<<(n//2)):\n    t = 0\n    k = i\n    for j in range(20):\n        if k & 1:\n            t += a[(n//2 + n%2) + j]\n        k = k >> 1\n    t = t % m\n    k = bisect.bisect_left(b,m - t - 1)\n    if k < len(b):\n        t2 = b[k]\n        if t2 > m - t - 1:\n            if k - 1 >= 0:\n                t2 = b[k - 1]\n    else:\n        t2 = b[-1]\n    otv = max(otv,(t + t2)%m,(t + b[-1])%m)\nprint(otv % m)\n            \n\n", "lang_cluster": "Python", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "1f6e29aeac5c56e4353efe1031503d31", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "ll = [int(x) for x in input().split()]\n\nl = ll[:]\n\ndef ok(l):\n\tfor i in range(6):\n\t\tfor j in range(4):\n\t\t\tif l[i * 4 + j] != l[i * 4]:\n\t\t\t\treturn\n\tprint('YES')\n\texit(0)\n\n\na = l[2]\nl[2] = l[16]\nl[16] = l[9]\nl[9] = l[15]\nl[15] = a\n\na = l[3]\nl[3] = l[18]\nl[18] = l[8]\nl[8] = l[13]\nl[13] = a\n\nok(l)\n\nfor i in range(2):\n\ta = l[2]\n\tl[2] = l[16]\n\tl[16] = l[9]\n\tl[9] = l[15]\n\tl[15] = a\n\n\ta = l[3]\n\tl[3] = l[18]\n\tl[18] = l[8]\n\tl[8] = l[13]\n\tl[13] = a\n\nok(l)\n\nl = ll[:]\na = l[12]\nl[12] = l[11]\nl[11] = l[16]\nl[16] = l[4]\nl[4] = a\n\na = l[13]\nl[13] = l[10]\nl[10] = l[17]\nl[17] = l[5]\nl[5] = a\n\nok(l)\n\nfor i in range(2):\n\ta = l[12]\n\tl[12] = l[11]\n\tl[11] = l[16]\n\tl[16] = l[4]\n\tl[4] = a\n\n\ta = l[13]\n\tl[13] = l[10]\n\tl[10] = l[17]\n\tl[17] = l[5]\n\tl[5] = a\nok(l)\n\nl = ll[:]\na = l[6]\nl[6] = l[18]\nl[18] = l[22]\nl[22] = l[14]\nl[14] = a\n\na = l[7]\nl[7] = l[19]\nl[19] = l[23]\nl[23] = l[15]\nl[15] = a\nok(l)\n\nfor i in range(2):\n\ta = l[6]\n\tl[6] = l[18]\n\tl[18] = l[22]\n\tl[22] = l[14]\n\tl[14] = a\n\n\ta = l[7]\n\tl[7] = l[19]\n\tl[19] = l[23]\n\tl[23] = l[15]\n\tl[15] = a\nok(l)\n\nl = ll[:]\na = l[0]\nl[0] = l[4]\nl[4] = l[8]\nl[8] = l[23]\nl[23] = a\n\na = l[2]\nl[2] = l[6]\nl[6] = l[10]\nl[10] = l[21]\nl[21] = a\nok(l)\n\nfor i in range(2):\n\ta = l[0]\n\tl[0] = l[4]\n\tl[4] = l[8]\n\tl[8] = l[23]\n\tl[23] = a\n\n\ta = l[2]\n\tl[2] = l[6]\n\tl[6] = l[10]\n\tl[10] = l[21]\n\tl[21] = a\nok(l)\n\nprint('NO')", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "3b77a352c0b3b038778539958dd88c64", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "r, g, b = map(int, input().split())\nprint(max([((r+1)//2 - 1) * 3, ((g+1)//2 - 1) * 3 + 1, ((b+1)//2 - 1) * 3 + 2]) + 30)", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "57fad86908be5d589039e698597105f1", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = raw_input()\na = map(int, raw_input().split())\nb = map(int, raw_input().split())\nres = 0\nfor x in range(1, 6):\n    n = a.count(x) + b.count(x)\n    if(n % 2 == 1):\n        print -1\n        exit()\n    else:\n        res += abs(n / 2 - a.count(x))\nprint res / 2", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "efa4219fd18fbe76e66553bb3a468335", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n = int(raw_input()) % 360\nif n < 0:\n    n += 360\n\nif n > 180:\n    n = -360 + n\n\nif abs(n) <= 45:\n    print 0\nelif 45 <= n <= 135:\n    print 1\nelif -135 < n < -45:\n    print 3\nelse:\n    print 2\n", "lang_cluster": "Python", "tags": ["math", "geometry"], "code_uid": "742436e466bea1695870559e4dff5239", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = input()\n\nif n%2 == 0:\n    print n/2\nelse:\n    for i in xrange(2, int(n**0.5)+1):\n        if n%i == 0:\n            print (n-i)/2 + 1\n            break\n    else:\n        print 1", "lang_cluster": "Python", "tags": ["math", "implementation", "number theory"], "code_uid": "43c1744bf43a97b17ef35323d96f0c4f", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "Line=raw_input()\nColors=[]\nfor c in Line:Colors.append(c)\nGlobal=set()\nAns=0\n#print Colors\n\ndef LtoS(L):\n    S=\"\"\n    for c in L:S=S+str(c)\n    return S\n\ndef moveUp(L):\n    Colors2=[0]*6\n    Colors2[0]=L[3]\n    Colors2[1]=L[5]\n    Colors2[4]=L[4]\n    Colors2[2]=L[2]\n    Colors2[3]=L[1]\n    Colors2[5]=L[0]\n    return Colors2\ndef moveRight(L):\n    Colors2=[0]*6\n    Colors2[0]=L[4]\n    Colors2[1]=L[2]\n    Colors2[5]=L[5]\n    Colors2[3]=L[3]\n    Colors2[2]=L[0]\n    Colors2[4]=L[1]\n    return Colors2\ndef Turn(L):\n    Colors2=[0]*6\n    Colors2[0]=L[0]\n    Colors2[1]=L[1]\n    Colors2[2]=L[5]\n    Colors2[4]=L[3]\n    Colors2[5]=L[4]\n    Colors2[3]=L[2]\n    return Colors2\n\n\n\n\nitern=0\nFuckingNew=False\nfor st1 in xrange(6):\n    for st2 in xrange(6):\n        for st3 in xrange(6):\n            for st4 in xrange(6):\n                for st5 in xrange(6):\n                    for st6 in xrange(6):\n                        itern+=1\n                        s=set()\n                        s.add(st1)\n                        s.add(st2)\n                        s.add(st3)\n                        s.add(st4)\n                        s.add(st5)\n                        s.add(st6)\n                        if(len(s)!=6):continue\n                        FuckingNew=False\n                        List=[Colors[st1],Colors[st2],Colors[st3],Colors[st4],Colors[st5],Colors[st6]]\n                        def check():\n                             global FuckingNew\n                             global Ans\n                            # print List\n                             if not LtoS(List) in Global:\n                              if not FuckingNew:\n                                  Ans=Ans+1\n                                  FuckingNew=True\n                                #  print Global\n                              Global.add(LtoS(List))\n                        for c in xrange(4):\n                         check()\n                         List=Turn(List)\n                        List=moveUp(List)\n                        for c in xrange(4):\n                          check()\n                          List=Turn(List)\n                        List=moveUp(List)\n                        for c in xrange(4):\n                          check()\n                          List=Turn(List)\n                        List=moveUp(List)\n                        for c in xrange(4):\n                          check()\n                          List=Turn(List)\n                        List=moveUp(List)\n                        for c in xrange(4):\n                          check()\n                          List=Turn(List)\n                        List=moveRight(List)\n                        for c in xrange(4):\n                           check()\n                           List=Turn(List)\n                        List=moveRight(List)\n                        List=moveRight(List)\n                        for c in xrange(4):\n                           check()\n                           List=Turn(List)\n\n                       # print itern,Global\n\n\n\n\n\n\n                        #Kataem:\n\n#print Global\nprint Ans\n                        \n\n\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "2aee26b32d114ee08548b9918c02a6b9", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a, b = map(int, input().split())\nc, d = map(int, input().split())\nans = -1\n\nfor i in range(100):\n    for j in range(100):\n        if i*a+b == c*j+d:\n            ans = c*j+d\n            print(ans)\n            exit()\nprint(ans)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "90432f10624293798d78fe149ecd4a93", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n = raw_input()\nprint '%05d' % pow(int(n[0] + n[2] + n[4] + n[3] + n[1]), 5, 10**5)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "9e22f9f39f9588eb1cf90caaf4129ba2", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "p, y = [int(x) for x in input().split()]\nres = -1\nfor i in range(y, p, -1):\n    flag = True\n    for a in range(2, min(p+1, int(i**0.5)+1)):\n        if i % a == 0:\n            flag = False\n            break\n    if flag:\n        res = i\n        break\nprint(res)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "number theory"], "code_uid": "91b049b463f7a7123db237b4f0ba2e0e", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a, b = [int(x) for x in input().split(' ')]\nif abs(a - b) <= 1 and max(a, b) > 0:\n    print('YES')\nelse:\n    print('NO')", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "a651ed66937753c22fd86b2cc16a750a", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "r1, r2, wk, bk = map (lambda x: [int (ord (x[0]) - ord ('a') + 1) - 1, int (x[1]) - 1], raw_input ().split ())\nfield = [[0 for j in xrange (8)] for i in xrange (8)]    \nmoves = ((0, 0), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1))\nvalid = lambda x, y: 0 <= x[0] + y[0] < 8 and 0 <= x[1] + y[1] < 8 \nf = lambda r, i, o, z: (wk[z] != r[z] or (i - wk[o]) * (r[o] - wk[o]) > 0) and r[o] != i\nfor i in xrange (8):\n    field[r1[0]][i] = f (r1, i, 1, 0) or field[r1[0]][i]\n    field[i][r1[1]] = f (r1, i, 0, 1) or field[i][r1[1]]\n    field[r2[0]][i] = f (r2, i, 1, 0) or field[r2[0]][i]\n    field[i][r2[1]] = f (r2, i, 0, 1) or field[i][r2[1]]\nfor mv in moves:\n    if valid (wk, mv):\n        field[wk[0] + mv[0]][wk[1] + mv[1]] = 1\nprint 'CHECKMATE' if all ([field[mv[0] + bk[0]][mv[1] + bk[1]] for mv in moves if valid(bk, mv)]) else 'OTHER'\n\n            \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "e6ae83187bf7653a88d36479c50ab03c", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\na,b,n=map(int,input().split())\nc=0\nwhile(n!=0):\n    if(n>0):\n        n-=math.gcd(a,n)\n        c+=1\n        #print(n)\n    if(n>0):\n        n-=math.gcd(b,n)\n        #print(n)\n        c+=1\n    \nif(c%2!=0):\n    print(\"0\")\nelse:\n    print(\"1\")\n    \n    ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "013814e31d13c35bb4ad02f9a2008610", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from functools import lru_cache\r\nimport itertools\r\ndef invnum(seq):\r\n    N=len(seq)\r\n    res=0\r\n    for i in range(N):\r\n        for j in range(i+1,N):\r\n            if seq[i]>seq[j]:\r\n                res+=1\r\n    return res\r\ndef naive(N,k,flag):\r\n    res=0\r\n    for p in itertools.permutations(range(N),N):\r\n        for q in itertools.permutations(range(N),N):\r\n            if ((p<q) or (not(flag))) and (invnum(p)-invnum(q)>k):\r\n                res+=1\r\n    return res\r\nn,mod=map(int,input().split())\r\nmemo=[[{},{}] for _ in range(n+1)]\r\ndef solve(N,k,flag):\r\n    if k in memo[N][flag]:\r\n        return memo[N][flag][k]\r\n    '''\r\n    \u9577\u3055N\u306e\u9806\u5217\r\n    invnum(p)-invnum(q)>k\u3068\u306a\u308b\u5834\u5408\u306e\u6570\r\n    flag=True p<q\u306e\u6761\u4ef6\u3042\u308a\r\n    flag=False p<q\u306e\u6761\u4ef6\u306a\u3057\r\n    '''\r\n    if N==1:\r\n        res=-1\r\n        if flag:\r\n            res=0\r\n        else:\r\n            if k<0:\r\n                res=1\r\n            else:\r\n                res=0\r\n        memo[N][flag][k]=res\r\n        return res\r\n    invnum_INF=(N*(N-1))//2\r\n    if k<-invnum_INF-1:\r\n        res=solve(N,-invnum_INF-1,flag)\r\n        memo[N][flag][k]=res\r\n        return res\r\n    if k>=invnum_INF:\r\n        memo[N][flag][k]=0\r\n        return 0\r\n    res=0\r\n\r\n    for delta in range(-N+1,N):\r\n        if flag and (delta>0):\r\n            continue\r\n        wt=min(N-delta,delta+N)\r\n        res+=solve(N-1,k-delta,(delta==0)&flag)*wt\r\n        res%=mod\r\n    memo[N][flag][k]=res%mod\r\n    return res%mod\r\nans=solve(n,0,1)%mod\r\nprint(ans)\r\n\r\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "68e15d4735a067225d35c8ae306413f5", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nstdin = sys.stdin\n\nn, q = map(int, stdin.readline().strip().split())\n\nqs = []\nfor i in range(q):\n    aa, bb = stdin.readline().strip().split()\n    qs.append((list(reversed(aa)), bb))\n\nsts = set()\ndef dfs(have):\n    if len(have) == n:\n        sts.add(''.join(have))\n    else:\n        for aa, bb in qs:\n            if have[-1] == bb:\n                dfs(have[:-1] + aa)\n                \ndfs(['a'])\nprint len(sts)\n", "lang_cluster": "Python", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "81f51323c411f1ed488d5d010fd6b7ab", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s=raw_input()\nn=input()\nm=len(s)\nINF = 1000\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;l[0][0][k] = 0\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            # 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\nans = -INF\nfor k in range(2):\n    for j in range(min(n,m)+1):\n        if j%2==n%2:\n            ans = max(ans,-l[m][j][k])\n            ans = max(ans,r[m][j][k])\nprint ans", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "2e0ce00c03489a4c017e28f6c2ca5d10", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "R=lambda:map(int,raw_input().split())\np=[R(),R(),R()]\ndef T(i,j,k):\n  x,y,u,v,a,b=p[i]+p[j]+p[k]\n  return (x==u and not(y<b<v or v<b<y)) or (y==v and not(x<a<u or u<a<x))\nif p[0][0]==p[1][0]==p[2][0] or p[0][1]==p[1][1]==p[2][1]:\n  print 1\nelif T(0,1,2) or T(1,2,0) or T(2,0,1):\n  print 2\nelse:\n  print 3\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "f81a2ba1c28f24a8df03fa11a522b4c7", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "s = input() + 'X' * int(input())\nfor v in range(len(s) - len(s) % 2, 0, -2):\n    for i in range(len(s) - v + 1):\n        if all(s[j + v // 2] in ('X', s[j]) for j in range(i, i + v // 2)):\n            print(v), exit()", "lang_cluster": "Python", "tags": ["brute force", "strings", "implementation"], "code_uid": "d5a3bc1bd6308b3e3dc049119053a1c1", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nfrom collections import defaultdict\nn = int(sys.stdin.readline())\ncards = sys.stdin.readline().strip().split()\nfirst = set()\nsecond = set()\ncur = tuple(cards[-4:])\nfirst.add(cur)\n\n#print cur\n\nfor i in xrange(n-1,0,-1):\n    #print \"i = \", i\n    second = set()\n    for elem in first:\n        #print \"elem =\", elem\n        newList = [cards[i-4]] if i-4 >= 0 else []\n        #print \"newList =\", newList\n        if elem[-1][0] == elem[-2][0] or elem[-1][1] == elem[-2][1]:\n            anotherTuple = tuple(newList + list(elem)[:-2] + [elem[-1]])\n            second.add(anotherTuple)\n        if len(elem) == 4 and (elem[-1][0] == elem[0][0] or elem[-1][1] == elem[0][1]):\n            anotherTuple = tuple(newList + [elem[3]] + [elem[1]] + [elem[2]])\n            second.add(anotherTuple)\n    first = second\n    \nprint 'YES' if len(first) > 0 else 'NO'\n\t", "lang_cluster": "Python", "tags": ["dfs and similar", "dp"], "code_uid": "d5eae578142926167faac6012f1447a4", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nimport sys\n\ndef main():\n  n = int(raw_input())\n  s = raw_input()\n  for i in range(1, 100): # jump length\n    for j in range(len(s)): # start index\n      good = True\n      for k in range(5): # jumps\n        if j + k*i >= n or s[j + k*i] == '.':\n          good = False\n          break\n      if good:\n        print 'yes'\n        return\n  print 'no'\n\n\nif __name__ == '__main__':\n  main()\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "c314ef23c7945a19556c291c21382dc6", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "x,y,z,k=map(int,raw_input().split())\nx,y,z = sorted([x,y,z])\nx-=1 \ny-=1\nz-=1\nif x>k/3: x=k/3\nk-=x\nif y>k/2: y=k/2\nk-=y\nif z>k: z=k\n\nprint (x+1)*(y+1)*(z+1)", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "8c472ff648f2ac4e888036b1b000561c", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys,heapq\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif a<b: a,b=b,a\n\nif b==0:\n    # 1 01 001 0001 ... is optimal, plus a long series of 0's\n    print((n-1)*a)\nelse:\n    # pascal's triangle thing\n    pascal=[[1]*20005]\n    for i in range(20004):\n        newrow=[1]\n        for j in range(1,20005):\n            newrow.append(newrow[-1]+pascal[-1][j])\n            if newrow[-1]>n: 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", "tags": ["greedy", "dp"], "code_uid": "e5ebc39aca719b857ef391d2e566ae9e", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "(n,m)=map(int, raw_input().split())\ncount=0\nfor i in range(0,n):\n    p=(i+1)%5\n    count=count+(p+m)/5;\nprint count", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "9309dd35e5af0c469fe905eea1914bc9", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#D razbor 1\n\ndef func(n):\n    if n<8:\n        return n,n\n    \n    max_a = int(n**(1/3))\n    if (max_a+1)**3<=n:\n        max_a += 1\n    \n    v1=func(n-max_a**3)\n    v1=(v1[0]+1,v1[1]+max_a**3)\n    \n    v2=func(max_a**3-1-(max_a-1)**3)\n    v2=(v2[0]+1,v2[1]+(max_a-1)**3)\n    \n    if v2>v1:\n        return v2\n    else:\n        return v1\n\n\nprint(' '.join(map(str, func(int(input())))))  ", "lang_cluster": "Python", "tags": ["brute force", "greedy", "constructive algorithms", "binary search"], "code_uid": "5f2c773ab846b2f93540a547db5c3813", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def find(n,k):\n    if k==0:\n        return False\n    count=0\n    t=n\n    while n>0:\n        if n<k:\n            count+=n\n            n=0\n        else:\n            count+=k\n            n-=k \n        n=n-n//10\n    if 2*count>=t:\n        return True\n    else:\n        return False\n        \ndef binarySearch(l,r,n):\n    while l<=r:\n        mid=l+(r-l)//2\n        c=find(n,mid)\n        c1=find(n,mid-1)\n        c2=find(n,mid+1)\n        if c and not c1:\n            return mid   \n        elif c:\n            r=mid-1 \n        else:\n            l=mid+1\n\nn=int(input())\nprint(binarySearch(1,n,n))", "lang_cluster": "Python", "tags": ["implementation", "binary search"], "code_uid": "95d5394e0a400249e4fdc544b5961d7f", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "input()\na = [0]*4\ns = input()\n\nfor i in s:\n    if i == \"U\":\n        a[0] += 1\n    elif i == \"D\":\n        a[1] += 1\n    elif i == \"L\":\n        a[2] += 1\n    elif i == \"R\":\n        a[3] += 1\n\nprint (min(a[0], a[1])*2+min(a[2], a[3])*2)", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "1954759869a4aa8c943b6fd08a60457a", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "i = input()\nx = int(i)\ncont = 0\nwhile x:\n    x -= int(max(i))\n    i = str(x)\n    cont += 1\nprint(cont)\n", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "d64fa7f334d8553edfa9e7543baaa433", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/env python3 \n\nimport itertools\n\nnotes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H']\n\nn = [notes.index(n) for n in input().strip().split()]\n\nfor (X,Y,Z) in itertools.permutations(n):\n  d1 = Y-X\n  if (d1 < 0):\n    d1+=12\n  d2 = Z-Y\n  if (d2 < 0):\n    d2+=12\n  if (d1 == 4) and (d2 == 3):\n    print(\"major\")\n    exit()\n  if (d1 == 3) and (d2 == 4):\n    print(\"minor\")\n    exit()\n\nprint(\"strange\")\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "89866317b40d9757e222befaef5b53fd", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n=input();print[0,1,18,1800,670320,734832000,890786230,695720788,150347555][n%2*-~n/2]\n", "lang_cluster": "Python", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "039dc8b40222792f7f431eaaa1d87a1c", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def main():\n    elements = [\"H\", \"He\", \"Li\", \"Be\", \"B\", \"C\", \"N\", \"O\", \"F\", \"Ne\", \"Na\", \"Mg\", \"Al\", \"Si\", \"P\", \"S\", \"Cl\", \"Ar\", \"K\",\n                \"Ca\", \"Sc\", \"Ti\", \"V\", \"Cr\", \"Mn\", \"Fe\", \"Co\", \"Ni\", \"Cu\", \"Zn\", \"Ga\", \"Ge\", \"As\", \"Se\", \"Br\", \"Kr\",\n                \"Rb\", \"Sr\", \"Y\", \"Zr\", \"Nb\", \"Mo\", \"Tc\", \"Ru\", \"Rh\", \"Pd\", \"Ag\", \"Cd\", \"In\", \"Sn\", \"Sb\", \"Te\", \"I\",\n                \"Xe\", \"Cs\", \"Ba\", \"La\", \"Ce\", \"Pr\", \"Nd\", \"Pm\", \"Sm\", \"Eu\", \"Gd\", \"Tb\", \"Dy\", \"Ho\", \"Er\", \"Tm\", \"Yb\",\n                \"Lu\", \"Hf\", \"Ta\", \"W\", \"Re\", \"Os\", \"Ir\", \"Pt\", \"Au\", \"Hg\", \"Tl\", \"Pb\", \"Bi\", \"Po\", \"At\", \"Rn\", \"Fr\",\n                \"Ra\", \"Ac\", \"Th\", \"Pa\", \"U\", \"Np\", \"Pu\", \"Am\", \"Cm\", \"Bk\", \"Cf\", \"Es\", \"Fm\", \"Md\", \"No\", \"Lr\", \"Rf\",\n                \"Db\", \"Sg\", \"Bh\", \"Hs\", \"Mt\", \"Ds\", \"Rg\", \"Cn\", \"Nh\", \"Fl\", \"Mc\", \"Lv\", \"Ts\", \"Og\"]\n    elements = [s.upper() for s in elements]\n    s = input()\n    f = [True] + [False] * len(s)\n    for i in range(len(s)):\n        if not f[i]:\n            continue\n        for e in elements:\n            if s[i:].startswith(e):\n                f[i + len(e)] = True\n    print(\"YES\" if f[len(s)] else \"NO\")\n\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["brute force", "strings", "dp"], "code_uid": "f8725fea4b66b415c193f203ae128008", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from math import factorial as fact\nn = input ()\nM = 1000000007\n\ndef egcd (a, b):\n    if a % b == 0:\n        return (0, 1)\n    x = egcd (b, a % b)\n    return (x[1], x[0] - x[1] * (a / b))\n\ndef C (n, k): \n    a = 1\n    for i in xrange (n - k + 1, n + 1):\n        a *= i\n        a %= M\n    b = 1\n    for i in xrange (1, k + 1):\n        b *= i\n        b %= M\n    return (a * egcd (b, M)[0]) % M\n    \nprint (2 * C (n * 2 - 1, n) - n) % M\n\n", "lang_cluster": "Python", "tags": ["math", "combinatorics"], "code_uid": "4082179e67958ae9796965a2e9e04a50", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import bisect\ndef LIS(As):\n    L = [As[0]]\n    for a in As[1:]:\n        if a >= 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    else:\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", "tags": ["dp", "constructive algorithms"], "code_uid": "447136ef191b638fe69854a5ac24ba63", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nimport random\nimport sys\n\ndef main(s):\n    \n    if (len(s)==1 and (s[0]==\"0\" or s[0]==\"_\" or s[0]==\"X\")):\n        return 1\n    elif (s[0]==\"0\" and len(s)>1):\n        return 0\n    elif (len(s)==1):\n        return 0\n    mult1=1\n    mult2=1\n    f=False\n    for i in range(len(s)-2): \n\n        if s[i]==\"_\":\n            if (i!=0):\n                mult1*=10\n            else:\n                mult1*=9\n        elif s[i]==\"X\" and mult2==1:\n            if (i!=0):\n                mult2=10 \n            else:\n                mult2=9 \n                f=True\n    ans=0\n    for i in range(100):\n        if (i%25)!=0:\n            continue\n        val=list([c for c in str(i)]) \n        if (i==0):\n            val=[\"0\",\"0\"]\n        \n        mult_val=mult2\n        check=[s[-2],s[-1]]\n\n        if check[0]==\"X\":\n            if (val[0]=='0' and f):\n                continue\n            check[0]=val[0] \n            mult_val=1\n            if check[1]==\"X\":\n                \n                check[1]=val[0] \n                \n        if (check[1]==\"X\" and check[0] !=\"X\"):\n            if (val[1]=='0' and f):\n                continue\n            check[1]=val[1] \n            mult_val=1\n        if (check[0]==\"_\"):\n            check[0]=val[0]\n        if (check[1]==\"_\"):\n            check[1]=val[1] \n        if (val==check) and not (len(s)==2 and check[0]==\"0\"):\n            ans+=mult_val*mult1\n\n    return ans\n    \n\n            \ns=input() \nprint(main(s))\n\n\n\n                    \n                    \n\n            \n            \n", "lang_cluster": "Python", "tags": ["brute force", "dp", "dfs and similar"], "code_uid": "4119344ec5ad3e0ebe597956ab8fbfc8", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = input()\r\nwhile n[1:]:\r\n    n = str(sum(map(int, n)))\r\nprint(n)", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "78b6416630ecb3982527da45bf16f9f2", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from fractions import gcd\n\nn = input()\nH = dict()\ninf = 10000000\n\ndef number (n,b):\n    s = 0\n    while b>1:\n        s += n/b\n        n,b = b,n%b\n    if b==1: return s+n-1\n    else:    return inf\n\nm = inf\nfor b in range(1,(n+1)/2+1):\n    m = min (number(n,b),m)\nprint m\n    \n", "lang_cluster": "Python", "tags": ["dfs and similar", "math", "number theory", "brute force"], "code_uid": "3c0f9d4fb2698b14254285d95ca84562", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\n\n\ndef cnt(n, x):\n    res = 0\n    while n > x:\n        n //= 2\n        res += 1\n    if n == x:\n        return res\n    return -1\n\n\ndef main():\n    n, k = map(int, input().split())\n    a = list(map(int, input().split()))\n    b = set()\n    b.add(0)\n    for i in a:\n        while i > 0:\n            b.add(i)\n            i //= 2\n    ans = int(10e9)\n    for x in b:\n        s = []\n        for i in a:\n            c = cnt(i, x)\n            if c >= 0:\n                s.append(c)\n        s.sort()\n        if len(s) >= k:\n            l = sum(s[:k])\n            ans = min(ans, l)\n    print(ans)\n\nmain()\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "3461a889a04136908e592bf61c160f18", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def rev(x):\n    res = int(str(x)[::-1])\n    return res\ndef primes_sieve(n):\n    sieve = [True] * n\n    for i in range(3, int(n ** .5) + 1, 2):\n        if sieve[i]:\n            sieve[i * i :: 2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)\n    return sieve\narr = primes_sieve(1000000)\nn = int(input())\nprint([i for i in range(3, 1000000, 2) if i != rev(i) and rev(i) % 2 and arr[i] and arr[rev(i)]][n - 1])", "lang_cluster": "Python", "tags": ["brute force", "implementation", "number theory"], "code_uid": "19f6bb4b3293d0b399d526b06f57121b", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from operator import itemgetter\n\nn = list(map(int, list(input())))\nl = n[:3:]\nr = n[3::]\nls = sum(l)\nrs = sum(r)\n\nans = []\nans1 = []\nfor i in range(3):\n    ans.append([9 - l[i], 1])\n    ans.append([r[i], 2])\n    ans1.append([9 - r[i], 2])\n    ans1.append([l[i], 1])\ncnt = 0\nans.sort(key=itemgetter(0), reverse=True)\nans1.sort(key=itemgetter(0), reverse=True)\nif ls < rs:\n    i = 0\n    while ls < rs:\n        if ans[i][1] == 1:\n            ls += ans[i][0]\n            cnt += 1\n        else:\n            rs -= ans[i][0]\n            cnt  += 1\n        i += 1\n    print(cnt)\n\nelif ls > rs:\n    i = 0\n    while ls > rs:\n        if ans1[i][1] == 1:\n            ls -= ans1[i][0]\n            cnt += 1\n        else:\n            rs += ans1[i][0]\n            cnt  += 1\n        i += 1\n    print(cnt)\n\nelse:print(0)", "lang_cluster": "Python", "tags": ["brute force", "greedy", "implementation"], "code_uid": "44bea78f1cfd993bdc1cd51405909e20", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"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", "tags": ["implementation"], "code_uid": "26527f1a58b993877fa7b77830ae430a", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s=raw_input().strip()\ny,x=0,0\nseen=[(y,x)]\nb=False\nfor i in s:\n    if i=='L':x-=1\n    elif i=='R':x+=1\n    elif i=='U':y-=1\n    else:y+=1\n    co=0\n    for y2,x2 in seen:\n        if abs(y2-y)+abs(x2-x)<=1:\n            co+=1\n    seen.append((y,x))\n    if co>1:b=True\nprint 'BUG' if b else 'OK'\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "16d609cc62d8c3f03af93633f39bf46f", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from sys import stdin\nn=int(stdin.readline().strip())\nx=n-2+n-3+n-3+(n-4)*(n-3)\nprint(x)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "ae080d05dd0b569302560ad482e44c4e", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "li=lambda:(map(int,raw_input().strip().split()))\nni=lambda:(int(raw_input()))\nsi=lambda:(raw_input())\nimport math\nfrom collections import Counter\nn=ni()\nr=si()\nl=len(r)\ng=1\nfor i in range(0,l-1):\n    if r[i]==r[i+1]:\n        if r[i]==\"?\":\n            continue\n        else:\n            print \"No\"\n            exit(0)\ni=0\nif r[i]==\"?\" or r[l-1]==\"?\":\n    print \"Yes\"\n    exit(0)\nfor i in range(1,l-2):\n    if r[i]==\"?\":\n        if r[i-1]!=r[i+1] and r[i-1]!=\"?\" and r[i+1]!=\"?\":\n            g=1\n        else:\n            g=2\n            print \"Yes\"\n            exit(0)\n            break\nif g==1:\n    print \"No\"", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "3d797731845954dd10c99094e35e5b28", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "lst=list(map(int,input().split()))\nd={}\nfor k in lst:\n    d[k]=lst.count(k)\nsm=[]    \nfor k in d:\n    if d[k]==2:\n        sm.append(d[k]*k)\n    elif d[k]>=3:\n        sm.append(k*3)\n\nif len(sm)!=0:\n    print(sum(lst)-max(sm))\nelse:\n    print(sum(lst))", "lang_cluster": "Python", "tags": ["constructive algorithms", "implementation"], "code_uid": "77970b9d5c990ae4dd4dd61e1b3481fe", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "#import resource\nimport sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\n#threading.Thread(target=main).start()\n#import threading\n#threading.stack_size(2**26)\n#sys.setrecursionlimit(10**7)\nmod=(10**9)+7\n#fact=[1]\n#for i in range(1,1001):\n#    fact.append((fact[-1]*i)%mod)\n#ifact=[0]*1001\n#ifact[1000]=pow(fact[1000],mod-2,mod)\n#for i in range(1000,0,-1):\n#    ifact[i-1]=(i*ifact[i])%mod\nfrom sys import stdin, stdout\n#from bisect import bisect_left as bl\n#from bisect import bisect_right as br\n#import itertools\n#import math\n#import heapq\n#from random import randint as rn\n#from Queue import Queue as Q\ndef modinv(n,p):\n    return pow(n,p-2,p)\ndef ncr(n,r,p):\n    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p\n    return t\ndef ain():\n    return map(int,sin().split())\ndef sin():\n    return stdin.readline().strip()\ndef GCD(x, y):\n   while(y):\n       x, y = y, x % y\n   return x\ndef comp(a,b):\n    if(a[1]>b[1]):\n        return 1\n    elif(a[1]<b[1]):\n        return -1\n    else:\n        if(a[0]>b[0]):\n            return 1\n        else:\n            return -1\n\"\"\"**************************************************************************\"\"\"\nn=input()\ns=0\nfor i in range(2,n):\n    k=i*(i+1)\n    s+=k\nprint s\n", "lang_cluster": "Python", "tags": ["math", "greedy", "dp"], "code_uid": "4ec66c34803bbcc43031bd18f240eb8d", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nk = max(a)\nprint(k ^ a[-1])", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "5829f415345fca134fef7f57bafbab91", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "r=lambda:map(int,raw_input().split())\nX,Y,Z=r()\nx,y,z=r()\na=r()\nprint (Z>z)*a[3] + (Z<0)*a[2]+(Y>y)*a[1]+(Y<0)*a[0]+(X>x)*a[5]+(X<0)*a[4]\n", "lang_cluster": "Python", "tags": ["brute force", "geometry"], "code_uid": "7e6880b62165a6a15162143f83f8ec75", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def next(dx, dy):\n    return ([(dx,dy+1), (dx, dy-1)] if dy == 0 else [(dx+1,dy), (dx-1, dy)] if dx * dy == 0 else [(dx,0), (0, dy)])\nvisited = set()\nstates = set()\nn = int(raw_input())\nT = map(int, raw_input().split())\nstates.add((0,0,0,1))\nfor t in T:\n    new_states = set()\n    for x,y,dx,dy in states:\n        cnt = 0\n        for k in range(1, t + 1):\n            visited.add((x + k * dx, y + k * dy))\n            cnt += 1\n        next_dirs = next(dx, dy)\n        for ndx, ndy in next_dirs:\n            new_states.add((x + t*dx, y + t*dy, ndx, ndy))\n    states = new_states\nprint len(visited)\n", "lang_cluster": "Python", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "cbaf2c27b8f265d1f59c25efd30dacde", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "hh,mm=input().split(\":\")\na=int(input())\nm=int(hh)*60+int(mm)+a\nm=m%1440\nhh,mm=m//60,m%60\nif hh<10:\n    hh='0'+str(hh)\nif mm<10:\n    mm='0'+str(mm)\nprint(\"{}:{}\".format(hh,mm))", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "97b3d614dcd96db4bcbace516222ec62", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a,N,K=[0]+[int(i)for i in input().split()]\nd=lambda n:sum([min(N-(n<<e)+1,1<<e)for e in range(99)if n<<e<=N])\nc=lambda n:d(n)+(d(n+1),0)[n&1]\nfor b in range(59,-1,-1):a+=1<<b if c(a+2**b)>=K else 0\nprint(a)\n    # print('b: ', b)\n    # print('a+2**b: ', a+2**b)\n    # print('c: ', c(a+2**b,b))\n    # print('a: ', a)\n    # print()\n# print()\n# print(c(4,2))\n# print(c(6,1))\n# print(d(6))\n# print(d(7))\n# print(d(3))\n", "lang_cluster": "Python", "tags": ["math", "binary search", "dp", "combinatorics"], "code_uid": "24539f291a3323aa1ea97fc2e9ff006b", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "modu = 10 ** 9 + 7\n\ndef S(x):\n\tif x == 0:\n\t\treturn 0\n\tif x & 1:\n\t\treturn 11 * pow(3, x / 2, modu) - 7\n\telse:\n\t\treturn 19 * pow(3, x / 2 - 1, modu) - 7\n\ndef T(x):\n\treturn (S(x) + S((x + 1) / 2)) * pow(2, modu - 2, modu) % modu\n\n[l, r] = [int(x) for x in raw_input().split(' ')]\nprint (T(r) - T(l - 1) + modu) % modu\n\n\n", "lang_cluster": "Python", "tags": ["math", "matrices", "dp"], "code_uid": "0fb9f4f1f2332046b5c3ac136f65d806", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x, y = map(int, input().split())\np = x * x + y * y\nd = int(p ** 0.5)\nif d * d == p: print('black')\nelse:\n    if x * y < 0: print('black' if d % 2 else 'white')\n    else: print('white' if d % 2 else 'black')", "lang_cluster": "Python", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "d0988bd7c5fc4587e10a02d6f92f5b8c", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,m=[int(k) for k in raw_input().split(\" \")]\n\nif m>n:\n    m,n=n,m\n\nif m>=3:\n    if (m*n)%2:\n        print m*n-1\n    else:\n        print m*n\nelif m==2:\n    if n==2:\n        print 0\n    elif n==3:\n        print 4\n    elif n==7:\n        print 12\n    else:\n        print n*m\nelse:\n    n6=n%6\n    nn=(n/6)*6\n    if n6==5:\n        nn+=4\n    if n6==4:\n        nn+=2\n    print nn\n", "lang_cluster": "Python", "tags": ["brute force", "constructive algorithms", "flows", "graph matchings"], "code_uid": "d77c5ad6ec3f076c6eac848bd2103055", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def chk(x,y,x1,y1,x2,y2):\n    if x==x1 or y==y1:\n        return False\n    if x==x2 and y==y2:\n        return False\n    if abs(x-x1)*abs(y-y1)==2:\n        return False\n    if abs(x-x2)*abs(y-y2)==2:\n        return False\n    return True\n\ns=input()\nx1=ord(s[0])-ord('a')\ny1=int(s[1])-1\ns=input()\nx2=ord(s[0])-ord('a')\ny2=int(s[1])-1\nans=0\nfor i in range(8):\n    for j in range(8):\n        if chk(i,j,x1,y1,x2,y2):\n            ans+=1\nprint(ans)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "implementation"], "code_uid": "0cfb0e49cd62e9c95e429e645707dfcd", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "#\t!/usr/bin/env python3\n#\tcoding: UTF-8\n#\tModified: <06/Feb/2019 07:48:18 PM>\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology (IIIT),Gwalior\n\n#\tQuestion Link\n#\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 1000000007\n\n\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\n\n\ndef get_ints(): return map(int, sys.stdin.readline().split())\n\n\ndef input(): return sys.stdin.readline()\n\n# ///==========MAIN=============///\n\n\ngraph = [[] for _ in range(405)]\ngraph_reverse = [[] for _ in range(405)]\nvisited = [False] * 405\nvisited_other = [False] * 405\nstack = []\nscc = 0\n\n\ndef explore(node):\n    visited[node] = True\n    for neighbour in graph_reverse[node]:\n        if visited[neighbour] == False:\n            explore(neighbour)\n    stack.append(node)\n\n\ndef dfs(n, m):\n    for i in range(n):\n        for j in range(1, m + 1):\n            if visited[i * m + j] == False:\n                explore(i * m + j)\n\n\ndef explore_other(node):\n    visited_other[node] = True\n    for neighbour in graph[node]:\n        if visited_other[neighbour] == False:\n            explore_other(neighbour)\n\n\ndef dfs_o(n, m):\n    global scc\n    for node in reversed(stack):\n        if visited_other[node] == False:\n            scc += 1\n            #print(node, scc)\n            explore_other(node)\n\n\ndef main():\n    n, m = get_ints()\n    horizontal = input().strip()\n    for i in range(n):\n        if horizontal[i] == '<':\n            for j in range(1, m):\n                graph[i * m + j + 1].append(i * m + j)\n                graph_reverse[i * m + j].append(i * m + j + 1)\n        else:\n            for j in range(1, m):\n                graph[(i) * m + j].append(i * m + (j + 1))\n                graph_reverse[i * m + (j + 1)].append((i) * m + j)\n    vertical = input().strip()\n    for j in range(1, m + 1):\n        if vertical[j - 1] == '^':\n            for i in range(n - 1):\n                graph[(i + 1) * m + j].append((i) * m + (j))\n                graph_reverse[(i) * m + (j)].append((i + 1) * m + j)\n        else:\n            for i in range(n - 1):\n                graph[i * m + j].append((i + 1) * m + (j))\n                graph_reverse[(i + 1) * m + (j)].append((i) * m + j)\n    '''for i in range(n + 1):\n        for j in range(1, m + 1):\n            print(graph[i * m + j], end=' ')\n        print()\n    print('next')\n    for i in range(n + 1):\n        for j in range(1, m + 1):\n            print(graph_reverse[i * m + j], end=' ')\n        print()'''\n\n    dfs(n, m)\n    # print(stack)\n    dfs_o(n, m)\n    print('YES' if scc == 1 else 'NO')\n\n\nif __name__ == \"__main__\":\n    main()\n", "lang_cluster": "Python", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "317d853422615c18d1883121d42620e4", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def rf():\n    cs = list(map(int, input().split(' ')))\n    cs = list(zip(cs[0::2], cs[1::2]))\n    return cs\n\ndef cross(p, p1, p2):\n    return (p2[1] - p[1]) * (p1[0] - p[0]) - (p2[0] - p[0]) * (p1[1] - p[1])\n\ndef inside(p, f):\n    os = 0\n    total = 0\n    for i in range(len(f)):\n        p1 = f[i]\n        p2 = f[(i+1)%len(f)]\n        delta = cross(p, p1, p2)\n\n        os += delta\n        total += abs(delta)\n    \n    os = abs(os)\n    return os == total\n\n#for yy in range(0, 7):\n#    for xx in range(0, 7):\n#        #print(inside((xx, yy), [(4, 0), (5, 1), (4, 2), (3, 1)]), end=' ')\n#        #print(inside((xx, yy), [(2, 1), (3, 1), (3, 4), (2, 4)]), end=' ')\n#        #print(inside((xx, yy), [(3, 1), (5, 3), (3, 5), (1, 3)]), end=' ')\n#    print()\n#exit()\n\nfs = [rf(), rf()]\n\nres = False\nfor fi in range(2):\n    f1 = fs[fi]\n    f2 = fs[1-fi]\n    for pi in range(len(f1)):\n        cur = inside(f1[pi], f2)\n        res = res or cur\n\n    res = res or inside( ((f1[0][0] + f1[2][0]) // 2, (f1[0][1] + f1[2][1]) // 2), f2 )\n\nprint(['NO', 'YES'][res])", "lang_cluster": "Python", "tags": ["brute force"], "code_uid": "3d220b07de6f435b8f8d37cea1e092e7", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import *\nk, n, s, p = map(int, input().split())\nq = k * ceil(n / s)\nw = ceil(q / p)\nprint(w)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "a20312e80bf4ce08b5c1c0917d811db1", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "(n,h,m) = [int(x) for x in input().split()]\nhouses= [h]*n\nfor i in range(m):\n    (l,r,x) = [int(x) for x in input().split()]\n    for j in range(l-1,r):\n        houses[j] = min(houses[j],x)\n\nmx = 0\nfor j in range(n):\n    mx += houses[j]*houses[j]\n\nprint(mx)\n    ", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "7b509396aeaeb6bb60154fd40d60ccae", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def gcd(m, n):\n\treturn m if not n else gcd(n, m%n)\nn = int(input())\ncnt = 0\nfor i in range(2, int(n**0.5)+2):\n\tfor j in range(1+i%2, i, 2):\n\t\tif gcd(i,j)==1:\n\t\t\tcnt += n//(i*i+j*j)\nprint(cnt)", "lang_cluster": "Python", "tags": ["brute force", "math"], "code_uid": "deb61e795dc3b0d15fd7b9c893f3b57d", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, t = input(), [0] * 1002\nfor i in map(int, input().split()): t[i] += 1\nT = int(input()) + 1\nfor i in range(1000): t[i + 1] += t[i]\nprint(max(t[i + T] - t[i] for i in range(-1, 1001 - T)))", "lang_cluster": "Python", "tags": ["brute force", "implementation", "binary search"], "code_uid": "a71a01171806a337eb6b0f1c9f3268f4", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "G = list(map(int, input().split()))\nN = G[0]\nM = G[1]\n\nif M > 1:\n  print(N * (M - 1))\nelse:\n  print(M * (N - 1))\n\t\t \t\t\t\t\t \t        \t\t\t\t\t  \t \t\t\t\t", "lang_cluster": "Python", "tags": ["math"], "code_uid": "bd0cd59e2175057a315437451a1cd34d", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, B = [int(x) for x in input().split()]\narr = [int(x) for x in input().split()]\n\nposs_Splits = []\nps = 0\nptlan = 0\nfor i in range(n - 1):\n    if arr[i] % 2 == 0:\n        ps += 1\n    else:\n        ptlan += 1\n    if ps == ptlan:\n        poss_Splits.append((abs(arr[i] - arr[i + 1]), i))\n\nposs_Splits = sorted(poss_Splits)\ni = 0\nwhile i < len(poss_Splits) and B >= poss_Splits[i][0]:\n    B -= poss_Splits[i][0]\n    i += 1\n\nprint(i)", "lang_cluster": "Python", "tags": ["sortings", "dp", "greedy"], "code_uid": "66cfcfd8de32080acc1f9e4a13f022a0", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "#from math import *\n#from collections import Counter\ndef rl(s): return xrange(len(s))\n\nINF = 2147483647\n\n\nimport sys\nstdin = sys.stdin\n\na, ta = map(int, stdin.readline().strip().split())\nb, tb = map(int, stdin.readline().strip().split())\nsimion = map(int, stdin.readline().strip().split(':'))\nsimion = simion[0]*60 + simion[1] - 5*60\n\nb_starts = [0]\nwhile True:\n    nextb = b_starts[-1] + b\n    if nextb > (23-5)*60+59:\n        break\n    b_starts.append(nextb)\n\n#print b_starts\n\nrr = 0\nfor bst in b_starts:\n    b_end = bst + tb\n    if b_end > simion and bst < simion + ta:\n        rr += 1\n\nprint rr\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "d35539a41389add4fe3136955aea3cc3", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from math import *\nx, y, z = map(float, raw_input().split())\n\nans = [\n    \"x^y^z\",\n    \"x^z^y\",\n    \"(x^y)^z\",\n    \"(x^z)^y\",\n    \"y^x^z\",\n    \"y^z^x\",\n    \"(y^x)^z\",\n    \"(y^z)^x\",\n    \"z^x^y\",\n    \"z^y^x\",\n    \"(z^x)^y\",\n    \"(z^y)^x\"\n]\n\n\na = [-1e9]*12\nif x <= 1.0 and y <= 1.0 and z <= 1.0:\n    a[0] = y**z*log(x)\n    a[1] = z**y*log(x)\n    a[2] = z*y*log(x)\n    a[4] = x**z*log(y)\n    a[5] = z**x*log(y)\n    a[6] = x*z*log(y)\n    a[8] = x**y*log(z)\n    a[9] = y**x*log(z)\n    a[10] = x*y*log(z)\nelse:\n    if x > 1.0:\n        a[0] = z*log(y) + log(log(x))\n        a[1] = y*log(z) + log(log(x))\n        a[2] = log(z*y) + log(log(x))\n    if y > 1.0:\n        a[4] = z*log(x) + log(log(y))\n        a[5] = x*log(z) + log(log(y))\n        a[6] = log(x*z) + log(log(y))\n    if z > 1.0:\n        a[8] = y*log(x) + log(log(z))\n        a[9] = x*log(y) + log(log(z))\n        a[10] = log(x*y) + log(log(z))\n\na = sorted([[a[i], i] for i in xrange(12)],reverse=True)\nmx = a[0][0]\nmxi = a[0][1]\nfor ai, i in a[1:]:\n    if abs(mx - ai) < 1e-7:\n        mxi = min(mxi, i)\n\nprint ans[mxi]", "lang_cluster": "Python", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "cfebf84f9de787d3ff340f2e081fc9e7", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "mod = 1000000007\nn,k = [int(x)for x in input().split()]\ndp = [[0 for i in range(n+1)]for j in range(k+1)]\n\nfor i in range(1,n+1):\n\tdp[1][i] = 1\n\nfor l in range(2,k+1):\n\tfor i in range(1,n+1):\n\t\tfor j in range(i,n+1,i):\n\t\t\tdp[l][j] += dp[l-1][i]\n\t\t\tif(dp[l][j] >= mod):\n\t\t\t\tdp[l][j] -= mod\nsum = 0\nfor i in range(1,n+1):\n\tsum += dp[k][i]\n\tif sum >= mod:\n\t\tsum -= mod\nprint(sum)", "lang_cluster": "Python", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "45cf14251528aba84cb5ddcfba19d273", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import math\nfor _ in range(int(input())):\n    n=int(input())\n    if n%2==0:\n        print(n//2,n//2)\n    else:\n        flag=0\n        for i in range(2,int(math.sqrt(n))+1):\n            if n%i==0:\n                temp=i \n                flag=1\n                break\n        if flag==0:\n            print(1,n-1)\n            \n        else:\n            x=n//temp\n            print(x,(temp-1)*x)\n            ", "lang_cluster": "Python", "tags": ["math", "greedy", "number theory"], "code_uid": "a6f54e5f0645274bd6662aa9405f5ab1", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "r, h = map(int, raw_input().split())\nr *= 2\nh *= 2\nq = (h / (r / 2) + 1) / 2\nxuy = h + r / 2 - (q * r - r / 2)\nxux = r / 2\nprint 2 * q + (1 if xuy ** 2 + xux ** 2 >= r ** 2 else 0)\n\n", "lang_cluster": "Python", "tags": ["geometry"], "code_uid": "9f56541c8eabc11a95bba06b791da202", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n, m = [int(x) for x in raw_input().split(' ')]\nif m <= 1:\n    print 1\nelif m <= (n / 2):\n    print m\nelse:\n    print (n - m)\n", "lang_cluster": "Python", "tags": ["math", "greedy"], "code_uid": "56d4e38d9a1c439004b474284b7f1071", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n    a = 0\n    while n:\n        if (n >= 10):\n            a = a * 10 + 9\n            n -= 9;\n        else:\n            a = a * 10 + n\n            n = 0\n    print(a, a)\n    exit(0)\np = 1\nfor i in range(1,n):\n    p *= 10\n    m = p // 10 * i * 45 + 1\n    #print(m, p, m + p)\n    if (m + p > n):\n        k = n - m\n        while k < 0:\n            k += n\n        if (k >= p):\n            continue\n        print(k + 1, p + k)\n        exit(0)\n    \n", "lang_cluster": "Python", "tags": ["constructive algorithms"], "code_uid": "41c039b3b0ededf4db82b59f49b28418", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,t = map(int, raw_input().split())\nc = n*(n+1)/2\na = [0] * c\na[0] = t\ncounter = 0\nlevel = 0\nfor i in range(c):\n\tif (a[i] > 1):\n\t\trem = a[i] - 1\n\t\ta[i] = 1\n\t\tif i+ level + 1 < c:\n\t\t\ta[i + level + 1] += rem/2.0\n\t\tif i+ level+ 2 < c:\n\t\t\ta[i + level + 2] += rem/2.0\n\tif i == counter:\n\t\tlevel += 1\n\t\tcounter += level + 1;\nprint a.count(1)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "d994c751a1e52d084e958ad117aa34de", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from sys import stdin\n\n(x, y) = [int(buf) for buf in stdin.readline().strip().split()]\n\nk = min(x//2, y//24)\n\nx -= 2 * k\ny -= 24 * k\n\nans = 0\nwhile y >= 2 and x*100 + y*10 >= 220:\n    ans = 1 - ans\n    if ans == 1:\n        y -= 22 - min(x, 2) * 10\n        x -= min(x, 2)\n    else:\n        x -= 2 - min((y-2)//10, 2)\n        y -= 2 + min((y-2)//10, 2) * 10\n\nprint('Ciel' if ans == 1 else 'Hanako')", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "0bb6377b193dcc78d2f4660ec7c5aa32", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "x=map(int,raw_input().split(' '))\nn=x[0]\nm=x[1]\ns=x[2]\ntmp=(n%s)*((n/s)+1)\ntmp=n if (tmp==0) else tmp\ntmp1=(m%s)*((m/s)+1)\ntmp1=m if (tmp1==0) else tmp1\nprint(tmp1*tmp)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "02b74338b920049762812985ed051a10", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = list(input())\nif a[0] == 'f':\n    print('ftp://',end = '')\n    a = a[3:]\n    while len(a[:''.join(a).index('ru')]) == 0:\n        if len(a[:''.join(a).index('ru')]) != 0:\n            print(''.join(a[:''.join(a).index('ru')]),end = '')\n        else:\n            print('ru',end = '')\n            a = a[''.join(a).index('ru')+2:]\n    print(''.join(a[:''.join(a).index('ru')]),end = '')        \n    a = a[''.join(a).index('ru')+2:]\n    print('.ru',end='')\n    if len(a) != 0:\n        print('/',end='')\n        print(''.join(a))  \nelse:\n    print('http://',end = '')\n    a = a[4:]    \n    while len(a[:''.join(a).index('ru')]) == 0:\n        if len(a[:''.join(a).index('ru')]) != 0:\n            print(''.join(a[:''.join(a).index('ru')]),end = '')\n        else:\n            print('ru',end = '')\n            a = a[''.join(a).index('ru')+2:]\n    print(''.join(a[:''.join(a).index('ru')]),end = '')\n    a = a[''.join(a).index('ru')+2:]\n    print('.ru',end='')\n    if len(a) != 0:\n        print('/',end='')\n        print(''.join(a)) ", "lang_cluster": "Python", "tags": ["strings", "implementation"], "code_uid": "cc401c8587aef9859ad1245ff60c6953", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import time\n\na=list(map(int,input().split()))[1:]\nprint(' '.join(map(str,sorted(a))))\n\nt0=time.clock();\nwhile time.clock()-t0<1.5:\n    pass\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "0624b8d72775229f75a5155a24edf428", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# vars: A, B, k, k1, n, res, x\nn = int(input())\nk = int(input())\nA = int(input())\nif k == 1:\n\tprint((n-1)*A)\n\texit()\nB = int(input())\nres = 0\nx = n\nk1 = (k-1)*A\nwhile x > 1:\n\tres += A*(x % k)\n\tx //= k\n\tif x:\n\t\tif B > x * k1:\n\t\t\tres += (x*k-1)*A\n\t\t\tx = 1\n\t\telse:\n\t\t\tres += B\nprint(res-(1-x)*A)\n# a, b -> a // b, a % b\n", "lang_cluster": "Python", "tags": ["greedy", "dp"], "code_uid": "9d163d2f1d6992cb2d0e5dd7b6e01ea2", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\na=n//3\nb=n%3\nif b==2:\n    a=a+1\np=a//12\nq=a%12\nprint(p,q)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "607cfc90cbbdd84013355718b776f850", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"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", "tags": ["number theory"], "code_uid": "553646c9245a5da19ebacf0aaff83f5b", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import sys\nm=[]\ndef madd(*a):\n    m.append(sum(map(lambda x: 2**x,a)))\nfor i in range(19): \n    madd(i)\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\npadd(range(3))\npadd(range(3,7))\npadd(range(7,12))\npadd(range(12,16))\npadd(range(16,19))\npadd([7,12,16])\npadd([3,8,13,17])\npadd([0,4,9,14,18])\npadd([1,5,10,15])\npadd([2,6,11])\npadd([0,3,7])\npadd([1,4,8,12])\npadd([2,5,9,13,16])\npadd([6,10,14,17])\npadd([11,15,18])\na1 = (raw_input()+raw_input()+' '+raw_input()+raw_input()+raw_input()).split()\na = zip(a1,[0,3,7]+[1,4,8,12]+[2,5,9,13,16]+[6,10,14,17]+[11,15,18])\npx = sum([2**y for x,y in a 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", "lang_cluster": "Python", "tags": ["dfs and similar", "games", "dp", "bitmasks", "implementation"], "code_uid": "4535e3880229fe4d163595b0ae3e83fd", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "R = lambda: map(int, input().split())\ns = input()\ncc, c = 0, 0\nfor r in range(len(s)):\n    if r == 0 or s[r] == s[r - 1]:\n        c += 1\n    else:\n        cc += (c % 2 == 0)\n        c = 1\ncc += (c % 2 == 0)\nprint(cc)", "lang_cluster": "Python", "tags": ["two pointers", "implementation"], "code_uid": "2a8c52126adfe7089a1f7d4b95d44c05", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def is_intersect(r1, r2, R, x1, y1, x2, y2):\n    d = (x1 - x2)**2 + (y1 - y2)**2\n    return d >= (r1 + R)**2 or r1 < r2 and d <= (r2 - r1)**2 or R < r1 and d <= (r1 - R)**2\n\nx1, y1, r1, R1 = map(int, input().split())\nx2, y2, r2, R2 = map(int, input().split())\n\nres1 = is_intersect(r1, r2, R2, x1, y1, x2, y2)\nres2 = is_intersect(R1, r2, R2, x1, y1, x2, y2)\nres3 = is_intersect(r2, r1, R1, x2, y2, x1, y1)\nres4 = is_intersect(R2, r1, R1, x2, y2, x1, y1)\n\nprint(res1 + res2 + res3 + res4)\n", "lang_cluster": "Python", "tags": ["geometry"], "code_uid": "d5ec3e39a7da50bf1ae1f50bd39dbf68", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def lucky(x):\n  while x>0:\n    d=x%10\n    x/=10\n    if d!=4 and d!=7:\n      return False\n  return True\nn,k=map(int,raw_input().split())\nk-=1\np=[1]*16\nfor i in xrange(13):p[i+1]=p[i]*(i+1)\na=[]\ndef n_th(x):\n  if n-x<13:\n    return a[x-1-n]+max(0,n-13)+1\n  else:\n    return x\nif n<=13 and k>=p[n]:print -1\nelse:\n  s=[1]*16\n  for b in reversed(xrange(min(13,n))):\n    u=0\n    while k>=p[b]:\n      k-=p[b]\n      while not s[u]:u+=1\n      u+=1\n    while not s[u]:u+=1\n    a.append(u)\n    s[u]=0\n  t=0\n  for w in xrange(1,10):\n    for x in xrange(1<<w):\n      y=0\n      for b in xrange(w):\n        y=y*10+(7 if ((1<<b)&x) else 4)\n      if y<=n and lucky(n_th(y)):t+=1\n  print t\n", "lang_cluster": "Python", "tags": ["brute force", "combinatorics", "number theory"], "code_uid": "2e0f7b1dc6379616f8f2a4277aef0e72", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def main():\n    w, m, k = map(int, raw_input().split())\n    count = 0\n    while w > 0:\n        bits = len(str(m))\n        number = ((10**bits)-1-m+1)\n        if number * bits * k <= w:\n            w -= number * bits * k\n            count += number\n            m = 10**bits\n        else:\n            count += w / (len(str(m))*k)\n            break\n    print count\n\nif __name__ == '__main__':\n    main()\n\n", "lang_cluster": "Python", "tags": ["math", "implementation", "binary search"], "code_uid": "d7c0d83d9a870ad0e2eb33e1772da534", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import math\r\nn, m = map(int, input().split())\r\nf = [0] * (n + 1)\r\nans = 1\r\nsum = [0]\r\nk = int(math.log2(n))\r\ntmp = [0] * (int(k+1) * m)\r\nfor i in range(1, k + 1):\r\n    sum.append(sum[-1])\r\n    for j in range(1, m + 1):\r\n        if tmp[i * j] == 0:\r\n            sum[-1] += 1\r\n            tmp[i * j] = 1\r\nfor i in range(2, n + 1):\r\n    if f[i] == 1:\r\n        continue\r\n    now, v = i, 0\r\n    while now <= n:\r\n        f[now] = 1\r\n        now *= i\r\n        v += 1\r\n    ans += sum[v]\r\nprint(ans)", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "0d64b655ac8fe6b4dbc0a42cf3650ea7", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=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\n\n", "lang_cluster": "Python", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "0c93ad4dd4b82e5af97cc54864f86685", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"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\nSIDES = [\n    lambda c, v: (1 + 2 * c - v, 2 + 2 * v),\n    lambda c, v: (-1 + c - 2 * v, 2 + 2 * c),\n    lambda c, v: (-c - 2 - v, 2 * c - 2 * v),\n    lambda c, v: (-1 - 2 * c + v, -2 - 2 * v),\n    lambda c, v: (1 - c + 2 * v, -2 - 2 * c),\n    lambda c, v: (2 + c + v, -2 * c + 2 * v),\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\nprint(*SIDES[n // (c + 1)](c, n % (c + 1)))\n", "lang_cluster": "Python", "tags": ["math", "implementation", "binary search"], "code_uid": "dd0321cd91172ecf881da2b7bc24bcd5", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import random\n\n\ndef gcd(x, y):\n    while y:\n        x, y = y, x % y\n    return x\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    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\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\nn, k = map(int, raw_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\nif is_prime(n):\n    print(solve(n, 1))\n    exit()\n\nsn = int(n**0.5)\nif (sn*sn == n) and is_prime(sn):\n    print(solve(sn, 2))\n    exit()\n\nans, f = 1, _factor(n)\nif is_prime(f) and (f > sn):\n    ans = ans * solve(f, 1) % 1000000007\n    n /= f\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\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", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "1bc8c035b7e734e2b23195371cf11dda", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["greedy", "dp", "games"], "code_uid": "98f5b172927132a6fed4a948807da868", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input()\nprint (3**(n-1))%1000003 if n>0 else 1", "lang_cluster": "Python", "tags": ["math"], "code_uid": "92c1c05296fc6833aa4e6e281fcbb4f7", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"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 s1<s2:\n        teams[t2][0]-=3\n    else:\n        teams[t1][0]-=1\n        teams[t2][0]-=1\n    teams[t1][1]-=s1-s2\n    teams[t2][1]-=s2-s1\n    teams[t1][2]-=s1\n    teams[t2][2]-=s2\n    teams[t1][4]+=1\n    teams[t2][4]+=1\noppo=[t[3] for t in teams.values() if t[3]!='BERLAND' and t[4]<3][0]\nfor xy in range(1,123):\n    for y in range(0,123):\n        t1,t2=teams['BERLAND'][:],teams[oppo][:]\n        t1[0]-=3\n        t1[1]-=xy\n        t2[1]+=xy\n        t1[2]-=y+xy\n        t2[2]-=y\n        t1[4]+=1\n        t2[4]+=1\n        tms=[t for t in teams.values() if t[4]>2]+[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'", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "25924f9f0b8fd5eccfcb7371b802d907", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef solve(ft):\n    n, k = map(int, input().split())\n    m = 10**9 + 7\n    ans = v = 1\n    for i in range(1, min(k+1, n+1)):\n        v *= (n-i+1) % mo\n        v %= mo\n        ans += (v * pow(ft[i], m-2, m)) % m\n        ans %= mo\n    return ans\n\nft = [0]*(10**5+1)\nmo = 10**9 + 7\nft[0], ft[1] = 1, 1\nfor i in range(2, 10**5+1):\n    ft[i] = (ft[i-1] * i % mo) % mo\n\nprint(solve(ft))", "lang_cluster": "Python", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "59d4b9b77923ac829a1a3f653d532edd", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "\na,m=map(int,input().split())\n\nfor i in range(21):\n    a+=a%m\nif a%m:\n    print('No') \nelse:\n    print('Yes')", "lang_cluster": "Python", "tags": ["math", "matrices", "implementation"], "code_uid": "a948819cf4ebc977abc818089ca82865", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from __future__ import division, print_function\nimport __pypy__\n\nadd = __pypy__.intop.int_add\nsub = __pypy__.intop.int_sub\nmul = __pypy__.intop.int_mul\n\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    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    grid= [0]*(n*m)\n    grid[0]=g\n    for i in range(1,n*m):\n        grid[i]=modmuladd(grid[i-1],x,y)\n    B=[]\n    ans=0\n    for i in range(n):\n        B.append(printMin(grid[i*m:(i+1)*m],m,b))\n    grid=[]\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", "tags": ["two pointers", "data structures"], "code_uid": "acd470767f6dfc679c3b0d467505fdf9", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# cook your dish here\nn=int(input())\nminx=miny=maxx=maxy=0\nc=[]\ndx={}\ndy={}\nfor i in range(4*n+1):\n    x,y=map(int,input().split(' '))\n    c.append([x,y])\n    if x not in dx:\n        dx[x]=1\n    else:\n        dx[x]+=1\n    if y not in dy:\n        dy[y]=1\n    else:\n        dy[y]+=1\n\nminx=miny=maxx=maxy=0\n\nfor i in sorted(dx.keys()):\n    if dx[i]>=2 and minx==0:\n        minx=i\n        break\n    \nfor i in sorted(dy.keys()):\n    if dy[i]>=2 and miny==0:\n        miny=i\n        break\n\nfor i in list(reversed(sorted(dx.keys()))):\n    if dx[i]>=2 and maxx==0:\n        maxx=i\n        break\n\nfor i in list(reversed(sorted(dy.keys()))):\n    if dy[i]>=2 and maxy==0:\n        maxy=i\n        break\n        \n\n\nfor i in c:\n    if minx<=i[0]<=maxx and miny<=i[1]<=maxy:\n        if (i[0]!=minx and i[0]!=maxx) and (i[1]!=miny and i[1]!=maxy):\n            print(i[0],i[1])\n            break\n    else:\n        print(i[0],i[1])\n        break\n        \n    \n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "839cc316206ed57771ab763e44cc9267", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "#!/usr/bin/env python3\n\n[n, m, x, y, vx, vy] = map(int, input().strip().split())\n\n# x, y >= 0, x + y > 0\n# (d, p, q) : px + qy = d\ndef mygcd(x, y):\n\tif x > y:\n\t\td, p, q = mygcd(y, x)\n\t\treturn d, q, p\n\tif x == 0:\n\t\treturn y, 0, 1\n\tm, r = divmod(y, x)\n\td, p, q = mygcd(r, x)\n\treturn d, q - p*m, p\n\n\n\ndef solve(n, m, x, y, vx, vy):\n#\tprint ('solve', n, m, x, y, vx, vy)\n\tif vx < 0:\n\t\tcx, cy = solve(n, m, n - x, y, -vx, vy)\n\t\tif cx < 0:\n\t\t\treturn cx, cy\n\t\telse:\n\t\t\treturn n - cx, cy\n\tif vy < 0:\n\t\tcx, cy = solve(n, m, x, m - y, vx, -vy)\n\t\tif cx < 0:\n\t\t\treturn cx, cy\n\t\telse:\n\t\t\treturn cx, m - cy\n\t# vx, vy is nonnegative\n\tif vx == 0:\n\t\tif x in (0, n):\n\t\t\treturn x, m\n\t\telse:\n\t\t\treturn -1, -1\n\tif vy == 0:\n\t\tif y in (0, m):\n\t\t\treturn n, y\n\t\telse:\n\t\t\treturn -1, -1\n\t# vx = vy > 0\n\td, p, q = mygcd(n, m)\n\tif (x - y) % d != 0:\n\t\treturn -1, -1\n\tif x == y and n == m:\n\t\treturn n, m\n\tif x == y:\n\t\treturn ((m // d) % 2) * n, ((n // d) % 2) * m\n\tmxy = min(x, y)\n\tx, y = x - mxy, y - mxy\n\tn //= d\n\tm //= d\n\tx //= d\n\ty //= d\n\tc = x - y\n\tp = (p * c) % m\n\tq = (-q * c) % n\n#\tprint ('nmxypq', n, m, x, y, p, q, '=', p*n - x, q*m - y)\n\tif p*n - x < 0:\n\t\tp += m * (-((x - p*n) // m))\n\tif q*m - y < 0:\n\t\tq += n * (-((y - q*m) // n))\n\treturn (p % 2) * n * d, (q % 2) * m * d\n\t\ncx, cy = solve(n, m, x, y, vx, vy)\nif cx < 0:\n\tprint (-1)\nelse:\n\tprint (cx, cy)\n\n\t\n", "lang_cluster": "Python", "tags": ["geometry", "number theory"], "code_uid": "30a058a0f17e0b236566e66ad864b618", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "aaa =0\n\n\n\ndef f(l1,r1,l2,r2,top):\n\n  global aaa\n\n  if (l1>r1 or l2>  r2):\n\n    return 0\n\n  if (top-1<=aaa) or (r1-l1+1<=aaa) or (r2-l2+1<=aaa):\n\n    return 0\n\n  if top==2:\n\n    return 1\n\n  if (l1>top):\n\n    l1 -=top\n\n    r1 -= top\n\n  if (l2>top):\n\n    l2-=top\n\n    r2-=top\n\n  #print(l1,r1,l2,r2,top)\n\n  if (l1==l2 and r1==r2):\n\n    return r1-l1+1\n\n  if (l1==0 and r1==top-1):\n\n    return r2-l2+1\n\n  if (l2==0 and r2==top-1):\n\n    return r1-l1+1\n\n  if ( (l1<= l2 and l2<= r1) or (l2<= l1 and l1<= r2)):\n\n    ans =  min(r1,r2) -max(l1,l2)  +1\n\n  else:\n\n    ans = 0\n\n  #print(ans)\n\n  top = top//2\n\n  ans = max(ans, f(l1,min(r1,top-1),l2,min(r2,top-1), top))\n\n  ans = max(ans, f(l1,min(r1,top-1),max(top+1,l2),r2, top))\n\n  ans = max(ans, f(max(l1,top+1),r1, l2,min(r2,top-1), top))\n\n  ans = max(ans, f(max(l1,top+1),r1, max(l2,top+1),r2, top))\n\n  aaa = max(aaa,ans)\n\n  return ans\n\n\n\na = input().split()\n\n\n\n\n\nprint(f(int(a[0]),int(a[1]),int(a[2]),int(a[3]),2**36))\n\n\n\n# Made By Mostafa_Khaled", "lang_cluster": "Python", "tags": ["divide and conquer"], "code_uid": "6f8e825e5f13871df75bc28a3c1c0e10", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a, b = input().split()\nx = int(max(a + b)) + 1\ns, v = int(a, x) + int(b, x), 0\nwhile s:\n    s, v = s // x, v + 1\nprint(v)", "lang_cluster": "Python", "tags": ["math"], "code_uid": "015ea30b7d0e1b1543b3e8ccc2c19604", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, a = [int(x) for x in raw_input().split()]\nif a%2:\n\tprint a/2+1\nelse:\n\tprint (n-a)/2+1", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "e445dc81f1f904a15d67644de24dfe1b", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import re\nimport sys\nimport time\n\ndef read(t=None):\n\tstring = raw_input()\n\treturn string if t is None else [t(x) for x in string.split()]\n\ndef solve():\n\ts, b, e = read(int)\n\tx, y = read(int)\n\tp, bus_d = read(int)\n\n\tif y <= x:\n\t\t#print \"--> man faster than bus: \",\n\t\tprint abs(e-b) * y\n\t\treturn\n\n\t# man should always get on the bus\n\n\tman_d = (e-b) / abs(e-b)\n\n\t#print \"man_d: %2d, bus_d: %2d\"%(man_d, bus_d)\n\n\tif man_d == 1:\n\t\tif bus_d == 1:\n\t\t\tdelta = b-p\n\t\t\tif delta < 0:\n\t\t\t\tdelta = s-p+s+b\n\t\telse:\n\t\t\tdelta = p+b\n\telse:\n\t\tif bus_d == 1:\n\t\t\tdelta = s-p + s-b\n\t\telse:\n\t\t\tdelta = p-b\n\t\t\tif delta < 0:\n\t\t\t\tdelta = p+s+s-b\n\n\twalk = 1.0 * (x*delta) / (y-x)\n\tdist = abs(e-b)\n\n\t#print \"delta: %f\"%delta\n\t#print \"time: %f\"%time\n\t#print \"walk: %f\"%walk\n\t#print \"dist: %f\"%dist\n\n\tif walk >= dist:\n\t\t#print \"--> forget the bus: \",\n\t\tprint dist * y\n\t\treturn\n\telse:\n\t\t#print \"--> use bus: \",\n\t\t#ans = time+(dist-walk)*x\n\t\t#print \"%g\"%ans\n\t\tprint x * (delta + dist)\n\nif __name__ == \"__main__\":\n\tsolve()", "lang_cluster": "Python", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "25fa8eb9c0fb497a8d9101adfd089f51", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b = map(int, raw_input().split())\nif a != b:\n\tprint 1\nelse:\n\tprint a\n\t#rs", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "52e07f41a04ebf57c24c51397f52e302", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import sqrt\nx = int(input())\nnumbers = [int(i) for i in str(x)]\ncount = 0\nfor i in range(1, int(sqrt(x)) + 1):\n    if x % i == 0:\n        digits = [int(j) for j in str(i)]\n        flag = 0\n        for j in digits:\n            if j in numbers:\n                flag = 1\n                break\n        if flag:\n            count += 1\n        digits = [int(j) for j in str(x // i)]\n        flag = 0\n        for j in digits:\n            if j in numbers:\n                flag = 1\n                break\n        if flag and x // i != i:\n            count += 1\nprint (count)", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "819e6f104b03b97b1c8763f699c91903", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"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", "tags": ["dp", "games"], "code_uid": "232db7ac953f0ebf0d7c69d5f0102e5a", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "x=input()\nprint int(2**len(bin(3*x))/4-x*3<6)", "lang_cluster": "Python", "tags": ["math", "dp"], "code_uid": "2b167ddbe1609a3f987545fe34a94ef2", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"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", "tags": ["greedy", "data structures"], "code_uid": "553e6d02cd0b1357e9342b42f0b13f9d", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n = int(raw_input())\n\ndef num_ways(make, n):\n    if make == 0: return 0\n    if make <= n: return (make - 1) / 2\n    extra = 2 * n - make + 1\n    return extra / 2\n\ntarget = 0\nsearch = 0\nwhile search < 2 * n:\n    target += 1\n    search = 10 * search + 9\n\ntarget -= 1\nsearch /= 10\n\nans = 0\ncur = search\nwhile cur < 2 * n:\n    # print 'num ways to make %d using 1..%d is %d' % (cur, n, num_ways(cur, n))\n    ans += num_ways(cur, n)\n    cur += 10 ** target\n\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "2e4383007a3e503c04e5b7b02c6be018", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def solve(n, st, k):\n    MOD = int(1e9 + 7)\n    dp = [0] * (n + 1)\n    prefix_sum = [0] * (n + 1)\n    dp[st] = 1\n    for times in range(k):\n        prefix_sum[0] = 0\n        for i in range(1, n + 1):\n            prefix_sum[i] = prefix_sum[i - 1] + dp[i]\n            if prefix_sum[i] >= MOD: prefix_sum[i] -= MOD\n        for i in range(1, n + 1):\n            t = prefix_sum[n] - prefix_sum[i] + prefix_sum[i - 1] - prefix_sum[i >> 1]\n            while t < 0: t += MOD\n            while t >= MOD: t -= MOD\n            dp[i] = t\n    return sum(dp) % MOD\n    \n \ndef main():\n    n, a, b, k = [int(i) for i in input().split()]\n    if a > b:\n        print(solve(n - b, a - b, k))\n    else:\n        print(solve(b - 1, b - a, k))\n    \nmain()", "lang_cluster": "Python", "tags": ["dp", "combinatorics"], "code_uid": "687bcde028757d52d499fa63d3c90e08", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,m,k=map(int,raw_input().split())\nd=0\nif k>n or k==1 :\n\td=m**(n)\nelif k==n:\n\td=m**((n+1)/2)\nelif k%2==0:\n    d=m\nelse:\n    d=(m*(m-1))+m\nprint d%(10**9+7)\n", "lang_cluster": "Python", "tags": ["dsu", "math", "combinatorics", "graphs"], "code_uid": "0a5e0e66226982a70a329e4ab35d9910", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "n, p = map(float, input().split())\r\nans, n = 0, int(n)\r\nall = n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(n):\r\n    deln, newp = n - i, 0\r\n    if i > 2:\r\n        newp += i * (i - 1) * (i - 2) // 6\r\n    if i > 1:\r\n        newp += deln * i * (i - 1) // 2\r\n    if deln > 1:\r\n        newp += deln * (deln - 1) * i / 4\r\n\r\n    if newp / all >= p:\r\n        break\r\n    ans += 1\r\n\r\nprint(ans)\r\n", "lang_cluster": "Python", "tags": ["math", "probabilities", "combinatorics"], "code_uid": "36627a5ef9ebd0563375ca34ea3404ae", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "def gcd(a, b):\n    return gcd(b, a % b) if b else a\n\nwhile 1:\n    try:\n        x, y = map(int, input().split())\n    except:\n        break\n\n    if gcd(x, y) != 1:\n        print('Impossible')\n        continue\n\n    res=''\n    while x > 0 and y > 0:\n        if x > y:\n            cnt, give = x // y, 'A'\n            x %= y\n        else:\n            cnt, give = y // x, 'B'\n            y %= x\n        if x == 0 or y == 0:\n            cnt -= 1\n        res += str(cnt) + give\n\n    print(res)\n", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "983e77067387183e266f1c4dddd84560", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def gh(a,b):\n    t=1\n    while b>0:\n        if b&1:t=(t*a)%1000000007\n        b=b>>1\n        a=(a*a)%1000000007\n    return t\na=int(input())\nif a==0:print(1);exit()\nprint((((gh(2,2*a-1)+gh(2,a-1))%1000000007)))", "lang_cluster": "Python", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "c5989fe04d37462895addfb70c1b3e5b", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "s = raw_input()\ns = s.split(\" \")\nvladik = int(s[0])\nvalera = int(s[1])\nc = 1\n\nwhile True:\n    vladik -= c\n    c += 1\n    valera -= c\n    c += 1\n    if vladik < 0:\n        print \"Vladik\"\n        break\n    if valera < 0:\n        print \"Valera\"\n        break\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "572bae3fb78979c68bc31c24dc7b3486", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = [int(i) for i in input().split()]\nflag=False\nd1 = a[1]-a[0]\nd2 = a[2]-a[1]\nd3 = a[3]-a[2]\nq1 = a[1]/a[0]\nq2 = a[2]/a[1]\nq3 = a[3]/a[2]\nif(d1==d2==d3):\n    print(a[3]+d1)\n    flag=True\nelif(q1==q2==q3):\n    otv = a[3]*q1-(int(a[3]*q1))\n    tmp = 0 + otv\n    if(tmp<=0):\n        print(int(a[3]*q1))\n        flag=True\nif(flag==False):\n    print('42')", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "8fe337f9131be11fd5b5e19242e7a9f3", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a,b,c=map(int,input().split())\nM=998244353\ndef C(x, y):\n\tz,t=0, 1\n\tfor i in range(min(x,y)+1):\n\t\tz+=t\n\t\tt*=(x-i)*(y-i)*pow(i+1,M-2,M)%M\n\treturn z\nprint(C(a,b)*C(a,c)*C(b,c)%M)\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "47aed50c65c63b3d6e7a19409308fac5", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "A=list(map(int,input().split()))\nscore=0\nfor i in range(14):\n    score=max(score,sum([j for j in [(A[j] if i!=j else 0)+A[i]//14+(1 if (j+13-i)%14<A[i]%14 else 0) for j in range(14)] if j%2==0]))\nprint(score)\n", "lang_cluster": "Python", "tags": ["brute force", "implementation"], "code_uid": "485f76e306ca4f73720657504c0ad37f", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "def go(n,h,v={}):\n  if (n,h) not in v:\n    v[(n,h)]=(h and sum(go(i,h-1,v)*go(n-1-i,h-1,v) for i in range(n)) or 0) if n else 1\n  return v[(n,h)]\nn,h=map(int,raw_input().split())\nprint go(n,n)-go(n,max(0,h-1))\n", "lang_cluster": "Python", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "79446a2cbbf65ce022c709e6c8840ede", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n,x,y,c = map(int,raw_input().split())\ndef count(t):\n\tt1 = (2*t+1)**2 - 2*t*(t+1)\n\tif(t>n-x):\n\t\tt1-=(t-(n-x))**2\n\tif(t>n-y):\n\t\tt1-=(t-(n-y))**2\n\tif(t>x-1):\n\t\tt1-=(t-(x-1))**2\n\tif(t>y-1):\n\t\tt1-=(t-(y-1))**2\n\n\te1 = (n-x) + (n-y)\n\te2 = (n-y) + (x-1)\n\te3 = (x-1) + (y-1)\n\te4 = (y-1) + (n-x)\n\n\tfor e in [e1,e2,e3,e4]:\n\t\tif(t>e+1):\n\t\t\tp = t-(e+1)\n\t\t\tt1 += (p*(p+1))/2\n\n\t# print 't1',t1\n\treturn t1\n\nbeg=0\nend=n*2\nwhile(beg!=end):\n\tmid = (beg+end)/2\n\tif(count(mid)<c):\n\t\tbeg = mid+1\n\telse:\n\t\tend = mid\n\nprint beg\t", "lang_cluster": "Python", "tags": ["math", "implementation", "binary search"], "code_uid": "d7ff9001c6c3734dc9366a73ea776634", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = input()\nb = input()\n\nd = {}\nfor e in b:\n    if e == '9':\n        e = '6'\n    if e == '5':\n        e = '2'\n    if e in d:\n        d[e] = d[e] + 1\n    else:\n        d[e] = 1\n\nn = {}\nfor e in a:\n    if e == '9':\n        e = '6'\n    if e == '5':\n        e = '2'\n    if e in n:\n        n[e] += 1\n    else:\n        n[e] = 1\nresult = 10000000\nfor e in n:\n    if e not in d:\n        result = 0\n        break\n    else:\n        temp_result = int(d[e] / n[e])\n        if temp_result < result:\n            result = temp_result\n            \nprint(result)\n", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "af375de48c39ee8e0610b66a37c37251", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n=int(input())\r\nif n==1:\r\n  print(3)\r\nelse:\r\n  n-=1\r\n  a,b=n//3,n%3\r\n  ans=4*(a+1)\r\n  if b==1:\r\n    ans+=1\r\n  elif b==2:\r\n    ans+=3\r\n  print(ans)", "lang_cluster": "Python", "tags": ["math", "geometry", "binary search"], "code_uid": "72fdc9eb1333479716dd2045bcabdd38", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\r\n\r\nsys.setrecursionlimit(10**5)\r\nint1 = lambda x: int(x)-1\r\np2D = lambda x: print(*x, sep=\"\\n\")\r\ndef II(): return int(sys.stdin.buffer.readline())\r\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\ndef LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))\r\ndef LLI1(rows_number): return [LI1() for _ in range(rows_number)]\r\ndef BI(): return sys.stdin.buffer.readline().rstrip()\r\ndef SI(): return sys.stdin.buffer.readline().rstrip().decode()\r\ninf = 10**16\r\n# md = 10**9+7\r\n# md = 998244353\r\n\r\nn, md = LI()\r\n\r\ndef nHr(hn, hr):\r\n    return nCr(hn+hr-1, hr-1)\r\n\r\ndef nPr(com_n, com_r):\r\n    if com_r < 0: return 0\r\n    if com_n < com_r: return 0\r\n    return fac[com_n]*ifac[com_n-com_r]%md\r\n\r\ndef nCr(com_n, com_r):\r\n    if com_r < 0: return 0\r\n    if com_n < com_r: return 0\r\n    return fac[com_n]*ifac[com_r]%md*ifac[com_n-com_r]%md\r\n\r\nn_max = 405\r\nfac = [1]\r\nfor i in range(1, n_max+1): fac.append(fac[-1]*i%md)\r\nifac = [1]*(n_max+1)\r\nifac[n_max] = pow(fac[n_max], md-2, md)\r\nfor i in range(n_max-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%md\r\npw = [1]\r\nfor i in range(400): pw.append(pw[-1]*2%md)\r\n\r\n# dp[i][j]...i\u306bj\u500b\u76ee\u306e\u767d\u3092\u7f6e\u3044\u305f\u3068\u304d\u306e\u5834\u5408\u306e\u6570\r\ndp = [[0]*(n//2+2) for _ in range(n+2)]\r\ndp[0][0] = 1\r\nfor i in range(1, n+2):\r\n    for j in range(1, n//2+2):\r\n        v = 0\r\n        for k in range(i-2, -1, -1):\r\n            v += dp[k][j-1]*pw[i-k-2]*nCr(i-j, i-k-1)%md\r\n        dp[i][j] = v%md\r\n# p2D(dp)\r\n\r\nans = sum(dp[-1])%md\r\nprint(ans)\r\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "213abb6b88cf764543ad4e506e341762", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "d={input():0}\nfor i in range(20,0,-1):\n d,e={},d\n u=10**i/9\n for v,c in e.items():\n  for x in range(-6,7):\n\tt=x*u+v\n\tif abs(t)<u:d[t]=min(c+i*abs(x),d.get(t,999))\nprint d[0]\n\n", "lang_cluster": "Python", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "20d6b4c504331b07be8f356fb8462638", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import fractions\nt = raw_input()\nt = t.split(\" \")\na = int(t[0])\nb = int(t[1])\nl = fractions.gcd(a,b)\na = a/l\nb = b/l\nif(a==b+1 or b==a+1):\n\tprint \"Equal\"\nelif(a>b):\n\tprint \"Masha\"\nelse:\n\tprint \"Dasha\"\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "6ed379c736421661de38eabff9b18f80", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "\nn,m=map(int, raw_input().split(' '))\n\n\n\n\t\nif n==1 or m==1 or (n==2 or m==2):\n\tif n==1 or m==1:\n        \tprint n*m\n\telse:\n\t\tif n*m%4!=0:\n\t\t\tprint n*m/2+1\n\t\telse:\n\t\t\tif  n*m%8==0:\n\t\t\t\tprint n*m/2\n\t\t\telse:\n\t\t\t\tprint (n*m/8+1)*4\n\t\n\n\nelse:\n\tif n*m%2==0:\n\t\tprint n*m/2\n\telse:\n\t\tprint n*m/2+1\n\n", "lang_cluster": "Python", "tags": ["greedy", "constructive algorithms", "implementation"], "code_uid": "3720781409bdf5a03e4f35682b26bf43", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "ar = raw_input().split()\nn = int(ar[0])\nm = int(ar[1])\nk = int(ar[2])\nif n%2==0:\n\tprint \"Marsel\"\nelse:\n\twin=False\n\ti=1\n\twhile i*i<=m:\n\t\tif m%i==0:\n\t\t\tif k<=i and i<m:\n\t\t\t\twin=True\t\t\n\t\t\tif k<=m/i and m/i<m:\n\t\t\t\twin=True\n\t\ti+=1\t\n\tif win:\n\t\tprint \"Timur\"\n\telse:\n\t\tprint \"Marsel\"\t\n", "lang_cluster": "Python", "tags": ["dp", "number theory", "games"], "code_uid": "824ed31a5bc6c21a038f9bf1601d29f9", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 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\nfrom Queue import Queue, PriorityQueue\nfrom collections import deque, defaultdict, Counter\ngetcontext().prec = 100\n\nMOD = 10**9 + 7\nINF = float(\"+inf\")\n\nn, p, t = raw_input().split()\nn = int(n)\np = float(p)\nt = int(t)\n\n\ndef prob(n, k, p):\n    \"\"\"nCk(n, k) * p**k * (1-p)**(n-k)\"\"\"\n    q = 1 - p\n    dec = [p] * k + [q] * (n - k) + [1.0 / x for x in range(1, k + 1)]\n    inc = range(n, n - k, -1)\n\n    res = 1.0\n    while inc or dec:\n        if (res > 1.0 and dec) or not inc:\n            res *= dec[-1]\n            del dec[-1]\n        else:\n            res *= inc[-1]\n            del inc[-1]\n\n    return res\n\nres = 0.0\nif t <= n:\n    for x in xrange(1, n + 1):\n        res += x * prob(t, x, p)\nelse:\n    for x in xrange(1, n):\n        res += x * prob(t, x, p)\n    for tlast in xrange(n, t + 1):\n        res += n * prob(tlast - 1, n - 1, p) * p\n# asda\n\nprint res\n", "lang_cluster": "Python", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "3959e911431c387924e3be05b59ac66f", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n = int(input())\n\nboard = [[0 for i in range(n + 1)] for j in range(2 * n + 1)]\n\nboard[0][0] = 1\nfor i in range(1, n):\n    for j in range(len(board[0])):\n        if j > 0:\n            board[i][j-1] += board[i-1][j]\n        if j + 1 < len(board[0]) and j < 2 * n - i:\n            board[i][j+1] += board[i-1][j]\nfor i in range(n, 2 * n + 1):\n    for j in range(len(board[0])):\n        if j > 0:\n            board[i][j-1] += board[i-1][j]\n            #board[i][j-1] %= 1000000007\n        if j + 1 < len(board[0]) and j < 2 * n - i:\n            board[i][j+1] += board[i-1][j]       \n            #board[i][j+1] %= 1000000007     \nans = 0\nfor i in range(1, len(board), 2):\n    \n    ans += sum(board[i])\n    ans %= 1000000007\n        \nprint(ans)", "lang_cluster": "Python", "tags": ["greedy", "dp", "trees"], "code_uid": "c2cefbab4fd6e05a41095608e57535ae", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "number theory"], "code_uid": "33f615be1cd4c16a8b99b89a33636a2c", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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    if n < k or k < 0:\n        return 0\n    ans = 1\n    for i in range(n - k + 1, n + 1):\n        ans *= i\n        ans %= MOD\n    for i in range(1,k+1):\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(m-1,m - 2 * k - 1,MOD) % MOD)\n\n", "lang_cluster": "Python", "tags": ["dp", "combinatorics"], "code_uid": "b457e9776120de3bb4db1536548c5931", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x = 0\ny = 0\nnx,ny = map(int,input().split())\nif ((nx == 0 or nx == 1) and ny == 0):\n    print(0)\nelse:\n    x = 1\n    turn = 0\n    flag = 0\n    while True:\n        turn = turn + 1\n        while y != x:\n            y = y + 1\n            if(x == nx and y == ny):\n                flag = 1    \n                break\n        if flag == 1:\n            break\n        k = x * -1\n        turn = turn + 1\n        while x != k:\n            x = x - 1\n            if(x == nx and y == ny):\n                flag = 1\n                break\n        if flag == 1:\n            break\n        turn  = turn + 1\n        while y != x:\n            y = y - 1 \n            if(x == nx and y == ny):\n                flag = 1\n                break\n        if flag == 1:\n            break\n        k = (x * -1) + 1\n        turn = turn  + 1\n        while x != k:\n            x = x + 1\n            if(x == nx and y == ny):\n                flag = 1\n                break\n        if flag == 1:\n            break\n    print(turn)", "lang_cluster": "Python", "tags": ["brute force", "geometry", "implementation"], "code_uid": "c1577d63964782d720f9d6b0b370dd4b", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"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 len(set(str(x)))<=2:\n        return 1 \ncnt=0 \nwhile cnt<=10**5 :\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", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "857ceca9668878fc3878603eab2be0f1", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "implementation", "binary search"], "code_uid": "a872c92bd140103c3baf4f7a0985d966", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "N, M = map(int, input().split())\r\ndigits = \"0123456789abcdef\"\r\nans = \"\"\r\nwhile N:\r\n    ans = digits[N % M] + ans\r\n    N //= M\r\na = len(ans)\r\nb = len(set(ans))\r\nprint([\"NO\", \"YES\"][a == b])", "lang_cluster": "Python", "tags": ["number theory"], "code_uid": "8c3eaf96c529a10d885b1aebce9aba0b", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,k = map(int, input().split())\n\na = list(map(int,input().split()))\nall_sum = sum(a)\nr4,r2 = n,n*2\nfor v in range(len(a)):\n\tmid = a[v] // 4\n\ta[v] = a[v] % 4\n\tif mid <= r4:\n\t\tr4 -= mid\n\telse:\n\t\ta[v] += 4 * (mid - r4)\n\t\tr4 = 0\n\tif r4 == 0:\n\t\tbreak\nmid = 0\nr22 = 0\nfor v in a:\n\tif v % 2 == 1:\n\t\tmid += 1\n\tr22 += v // 2\n#print(r4,r22,mid,r2)\nif r4 > 0:\n\tmid -=r4\n\tr22 -= r4\n\tif mid < 0:\n\t\tr22 -= (mid // -2)\n\t\tmid = 0\n\nif r22 + mid > r2:\n\tprint('NO')\nelse:\n\tprint('YES')\n\n\n\n\n\n", "lang_cluster": "Python", "tags": ["brute force", "greedy", "implementation"], "code_uid": "cc232d8bd2224b6b72afb51d11f41cfa", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "I = lambda : map(int, raw_input().split())\n\ndef main():\n    mod = 10**9 + 7\n    n = input()\n    a = I()\n\n    c = [[0]*(n+1) for i in range(n+1)]\n    for i in xrange(n+1):\n        c[i][0] = c[i][i] = 1\n        for j in xrange(1,i):\n            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod\n\n    dp = [[0]*(n+1) for i in range(11)]\n\n    for i in xrange(a[9],n+1):\n        dp[9][i] = 1\n\n    for i in xrange(8,-1,-1):\n        for j in xrange(n+1):\n            for k in xrange(j-a[i]+1):\n                if i > 0:\n                    dp[i][j] += dp[i+1][k] * c[j][k]\n                elif j > 0 and k > 0:\n                    dp[i][j] += dp[i+1][k] * c[j-1][k-1]\n\n    print sum(dp[0][i] for i in xrange(1,n+1)) % mod\n\nif __name__ == '__main__':\n    main()\n", "lang_cluster": "Python", "tags": ["dp", "combinatorics"], "code_uid": "451405df1c5b27d671aa1645577402aa", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "def mirror(x):\n    k = 0\n    a = x\n    while a:\n        k += 1\n        a //= 10\n    s = k * '1'\n    return int(s) * 9 - x\n\n\nl, r = map(int, input().split())\nmax_p = max(l * mirror(l), r * mirror(r))\nfor s in range(10):\n    n = 5 * 10 ** s\n    if l < n < r:\n        max_p = max(max_p, n * mirror(n))\nprint(max_p)\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "62e6822302d4de6f36f40a2d7260582c", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n, c = map(int, input().split())\nmod = 10 ** 6 +3\ninv = [0, 1]\nfor i in range(2, max(n, c) + 1):\n    inv.append(inv[mod % i] * (mod - mod // i) % mod)\nans = 1\nfor i in range(1, n + c + 1):\n    ans = ans * i % mod\nfor i in range(1, c + 1):\n    ans = ans * inv[i] % mod\nfor i in range(1, n + 1):\n    ans = ans * inv[i] % mod\nans += mod - 1\nans %= mod\nprint(ans)\n\n", "lang_cluster": "Python", "tags": ["combinatorics"], "code_uid": "b72886e9f716a7a369948ae8f9b5911d", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "77974050b62b1129a7936b706e7dd1cb", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "\n\nif __name__ == '__main__':\n\t[a, b, w, x, c] = [int(t) for t in raw_input().strip().split()]\n\t#print 'a b w x c' \n\t#print a, b, w, x, c \n\n\tk1 = 0\n\tif b >= x:\n\t\tk1 = (b - x) / x + (1 if ((b-x) % x > 0) else 0)\n\tb -= k1 * x\n\t\n\tif c - k1 <= a:\n\t\tprint c - a\n\t\texit(0)\t\n\t\n\tc -= k1\n\n\tt = 0\n\ttimes_a_red = [0]\n\tb_start = b\n\t\n\twhile True:\n\t\tif b < x:\n\t\t\tt += 1\n\t\t\tb = w - (x - b)\n\t\telse:\n\t\t\tb = b - x\n\t\ttimes_a_red.append(t)\n\t\tif b == b_start:\n\t\t\tbreak\n\t#print times_a_red\n\n\tlo = 1\n\thi = 2**64 - 1\n\tres = 0\t\n\twhile lo <= hi:\n\t\tmid = lo + (hi - lo) / 2\n\t\t_len = len(times_a_red) - 1\n\t\ta_decr = mid / _len * times_a_red[-1] + times_a_red[mid % _len] \n\t\tif c - mid <= a - a_decr:\n\t\t\tres = mid\n\t\t\thi = mid - 1\n\t\telse:\n\t\t\tlo = mid + 1\n\tprint res + k1\n\texit(0)\n\n\t\t\t\n\n\n\n\n\n\t\t\n\n\n\n", "lang_cluster": "Python", "tags": ["math", "binary search"], "code_uid": "2e94050bac6ccfa9b7fdaa8c7a1de22e", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "\ndef mult_mod(a, b, m):\n    c = [[a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],\n         [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]]]\n    for i in range(2):\n        for j in range(2):\n            c[i][j] %= m\n    return c\n\ndef pow_mod(n, m):\n    p = [[1, 1],\n         [1, 0]]\n\n    a = [[1, 0],\n         [0, 1]]\n\n    while n:\n        if n % 2:\n            a = mult_mod(a, p, m)\n        p = mult_mod(p, p, m)\n        n /= 2\n    return a\n\ndef fib(n, m):\n    return pow_mod(n, m)[0]\n\ndef egcd(a, b):\n    if b == 0:\n        return 1, 0, a\n    x1, y1, c = egcd(b, a % b)\n    return y1, x1 - (a / b) * y1, c\n\ndef crt(a0, n0, a1, n1):\n    if min(n0, n1) < 0:\n        return 0, -1\n    x, y, g = egcd(n0, n1)\n    if (a0 - a1) % g:\n        return 0, -1\n    x *= (a1 - a0) / g\n    y *= (a1 - a0) / g\n    k = n1 * n0 / g\n    return (n0 * x + a0) % k, k\n\n\n# 2**13 ->   12288\n# 5**8  -> 1562500\n# 5**9  -> 7812500\n\n\ndef find(f, m, l):\n    resp = []\n    x0 = 0\n    x1 = 1\n    for i in range(l):\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, 7812500)\n\nif len(a) == 0 or len(b) == 0:\n    print('-1')\nelse:\n    ans = 10 ** 30\n    for i in a:\n        for j in b:\n            a0, n0 = crt(i, 12288, j, 7812500)\n            if n0 != -1:\n                x1, x0 = fib(a0, 10 ** 13)\n                if x0 == f:\n                    ans = min(ans, a0)\n                else:\n                    a0 += n0\n                    fm = pow_mod(n0, 10 ** 13)\n                    x3 = (x1 * fm[0][0] + x0 * fm[1][0]) % 10 ** 13\n                    x2 = (x1 * fm[0][1] + x0 * fm[1][1]) % 10 ** 13\n                    while (x2,x3) != (x0, x1):\n                        if x2 == f:\n                            ans = min(ans, a0)\n                            break\n                        a0 += n0\n                        x3, x2 = (x3 * fm[0][0] + x2 * fm[1][0]) % 10 ** 13, (x3 * fm[0][1] + x2 * fm[1][1]) % 10 ** 13\n    if ans < 10 ** 30:\n        print(ans)\n    else:\n        print(-1)", "lang_cluster": "Python", "tags": ["brute force", "math", "matrices"], "code_uid": "b857e23e40436ad73ba83e8f1defc981", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "a, b, m, r0 = map(int, raw_input().split())\nnums = {}\ni = 0\nr = r0\nwhile True:\n    r = (a * r + b) % m\n    if r in nums:\n        print i - nums[r]\n        break\n    nums[r] = i\n    i += 1\n", "lang_cluster": "Python", "tags": ["implementation", "number theory"], "code_uid": "fd2383e4db15e47bb1fe827981593ece", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "__author__ = 'trunghieu11'\n\ndef primTable(n):\n    prime = [True] * n\n    prime[0] = prime[1] = False\n    for i in range(2, n):\n        if prime[i]:\n            j = i * i\n            while j < n:\n                prime[j] = False\n                j += i\n    return prime\n\ndef isPalindrome(x):\n    return x == x[::-1]\n\ndef main():\n    p, q = map(int, raw_input().split())\n    n = 2000000\n    pri = 0\n    pal = 0\n    isPrime = primTable(n)\n    answer = -1\n    for i in range(1, n):\n        pri += isPrime[i]\n        pal += isPalindrome(str(i))\n        if pri * q <= pal * p:\n            answer = i\n    print answer\n\nif __name__ == '__main__':\n    main()", "lang_cluster": "Python", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "1a411e2a8bb943676fa3a2df3e9b4781", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x=int(input())\ns=input().split()\na=[int(num)for num in s]\nq=0\nfor i in a:\n    if i==min(a) and not max(a)==min(a):\n        q+=1\nif max(a)==min(a):\n    print('Bob')\nelif x/2<q:\n    print('Bob')\nelse :\n    print('Alice')\n    ", "lang_cluster": "Python", "tags": ["games"], "code_uid": "c93d3a37057e9d5b95fa792c6af8305a", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin\n\nx,y,n,d = [int(x) for x in stdin.readline().split()]\nd = d**2\n\n\nv = []\n\nfor vec in range(n):\n    v.append([int(x) for x in stdin.readline().split()])\n\nfound = {}\n\ndef winner(x,y,v,d):\n    if x**2 + y**2 > d:\n        return 1\n    if (x,y) in found:\n        return found[(x,y)]\n    for a,b in v:\n        if winner(x+a,y+b,v,d) == 0:\n            found[(x,y)] = 1\n            return 1\n    found[(x,y)] = 0\n    return 0\n\nif winner(x,y,v,d):\n    print('Anton')\nelse:\n    print('Dasha')\n", "lang_cluster": "Python", "tags": ["dp", "games"], "code_uid": "e86f61f6bd0f8de1ca8d84fadfb4e5d1", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "big = 100010\ndef gen_mu():\n    mu = [1]*big\n    mu[0] = 0\n    P = [True]*big\n    P[0] = P[1] = False\n    for i in range(2,big):\n        if P[i]:\n            j = i\n            while j<big:\n                P[j] = False\n                mu[j] *= -1\n                j += i\n            j = i*i\n            while j<big:\n                mu[j] = 0\n                j += i*i\n    return mu\n\nm = int(input())\nmu = gen_mu()\n\nMOD = 10**9+7\ndef mod_inv(x):\n    return pow(x, MOD-2, MOD)\n\ns = 1\nfor i in range(2,big):\n    # p is probabilty that i | a random number [1,m]\n    p = (m//i)*mod_inv(m)\n    s += (-mu[i])*(p)*mod_inv(1-p)\nprint(s%MOD)", "lang_cluster": "Python", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "1ee4008c29d46997a3e10ad56688f169", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\ns = set()\nd = dict()\nans = 0\n\ndef find():\n\tmax = -1\n\tmaxx = -1\n\tfor i in s:\n\t\tif len(d[i]) == 0:\n\t\t\tmaxx = i\n\t\t\tmax = n + 1\n\t\telse:\n\t\t\tif max < d[i][0]:\n\t\t\t\tmax = d[i][0]\n\t\t\t\tmaxx = i\n\treturn maxx\n\n\nfor i in xrange(n + 10):\n\td[i] = []\n\nfor i,x in enumerate(a):\n\td[x].append(i)\n\nfor i in a:\n\tif not i in s:\n\t\tans += 1\n\t\tif len(s) >= k:\n\t\t\tx = find()\n\t\t\ts.remove(x)\n\n\t\ts.add(i)\n\td[i].pop(0)\n\nprint ans\n", "lang_cluster": "Python", "tags": ["greedy"], "code_uid": "3192bcb293aae5e44bc8e77570d27d2f", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a1, b1, c1 = map(int, input().split())\na2, b2, c2 = map(int, input().split())\n\nif a1 == 0 and b1 == 0 and a2 == 0 and b2 == 0 and c1 != c2:\n    print(0)\nelif (a1 == 0 and b1 == 0 and c1 == 0) or (a2 == 0 and b2 == 0 and c2 == 0):\n    print(\"-1\")\nelif (a1 == 0 and b1 == 0 and c1 != 0) or (a2 == 0 and b2 == 0 and c2 != 0) and (c1 == c2):\n    print(0)\nelif a1*b2 == a2*b1:\n    if b2*c1 == c2*b1 and c1*a2 == c2*a1:\n        print(\"-1\")\n    else:\n        print(0)\nelse:\n    print(1)\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "2c42de7570f64e2cb51153d1b58eff44", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "#Code by Sounak, IIESTS\r\n#------------------------------warmup----------------------------\r\n\r\nimport os\r\nimport sys\r\nimport math\r\nfrom io import BytesIO, IOBase\r\nimport io\r\nfrom fractions import Fraction\r\nimport collections\r\nfrom itertools import permutations\r\nfrom collections import defaultdict\r\nfrom collections import deque\r\nfrom collections import Counter\r\nimport threading\r\n\r\n#sys.setrecursionlimit(300000)\r\n#threading.stack_size(10**8)\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\n#-------------------game starts now-----------------------------------------------------\r\n#mod = 9223372036854775807  \r\nclass SegmentTree:\r\n    def __init__(self, data, default=10**18, func=lambda a, b: min(a,b)):\r\n        \"\"\"initialize the segment tree with data\"\"\"\r\n        self._default = default\r\n        self._func = func\r\n        self._len = len(data)\r\n        self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n        self.data = [default] * (2 * _size)\r\n        self.data[_size:_size + self._len] = data\r\n        for i in reversed(range(_size)):\r\n            self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n    def __delitem__(self, idx):\r\n        self[idx] = self._default\r\n \r\n    def __getitem__(self, idx):\r\n        return self.data[idx + self._size]\r\n \r\n    def __setitem__(self, idx, value):\r\n        idx += self._size\r\n        self.data[idx] = value\r\n        idx >>= 1\r\n        while idx:\r\n            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n            idx >>= 1\r\n \r\n    def __len__(self):\r\n        return self._len\r\n \r\n    def query(self, start, stop):\r\n        if start == stop:\r\n            return self.__getitem__(start)\r\n        stop += 1\r\n        start += self._size\r\n        stop += self._size\r\n \r\n        res = self._default\r\n        while start < stop:\r\n            if start & 1:\r\n                res = self._func(res, self.data[start])\r\n                start += 1\r\n            if stop & 1:\r\n                stop -= 1\r\n                res = self._func(res, self.data[stop])\r\n            start >>= 1\r\n            stop >>= 1\r\n        return res\r\n \r\n    def __repr__(self):\r\n        return \"SegmentTree({0})\".format(self.data)\r\n    \r\nclass SegmentTree1:\r\n    def __init__(self, data, default=0, func=lambda a, b: a+b):\r\n        \"\"\"initialize the segment tree with data\"\"\"\r\n        self._default = default\r\n        self._func = func\r\n        self._len = len(data)\r\n        self._size = _size = 1 << (self._len - 1).bit_length()\r\n \r\n        self.data = [default] * (2 * _size)\r\n        self.data[_size:_size + self._len] = data\r\n        for i in reversed(range(_size)):\r\n            self.data[i] = func(self.data[i + i], self.data[i + i + 1])\r\n \r\n    def __delitem__(self, idx):\r\n        self[idx] = self._default\r\n \r\n    def __getitem__(self, idx):\r\n        return self.data[idx + self._size]\r\n \r\n    def __setitem__(self, idx, value):\r\n        idx += self._size\r\n        self.data[idx] = value\r\n        idx >>= 1\r\n        while idx:\r\n            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\r\n            idx >>= 1\r\n \r\n    def __len__(self):\r\n        return self._len\r\n \r\n    def query(self, start, stop):\r\n        if start == stop:\r\n            return self.__getitem__(start)\r\n        stop += 1\r\n        start += self._size\r\n        stop += self._size\r\n \r\n        res = self._default\r\n        while start < stop:\r\n            if start & 1:\r\n                res = self._func(res, self.data[start])\r\n                start += 1\r\n            if stop & 1:\r\n                stop -= 1\r\n                res = self._func(res, self.data[stop])\r\n            start >>= 1\r\n            stop >>= 1\r\n        return res\r\n \r\n    def __repr__(self):\r\n        return \"SegmentTree({0})\".format(self.data)\r\n    \r\nMOD=10**9+7\r\nclass Factorial:\r\n    def __init__(self, MOD):\r\n        self.MOD = MOD\r\n        self.factorials = [1, 1]\r\n        self.invModulos = [0, 1]\r\n        self.invFactorial_ = [1, 1]\r\n \r\n    def calc(self, n):\r\n        if n <= -1:\r\n            print(\"Invalid argument to calculate n!\")\r\n            print(\"n must be non-negative value. But the argument was \" + str(n))\r\n            exit()\r\n        if n < len(self.factorials):\r\n            return self.factorials[n]\r\n        nextArr = [0] * (n + 1 - len(self.factorials))\r\n        initialI = len(self.factorials)\r\n        prev = self.factorials[-1]\r\n        m = self.MOD\r\n        for i in range(initialI, n + 1):\r\n            prev = nextArr[i - initialI] = prev * i % m\r\n        self.factorials += nextArr\r\n        return self.factorials[n]\r\n \r\n    def inv(self, n):\r\n        if n <= -1:\r\n            print(\"Invalid argument to calculate n^(-1)\")\r\n            print(\"n must be non-negative value. But the argument was \" + str(n))\r\n            exit()\r\n        p = self.MOD\r\n        pi = n % p\r\n        if pi < len(self.invModulos):\r\n            return self.invModulos[pi]\r\n        nextArr = [0] * (n + 1 - len(self.invModulos))\r\n        initialI = len(self.invModulos)\r\n        for i in range(initialI, min(p, n + 1)):\r\n            next = -self.invModulos[p % i] * (p // i) % p\r\n            self.invModulos.append(next)\r\n        return self.invModulos[pi]\r\n \r\n    def invFactorial(self, n):\r\n        if n <= -1:\r\n            print(\"Invalid argument to calculate (n^(-1))!\")\r\n            print(\"n must be non-negative value. But the argument was \" + str(n))\r\n            exit()\r\n        if n < len(self.invFactorial_):\r\n            return self.invFactorial_[n]\r\n        self.inv(n)  # To make sure already calculated n^-1\r\n        nextArr = [0] * (n + 1 - len(self.invFactorial_))\r\n        initialI = len(self.invFactorial_)\r\n        prev = self.invFactorial_[-1]\r\n        p = self.MOD\r\n        for i in range(initialI, n + 1):\r\n            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\r\n        self.invFactorial_ += nextArr\r\n        return self.invFactorial_[n]\r\n \r\n \r\nclass Combination:\r\n    def __init__(self, MOD):\r\n        self.MOD = MOD\r\n        self.factorial = Factorial(MOD)\r\n \r\n    def ncr(self, n, k):\r\n        if k < 0 or n < k:\r\n            return 0\r\n        k = min(k, n - k)\r\n        f = self.factorial\r\n        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\r\nmod=10**9+7\r\nomod=998244353\r\n#-------------------------------------------------------------------------\r\nprime = [True for i in range(10001)] \r\nprime[0]=prime[1]=False\r\n#pp=[0]*10000\r\ndef SieveOfEratosthenes(n=10000):\r\n    p = 2\r\n    c=0\r\n    while (p <= n): \r\n          \r\n        if (prime[p] == True):\r\n            c+=1\r\n            for i in range(p*p, n+1, p): \r\n                #pp[i]=1\r\n                prime[i] = False\r\n        p += 1\r\n#-----------------------------------DSU--------------------------------------------------\r\nclass DSU:\r\n    def __init__(self, R, C):\r\n        #R * C is the source, and isn't a grid square\r\n        self.par = range(R*C + 1)\r\n        self.rnk = [0] * (R*C + 1)\r\n        self.sz = [1] * (R*C + 1)\r\n\r\n    def find(self, x):\r\n        if self.par[x] != x:\r\n            self.par[x] = self.find(self.par[x])\r\n        return self.par[x]\r\n\r\n    def union(self, x, y):\r\n        xr, yr = self.find(x), self.find(y)\r\n        if xr == yr: return\r\n        if self.rnk[xr] < self.rnk[yr]:\r\n            xr, yr = yr, xr\r\n        if self.rnk[xr] == self.rnk[yr]:\r\n            self.rnk[xr] += 1\r\n\r\n        self.par[yr] = xr\r\n        self.sz[xr] += self.sz[yr]\r\n\r\n    def size(self, x):\r\n        return self.sz[self.find(x)]\r\n\r\n    def top(self):\r\n        # Size of component at ephemeral \"source\" node at index R*C,\r\n        # minus 1 to not count the source itself in the size\r\n        return self.size(len(self.sz) - 1) - 1\r\n#---------------------------------Lazy Segment Tree--------------------------------------\r\n# https://github.com/atcoder/ac-library/blob/master/atcoder/lazysegtree.hpp\r\nclass LazySegTree:\r\n    def __init__(self, _op, _e, _mapping, _composition, _id, v):\r\n        def set(p, x):\r\n            assert 0 <= p < _n\r\n            p += _size\r\n            for i in range(_log, 0, -1):\r\n                _push(p >> i)\r\n            _d[p] = x\r\n            for i in range(1, _log + 1):\r\n                _update(p >> i)\r\n \r\n        def get(p):\r\n            assert 0 <= p < _n\r\n            p += _size\r\n            for i in range(_log, 0, -1):\r\n                _push(p >> i)\r\n            return _d[p]\r\n \r\n        def prod(l, r):\r\n            assert 0 <= l <= r <= _n\r\n \r\n            if l == r:\r\n                return _e\r\n \r\n            l += _size\r\n            r += _size\r\n \r\n            for i in range(_log, 0, -1):\r\n                if ((l >> i) << i) != l:\r\n                    _push(l >> i)\r\n                if ((r >> i) << i) != r:\r\n                    _push(r >> i)\r\n \r\n            sml = _e\r\n            smr = _e\r\n            while l < r:\r\n                if l & 1:\r\n                    sml = _op(sml, _d[l])\r\n                    l += 1\r\n                if r & 1:\r\n                    r -= 1\r\n                    smr = _op(_d[r], smr)\r\n                l >>= 1\r\n                r >>= 1\r\n \r\n            return _op(sml, smr)\r\n \r\n        def apply(l, r, f):\r\n            assert 0 <= l <= r <= _n\r\n            if l == r:\r\n                return\r\n \r\n            l += _size\r\n            r += _size\r\n \r\n            for i in range(_log, 0, -1):\r\n                if ((l >> i) << i) != l:\r\n                    _push(l >> i)\r\n                if ((r >> i) << i) != r:\r\n                    _push((r - 1) >> i)\r\n \r\n            l2 = l\r\n            r2 = r\r\n            while l < r:\r\n                if l & 1:\r\n                    _all_apply(l, f)\r\n                    l += 1\r\n                if r & 1:\r\n                    r -= 1\r\n                    _all_apply(r, f)\r\n                l >>= 1\r\n                r >>= 1\r\n            l = l2\r\n            r = r2\r\n \r\n            for i in range(1, _log + 1):\r\n                if ((l >> i) << i) != l:\r\n                    _update(l >> i)\r\n                if ((r >> i) << i) != r:\r\n                    _update((r - 1) >> i)\r\n \r\n        def _update(k):\r\n            _d[k] = _op(_d[2 * k], _d[2 * k + 1])\r\n \r\n        def _all_apply(k, f):\r\n            _d[k] = _mapping(f, _d[k])\r\n            if k < _size:\r\n                _lz[k] = _composition(f, _lz[k])\r\n \r\n        def _push(k):\r\n            _all_apply(2 * k, _lz[k])\r\n            _all_apply(2 * k + 1, _lz[k])\r\n            _lz[k] = _id\r\n \r\n        _n = len(v)\r\n        _log = _n.bit_length()\r\n        _size = 1 << _log\r\n        _d = [_e] * (2 * _size)\r\n        _lz = [_id] * _size\r\n        for i in range(_n):\r\n            _d[_size + i] = v[i]\r\n        for i in range(_size - 1, 0, -1):\r\n            _update(i)\r\n \r\n        self.set = set\r\n        self.get = get\r\n        self.prod = prod\r\n        self.apply = apply\r\n \r\n \r\nMIL = 1 << 20\r\n \r\n \r\ndef makeNode(total, count):\r\n    # Pack a pair into a float\r\n    return (total * MIL) + count\r\n \r\n \r\ndef getTotal(node):\r\n    return math.floor(node / MIL)\r\n \r\n \r\ndef getCount(node):\r\n    return node - getTotal(node) * MIL\r\n \r\n \r\nnodeIdentity = makeNode(0.0, 0.0)\r\n \r\n \r\ndef nodeOp(node1, node2):\r\n    return node1 + node2\r\n    # Equivalent to the following:\r\n    return makeNode(\r\n        getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2)\r\n    )\r\n \r\n \r\nidentityMapping = -1\r\n \r\n \r\ndef mapping(tag, node):\r\n    if tag == identityMapping:\r\n        return node\r\n    # If assigned, new total is the number assigned times count\r\n    count = getCount(node)\r\n    return makeNode(tag * count, count)\r\n \r\n \r\ndef composition(mapping1, mapping2):\r\n    # If assigned multiple times, take first non-identity assignment\r\n    return mapping1 if mapping1 != identityMapping else mapping2\r\n\r\nclass LazySegUpdate():\r\n    def __init__(self, N):\r\n        self.N = N\r\n        n = 4 * N\r\n        self.tree = [0] * n\r\n        self.lazy = [0] * n\r\n        \r\n    def queryHelper(self, index, s, e, l, r):\r\n        if self.lazy[index]:\r\n            # Apply lazy to node.\r\n            update = self.lazy[index]\r\n            self.lazy[index] = 0\r\n            self.tree[index] = max(self.tree[index], update)\r\n            # Check if this is leaf.\r\n            if s != e:\r\n                self.lazy[2 * index] = max(self.lazy[2 * index], update)\r\n                self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)\r\n                \r\n        if s > e or s > r or e < l:\r\n            return 0\r\n        if s >= l and e <= r:\r\n            return self.tree[index]\r\n        # Overlapped.\r\n        mid = (s + e) // 2\r\n        return max(self.queryHelper(2 * index, s, mid, l, r), self.queryHelper(2 * index + 1, mid + 1, e, l, r))\r\n    \r\n    def updateHelper(self, index, s, e, l, r, h):\r\n        if self.lazy[index]:\r\n            # Apply lazy to node.\r\n            update = self.lazy[index]\r\n            self.lazy[index] = 0\r\n            self.tree[index] = max(self.tree[index], update)\r\n            \r\n            if s != e:\r\n                self.lazy[2 * index] = max(self.lazy[2 * index], update)\r\n                self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)\r\n                \r\n        if s > e or s > r or e < l:\r\n            return\r\n        if s >= l and e <= r:\r\n            self.tree[index] = max(self.tree[index], h)\r\n            if s != e:\r\n                self.lazy[2 * index] = max(self.lazy[2 * index], h)\r\n                self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], h)\r\n            return\r\n        \r\n        mid = (s + e) // 2\r\n        self.updateHelper(2 * index, s, mid, l, r, h)\r\n        self.updateHelper(2 * index + 1, mid + 1, e, l, r, h)\r\n        self.tree[index] = max(self.tree[2 * index], self.tree[2 * index + 1])\r\n        \r\n    def query(self, l, r):\r\n        return self.queryHelper(1, 0, self.N - 1, l, r - 1)\r\n    \r\n    def update(self, l, r, h):\r\n        self.updateHelper(1, 0, self.N - 1, l, r - 1, h)\r\n#---------------------------------Pollard rho--------------------------------------------\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, 9780504, 1795265022]:\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 math.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 = math.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 = math.gcd(abs(x - y), n)\r\n                if f != n:\r\n                    return f\r\n    return n\r\n \r\n \r\n@memodict\r\ndef prime_factors(n):\r\n    \"\"\"returns a Counter of the prime factorization of n\"\"\"\r\n    if n <= 1:\r\n        return Counter()\r\n    f = pollard_rho(n)\r\n    return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)\r\n \r\n \r\ndef distinct_factors(n):\r\n    \"\"\"returns a list of all distinct factors of n\"\"\"\r\n    factors = [1]\r\n    for p, exp in prime_factors(n).items():\r\n        factors += [p**i * factor for factor in factors for i in range(1, exp + 1)]\r\n    return factors\r\n \r\n \r\ndef all_factors(n):\r\n    \"\"\"returns a sorted list of all distinct factors of n\"\"\"\r\n    small, large = [], []\r\n    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):\r\n        if not n % i:\r\n            small.append(i)\r\n            large.append(n // i)\r\n    if small[-1] == large[-1]:\r\n        large.pop()\r\n    large.reverse()\r\n    small.extend(large)\r\n    return small\r\n#-----------------------------------Sorted List------------------------------------------\r\nclass SortedList:\r\n    def __init__(self, iterable=[], _load=200):\r\n        \"\"\"Initialize sorted list instance.\"\"\"\r\n        values = sorted(iterable)\r\n        self._len = _len = len(values)\r\n        self._load = _load\r\n        self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]\r\n        self._list_lens = [len(_list) for _list in _lists]\r\n        self._mins = [_list[0] for _list in _lists]\r\n        self._fen_tree = []\r\n        self._rebuild = True\r\n \r\n    def _fen_build(self):\r\n        \"\"\"Build a fenwick tree instance.\"\"\"\r\n        self._fen_tree[:] = self._list_lens\r\n        _fen_tree = self._fen_tree\r\n        for i in range(len(_fen_tree)):\r\n            if i | i + 1 < len(_fen_tree):\r\n                _fen_tree[i | i + 1] += _fen_tree[i]\r\n        self._rebuild = False\r\n \r\n    def _fen_update(self, index, value):\r\n        \"\"\"Update `fen_tree[index] += value`.\"\"\"\r\n        if not self._rebuild:\r\n            _fen_tree = self._fen_tree\r\n            while index < len(_fen_tree):\r\n                _fen_tree[index] += value\r\n                index |= index + 1\r\n \r\n    def _fen_query(self, end):\r\n        \"\"\"Return `sum(_fen_tree[:end])`.\"\"\"\r\n        if self._rebuild:\r\n            self._fen_build()\r\n \r\n        _fen_tree = self._fen_tree\r\n        x = 0\r\n        while end:\r\n            x += _fen_tree[end - 1]\r\n            end &= end - 1\r\n        return x\r\n \r\n    def _fen_findkth(self, k):\r\n        \"\"\"Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`).\"\"\"\r\n        _list_lens = self._list_lens\r\n        if k < _list_lens[0]:\r\n            return 0, k\r\n        if k >= self._len - _list_lens[-1]:\r\n            return len(_list_lens) - 1, k + _list_lens[-1] - self._len\r\n        if self._rebuild:\r\n            self._fen_build()\r\n \r\n        _fen_tree = self._fen_tree\r\n        idx = -1\r\n        for d in reversed(range(len(_fen_tree).bit_length())):\r\n            right_idx = idx + (1 << d)\r\n            if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:\r\n                idx = right_idx\r\n                k -= _fen_tree[idx]\r\n        return idx + 1, k\r\n \r\n    def _delete(self, pos, idx):\r\n        \"\"\"Delete value at the given `(pos, idx)`.\"\"\"\r\n        _lists = self._lists\r\n        _mins = self._mins\r\n        _list_lens = self._list_lens\r\n \r\n        self._len -= 1\r\n        self._fen_update(pos, -1)\r\n        del _lists[pos][idx]\r\n        _list_lens[pos] -= 1\r\n \r\n        if _list_lens[pos]:\r\n            _mins[pos] = _lists[pos][0]\r\n        else:\r\n            del _lists[pos]\r\n            del _list_lens[pos]\r\n            del _mins[pos]\r\n            self._rebuild = True\r\n \r\n    def _loc_left(self, value):\r\n        \"\"\"Return an index pair that corresponds to the first position of `value` in the sorted list.\"\"\"\r\n        if not self._len:\r\n            return 0, 0\r\n \r\n        _lists = self._lists\r\n        _mins = self._mins\r\n \r\n        lo, pos = -1, len(_lists) - 1\r\n        while lo + 1 < pos:\r\n            mi = (lo + pos) >> 1\r\n            if value <= _mins[mi]:\r\n                pos = mi\r\n            else:\r\n                lo = mi\r\n \r\n        if pos and value <= _lists[pos - 1][-1]:\r\n            pos -= 1\r\n \r\n        _list = _lists[pos]\r\n        lo, idx = -1, len(_list)\r\n        while lo + 1 < idx:\r\n            mi = (lo + idx) >> 1\r\n            if value <= _list[mi]:\r\n                idx = mi\r\n            else:\r\n                lo = mi\r\n \r\n        return pos, idx\r\n \r\n    def _loc_right(self, value):\r\n        \"\"\"Return an index pair that corresponds to the last position of `value` in the sorted list.\"\"\"\r\n        if not self._len:\r\n            return 0, 0\r\n \r\n        _lists = self._lists\r\n        _mins = self._mins\r\n \r\n        pos, hi = 0, len(_lists)\r\n        while pos + 1 < hi:\r\n            mi = (pos + hi) >> 1\r\n            if value < _mins[mi]:\r\n                hi = mi\r\n            else:\r\n                pos = mi\r\n \r\n        _list = _lists[pos]\r\n        lo, idx = -1, len(_list)\r\n        while lo + 1 < idx:\r\n            mi = (lo + idx) >> 1\r\n            if value < _list[mi]:\r\n                idx = mi\r\n            else:\r\n                lo = mi\r\n \r\n        return pos, idx\r\n \r\n    def add(self, value):\r\n        \"\"\"Add `value` to sorted list.\"\"\"\r\n        _load = self._load\r\n        _lists = self._lists\r\n        _mins = self._mins\r\n        _list_lens = self._list_lens\r\n \r\n        self._len += 1\r\n        if _lists:\r\n            pos, idx = self._loc_right(value)\r\n            self._fen_update(pos, 1)\r\n            _list = _lists[pos]\r\n            _list.insert(idx, value)\r\n            _list_lens[pos] += 1\r\n            _mins[pos] = _list[0]\r\n            if _load + _load < len(_list):\r\n                _lists.insert(pos + 1, _list[_load:])\r\n                _list_lens.insert(pos + 1, len(_list) - _load)\r\n                _mins.insert(pos + 1, _list[_load])\r\n                _list_lens[pos] = _load\r\n                del _list[_load:]\r\n                self._rebuild = True\r\n        else:\r\n            _lists.append([value])\r\n            _mins.append(value)\r\n            _list_lens.append(1)\r\n            self._rebuild = True\r\n \r\n    def discard(self, value):\r\n        \"\"\"Remove `value` from sorted list if it is a member.\"\"\"\r\n        _lists = self._lists\r\n        if _lists:\r\n            pos, idx = self._loc_right(value)\r\n            if idx and _lists[pos][idx - 1] == value:\r\n                self._delete(pos, idx - 1)\r\n \r\n    def remove(self, value):\r\n        \"\"\"Remove `value` from sorted list; `value` must be a member.\"\"\"\r\n        _len = self._len\r\n        self.discard(value)\r\n        if _len == self._len:\r\n            raise ValueError('{0!r} not in list'.format(value))\r\n \r\n    def pop(self, index=-1):\r\n        \"\"\"Remove and return value at `index` in sorted list.\"\"\"\r\n        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\r\n        value = self._lists[pos][idx]\r\n        self._delete(pos, idx)\r\n        return value\r\n \r\n    def bisect_left(self, value):\r\n        \"\"\"Return the first index to insert `value` in the sorted list.\"\"\"\r\n        pos, idx = self._loc_left(value)\r\n        return self._fen_query(pos) + idx\r\n \r\n    def bisect_right(self, value):\r\n        \"\"\"Return the last index to insert `value` in the sorted list.\"\"\"\r\n        pos, idx = self._loc_right(value)\r\n        return self._fen_query(pos) + idx\r\n \r\n    def count(self, value):\r\n        \"\"\"Return number of occurrences of `value` in the sorted list.\"\"\"\r\n        return self.bisect_right(value) - self.bisect_left(value)\r\n \r\n    def __len__(self):\r\n        \"\"\"Return the size of the sorted list.\"\"\"\r\n        return self._len\r\n \r\n    def __getitem__(self, index):\r\n        \"\"\"Lookup value at `index` in sorted list.\"\"\"\r\n        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\r\n        return self._lists[pos][idx]\r\n \r\n    def __delitem__(self, index):\r\n        \"\"\"Remove value at `index` from sorted list.\"\"\"\r\n        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)\r\n        self._delete(pos, idx)\r\n \r\n    def __contains__(self, value):\r\n        \"\"\"Return true if `value` is an element of the sorted list.\"\"\"\r\n        _lists = self._lists\r\n        if _lists:\r\n            pos, idx = self._loc_left(value)\r\n            return idx < len(_lists[pos]) and _lists[pos][idx] == value\r\n        return False\r\n \r\n    def __iter__(self):\r\n        \"\"\"Return an iterator over the sorted list.\"\"\"\r\n        return (value for _list in self._lists for value in _list)\r\n \r\n    def __reversed__(self):\r\n        \"\"\"Return a reverse iterator over the sorted list.\"\"\"\r\n        return (value for _list in reversed(self._lists) for value in reversed(_list))\r\n \r\n    def __repr__(self):\r\n        \"\"\"Return string representation of sorted list.\"\"\"\r\n        return 'SortedList({0})'.format(list(self))\r\n#---------------------------------Binary Search------------------------------------------\r\ndef binarySearch(arr, n, key):\r\n    left = 0\r\n    right = n-1\r\n    mid = 0\r\n    res = n\r\n    while (left <= right):\r\n        mid = (right + left)//2\r\n        if (arr[mid] >= key):\r\n            res=mid\r\n            right = mid-1\r\n        else:\r\n            left = mid + 1\r\n    return res\r\n\r\ndef binarySearch1(arr, n, key):\r\n    left = 0\r\n    right = n-1\r\n    mid = 0\r\n    res=-1\r\n    while (left <= right):\r\n        mid = (right + left)//2\r\n        if (arr[mid] > key):\r\n            right = mid-1\r\n        else:\r\n            res=mid\r\n            left = mid + 1\r\n    return res\r\n#---------------------------------running code------------------------------------------\r\ntt=1\r\n#tt=int(input())\r\nfor _ in range (tt):\r\n    #input()\r\n    #n=int(input())\r\n    n,m=map(int,input().split())\r\n    #a=list(map(int,input().split()))\r\n    #b=list(map(int,input().split()))\r\n    #s=input()\r\n    #n=len(s)\r\n    DP=[0]*(n+5)\r\n    CUM=[1]*(n+5)\r\n    CUM[1]=0\r\n    DP[1]=1\r\n     \r\n    S=1\r\n     \r\n    for i in range(2,n+1):\r\n        CUM[i]=(CUM[i-1]+CUM[i])%m\r\n        DP[i]=(S+CUM[i])%m\r\n        S+=DP[i]\r\n        S%=m\r\n     \r\n        for j in range(i+i,n+1,i):\r\n            CUM[j]=(CUM[j]+DP[i]-DP[i-1])%m\r\n     \r\n    print(DP[n])", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "97e862a6bcabaf8b203916591239d370", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "\n\"\"\"\nT=[[0, 2, 1],\n[1, 0, 100],\n[1, 2, 0]]\nn=5\n\"\"\"\nT=[]\nfor _ in range(3):\n    T.append(map(int,raw_input().split()))\nn=int(raw_input())\n\nDP=[[[0 for i in range(3)] for j in range(3)] for k in range(2)]\n\nfor i in range(n):\n    t=i&1\n    for a in range(3):\n        for b in range(3):\n            if a!=b:\n                c=3-a-b\n                j=t^1\n                #print a,b,c,i,t,j\n                DP[j][a][b]=min(DP[t][a][c]+T[a][b]+DP[t][c][b],DP[t][a][b]+T[a][c]+DP[t][b][a]+T[c][b]+DP[t][a][b])\n\n\nprint DP[j][0][2]\nexit()\n", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "99f9b00c62224fe5cadb974fcf81b800", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n,k=map(int,input().split())\ntuk=n-k\nhell=998244353\nif(tuk<=0):\n\tprint(0)\n\texit(0)\nfact=[1]*200005\nfor i in range(2,200005):\n\tfact[i]=(i*fact[i-1])%hell\ndef C(n,r):\n\tans=1;\n\tans=(fact[r]*fact[n-r])%hell\n\tans=(fact[n]*pow(ans,hell-2,hell))%hell\n\treturn ans\nans=C(n,tuk)\nif(k!=0):\n\tans*=2\nres=0\nfor i in range(tuk):\n\tt=(C(tuk,i)*pow(tuk-i,n,hell))%hell\n\tif(i%2):\n\t\tres=(res-t+hell)%hell;\n\telse:\n\t\tres=(res+t)%hell;\nans=(ans*res)%hell;\nprint(ans)\n", "lang_cluster": "Python", "tags": ["math", "combinatorics", "fft"], "code_uid": "b58ecd487abe0909267946024873b0a9", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import sqrt\npt = lambda *a, **k: print(*a, **k, flush=True)\nrd = lambda: map(int, input().split())\nn = int(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)\n", "lang_cluster": "Python", "tags": ["geometry", "graphs"], "code_uid": "8f579f9ebc8eb9a0ceec8194d4027c4c", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "def pos(x):\n    global m\n    global n\n    row=x/m\n    column=x%m\n    p=[row,column]\n    return p\nn,m,a,b=(int(i) for i in raw_input().split())\nl=pos(a-1)\npar=l[0]\npac=l[1]\nl=pos(b-1)\npbr=l[0]\npbc=l[1]\nif (par==pbr) or ((pac==0) and (pbc==m-1)) or (pac==0 and b==n):\n    print 1\nelif (pac-pbc==1) or (pac==0) or (pbc==m-1) or (a==1) or (b==n) or (pbr-par==1):\n    print 2\nelse:\n    print 3\n#print par,pac,pbr,pbc\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "26d8ae30cd9b24cbc71b49107923e941", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "strLine = input()\nlistSplit = strLine.split()\nd = int(listSplit[0])\nL = int(listSplit[1])\nv1 = int(listSplit[2])\nv2 = int(listSplit[3])\nres = (L - d) / (v1 + v2)\nprint('{0:.6f}'.format(res))\n", "lang_cluster": "Python", "tags": ["math"], "code_uid": "4f2177dea697c1a9953c00e1e2911ec3", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "l = [1, 2]\nfor i in range(1, 100):\n    l.append(l[i]+l[i-1])\n    if l[-1]>10**18:\n        break\n\nl = [0, 0] + l\ndef perm(n, k):\n    if n == 1 and k == 1:\n        return [1]\n    if n == 2 and k == 1:\n        return [1, 2]\n    if n == 2 and k == 2:\n        return [2, 1]\n    if k <= l[n]:\n        return [1] + [i+1 for i in perm(n-1, k)]\n\n    return [2, 1] + [i+2 for i in perm(n-2, k - l[n])]\n\nn, k = map(int, input().split(' '))\nprint(' '.join([str(x) for x in perm(n, k)]))\n\n", "lang_cluster": "Python", "tags": ["constructive algorithms", "math", "combinatorics", "binary search", "greedy", "implementation"], "code_uid": "23e467c4012cabf08a07532a154dbe69", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "s=map(int, raw_input().split())\nl=s.pop()\nans=((l+1)*(l+2)*(l+3))/6\nfor i in range(l+1):\n    for j in s:\n        x = min(j+j-sum(s)+i, l-i)\n        if x>=0: ans -= ((x+1)*(x+2))/2\nprint ans\n\n", "lang_cluster": "Python", "tags": ["math", "implementation", "combinatorics"], "code_uid": "54c6604eb1c6c1d616b8cd7e1c9bf1b6", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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", "tags": ["dfs and similar", "constructive algorithms", "data structures"], "code_uid": "6caaadc75b1c085d364f7b43c0dd60f2", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "number theory"], "code_uid": "14d5aa117e90feef6daaabe02d90af5c", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"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", "tags": ["constructive algorithms", "trees"], "code_uid": "3b4ffe6458b02ca21ec2f48fbed07429", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "n=input()\nm=[10000000000,-1]\nfor a in xrange(1,int(n**(1.0/3))+1):\n    if n%a:continue\n    for b in xrange(a,int((n/a)**0.5)+1):\n        if (n/a)%b:continue\n        c=n/a/b\n        m[1]=max((a+2)*(b+2)*(c+1)-n,m[1])\n        t=(a+1)*(b+2)*(c+2)-n\n        if t>0:\n            m[0]=min(t,m[0])\nprint m[0],m[1]\n", "lang_cluster": "Python", "tags": ["math", "implementation"], "code_uid": "30a0da4ae8caaced6f4529a9697e476f", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n,k,l,m=map(int,input().split())\nfc={1:1,2:1}\ndef f(n):\n\tif n not in fc: k=n//2;fc[n]=(f(k+1)**2+f(k)**2 if n%2 else f(k)*(2*f(k+1)-f(k)))%m\n\treturn fc[n]\ns=k<2**l\nfor i in range(l): s*=pow(2,n,m)-f(n+2) if (k>>i)%2 else f(n+2)\nprint(s%m)\n\n", "lang_cluster": "Python", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "52ae8a8c3d2d09965d65c78a155c4e4c", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "def aux(x, a, b, i, vis):\n\tstack = [i]\n\twhile stack:\n\t\ti = stack.pop()\n\t\tif i-b >= 0 and i-b not in vis:\n\t\t\tvis.add(i-b)\n\t\t\tstack.append(i-b)\n\t\tif i+a <= x and i+a not in vis:\n\t\t\tvis.add(i+a)\n\t\t\tstack.append(i+a)\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\ndef gcd(a, b):\n\twhile b > 0:\n\t\ta, b = b, a%b \n\treturn a\n\ndef solve_good(m, a, b):\n\tg = gcd(a, b)\n\tfirst = min(m, a+b)\n\tvis = set([0])\n\ttot = 0\n\tfor i in xrange(first+1):\n\t\tct = single(i, a, b, vis)\n\t\ttot += ct\n\ttot += g * (sum_seq((m-first)/g + ct) - sum_seq(ct))\n\tif (m-first) / g > 0:\n\t\ttot -= ((m-first)/g + ct) * ((g-1) - (m-first) % g)\n\ttot += ct * min(g-1, m-first)\n\treturn tot \n\n\n\nm, a, b = map(int, raw_input().split())\nprint solve_good(m, a, b)", "lang_cluster": "Python", "tags": ["dfs and similar", "math", "number theory"], "code_uid": "797c1ce51b29b5aa27449af9d080a1d9", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from collections import *\nn = input()\ns = raw_input()\nb = [int (i) for i in raw_input().split(' ')]\nn = n\ncnt = defaultdict(int)\nmultiples = []\nbiggest = 'a'\nans = 0\nfor i in range(n//2):\n    if(s[i] == s[n-i-1]):\n        multiples.append(i)\n        cnt[s[i]] += 1\n        ans += max(b[i],b[n-i-1])\n    else:\n        ans += b[i] + b[n-i-1]\n\nfor i in range(26):\n    if(cnt[chr(ord('a')+i)] > cnt[biggest]):\n        biggest = chr(ord('a')+i)\nmore = max(max(cnt.values())*2-sum(cnt.values()),0)\ntakes = []\nfor i in range(n//2):\n    if(s[i] != s[n-i-1] and s[i] != biggest and s[n-i-1] != biggest):\n        takes.append(min(b[i],b[n-i-1]))\ntakes = sorted(takes)[:more]\npen = sum(takes)\nprint(ans-pen)", "lang_cluster": "Python", "tags": ["greedy", "flows", "graphs"], "code_uid": "3783cbf51c3f2c5202afa365feda1c4c", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"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", "tags": ["implementation"], "code_uid": "a20886f7b3e1d6422d8274ab2e50e53a", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "n,m=[int(x) for x in input().split()]\nfor i in range(n+m):\n    s=input()\nif n==m:\n    print('Yes')\nelse:\n    print('No')", "lang_cluster": "Python", "tags": ["math", "greedy", "geometry", "brute force"], "code_uid": "3d0b2703ee180f2eee303e4da431396b", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from math import sqrt\na, b = map(int, input().split())\nif a > b:\n    a, b = b, a\nu = []\nsqa = int(sqrt(a))\nsqb = int(sqrt(b))\nfor i in range(1, sqb + 1):\n    if i <= sqa and a % i == 0:\n        u.append((i, a // i))\n    elif b % i == 0:\n        u.append((i, b // i))\nok = False\nsqab = int(sqrt(a + b))\nfor i in range(sqab, 0, -1):\n    if (a + b) % i == 0:\n        k = (a + b) // i\n        for j in u:\n            if i >= j[0] and k >= j[1]:\n                ok = True\n                break\n    if ok:\n        break\nprint(2 * (i + k))\n            \n", "lang_cluster": "Python", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "d437e6934dcdb94fbe08fcd49b1fdf40", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "probabilities"], "code_uid": "ef0eb53fdbe7a960052b4e3ee415f1f5", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\nMOD = 998244353\nN, K = map(int, input().split())\nN -= 1\nKaijo = [1] * (N + 1)\nKaijoInv = [1] * (N + 1)\nfor i in range(1, N + 1):\n    Kaijo[i] = Kaijo[i - 1] * i % MOD\n    KaijoInv[i] = pow(Kaijo[i], MOD - 2, MOD)\nnCr = lambda n, r: 0 if r > n else Kaijo[n] * KaijoInv[n - r] % MOD * KaijoInv[r] % MOD\nnPr = lambda n, r: 0 if r > n else Kaijo[n] * KaijoInv[n - r] % MOD\n\nDP = [[0] * (K + 1) for _ in range(N + 1)]\nDP[0][0] = 1\nfor i in range(N + 1):\n    for j in range(K):\n        for k in range(N - i + 1):\n            DP[i + k][j + 1] += nCr(i + k, k) * DP[i][j] % MOD * pow(K - j, (i + k - 1) * k - (k * (k - 1) // 2), MOD) % MOD\n            DP[i + k][j + 1] %= MOD\nprint(DP[N][K])", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "graph matchings"], "code_uid": "9f1045179c00241dadbd7fb09678ff75", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["dp", "combinatorics", "trees", "graphs"], "code_uid": "827cc6e5b90df1bd83dd5c17ea929944", "src_uid": "fda761834f7b5800f540178ac1c79fca", "difficulty": 2800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from sys import stdin, stdout\nimport math, collections\nmod = 10**9+7\n\ndef isPower(n):\n    if (n <= 1):\n        return True\n    for x in range(2, (int)(math.sqrt(n)) + 1):\n        p = x\n        while (p <= n):\n            p = p * x\n            if (p == n):\n                return True\n\n    return False\nn = int(input())\narr = [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]\nans = arr[int(math.log(n, 2))]\ns = int(math.log(n, 2))\nfor i in range(3, int(n**0.5)+1):\n    if not isPower(i):\n        ans^=arr[int(math.log(n, i))]\n        s+=int(math.log(n, i))\nans^=((n-s)%2)\nprint(\"Vasya\" if ans else \"Petya\")", "lang_cluster": "Python", "tags": ["dp", "games"], "code_uid": "f6a25c059e6eeadf499f18f9838ca1cf", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "import math\nMOD = 10**9+7\n\nN,M,G = map(int,raw_input().split())\n\nif M == 0:\n    print int(G!=N%2)\n    exit()\nif M == 1:\n    ans = int(G!=N%2)\n    for i in xrange(N):\n        if i%2 == G:\n            ans += 1\n    print ans\n    exit()\n\nD = [0 for i in xrange(N+1)]\nD[0] = 1\nfor i in xrange(1,N+1):\n    D[i] = D[i-1]*(i+M-1)%MOD*pow(i,MOD-2,MOD)%MOD\nans = 0\nfor i in xrange(N+1):\n    if i%2 == G:\n        a,b = N-i,M-1\n        ans = (ans+D[a])%MOD\nprint ans\n", "lang_cluster": "Python", "tags": ["math", "combinatorics", "number theory"], "code_uid": "d1b8a25b20dd24c69b0259a4ea812327", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "mod, sx, sy, dx, dy, t = map(int, raw_input().split())\nv = (sx - 1, sy - 1, dx + sx + sy, dy + sx + sy, 1, 1)\nA = [\n[1, 0, 1, 0, 0, 0],\n[0, 1, 0, 1, 0, 0],\n[1, 1, 2, 1, 1, 2],\n[1, 1, 1, 2, 1, 2],\n[0, 0, 0, 0, 1, 1],\n[0, 0, 0, 0, 0, 1]\n]\nI = lambda: [[1 if i == j else 0 for j in xrange(6)] for i in xrange(6)]\ndef mul(M, N):\n    global mod\n    res = [[0] * 6 for i in xrange(6)]\n    for i in xrange(6):\n        for j in xrange(6):\n            for k in xrange(6):\n                res[i][j] += M[i][k] * N[k][j]\n                res[i][j] %= mod\n    return res\ndef power(M, k):\n    if k > 1:\n        res = power(M, k/2)\n        res = mul(res, res)\n        if k % 2:\n            res = mul(res, M)\n        return res\n    elif k == 1:\n        return M\n    else:\n        return I()\nB = power(A, t)\nV = [0] * 6\nfor i in xrange(6):\n    for j in xrange(6):\n        V[i] += B[i][j] * v[j]\n        V[i] %= mod\nprint V[0] + 1, V[1] + 1\n", "lang_cluster": "Python", "tags": ["math", "matrices"], "code_uid": "cb2a8334b7a2fd2c1f646780f92a628e", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n,t = map(int,input().split())\ndp = [[[[0,0] for i in range(t+1)] for j in range(5)] for k in range(n+1)]\ndp[2][2][1][0]=1\ndp[2][3][1][0]=2\ndp[2][4][1][0]=3\nans = 0\nfor i in range(3,n+1):\n\t\tfor j in range(1,5):\n\t\t\tfor k in range(1,t+1):\n\t\t\t\tfor l in range(1,j):\n\t\t\t\t\tdp[i][j][k][0]+=dp[i-1][l][k][0]+dp[i-1][l][k-1][1]\n\t\t\t\tfor l in range(4,j,-1):\n\t\t\t\t\tdp[i][j][k][1]+=dp[i-1][l][k][1]+dp[i-1][l][k][0]\nfor i in range(1,5):\n\tans+=dp[n][i][t][1]\nprint(ans)", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "8aa49e1f0722176ed734b888d0e45b21", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"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", "tags": ["brute force", "implementation", "number theory"], "code_uid": "95751fc42f8c357fd1a849d9a33d6b94", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"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", "tags": ["brute force", "dp", "combinatorics"], "code_uid": "a4bf85403c278cdb249341a6508fbd9d", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "import sys\r\n \r\ndef f(x):\r\n  return x - 97\r\ndef unf(x):\r\n  return (x)%26 + 97\r\n \r\na = input().encode()\r\nn = len(a)\r\nif n == 3:\r\n  b = b'the'\r\nelif n == 5:\r\n  b = b'buffy'\r\nelif n == 6:\r\n  b = b'slayer'\r\nelif n == 7:\r\n  b = b'vampire'\r\nelse:\r\n  print('none')\r\n  sys.exit()\r\nprint(bytes([unf(f(y)+f(x)) for x,y in zip(a, b)]).decode())", "lang_cluster": "Python", "tags": ["strings"], "code_uid": "0237599436cde52cc753eb00a538dd82", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "input()\np = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}\nprint(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))\n", "lang_cluster": "Python", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "809ed1389cdcfa23e5319ca388c854d1", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from sys import stdin\nfrom functools import lru_cache\nfrom collections import defaultdict\ninfile = stdin\nN, K = map(int, infile.readline().split())\nwatched = infile.readline().strip()\n\nmem = set()\nmem.add((0,0,0))\nfor i, letter in enumerate(watched):\n    for d in range(K+1):\n        for c in range(K+1):\n            if (i,d,c) in mem:\n                if letter in ('N', '?'):\n                    mem.add((i+1, max(d, c+1), c+1))\n                if letter in ('Y', '?'):\n                    mem.add((i+1, d, 0))\n\ndef good():\n    for i,d,c in mem:\n        if i == N and d == K:\n            return 'YES'\n    return 'NO'\n\n\nprint(good())", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "6f9c49bfb4737386ec2608705c85d5cd", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n=int(input())\ndp=[1]*(n)\nsb=0\nsr=0\nj=0\nans=0\nwhile(j<n):\n    if j%2==0:\n        dp[j]+=(sb)\n        dp[j]=dp[j]%1000000007\n        sr+=dp[j]\n    else:\n        dp[j] += (sr)\n        dp[j]=dp[j]%1000000007\n        sb += dp[j]\n    ans+=dp[j]\n    ans=ans%1000000007\n    j+=1\nprint(ans)\n", "lang_cluster": "Python", "tags": ["math", "dp"], "code_uid": "688a78b4d3eac8483fe7e77ca84630ad", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "cubes = [i**3.0 for i in range(2, int(1.8e5+5))]\n\ndef valid(mid):\n    return sum([mid//i for i in cubes if i <= mid])\n\ndef binary_search(k):\n    l = int(4.8 * k)\n    r = min(8.0 * k, 5.0 * (10**15))\n    while (l+1 < r):\n        mid = (l+r) / 2.0\n        res = valid(mid)\n        if (res < k):\n            l = mid\n        else:\n            r = mid\n    return int(r) if int(valid(r)) == k else -1\n\ndef main():\n    k = int(input())\n    print(binary_search(k))\n\nmain()\n", "lang_cluster": "Python", "tags": ["math", "binary search", "combinatorics"], "code_uid": "1ea3abdc6ea00928a8332713ef7e09c4", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "x, y = map(int, input().split())\nb = y // x\nif y % x != 0:\n    exit(print(0))\nds = set()\nM = 10**9 + 7\nfor i in range(1, int(pow(b,0.5)+1)):\n    if b % i == 0:\n        ds.add(i)\n        ds.add(b//i)\nds = sorted(list(ds))\nans = pow(2, b-1, M)\nf = ds[::]\nfor i in range(len(ds)):\n    f[i] = pow(2, ds[i]-1, M)\n    for j in range(i):\n        if ds[i] % ds[j] == 0:\n            f[i] -= f[j]\nprint(f[-1]%M)", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "06522cd83fcd78569f3d18d9db2a9c76", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "N = int(input())\nm1 = []\nm2 = []\nms = []\nfor n in range(N):\n    m1.append(input())\nfor n in range(N):\n    m2.append(input())\n\nms = [\n    m2,\n    [x[::-1] for x in m2],\n    [x for x in reversed(m2)],\n]\n\na = []\nfor m in ms:\n    a.append(m)\n    a.append([x[::-1] for x in reversed(m)])\n    a.append([''.join(m[j][i] for j in range(N - 1, -1, -1)) for i in range(N)])\n    a.append([''.join(m[j][i] for j in range(N)) for i in range(N - 1, -1, -1)])\n\nms = a\nprint(['NO', 'YES'][m1 in ms])\n", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "6daad217d40ceb7b6124ea2b0dcab42f", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "dp=[]\nfor i in xrange(333):\n    tmp = []\n    for j in xrange(333):\n        tmp.append(0)\n    dp.append(tmp)\n\nn = map(int,raw_input().split())[0]\na = map(int,raw_input().split())\ns1=\"BitLGM\"\ns2=\"BitAryo\"\n\nif n==2:\n    dp[0][0]=0\n    for i in xrange(302):\n        for j in xrange(302):\n            if(dp[i][j]==0):\n                k=1\n                while i+k<=300:\n                    dp[i+k][j]=1\n                    k=k+1\n                k=1\n                while j+k<=300:\n                    dp[i][j+k]=1\n                    k=k+1\n                k=1\n                while i+k<=300 and j+k<=300:\n                    dp[i+k][j+k]=1\n                    k=k+1\n    if dp[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", "tags": ["dp", "games"], "code_uid": "88e531939c5e2920f4896eb001a40907", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "Python 2", "source_code": "from sys import stdin,stdout\ndef gcd(a,b):\n    while b:\n        a,b=b,a%b\n    return a\ndef factors(a):\n    arr=[]\n    for i in range(1,int(a**(0.5))+1):\n        if a%i==0:\n            arr.append(i)\n    arr.sort()\n    return arr\nfor _ in range(1):\n    a,b=[int(i) for i in stdin.readline().split()]\n    ct=0\n    arr=factors(a)\n    while b:\n        c=gcd(a,b)\n        a,b=a/c,b/c\n        if a==1:\n            ct+=b\n            break\n        z=10**9\n        for i in arr:\n            if i>a:\n                break\n            x,y=i,a/i\n            if a%x==0 and x!=1:\n                z=min(z,b%x)\n                \n            if a%y==0 and y!=1:\n                z=min(z,b%y)\n            if z==0:\n                break\n        b-=z\n        ct+=z\n    stdout.write(str(ct)+'\\n')\n        \n        \n", "lang_cluster": "Python", "tags": ["math", "implementation", "binary search"], "code_uid": "397154aa6d184f7436101d16d48bc9d0", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "n,m=map(int,input().split())\nx,y,M=0,1,10**9+7\nwhile n>0:\n\tx,y,n=(2*m*x-x+y)%M,y*m%M,n-1\nprint((y+m*x)%M)", "lang_cluster": "Python", "tags": ["combinatorics"], "code_uid": "04f2f56111f840f4a30c2813364fba23", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"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]))", "lang_cluster": "Python", "tags": ["dfs and similar", "dp"], "code_uid": "5dc9178bfcb955f87229ff2e05c0b244", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"}
{"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", "tags": ["matrices", "strings"], "code_uid": "2851f7aa3d45f0e5bad47e7002d918fe", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "6b934f463744b99cabe28dd0c20d4578", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"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<<i!=n:\n\ti+=1\nprint a[i][k-1]", "lang_cluster": "Python", "tags": ["dp"], "code_uid": "47b410686f7e5ed7bfa25f2126dc537b", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp"], "code_uid": "b14ff838c33d36f84cf6e7326e9d356f", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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)]   \ns=0\nfor v in range(n):\n    tens = 10**v%k\n    f=[  (sum(   [f[(j+k-(x+1)*tens)%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\nprint(s%m)\n", "lang_cluster": "Python", "tags": ["dp", "implementation"], "code_uid": "a06e529109fcd598188d6765019dd515", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "MOD = 1000000007\n\n\ndef isSubset(a, b):\n\treturn (a & b) == a\n\n\ndef isIntersect(a, b):\n\treturn (a & b) != 0\n\n\n# Solve for each weakly connected component (WCC)\ndef cntOrder(s, t):\n\tp = len(s)\n\tm = len(t)\n\n\tinMask = [0 for i in range(m)]\n\n\tfor x in range(p):\n\t\tfor i in range(m):\n\t\t\tif t[i] % s[x] == 0:\n\t\t\t\tinMask[i] |= 1 << x\n\n\tcnt = [0 for mask in range(1<<p)]\n\tfor mask in range(1<<p):\n\t\tfor i in range(m):\n\t\t\tif isSubset(inMask[i], mask):\n\t\t\t\tcnt[mask] += 1\n\n\tdp = [[0 for mask in range(1<<p)] for k in range(m+1)]\n\tfor i in range(m):\n\t\tdp[1][inMask[i]] += 1\n\tfor k in range(m):\n\t\tfor mask in range(1<<p):\n\t\t\tfor i in range(m):\n\t\t\t\tif not isSubset(inMask[i], mask) and isIntersect(inMask[i], mask):\n\t\t\t\t\tdp[k+1][mask | inMask[i]] = (dp[k+1][mask | inMask[i]] + dp[k][mask]) % MOD\n\t\t\tdp[k+1][mask] = (dp[k+1][mask] + dp[k][mask] * (cnt[mask] - k)) % MOD\n\n\treturn dp[m][(1<<p)-1]\n\n\ndef dfs(u):\n\tglobal a, graph, degIn, visited, s, t\n\n\tvisited[u] = True\n\tif degIn[u] == 0:\n\t\ts.append(a[u])\n\telse:\n\t\tt.append(a[u])\n\n\tfor v in graph[u]:\n\t\tif not visited[v]:\n\t\t\tdfs(v)\n\n\ndef main():\n\tglobal a, graph, degIn, visited, s, t\n\n\t# Reading input\n\tn = int(input())\n\ta = list(map(int, input().split()))\n\n\t# Pre-calculate C(n, k)\n\tc = [[0 for j in range(n)] for i in range(n)]\n\tfor i in range(n):\n\t\tc[i][0] = 1\n\t\tfor j in range(1, i+1):\n\t\t\tc[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD\t\n\n\t# Building divisibility graph\n\tdegIn = [0 for u in range(n)]\n\tgraph = [[] for u in range(n)]\n\tfor u in range(n):\n\t\tfor v in range(n):\n\t\t\tif u != v and a[v] % a[u] == 0:\n\t\t\t\tgraph[u].append(v)\n\t\t\t\tgraph[v].append(u)\n\t\t\t\tdegIn[v] += 1\n\n\t# Solve for each WCC of divisibility graph and combine result\n\tans = 1\n\tcurLen = 0\n\tvisited = [False for u in range(n)]\n\tfor u in range(n):\n\t\tif not visited[u]:\n\t\t\ts = []\n\t\t\tt = []\n\t\t\tdfs(u)\n\n\t\t\tif len(t) > 0:\n\t\t\t\tsz = len(t) - 1\n\t\t\t\tcnt = cntOrder(s, t)\n\n\t\t\t\t# Number of orders for current WCC\n\t\t\t\tans = (ans * cnt) % MOD\n\t\t\t\t# Number of ways to insert <sz> number to array of <curLen> elements\n\t\t\t\tans = (ans * c[curLen + sz][sz]) % MOD\n\t\t\t\tcurLen += sz\t\t\n\n\tprint(ans)\n\nif __name__ == \"__main__\":\n\tmain()", "lang_cluster": "Python", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "527281884db59acd7dfd426dac0f0145", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0, "exec_outcome": "PASSED"}
{"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", "tags": ["number theory"], "code_uid": "7eec0f17c590fb5fd85d790a34f8d98a", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "import sys\ninput = sys.stdin.readline\n\nn,T=map(int,input().split())\nS=[list(map(int,input().split())) for i in range(n)]\n\nDP=[[0]*(4) for i in range(T+1)]\nmod=10**9+7\n\nfrom functools import lru_cache\n@lru_cache(maxsize=None)\ndef calc(used,recent,time):\n    ANS=0\n    for i in range(n):\n        #print(i,used)\n        if i in used:\n            continue\n        if time+S[i][0]>T:\n            continue\n        if S[i][1]==recent:\n            continue\n        if time+S[i][0]==T:\n            ANS+=1\n        if time+S[i][0]<T:\n            used2=list(used)+[i]\n            used2.sort()\n            recent2=S[i][1]\n            time2=time+S[i][0]\n            ANS=(ANS+calc(tuple(used2),recent2,time2))%mod\n\n    return ANS\n\nprint(calc(tuple(),-1,0)%mod)\n    \n", "lang_cluster": "Python", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "c4f8a8c3612afff865c378b4893b3b6b", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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", "tags": ["greedy", "games", "graph matchings"], "code_uid": "134cbaf1eb313187d55ed1df71fcce29", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "a,b,m=map(int,input().split())\nk=s=(10**9)%m\ni=0\nwhile k and i<a:\n    i+=1\n    if k<m-b:exit(print(1, str(i).zfill(9)))\n    k+=s\n    if k>=m:k-=m\nprint(2)", "lang_cluster": "Python", "tags": ["brute force", "number theory"], "code_uid": "fadb579435fdf7282023e8cd62f09af8", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"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 = []\nfor i in range(1,6):\n    if a[i]*b[10-i]>0:\n        k.append(i)\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.append((l,o))\n    a[l]+=1\n    b[10-l]+=1\n\nt=-1\nm=-1\nfor (l,o) in d:\n    if o>m:\n        m = o\n        t = l\n\nif t>0:\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]>0) and (b[9-i]>0)):\n            a[i]-=1\n            b[9-i]-=1\n            m+=1\n        for j in range(m):\n            c1[n]=str(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", "tags": ["implementation"], "code_uid": "3fcf16b2352e8bd1259aae4a567b95ef", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"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)\n", "lang_cluster": "Python", "tags": ["dfs and similar", "greedy", "dp"], "code_uid": "cc8b02d53011ee4c662d6863c06163a9", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "n = int(raw_input())\nmod = 10 ** 9 + 7\n\nlimit = 2 * n + 1\nnot_prime = (limit + 1) * [ False ]\nnot_prime[0] = not_prime[1] = True\nprimes = []\nfor i in range(limit + 1):\n    if not_prime[i]:\n        continue\n    primes.append(i)\n    for j in range(i * i, limit + 1, i):\n        not_prime[j] = True\n\ndef choose_mod(m, n, mod):\n    n = min(n, m - n)\n    factors = len(primes) * [ 0 ]\n    for pos, x in enumerate(primes):\n        if x > m:\n            break\n        for i in range(x, m + 1, x):\n            if i > n and i <= m - n:\n                continue\n            y = i\n            c = 0\n            while y % x == 0:\n                y //= x\n                c += 1\n            if i <= n:\n                factors[pos] -= c\n            else:\n                factors[pos] += c\n    result = 1\n    for pos, x in enumerate(factors):\n        y = primes[pos]\n        for i in range(x):\n            result = (result * y) % mod\n    return result\n\nprint((2 * choose_mod(2 * n + 1, n, mod) - 1) % mod)\n", "lang_cluster": "Python", "tags": ["combinatorics", "number theory"], "code_uid": "d28640d53ab32abf148e7a42c31ee1c1", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "from math import trunc\n\nMOD = 998244353\nMODF = float(MOD)\nSHRT = float(1 << 16)\nG = 3.0\nMAXSIZ = 1 << 20\n\n# Using pajenegod's crazy method for multiplication using floating point\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)\ndef fpow(a, b):\n    r = 1.0\n    while b:\n        if b & 1: r = mod_prod(r, a)\n        if b > 1: a = mod_prod(a, a)\n        b >>= 1\n    return r\n\nn, k = map(int, raw_input().split())\nf = [0.0] * MAXSIZ\nfor d in map(int, raw_input().split()):\n    f[d] = 1.0\n\nm = MAXSIZ\nm2 = m / 2\nw = [1] * m2\nw[1] = fpow(G, (MOD - 1) / m)\nfor i in xrange(2, m2):\n    w[i] = mod_prod(w[i - 1], w[1])\n\nrev = [0] * m\nfor i in xrange(m):\n    rev[i] = rev[i >> 1] >> 1\n    if i & 1: rev[i] |= m2\n\ndef ntt_transform(a):\n    for i in xrange(m):\n        if i < rev[i]: a[i], a[rev[i]] = a[rev[i]], a[i]\n    l = 2\n    while l <= m:\n        half, diff = l >> 1, m / l\n        for i in xrange(0, m, l):\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] = a[j] + v\n                pw += diff\n        l <<= 1\n\n\nntt_transform(f)\nf = [fpow(x, n >> 1) for x in f]\nntt_transform(f)\n\ninv_m = fpow(m, MOD - 2)\nans = mod_prod(sum(mod_prod(x, x) for x in f) % MODF, mod_prod(inv_m, inv_m))\nprint(int(ans))", "lang_cluster": "Python", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "362bde24ec88e69b19ba7b0dc6aad19b", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import sys\n\nimport itertools\n\nfrom collections import defaultdict\n\n\nfactorials = [1] * 19\n\nfor i in range(1, 19):\n    factorials[i] = i * factorials[i - 1]\n\n\ndef cumsum(l):\n    n = len(l)\n    for i in range(1, n):\n        l[i] += l[i-1]\n\n\ndef enum(l):\n\n    global K, S\n\n    options = itertools.product(*([(0, 1, 2)] * len(l)))\n\n    d = defaultdict(lambda: [0] * (25 + 1))\n\n    for opts in options:\n\n        s = 0\n        marks = 0\n        for i, opt in enumerate(opts):\n\n            if s > S:\n                break\n\n            if opt == 1:\n                s += l[i]\n            elif opt == 2:\n                if l[i] <= 18:\n                    s += factorials[l[i]]\n                    marks += 1\n                else:\n                    s = S + 1\n\n        if s <= S:\n            d[s][marks] += 1\n\n    return d\n\n\n[n, K, S] = map(int, sys.stdin.next().split(' '))\nl = sorted(map(int, sys.stdin.next().split(' ')))\n\np1 = enum(l[:(len(l) / 2)][::-1])\np2 = enum(l[(len(l) / 2):][::-1])\n\nvariants = 0\nfor s in p1:\n    if S - s in p2:\n        m1 = p1[s]\n        m2 = p2[S - s]\n        for (k1, c1) in enumerate(m1[:(K + 1)]):\n            for (k2, c2) in enumerate(m2[:(K + 1 - k1)]):\n                if k1 + k2 <= K:\n                    variants += c1 * c2\n\nprint(variants)\n", "lang_cluster": "Python", "tags": ["brute force", "math", "dp", "binary search", "bitmasks", "meet-in-the-middle"], "code_uid": "64421df4c96cf87c929aa9c42bbb974c", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3-64", "source_code": "import sys\r\nI = lambda: [*map(int, sys.stdin.readline().split())]\r\n\r\nn, a0, x, y, k, M = I()\r\n\r\nbig = 720720\r\nmod = [0] * big\r\nmod[a0 % big] += 1\r\ntot = a0\r\nfor i in range(n - 1):\r\n    a0 = (a0 * x + y) % M\r\n    tot += a0\r\n    mod[a0 % big] += 1\r\n\r\nm = 998244353\r\ntotal = 0\r\nfor i in range(k):\r\n    total += tot\r\n    if i < k - 1:\r\n        tot *= n\r\n        tot %= m\r\n        total *= n\r\n        total %= m\r\n        change = [0] * big\r\n        for j in range(big):\r\n            x = mod[j]\r\n            change[j - j % (i + 1)] += x\r\n            change[j] -= x\r\n            tot -= x * (j % (i + 1))\r\n        for j in range(big):\r\n            mod[j] = (n * mod[j] + change[j]) % m\r\nprint(total % m)", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "64236c19ef300c7efeb3419eb8b71fa3", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0, "exec_outcome": "PASSED"}
{"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)\n", "lang_cluster": "Python", "tags": ["dp", "combinatorics"], "code_uid": "71d8bfd68be3f794a930e26a6717b4f8", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "from decimal import *\nimport sys\ngetcontext().prec=100\nn,m=input().split()\nn=eval(n)\nm=eval(m)\nif n*m<=2:\n    if n==2 and m==1:\n        print(0.5)\n    else:\n        print(1)\n    sys.exit()\nn=Decimal(n)\nm=Decimal(m)\na=m*n\nb=n-1\nb=b*b\nans=(a-1+(n-1)*(m-1))/(n*(a-1))\nprint(ans)", "lang_cluster": "Python", "tags": ["probabilities", "math", "combinatorics"], "code_uid": "b789d18192ba2e17b13257b3cbd1406c", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "4e26c0808dd42332e7aeaeba49c8d677", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["dp", "bitmasks"], "code_uid": "d07abf08ad5b52169cfbcc4a7ba93b34", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"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(\" \")]\nmx=720720\nisok=[0]*mx\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)/mx", "lang_cluster": "Python", "tags": ["implementation"], "code_uid": "51b4e6a49cb937c817e00204341da532", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "numbers = []\nhighest = 0\nfor _ in range(int(input())):\n\tnumbers.append(int(input()))\n\tif highest < sum(numbers)/len(numbers): highest = sum(numbers)/len(numbers)\nprint(highest)\n\n\"\"\"\nFOO = sum(input)\nBAR = number input\nBAZ = 0\nQUZ = 0\n#BOTH SAEM ( \n\tBIGGR OF (\n\t\t(PRODUKT OF FOO AN QUZ) \n\t\tAN (PRODUKT OF BAR BAZ)\n\t) \n\tAN (PRODUKT OF FOO AN QUZ))\"\"\"", "lang_cluster": "Python", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "29b4306f0785cbf5582d609f2d24fd43", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "edff3a957d478a7e6be0b461f091dd6f", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "from math import gcd\ndef exd_gcd(a, b):\n  # always return as POSITIVE presentation\n  if a % b == 0:\n    return 0, (1 if b > 0 else -1)\n  x, y = exd_gcd(b, a % b)\n  return y, x - a // b * y\ndef interval_intersect(a, b, c, d):\n  if b <= a or d <= c:\n    return 0\n  if c < a:\n    a, b, c, d = c, d, a, b\n  if c < b:\n    return min(b, d) - c\n  else:\n    return 0\ndef ceil(a, b):\n  return (a + b - 1) // b\n\na1, b1, a2, b2, L, R = map(int, input().split())\ng = gcd(a1, a2)\nif (b1 - b2) % g != 0:\n  print(0)\n  exit(0)\nk, l = exd_gcd(a1, a2)\nl = -l\nk *= (b2 - b1) // g\nl *= (b2 - b1) // g\nd1 = a2 // g\nd2 = a1 // g\nassert(k * a1 + b1 == l * a2 + b2)\narb = 3238\nassert((k + arb * d1) * a1 + b1 == (l + arb * d2) * a2 + b2)\nL1, R1 = ceil(max(0, ceil(L - b1, a1)) - k, d1), ((R - b1) // a1 - k) // d1\nL2, R2 = ceil(max(0, ceil(L - b2, a2)) - l, d2), ((R - b2) // a2 - l) // d2\nprint(interval_intersect(L1, R1 + 1, L2, R2 + 1))\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "13e3a05982dc59b6d000d6646b03d23c", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"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 m<n:m*=2\n        self.n = n\n        self.m = m\n        self.data = [0]*(n+m)\n    def summa(self,l,r):\n        l+=self.m\n        r+=self.m\n        s = 0\n        while l<r:\n            if l%2==1:\n                s+=self.data[l]\n                l+=1\n            if r%2==1:\n                r-=1\n                s+=self.data[r]\n            l//=2\n            r//=2\n        return s%MOD\n    def add(self,ind,val):\n        ind += self.m\n        while ind>0:\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<b:\n            DP.add(i,DP.summa(a,b))#DP[i] = sum(DP[a:b])%MOD\n    \n    switchers[h]=DP.summa(n,n+1)\n\nfor h in range(1,n):\n    switchers[h] = (switchers[h]-switchers[h+1])%MOD\n\n\nswitchers2 = [0]*(n+1)\n\nfor h in range(1,n+1):\n    DP = sumseg(n+1)#[0]*(n+1)\n    DP.add(0,1)#DP[0] = 2\n    max_width = h\n    for i in range(1,n+1):\n        a = max(i-max_width,0)\n        b = i\n        if a<b:\n            DP.add(i,DP.summa(a,b))#DP[i] = sum(DP[a:b])%MOD\n    \n    switchers2[h]=DP.summa(n,n+1)\n\n\n\nsumma = 0\nfor h in range(1,n+1):\n    summa = (summa + switchers[h]*switchers2[h])%MOD\nprint summa\n", "lang_cluster": "Python", "tags": ["math", "dp", "combinatorics"], "code_uid": "c0da333d7ecebd29899dd8f5bad72bef", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "dp", "number theory"], "code_uid": "0be46b07bb4b0d4d74bdb28f4c8b0cca", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "a = list(map(int,input().split()))\na.sort()\nif int(a[1] % 2 == 0)+int(a[0] % 2 == 0)==1:\n print(a[2])\nelse:\n print(int((((a[1]-a[0])+(a[1]+a[0]))/2)))", "lang_cluster": "Python", "tags": ["math", "constructive algorithms"], "code_uid": "d38e6d3102319ea6fbe6f0b1a5b508ed", "src_uid": "b8008caf788336775cb8ebb76478b04c", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 2", "source_code": "import sys\nfrom collections import defaultdict as di\nrange = xrange\ninput = raw_input\n\ninp = [int(x) for x in sys.stdin.read().split()]\nii = 0\n\nn = inp[ii]\nii += 1\nA = []\nfor _ in range(n):\n    A.append(inp[ii:ii + n])\n    ii += n\n\nd = di(lambda:len(d))\nfor y in range(n):\n    for x in range(n): \n        for p in range(3):\n            d[y,x,p]\nm = len(d)\n\ninf = 1000000000\nlarge = 1000\nmat = [[inf]*m for _ in range(m)]\nfor i in range(m):\n    mat[i][i] = 0\n\nfor y in range(n):\n    for x in range(n):\n        for p in range(3):\n            for q in range(p+1, 3):\n                i = d[y,x,p]\n                j = d[y,x,q]\n                mat[i][j] = 1 + large\n                mat[j][i] = 1 + large\n\n# knight, bishop, rook\np = 0\nfor y in range(n):\n    for x in range(n):\n        i = d[y,x,p]\n        for dy,dx in [(1,2),(2,1),(-1,2),(-2,1)]:\n            x2 = x + dx\n            y2 = y + dy\n            if 0 <= x2 < n and 0 <= y2 < n:\n                j = d[y2,x2,p]\n                mat[i][j] = large\n                mat[j][i] = large\n\np = 1\nfor y in range(n):\n    for x in range(n):\n        i = d[y,x,p]\n        for dy,dx in [(1,1),(-1,1)]:\n            y2 = y + dy\n            x2 = x + dx\n            while 0 <= x2 < n and 0 <= y2 < n:\n                j = d[y2,x2,p]\n                mat[i][j] = large\n                mat[j][i] = large\n                y2 += dy\n                x2 += dx\n\np = 2\nfor y in range(n):\n    for x in range(n):\n        i = d[y,x,p]\n        for dy,dx in [(0,1),(1,0)]:\n            y2 = y + dy\n            x2 = x + dx\n            while 0 <= x2 < n and 0 <= y2 < n:\n                j = d[y2,x2,p]\n                mat[i][j] = large\n                mat[j][i] = large\n                y2 += dy\n                x2 += dx\n\nfor k in range(m):\n    for i in range(m):\n        for j in range(m):\n            if mat[i][k] + mat[k][j] < mat[i][j]:\n                mat[i][j] = mat[i][k] + mat[k][j]\n\ncoords = [None]*(n**2)\nfor y in range(n):\n    for x in range(n):\n        coords[A[y][x] - 1] = (y,x)\n\nbest = [0,0,0]\nfor goal in range(1, n**2):\n    y1,x1 = coords[goal - 1]\n    y2,x2 = coords[goal]\n\n    newbest = [inf,inf,inf]\n    for p in range(3):\n        for q in range(3):\n            newbest[q] = min(newbest[q], best[p] + mat[d[y1,x1,p]][d[y2,x2,q]])\n    best = newbest\nans = min(best)\nprint ans//large, ans%large", "lang_cluster": "Python", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "d8fde34e150cbd0120b6c8266a34894c", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "games"], "code_uid": "c131f330d1ffe63295ab1763111b323f", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0, "exec_outcome": "PASSED"}
{"lang": "Python 3", "source_code": "# I've proven, that z takes form of 2 ** (k - 1) - 1,\n# where 2 ** k - 1 is prime, which are called 'Mersenne primes'.\n\np = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127,\\\n    521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689,\\\n    9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503,\\\n    132049, 216091, 756839, 859433, 1257787, 1398269,\\\n    2976221, 3021377, 6972593, 13466917, 20996011]\nn = int(input())\nMOD = 10 ** 9 + 7\nprint((pow(2, p[n - 1] - 1, MOD) - 1) % MOD)\n", "lang_cluster": "Python", "tags": ["math", "number theory"], "code_uid": "5c9eaf9be0675a4bf093754d1cdfd1ed", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0, "exec_outcome": "PASSED"}
{"lang": "PyPy 3", "source_code": "p=10**9+7\nimport math\ndef prod(l):\n    x=1\n    for m in l:\n        x*=m\n    return x\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]*prod(e))%p\n    f=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", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "82312c0d29b68bd0521213ac1fd2df92", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "greedy", "constructive algorithms", "binary search"], "code_uid": "ff083337e57a4d175d8c91b77f2ca56e", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0, "exec_outcome": "PASSED"}
{"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", "tags": ["dp"], "code_uid": "f46ea57ff62ee34ecec207291864b5b3", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math"], "code_uid": "6e453a6fbc7d1f65d84fe0c9b52e3997", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0, "exec_outcome": "PASSED"}
{"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", "tags": ["math", "number theory"], "code_uid": "9e3fd6601445c75b2d3e4dd9a8c2d5a2", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0, "exec_outcome": "PASSED"}