{"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 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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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 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": "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 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": "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": "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 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": "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": "# 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": "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": "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": "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": "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 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": "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": "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": "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": "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": "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 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": "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 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 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": "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())\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": "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": "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": "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"}
